简体   繁体   English

有没有办法在 pandoc lua 过滤器中找出 output 格式

[英]Is there a way to figure out the output format in a pandoc lua filter

Lets say I have a code like this:可以说我有这样的代码:

return {
  {
    Str = function (elem)
      if elem.text == "any string" then
        return pandoc.RawInline ("latex", "anything")
      end
    end,
  }
}

Can i include a if statement that says: If the output file is latex then use this code and if the output file is html (or not latex) do that...我可以包含一个 if 语句,上面写着:如果 output 文件是 latex,那么使用这段代码,如果 output 文件是 html(或不是乳胶),那么这样做......

So I essentially wonder if there is a way of figuring out the output file format within the lua-filter.所以我基本上想知道是否有办法在 lua-filter 中找出 output 文件格式。

Yes, this is possible.是的,这是可能的。 Check out this pandoc lua filters example: https://pandoc.org/lua-filters.html#center-images-in-latex-and-html-output specifically these lines:查看这个 pandoc lua 过滤器示例: https://pandoc.org/lua-filters.html#center-images-in-latex-and-html-output特别是这些行:

if FORMAT:match 'latex' then
...
if FORMAT:match 'html' then

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

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