繁体   English   中英

Pandoc Lua 过滤器:如果参数来自标题(章节或章节),我如何检查 function Str

[英]Pandoc Lua filter: How can I check in function Str if argument comes from a title (of a chapter or section)

实际上,我为 markdown 到 LaTeX 转换做了一些过滤。 我为此使用 lua 过滤器。 现在我需要做这样的事情:

function Str (el)
  if is_in_a_title(el) then
    -- do this
  else
    -- do that
  end
end

这意味着在 Str 中我想检查参数是否属于章节/章节标题。 有没有办法做到这一点?

重新发布我在邮件列表上写的内容:

这最好通过运行子过滤器来完成:

local header_filter = {
  Str = function (el)
    -- do this
  end
}

function Header (h)
  return pandoc.util.walk_block(h, header_filter)
end

header_filter就像普通的 Lua 过滤器一样。 walk_block function 将该过滤器应用于 Header 下方的所有元素,并且仅适用于这些元素。

暂无
暂无

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

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