Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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