简体   繁体   中英

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*.

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.

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.

How should I proceed?

Success!

I needed curly brackets around the class to denote a "table"

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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