Chiming in: - That error happened to me when the code I was running had errors (so the problem might be on the Python side) - A quick way to test the python side is to just run the python program w/out any arguments. That would ensure there are no "compile-time" errors at least - This also looks quite similar to what I did in one of the panflute examples (might be useful in case you want a more complex filter) Best, Sergio On Tuesday, December 27, 2016 at 4:34:43 PM UTC-5, Luis Fernado Silva Castro de Araújo wrote: > > Sorry John, > > I tried, but Haskell is too foreign to me. It would be simpler to go with > a more familiar language. > > > - The aim is to create an acronym filter (in Haskell) to run with > pandoc. The filter would modify the current link syntax and make > [LRU](acro: "Least Recently Used") represent a definition for an acronym. > > > - In the LATEX side, an acronym addition would have to involve adding \usepackage[acronym,smallcaps]{glossaries} > to the preamble and \newacronym{LRU}{LRU}{Least Recently Used} for the > definition of LRU and finally \gls{LRU} to every time the term is used > in the text. > > > > I have been adapting Pacrodoc, however I am stuck at the following code: > > > # Based on https://github.com/cflewis/Pacrodoc/blob/master/pacrodoc.py > > import sys > import json > import re > import urllib > > acronyms = {} > > def processAcronym(linkData): > # Links look like this: > # [[{u'Str': u'Link Name'}], [u'Link URL', 'Link Title']] > acronym = linkData[0][0]['Str'] > acronymText = linkData[1][0] > > # First we check if there is an acronym being defined > if re.search('^acro:', linkData[1][0]): > # An acronym is being defined, so strip off the acro: > # prefix and unencode the text > acronyms[acronym] = {'text': urllib.unquote(acronymText[5:]), > 'used': False} > > # Strip out this link > return {'Str': ''} > > # Now we check if its referring to an acronym instead > if not acronymText and acronym in acronyms: > if not acronyms[acronym]['used']: > acronyms[acronym]['used'] = True > return {'Str': '%s (%s)' % (acronyms[acronym]['text'], > acronym)} > else: > return {'Str': acronym} > > # It was just a normal link, so return it unchanged > return {'Link': linkData} > > def lookForAcronyms(jsonData): > if isinstance(jsonData, list): > return [lookForAcronyms(value) for value in jsonData] > > if isinstance(jsonData, dict): > if 'Link' in jsonData: > return processAcronym(jsonData['Link']) > else: > return {k: lookForAcronyms(v) for k, v in jsonData.items()} > > return jsonData > > if __name__ == "__main__": > toJSONFilter(lookForAcronyms) > > > And I get the error: > > fd:4: hClose: resource vanished (Broken pipe) > > > > I hope anyone could shed some light on where I am getting it wrong. > Perhaps some pointers on how to do it using the more recent panflute > framework. > > Thanks > -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/719e577c-e900-4951-afb2-0423e71ff601%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.