Hello NUMBAT

I am Abhishek from Mumbai, India

GSoC-22 Contributor

Today I want to share with you some interesting work in texor and rebib

texor package

texor is a toolkit package that solves multiple challenges that occour in conversion of LaTeX source files to a web friendly RJ-web-article format.

The Challenges

LaTeX is a very descriptive language with a lot of functionality to extend it. Hence converting content from LaTeX is a bit tricky.

Some of these are :

  • Article Meta Data
  • Math Compatibility
  • Handling Code Environments
  • Table/Figure Compatibility
  • Bibliography

Stream Editor

Match    Find    Replace

Stream Editor


						stream_editor <- function(raw_lines, pattern, target, replacement) {
							break_points <- which(grepl(pattern, raw_lines))
							#check for length of break_points to avoid no matches
							if (!identical(break_points, integer(0))) {
								for (iterator in seq_along(break_points)) {
									modification_line <- raw_lines[break_points[iterator]]
									modified_line <- gsub(target, replacement, modification_line)
									raw_lines[break_points[iterator]] <- modified_line
								}
								message(paste(
								"Found ", length(break_points), "Matches for target :", target))
							} else {
								message(paste("Found 0 Matches for target : ", target))
							}
							return(raw_lines)
						}
						

Pandoc Lua Filters

To manipulate the AST we use pandoc filters.

My first Lua Filter


							function Div(el)
    							if el.classes[1] == 'thebibliography' then
        							return { }
    							end
							end 	
						

Math Filter


							function Math (m)
  								local left = m.mathtype == 'InlineMath' and '\\(' or '$$'
  								local right = m.mathtype == 'InlineMath' and '\\)' or '$$'
  								return pandoc.RawInline('markdown', left .. m.text .. right)
							end
						

For More Filters

rebib package

rebib is a tool kit package specifically for bibliography challenges.

Sample Conversion


							\bibitem[R Core Team]{R}
							R Core Team
							\newblock R: A Language and Environment for Statistical Computing
							\newblock \emph{R Foundation for Statistical Computing}, Vienna, Austria 
							\penalty0 2016.
							\newblock URL : \url{https://www.R-project.org/}, ISBN 3-900051-07-0
							

To


								@book{R,
									author = {{R Core Team}},
									title = {{R: A Language and Environment for Statistical Computing}},
									publisher = {R Foundation for Statistical Computing Vienna Austria},
									year = {2016},
									url = {https://www.R-project.org/},
									isbn = {3-900051-07-0}
								}
							

Demonstrations

Any Questions ?

Thank You !