jgm / pandocfilters

A python module for writing pandoc filters, with a collection of examples
BSD 3-Clause "New" or "Revised" License
512 stars 111 forks source link

Error in Pandoc scripting #1

Closed simonlau closed 10 years ago

simonlau commented 11 years ago
from pandocfilters import toJSONFilter

def caps(key, value, format, meta):
  if key == 'Str':
    return {'Str': value.upper()}

if __name__ == "__main__":
  toJSONFilter(caps)

In the above sample,

key == 'Str' is never true as

key are values like:

jgm commented 11 years ago

Yes, the json output produced for generics changed between aeson 0.6.1 and 0.6.2, breaking this module.

The problem is fixed if you install pandoc with the latest pandoc-types.

cabal update && cabal install --reinstall pandoc pandoc-types pandoc-citeproc

Or, if you're on Windows, grab the latest package installer.

+++ Simon Lau [Sep 30 13 02:09 ]:

In the below sample,

key == 'Str' is never true as

key are values like: * unMeta * tag * contents

from pandocfilters import toJSONFilter

def caps(key, value, format, meta): if key == 'Str': return {'Str': value.upper()}

if name == "main": toJSONFilter(caps)

— Reply to this email directly or [1]view it on GitHub. [xJAuenYDiIoVt3LF3y684xqQlLUiClfr2ujsuvd4bQQuL5rthviBCrFbltl3Bq-b.gif]

References

  1. https://github.com/jgm/pandocfilters/issues/1
simonlau commented 11 years ago

Thanks for the quick response. I'm actually on a Mac using pandoc 1.12.0.1 which I install as a binary. Is this fixed in 1.12.0.2?

jgm commented 11 years ago

Oh, bother. You're right - the osx package is also affected. I'll try to upload a new one today or tomorrow.

+++ Simon Lau [Sep 30 13 08:59 ]:

Thanks for the quick response. I'm actually on a Mac using pandoc 1.12.0.1 which I install as a binary. Is this fixed in 1.12.0.2?

— Reply to this email directly or [1]view it on GitHub. [xJAuenYDiIoVt3LF3y684xqQlLUiClfr2ujsuvd4bQQuL5rthviBCrFbltl3Bq-b.gif]

References

  1. https://github.com/jgm/pandocfilters/issues/1#issuecomment-25376037
jgm commented 11 years ago

A new OSX package has been uploaded (1.12.0.2). Let me know if that fixes things.