0

我有一些 html 文件,包括 mathjax 命令。我想使用 pandoc 将它翻译成 php extra markdown。

问题是 pandoc 在所有数学命令之前添加“\”。例如 \begin{equation} \$ x\^2 等

您知道如何使用 pandoc 避免这种情况吗?我认为一个相关的问题是:How to convert HTML with mathjax into latex using pandoc?

4

1 回答 1

2

你可以编写一个简短的 Haskell 程序 unescape.hs:

-- Disable backslash escaping of special characters when writing strings to markdown.
import Text.Pandoc

main = toJsonFilter unescape
  where unescape (Str xs) = RawInline "markdown" xs
        unescape x        = x

现在用ghc --make unescape.hs. 并与

pandoc -f html -t json | ./unescape | pandoc -f json -t markdown

这将禁用$markdown 输出中特殊字符(如 )的转义。

一种更简单的方法可能是通过 sed 管道 pandoc 的正常降价输出:

pandoc -f html -t markdown | sed -e 's/\\\([$^_*]\)/\1/g'
于 2013-04-15T18:36:57.017 回答