md2html: Do syntax highlighting too

This commit is contained in:
Jason A. Donenfeld 2016-02-23 06:32:03 +01:00
parent a9e9dfc55f
commit 1892cd9a60

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
import markdown import markdown
from pygments.formatters import HtmlFormatter
print(''' print('''
<style> <style>
.markdown-body { .markdown-body {
@ -277,9 +278,12 @@ print('''
background-color: transparent; background-color: transparent;
border: none; border: none;
} }
''')
print(HtmlFormatter(style='pastie').get_style_defs('.highlight'))
print('''
</style> </style>
''') ''')
print("<div class='markdown-body'>") print("<div class='markdown-body'>")
# Note: you may want to run this through bleach for sanitization # Note: you may want to run this through bleach for sanitization
markdown.markdownFromFile(output_format="html5") markdown.markdownFromFile(output_format="html5", extensions=["markdown.extensions.fenced_code", "markdown.extensions.codehilite", "markdown.extensions.tables"], extension_configs={"markdown.extensions.codehilite":{"css_class":"highlight"}})
print("</div>") print("</div>")