Created
September 16, 2020 18:41
-
-
Save waylan/4a470a6e05e04b9cadb1e11ba8d330de to your computer and use it in GitHub Desktop.
Some test tools I used when refactoring Python-Markdown's HTML parser. Preserved here for future reference.
This file contains 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 markdown | |
src = """ | |
<div><p markdown="1">Hello _World!_</p></div> | |
""" | |
md = markdown.Markdown(extensions=['md_in_html']) | |
print('Doc: ', '\n'.join(md.preprocessors['html_block'].run(src.split('\n')))) | |
print('Stash: ', md.htmlStash.rawHtmlBlocks) | |
md.htmlStash.reset() | |
print('Ouput: ', '\n---------------------\n' + md.convert(src) + '\n---------------------') | |
print('Stash: ', md.htmlStash.rawHtmlBlocks) |
This file contains 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 markdown | |
import timeit | |
with open('tests/extensions/extra/raw-html.txt') as f: | |
src = f.read() | |
num, dur = timeit.Timer(lambda: markdown.markdown(src, extensions=['md_in_html'])).autorange() | |
print(dur / num) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment