Mediawiki Scribunto 无法通过斜杠拆分页面

我有一个 Scribunto 模块,应该使用更多缩进的项目符号格式化子页面:

local p = {} --p 代表 package

function p.subpage_bullets( frame )
    local page = frame.args.page
    local parts = mw.text.split( page, "/", true )
    return string.rep("*", #parts) .. " " ..  parts[#parts]
end

return p

这在调试控制台中按预期工作。

=p.subpage_bullets(mw.getCurrentFrame():newChild{title="whatever",args={["page"]="Foo/Bar"}})
** Bar

我是这样从 DPL 中使用它的:

{{#dpl:
format=,{{#invoke:Helpers|subpage_bullets|page=%PAGE%}},<br />
|ordermethod=none
|namespace= {{NAMESPACE}}
}}

结果是页面没有缩进。因此,页面 Foo/Bar 返回 * Foo/Bar,而不是预期的 ** Bar

为什么它不起作用?我试图用 "%2f"/ "%2F" 替换拆分中的 "/", 但结果没有改变。

另一个相关的问题是,项目符号呈 * 形式呈现,而不是解释为维基文本,因此无法呈现为实际的项目符号。

原文链接 https://stackoverflow.com/questions/69705236

点赞