Skip to content
Discussion options

You must be logged in to vote

I'm going to just write out the solution because this is a good "Hello, World" filter from which you can learn to generalize:

-- filter.lua

-- this function will be executed for all Header elements in the document
Header = function(el)
  -- el.level == 1 makes it so you only catch "# ..." and not "## ...", etc
  -- el.classes is a pandoc List object, which has the method "includes"
  if el.level == 1 and el.classes:includes("bmsection") then
    -- pandoc.utils.stringify converts a pandoc value (in this case,
    -- the list of inlines that make up the header) into a plain string.
    local text = pandoc.utils.stringify(el.content)

    -- a RawBlock element contains a string that is pas…

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by ramiromagno
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@mcanouil
Comment options

@ramiromagno
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lua Issues related to the lua codebase, filter chain, etc
4 participants