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

Add latex-merge as RawBlock format #251

Open matthew-brett opened 3 months ago

matthew-brett commented 3 months ago

Quarto generates latex-merge as a RawBlock format.

Accept this as a RawBlock format.

Specifically Quarto filters generate this JSON from Markdown ![An image](some_image.jpg):

                    {
                        "c": [
                            "latex-merge",
                            "\\begin{figure}[H]"
                        ],
                        "t": "RawBlock"
                    },

Without this patch, initial parsing of the JSON input for any Panflute filter will fail with:

TypeError: element str not in group {'native', 'context', 'docbook',
'man', 'twiki', 'dokuwiki', 'rtf', 'tex', 'markdown', 'vimwiki', 'rst',
'creole', 'opml', 'haddock', 'docx', 'epub', 'icml', 'markdown_mmd',
'markdown_strict', 'org', 't2t', 'mediawiki', 'opendocument', 'json',
'muse', 'openxml', 'commonmark', 'gfm', 'html', 'fb2', 'noteref',
'textile', 'markdown_github', 'ipynb', 'markdown_phpextra', 'latex',
'odt', 'tikiwiki', 'jats', 'typst'}
matthew-brett commented 3 months ago

I think this is a specific instance of the problem referred to in https://github.com/sergiocorreia/panflute/issues/236 - I guess a more general question is - should RawBlocks be passed through by default - rather than passing through only if expicitly listed in RAW_FORMATS.