sergiocorreia / panflute

An Pythonic alternative to John MacFarlane's pandocfilters, with extra helper functions
http://scorreia.com/software/panflute/
BSD 3-Clause "New" or "Revised" License
500 stars 59 forks source link

Filters that take arguments? #107

Closed abers closed 4 years ago

abers commented 5 years ago

I want to create a notes filter that looks for text along the lines of say -

```note

Random commments

  1. to do
  2. list

```

Then depending on the arguments passed to it, it can either include the notes, and add LaTeX to give it say a yellow background, in the output or scrub them.

Would this be possible, or would I need to create two seperate filters?

sergiocorreia commented 5 years ago

You can certainly do it, in at least two ways.

First, you can set a metadata field (in the yaml headers) and ad an if clause to the filter based on that.

Else, you can add attributes to the block itself, as mentioned here: https://pandoc.org/MANUAL.html#fenced-code-blocks . They become properties of the panflute elements, which you can then access