ickc/pancritic

possible to turn this into a pandoc filter?

Closed this issue · 2 comments

Is it possible to turn the preprocessor into a pandoc filter?
There is a filter to produce criticmarkup from docx comments [1]. With the preprocessor I only get HTML output, but it would be nice to do the roundtrip with docx. As a filter one would be compatible with the rest of pandoc option.

[1] https://gist.github.com/noamross/12e67a8d8d1fb71c4669cd1ceb9bbcf9

I'm sure you can make the opposite flow work, but probably not neatly as a single filter. You'll need this or a similar pre-processor to convert the CriticMarkup to inline spans or something else that has AST coverage in Pandoc, then use a filter to massage the AST into whatever the docx Writer component needs it to be.

ickc commented

c.f. jgm/pandoc#1560 (comment) (I know it is also by you but just for future reference)

In short this is out of scope. I agree with @alerque that a better design may be preprocessor+filter s.t. the CriticMarkup is turn into some native AST structure first and have a filter to further process it, that enables someone to write a filter that work with CriticMarkup/pancritic.

There's a way to make the pancritic cli to be "compatible with the rest of pandoc option", i.e. just use some trickery to get arbitrary args and pass it to pandoc. I thought about it but didn't have time to implement it as it is not that important (as it can be used as an explicit pre-processor and pipe it to pandoc.)

The problem with CriticMarkup is that it is supposed to markup the source, which should be orthogonal to the markdown syntax. So it isn't nicely fit into the pandoc AST model. The original CriticMarkup team acknowledge this limitation (such as CriticMarkup breaking markdown syntax boundary) and never find a way to properly fix it. To me, CriticMarkup is more like an abandonware.

It would be nice if we can make CriticMarkup to work with docx. But I use docx very rarely so it is unlikely I would invest time into this. To future self or somebody else: see https://pandoc.org/MANUAL.html#reader-options --track-changes.

Also, according to Pandoc Extras · jgm/pandoc Wiki, there's PanDiff.