"""
Pandoc filter using panflute
"""

import panflute as pf


def prepare(doc):
    pf.debug(f'  Pandoc version: {doc.pandoc_version}')
    pf.debug('  Pandoc reader options:')
    for k, v in doc.pandoc_reader_options.items():
        pf.debug(f'    {k}={v}')

    assert doc.pandoc_version >= (2, 11, 0)
    assert doc.pandoc_reader_options['readerStandalone'] is False


def action(elem, doc):
    if isinstance(elem, pf.Element) and doc.format == 'latex':
        pass
        # return None -> element unchanged
        # return [] -> delete element


def finalize(doc):
    pass


def main(doc=None):
    return pf.run_filters([action],
                         prepare=prepare,
                         finalize=finalize,
                         doc=doc) 


if __name__ == '__main__':
    main()

@@ -299,16 +299,109 @@
  11, 0)%0A
+    standalone_key = 'readerStandalone' if doc.pandoc_version %3C (2, 16, 0) else %22standalone%22%0A
     asse
@@ -429,24 +429,17 @@
 options%5B
-'readerS
+s
 tandalon
@@ -439,17 +439,20 @@
 andalone
-'
+_key
 %5D is Fal

fix failed test with pandoc>=2.16