Skip to content

How to make a filter work post xml render? #12300

Answered by cderv
fredguth asked this question in Q&A
Discussion options

You must be logged in to vote

This is your filter


function RawBlock(el)
    print(':::', el.format)
    if el.format == "html" then
        print(':::', el.text)
      el.text = el.text:gsub('<fn%s+id="([^"]+)">', '<fn fn-type="other" id="%1">')
      print(':::', el.text)
    end
    return el
  end

What you are doing it probably not what you think.
You are

  • catching any RawBlock in the document => el.format is the raw format used on this rawblock.
  • printing to console some content
  • modifying the text of the Raw Block to be different with a gsub
  • Returning the raw block

Your idea of qmd -> AST -> XML is a good one. This means your filter shouldn't consider the footnote has been transform to xml yet. at: post-render m…

Replies: 1 comment 2 replies

Comment options

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

@cderv
Comment options

Answer selected by fredguth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
jats pandoc lua Issues related to the lua codebase, filter chain, etc
2 participants