简体   繁体   English

Pandoc lua 过滤器,将部分变成未编号的部分

[英]Pandoc lua filters, turn sections into unnumbered ones

I am developing a pandoc markdown template for a journal whose final format needs sections to be unnumbered, that is, \section and children should become \section*.我正在为一本期刊开发一个 pandoc markdown 模板,该期刊的最终格式需要不编号的章节,即 \section 和 children 应该成为 \section*。

I know that is sufficient to add {-} in the markdown next to the header title, but I want to force this behaviour and do not depend on users writing markdown correctly.我知道在 header 标题旁边的 markdown 中添加 {-} 就足够了,但我想强制执行此行为并且不依赖于用户正确编写 markdown。

I tried with:我试过:

function Header(el)
  el.classes = 'unnumbered'
  return el
end

but it makes the headers disappear... I am totally new to LUA so bear with me.但这会使标题消失......我对 LUA 完全陌生,所以请耐心等待。

How should I proceed?我该如何进行?

Success!成功!

I needed curly brackets around the class to denote a "table"我需要在 class 周围加上大括号来表示“表格”

function Header(el)
  el.classes = {'unnumbered'} -- curly brackets were missing here
  return el
end

or use an index since classes is a List:或使用索引,因为类是一个列表:

function Header(el)
  el.classes[1] = 'unnumbered' -- classes is a List
  return el
end

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

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