【问题标题】:Pandoc : generate a html embedding Latex equation from markdown inputPandoc:从markdown输入生成一个html嵌入Latex方程
【发布时间】:2017-04-29 16:23:18
【问题描述】:

我正在尝试使用 pandoc 将包含 Latex 方程式的 Markdown 文件转换为 Html 文件。

我在文件test.md 中尝试了以下合成器:

$$ \frac{1}{2} = 0.5 \neq \sqrt{2} $$

我调用 pandoc 使用

pandoc test.md -o test.html --mathjax

正如this answer 中所指出的那样。生成的test.html 文件包含一行

<p><span class="math">\[ \frac{1}{2} = 0.5 \neq \sqrt{2} \]</span></p>

当使用网络浏览器打开test.html 时,屏幕上的输出是乱七八糟的

\[ \frac{1}{2} = 0.5 \neq \sqrt{2} \]

而不是一个很好的“乳胶编译”方程。

我错过了什么?

附:我正在使用 pandoc 1.12.2.1

【问题讨论】:

    标签: html latex markdown pandoc


    【解决方案1】:

    生成的test.html 文件并不“完整”,因为仅生成了 html 的正文,而不是标题。但是,必须在标题中链接 mathjax 才能很好地显示方程式。

    要生成带有 &lt;html&gt; &lt;head&gt;&lt;body&gt; 标记的“完整” html 文件,必须使用 pandoc 的 --standalone(又名 -s)选项

    pandoc --standalone test.md -o test.html --mathjax
    

    更多详情

    使用调用

    pandoc --standalone test.md -o test.html --mathjax
    

    生成以下test.html 文件

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="Content-Style-Type" content="text/css" />
        <meta name="generator" content="pandoc" />
        <title></title>
        <style type="text/css">code{white-space: pre;}</style>
        <script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
    </head>
    <body>
    <p><span class="math">\[ \frac{1}{2} = 0.5 \neq \sqrt{2} \]</span></p>
    </body>
    </html>
    

    (注意&lt;script&gt; 标记链接到&lt;head&gt; 部分中的mathjax) 而调用

    pandoc test.md -o test.html --mathjax
    

    生成一个仅包含一行的文件

    <p><span class="math">\[ \frac{1}{2} = 0.5 \neq \sqrt{2} \]</span></p>
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-04
    • 1970-01-01
    • 2016-01-19
    • 2014-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多