Created
November 23, 2016 23:38
-
-
Save brokaw/0ce6eab91717851b682a510dd42dc7cc to your computer and use it in GitHub Desktop.
Markdown
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
#!/usr/bin/env python | |
# Requires third-party markdown library. pip install --user Markdown | |
import sys | |
import markdown | |
def main(): | |
input = sys.stdin.read() | |
extensions = ['markdown.extensions.extra', | |
'markdown.extensions.codehilite', 'markdown.extensions.smarty'] | |
extension_config = {'markdown.extensions.codehilite': { 'linenums': False, | |
'guess_lang': False }} | |
try: | |
output = markdown.markdown(input, extensions=extensions, extension_configs=extension_config, outputformat='html5') | |
except Exception as e: | |
print(input + "\n\nError: " + str(e)) | |
return 1 | |
print(input) | |
print("\n-----------------\n") | |
print(output) | |
return 0 | |
if __name__ == '__main__': | |
sys.exit(main()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment