md2html: Do syntax highlighting too
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 23 Feb 2016 05:32:03 +0000 (06:32 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 23 Feb 2016 14:00:05 +0000 (15:00 +0100)
filters/html-converters/md2html

index 67141ba67936c8e84c1638c499185991b90b32d7..c8ee7d97076d0885711923ae9dd1495fc6ee48f4 100755 (executable)
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 import markdown
+from pygments.formatters import HtmlFormatter
 print('''
 <style>
 .markdown-body {
@@ -277,9 +278,12 @@ print('''
     background-color: transparent;
     border: none;
 }
+''')
+print(HtmlFormatter(style='pastie').get_style_defs('.highlight'))
+print('''
 </style>   
 ''')
 print("<div class='markdown-body'>")
 # 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>")