Lua 在Pandoc过滤器中嵌套额外跨距会使图像消失

Lua 在Pandoc过滤器中嵌套额外跨距会使图像消失,lua,pandoc,Lua,Pandoc,由于CMS中的一些恼人的限制,我目前正在处理Pandoc过滤器的HTML输出,这是我努力工作的最终受益者 我的工作过滤器(现在带有明显的声明)如下所示: local List = require 'pandoc.List' local Emph = pandoc.Emph local Quoted = pandoc.Quoted local Span = pandoc.Span local Str = pandoc.Str local Strong = pandoc.Strong local

由于CMS中的一些恼人的限制,我目前正在处理Pandoc过滤器的HTML输出,这是我努力工作的最终受益者

我的工作过滤器(现在带有明显的声明)如下所示:

local List = require 'pandoc.List'

local Emph = pandoc.Emph
local Quoted = pandoc.Quoted
local Span = pandoc.Span
local Str = pandoc.Str
local Strong = pandoc.Strong

local image_base = "http://my.website.example/images/"
local image_author = "Someone Not Stigma"

function process_images(el)
  el.src = el.src:gsub("^file:images/", image_base)
  el.caption = {
    Strong( Quoted( "DoubleQuote", el.caption ) ),
    Str(" by "),
    Emph(image_author)
  }
  return el
end

return {{Image = process_images}}
pandoc --from=markdown-tex_math_dollars "Content.pure.txt" --lua-filter=".\pandoc-filter.lua" --to=html5 --template=".\pandoc-template.txt" -o "Content.txt"
在最终的HTML中,这给了我一个很好的图形,其中包含img和figcaption元素。精彩的不幸的是,我的CMS破坏了figcaption(就像它倾向于破坏其他东西一样),因此我想我应该把所有东西都包装在一个额外的跨度中,这样我就可以设计这个

function process_images(el)
  el.src = el.src:gsub("^file:images/", image_base)
  el.caption = {
    Span(
      {
        Strong( Quoted( "DoubleQuote", el.caption ) ),
        Str(" by "),
        Emph(image_author)
      },
      { class="img-caption" }
    )
  }
  return el
end
但不知何故,这会导致Pandoc从生成的HTML中完全删除图像

我曾尝试用列表({})语法替换表语法,但这只会让我产生对upvalue的抱怨。我看了手册,但就我所知,我做的一切都是对的

我错过了什么

我称潘多克为:

local List = require 'pandoc.List'

local Emph = pandoc.Emph
local Quoted = pandoc.Quoted
local Span = pandoc.Span
local Str = pandoc.Str
local Strong = pandoc.Strong

local image_base = "http://my.website.example/images/"
local image_author = "Someone Not Stigma"

function process_images(el)
  el.src = el.src:gsub("^file:images/", image_base)
  el.caption = {
    Strong( Quoted( "DoubleQuote", el.caption ) ),
    Str(" by "),
    Emph(image_author)
  }
  return el
end

return {{Image = process_images}}
pandoc --from=markdown-tex_math_dollars "Content.pure.txt" --lua-filter=".\pandoc-filter.lua" --to=html5 --template=".\pandoc-template.txt" -o "Content.txt"
扩展名为.txt(因为这些文件不支持浏览器)。使用的模板相当长(有相当多的YAML变量和相关标记),但请放心:$body$可以在其中找到。

我不是一个聪明人。各位,在发布问题之前,请务必更新到最新版本

我运行的是一个较旧版本的Pandoc(v2.6),升级到v2.9.1.1后,突然又出现了输出。在大约一年的时间里发布了很多版本


(在我的辩护中,我的Pandoc过滤器fu不是特别强大,因此假设用户错误而不是程序错误是有意义的。为什么每次假设错误都是用户错误,每次假设用户错误都是完全错误?

你能给出一个可重复的例子吗?您的过滤器必须有更多功能,因为默认情况下,
Strong
Str
等函数是未定义的。@tarleb这些只是在
pandoc
中声明的各种内容的方便声明:
local Emph=pandoc.Emph
local Quoted=pandoc.Quoted
,等等。除此之外,只有
image\u base
image\u author
的声明(它们是字符串,在第一个示例中可以正常工作)。除此之外,过滤器中没有任何其他内容。