繁体   English   中英

pandoc lua 过滤器在转换为 docx 时将引号样式应用于 Div

[英]pandoc lua filter to apply Quotations style to a Div when converting to docx

我正在使用 pandoc 从 latex 转换为 docx。 在 pandoc AST 中,latex \quoting 环境由一个 Div 表示,如下所示:

, Div
    ( "" , [ "quoting" ] , [] )
    [ Para
        [ Str
            "\26377\38065\23601\20986"
        ]
    ]

但是,在写出 docx 文件时会忽略这一点。 如何使用 lua 过滤器将参考 docx 文件中已定义的引用样式应用于此 Div 的内容? 我已经阅读了所有文档,但仍然缺乏自己编写过滤器的必要信息和技能。 任何帮助将不胜感激。

如果样式是通过custom-style属性传递的,则 docx 编写器将使用样式。 所以像这样的过滤器应该可以工作:

function Div (div)
  if div.classes:includes 'quoting' then
    div.attributes['custom-style'] = 'Quotations'
    return div
  end
end

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM