Issues with latex math in markdown files, for display on Github Pages (using jekyll)
Our solution: use kramdown parser, with GFM option (Github flavored Markdown). In the .Rmd, use $$ for display math and $ for inline math. then have a script which turns the inline math demarkation in the .md file from $ into $$ when appropriate (avoiding data frame usage), before uploading the .md to Github. This way, RStudio preview looks the same as the Github Pages version.
- doesn't respect
$or$$(will parse characters within these, such as_), but has workarounds: - has a useful option,
no_intra_emphasis, so underscores between ascii characters are not converted to<em>tags, so$x_1$is fine - need to escape underscores after non-ascii characters, for example
$\mathbf{x}\_1$ - need to double escape curly bracket:
\\{ - need three backslash for new line
\\\ =cannot be on its own line
- respects
$$, will not interpret anything in between these. can be used for display or inline math doesn't respect$for inline math, so then you need to escape all underscores (no such optionno_intra_emphasis) and curly brackets here- need to double escape some characters within
$, e.g.\\{, which won't render in RStudio - you can however use
$$for inline math:$$x_1$$and even$$\mathbf{x}_1$$work. Unfortunately$$will become display math in the RStudio preview (although it will be fine with Github Pages)
hard-line wrapping is not allowed. So newline character will make new lines (whereas redcarpet and RStudio will make a paragraph from contiguous lines of text).turn off optionhard_wrap- requires leading and trailing blank lines around
#headers, while redcarpet will make a header even without a trailing blank line
- both can handle backtick-fenced code blocks, redcarpet by default and kramdown with
GFMoption (github flavored markdown)
good, tks ~~