英文:
The output from "pandoc -f markdown -t native" shell command differs from the results generated by Pandoc Haskell library
问题
在执行以下命令时:
pandoc -f markdown example.md -t native
在 example.md 文件中的代码块:
$(λx.M)$
会生成:
[ Para [ Math InlineMath "(\955x.M)" ] ]
然而,下面的 Haskell 代码从相同的文件中读取:
module Main where
import Control.Monad
import Control.Monad.Catch
import Control.Monad.IO.Class
import qualified Data.Text.IO as TIO
import Text.Pandoc
main :: IO ()
main =
TIO.putStrLn
<<=
runIOorExplode (do
markdownText <- liftIO $ TIO.readFile "example.md"
doc <- readMarkdown def markdownText
writeNative def doc
)
并生成:
[ Para [ Str "$(\955x.M)$" ] ]
这里发生了什么?为什么数学块没有被解析为 Math
类型?
英文:
Executing the following command
pandoc -f markdown example.md -t native
on
example.md
$(λx.M)$
produces:
[ Para [ Math InlineMath "(5x.M)" ] ]
However, the following code reads from that same file:
module Main where
import Control.Monad
import Control.Monad.Catch
import Control.Monad.IO.Class
import qualified Data.Text.IO as TIO
import Text.Pandoc
main :: IO ()
main =
TIO.putStrLn
=<<
runIOorExplode (do
markdownText <- liftIO $ TIO.readFile "example.md"
doc <- readMarkdown def markdownText
writeNative def doc
)
and produces:
[ Para [ Str "$(\955x.M)$" ] ]
What's happening here ? Why isn't math blocks being parsed as Math
types ?
答案1
得分: 3
Pandoc 允许启用或禁用其支持的各种格式的各种扩展功能。def
默认的扩展集仅包含适用于大多数格式的一些扩展功能。对于 Pandoc 的 Markdown,您将需要来自 Text.Pandoc.Extensions
模块的 pandocExtensions
。修改读取器参数以使用这些扩展功能,并将修改后的选项作为第一个参数传递给 readMarkdown
应该会产生所需的结果。
英文:
Pandoc allows to enable or disable various extensions for the formats that it supports. The def
default set of extensions contains only a few extensions that work with most formats. For pandoc's Markdown you'll need pandocExtensions
from the Text.Pandoc.Extensions
module. Modifying the reader args to use those, and passing the modified options as the first arg to readMarkdown
should give the desired result.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论