pandoc:使用 html 标签渲染上标
pandoc: render supscript with html tags
我正在将 docx 文档转换为 markdon。 markdown 文件将用作 github 存储库中的 README 文件:
pandoc -s manuscript.docx -t markdown -o README.md
有没有办法告诉 pandoc 使用 html 标签渲染上标?
我会 pandoc 输出:
<sup>a_number</sup>
而不是:
^a_number^
扩展 scoa 的评论,您只需将 Superscript 元素替换为等效的 RawInline 元素。 This 过滤器为您完成(需要 python 3.3+ 和排笛包 (pip install panflute
)。
import panflute as pf
def action(elem, doc):
if isinstance(elem, pf.Superscript) and doc.format == 'markdown':
text = '<sup>' + pf.stringify(elem) + '</sup>'
return pf.RawInline(text)
if __name__ == '__main__':
pf.run_filter(action)
用法示例:
>> echo 2^10^ is 1024 | pandoc --to=markdown -F html_superscript.py
2<sup>10</sup> is 1024
我正在将 docx 文档转换为 markdon。 markdown 文件将用作 github 存储库中的 README 文件:
pandoc -s manuscript.docx -t markdown -o README.md
有没有办法告诉 pandoc 使用 html 标签渲染上标? 我会 pandoc 输出:
<sup>a_number</sup>
而不是:
^a_number^
扩展 scoa 的评论,您只需将 Superscript 元素替换为等效的 RawInline 元素。 This 过滤器为您完成(需要 python 3.3+ 和排笛包 (pip install panflute
)。
import panflute as pf
def action(elem, doc):
if isinstance(elem, pf.Superscript) and doc.format == 'markdown':
text = '<sup>' + pf.stringify(elem) + '</sup>'
return pf.RawInline(text)
if __name__ == '__main__':
pf.run_filter(action)
用法示例:
>> echo 2^10^ is 1024 | pandoc --to=markdown -F html_superscript.py
2<sup>10</sup> is 1024