Oops! Sorry again to have a duplicated post… a post on the same topic is in pandoc-discuss/support arguments on filters.
To compensate, let me wrote a combined summary of both posts (please expand or correct if incomplete/incorrect):
pandoc -t json | filter1 ... | ...
? e.g. I often see filters checking the output format from the json rather than the 1st arg.-M
command line option-M
option in (2)Comments:
As as filter writer, one would want their filter as easy to use as possible, and as few extra dependencies as possible. These criteria eliminates (1, 4) for easiness and (3) for dependencies. This leaves (2) as the only viable solution, which still has some cons needed to be dealt with. I personally don’t worry too much about things treated as Markdown, but metadata key collision is unavoidable if one want short, easy to remember keys (e.g. pantable -s -t csv
, anyone used to pandoc will almost be able to remember this.).
In addition, the above discussion hasn’t covered the case that one might want to write a program that can acts as both a filter and a standalone cli. e.g. I am thinking about using -s
to indicate it is a standalone cli (and without it, a pandoc filter). Using -M
means the options is parsed differently (and duplicated) in these 2 cases.
-O key=value
/--filter-option=KEY:VAL
/--filter-args
/--filter-arguments
-F "filter --split --on --hyphens"
/-F filter --split --on --space
Comments:
Just for the sake of letting the -F
option be backward compatible, (1) might be better. But either way it will be fine with me.