Skip to content

Instantly share code, notes, and snippets.

@ekaitz-zarraga
Created February 23, 2017 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekaitz-zarraga/80e7d07fca29b7403e38937125eb2a6b to your computer and use it in GitHub Desktop.
Save ekaitz-zarraga/80e7d07fca29b7403e38937125eb2a6b to your computer and use it in GitHub Desktop.
Test panflute. Capture Image URLs and change them.
import panflute as pf
"""
Stupid panflute test, capture Image URLs and change them, prints this:
Hola, esto es un docu
=====================
![IMAGEN](otra_url)
Hola tronco que la ![imagen](otra_url) mola mucho.
"""
def imageURLs(elem, doc):
if isinstance(elem, pf.Image):
elem.url = 'otra_url'
return elem
postcontent = '''
# Hola, esto es un docu
![IMAGEN](imagen1)
Hola tronco que la ![imagen](imagen2) mola mucho.
'''
if __name__ == '__main__':
postdocument = pf.convert_text(postcontent, input_format='markdown',
output_format='panflute',
standalone=True)
pf.run_filters( [ imageURLs ], doc = postdocument )
print pf.convert_text(postdocument, input_format='panflute',
output_format='markdown')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment