gpt4 book ai didi

html - 潘多克 : generate a html embedding Latex equation from markdown input

转载 作者:可可西里 更新时间:2023-11-01 13:00:04 26 4
gpt4 key购买 nike

我正在尝试使用 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} \]

而不是一个漂亮的“ latex 编译”方程式。

我错过了什么?

附言我正在使用 pandoc 1.12.2.1

最佳答案

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

<html> 生成一个“完整”的 html 文件<head><body>标签,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>

(注意 <script> 标签链接到 <head> 部分中的 mathjax)而调用

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

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

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

关于html - 潘多克 : generate a html embedding Latex equation from markdown input,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41140900/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com