简体   繁体   English

pandoc lua 过滤器在转换为 docx 时将 Emphasis 字符样式应用于 Emph 元素

[英]pandoc lua filter to apply Emphasis character style to Emph elements when converting to docx

I'm using pandoc to convert from latex to docx.我正在使用 pandoc 从 latex 转换为 docx。 In the pandoc AST, emphasized text is marked with "Emph", like this:在 pandoc AST 中,强调的文本用“Emph”标记,如下所示:

, Emph [ Str "Variety" ]

and is rendered as italics when writing out to the docx file.并在写入 docx 文件时呈现为斜体。 I would like to use a lua filter to apply Emphasis character style defined in the reference docx file to such text.我想使用 lua 过滤器将参考 docx 文件中定义的强调字符样式应用于此类文本。 I have read all the documentation but still lack the necessary info and skill to write the filter myself.我已经阅读了所有文档,但仍然缺乏自己编写过滤器的必要信息和技能。 Any help will be greatly appreciated.任何帮助将不胜感激。

This can be done by changing the Emph into a Span with a custom-style attribute:这可以通过将Emph更改为具有custom-style属性的Span来完成:

function Emph (emph)
  return pandoc.Span(emph.content, {['custom-style'] = 'Emphasis'})
end

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

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