Somewhat similar to How to convert HTML with mathjax into latex using pandoc? but in some sense, the opposite.
If I'm using Pandoc to create MD files with LaTeX, or even just MD files, how can I use Pandoc to convert these to HTML with the correct \(\)
, \[\]
tags for math?
Pandoc can convert between numerous markup and word processing formats, including, but not limited to, various flavors of Markdown, HTML, LaTeX and Word docx.
Generating PDF from Markdown with Pandoc There are actually two steps involved in converting a Markdown file to a PDF file: The Markdown source file is converted to a LaTeX source file. Pandoc invokes the pdflatex or xelatex or other TeX command and converts the . tex source file to a PDF file.
You can't. You can try opening the PDF in Word or Google Docs and saving in a format from which pandoc can convert directly.
LaTeX / TeX markup works great for producing high-quality typesetting for articles, research papers, manuals, books, etc. Markdown works great for distraction-free focus-on-what-you-want-to-say writing. Using tools such as pandoc or kramdown you can (auto-)convert plain text in markdown to LaTeX for further processing.
Following discussion here, I am able to convert test.md
(containing LaTeX code) to test.html
successfully.
pandoc --toc --standalone --mathjax -f markdown -t html test.md -o test.html
The doc on --mathjax
can be found here:
Use MathJax to display embedded TeX math in HTML output. TeX math will be put between (...) (for inline math) or [...] (for display math) and wrapped in tags with class math. Then the MathJax JavaScript will render it. The URL should point to the MathJax.js load script. If a URL is not provided, a link to the Cloudflare CDN will be inserted.
The option --standalone
is important, without which the LaTeX code can not be rendered correctly.
PS. wrap inline equation like $INLINE EQUATION$
and wrap display equation like $$DISPLAY EQUATION$$
.
You want to convert from markdown to html with mathjax support?
pandoc --mathjax input.md -o output.html
Assuming Windows as platform, the following .CMD
snippet should do the conversion:
set PATH=%ProgramFiles%\pandoc;%PATH%
set CDN=http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML
set IN=%~s1
if [%2]==[] (
set OUT=%~sdp1%~n1.html
) else (
set OUT=%~s2
)
echo Converting markdown to html ...
pandoc.exe -s --mathjax=%CDN% --from=markdown+pipe_tables --to=html --output="%OUT%" %IN%
Consult the pandoc help to tune the commandline parameters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With