pandoc - 禁用强调降价的大写
pandoc - disable capitalization of emphasis markdown
对于我的程序,我有一个降价文档,用于生成 Unix 手册页和纯文本文档。
pandoc -s -w plain -o program.txt program.md
pandoc --no-wrap -s -w man -o program.1 program.md
Markdown 中带有双星号的内容(例如**foobar**
)用于在手册页中以粗体 文本表示强调结果。但在文本输出中,它导致大写。
例如:
echo '**foobar**' | pandoc -w plain
结果:
FOOBAR
但我宁愿它忽略强调标记,只在纯文本输出中输出 foobar
。
我能想到的最好办法是使用 sed
表达式去除所有强调标记:
cat program.md | sed s/\*\*//g | pandoc --no-wrap -s -w plain -o program.txt
有更正式的方法吗?
您想使用 Pandoc 过滤器在输出到痛苦文本时将强文本转换为普通文本。
有一个过滤器可以做到这一点:https://github.com/sergiocorreia/panflute-filters/blob/master/filters/remove-strong.py
(它使用 Panflute,因此您需要 pip install panflute
,并安装 python 2.7+)
您也可以替换此行:
if isinstance(elem, pf.Strong)
有了这个:
if isinstance(elem, pf.Strong) and doc.format=='plain'
(或者只是 运行 仅用于文本输出的过滤器!)
对于我的程序,我有一个降价文档,用于生成 Unix 手册页和纯文本文档。
pandoc -s -w plain -o program.txt program.md
pandoc --no-wrap -s -w man -o program.1 program.md
Markdown 中带有双星号的内容(例如**foobar**
)用于在手册页中以粗体 文本表示强调结果。但在文本输出中,它导致大写。
例如:
echo '**foobar**' | pandoc -w plain
结果:
FOOBAR
但我宁愿它忽略强调标记,只在纯文本输出中输出 foobar
。
我能想到的最好办法是使用 sed
表达式去除所有强调标记:
cat program.md | sed s/\*\*//g | pandoc --no-wrap -s -w plain -o program.txt
有更正式的方法吗?
您想使用 Pandoc 过滤器在输出到痛苦文本时将强文本转换为普通文本。
有一个过滤器可以做到这一点:https://github.com/sergiocorreia/panflute-filters/blob/master/filters/remove-strong.py
(它使用 Panflute,因此您需要 pip install panflute
,并安装 python 2.7+)
您也可以替换此行:
if isinstance(elem, pf.Strong)
有了这个:
if isinstance(elem, pf.Strong) and doc.format=='plain'
(或者只是 运行 仅用于文本输出的过滤器!)