Created
February 23, 2017 17:29
-
-
Save ekaitz-zarraga/80e7d07fca29b7403e38937125eb2a6b to your computer and use it in GitHub Desktop.
Test panflute. Capture Image URLs and change them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import panflute as pf | |
""" | |
Stupid panflute test, capture Image URLs and change them, prints this: | |
Hola, esto es un docu | |
===================== | |
 | |
Hola tronco que la  mola mucho. | |
""" | |
def imageURLs(elem, doc): | |
if isinstance(elem, pf.Image): | |
elem.url = 'otra_url' | |
return elem | |
postcontent = ''' | |
# Hola, esto es un docu | |
 | |
Hola tronco que la  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