parse_latex: Parse LaTeX for Markdown

Description Usage Arguments Value Examples

View source: R/Github_LaTeX.R

Description

This function will take an Rmd file and knit it, or and md file, and any LaTex with $ or $$ delineations, create pngs of these equations, and then insert a link to these equations to display in markdown

Usage

1
2
3
4
5
parse_latex(rmd, new_md, git_username = NULL, git_reponame = NULL,
  git_branch = "master", text_height = 20,
  insert_string = paste0("\n<img src=\"%s%s\" ", "alt=\"Equation
  Fail\"", "height=\"", text_height, "\">\n"),
  raw_git_site = "https://rawgit.com", bad_string = "ZZZZZZZZZZZZZZZ", ...)

Arguments

rmd

Rmd or md file that needs to be parsed

new_md

Output md file (usually named README.md for gitHub

git_username

Username for repository (GitHub currently)

git_reponame

Repository name

git_branch

Branch of repository if not master

text_height

Height of LaTeX rendered passed ot insert_string

insert_string

String of HTML to put in LaTeX figure. Must have 2 %s for sprintf

raw_git_site

Site where to reference figure. img_prefix = file.path(raw_git_site git_username git_reponame git_branch). Must reference the figures directly with proper content-type headers

bad_string

String to sub in for dollar signs temporarily (not need to be changed)

...

Arguments to be passed to png_latex, such as LaTeX packages or a pass through argument to converter

Value

Filename of parsed MD file

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
rmd = file.path(tempdir(), "README_unparse.rmd")
download.file(
"https://raw.githubusercontent.com/muschellij2/Github_Markdown_LaTeX/master/README_unparse.rmd",
destfile = rmd, method = "curl")
new_md = file.path(tempdir(), "README.md")
parse_latex(rmd,
            new_md,
            git_username = "muschellij2",
            git_reponame = "Github_Markdown_LaTeX")
library(knitr)
new_html = pandoc(new_md, format = "html")
browseURL(new_html)

new_md = file.path(tempdir(), "README.md")
parse_latex(rmd,
            new_md,
            git_username = "muschellij2",
            git_reponame = "Github_Markdown_LaTeX")
library(knitr)
new_html = pandoc(new_md, format = "html")
browseURL(new_html)#'

muschellij2/latexreadme documentation built on May 23, 2019, 9:53 a.m.