Pandoc生成ODT文件时自定义样式无法生效的问题求助
Pandoc ODT自定义样式未写入XML问题
根据Pandoc官方文档,ODT输出支持直接使用自定义样式,无需额外扩展。但实际测试中发现,自定义样式并未写入ODT文件的XML结构中,而相同内容输出DOCX时该功能正常。
MD源文档
### header bla this is a <span custom-style="Anote">custom style span</span> ::: {custom-style="Poetry"} | A Bird came down the Walk--- | He did not know I saw--- ::: ::: {custom-style="bluestyle"} I'm blue ::: # My Header {style="Header 7"} scscscs this is a <span custom-style="mystyle">custom style span</span>
执行的Pandoc命令
pandoc test_input.md -o test_output.odt
环境版本信息
- pandoc 3.5.1
- Ubuntu 22.04
解决方法
使用自定义ODT模板
Pandoc默认ODT模板不包含自定义样式定义,需先创建包含目标样式的模板:- 导出默认模板:
pandoc -D odt > default_odt_template.odt - 用LibreOffice/OpenOffice打开模板,添加
Anote、Poetry、bluestyle、mystyle、Header 7等自定义样式并保存 - 命令中指定模板:
pandoc test_input.md --reference-doc=custom_template.odt -o test_output.odt
- 导出默认模板:
替换行内样式语法
用Pandoc原生Span语法替代HTML标签,兼容性更好:this is a [custom style span]{custom-style="Anote"}验证版本兼容性
该版本可能存在ODT样式写入bug,尝试升级到最新稳定版或回退至3.4版本测试。
内容的提问来源于stack exchange,提问作者Antonello
相关产品推荐
相关产品推荐

