aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld2016-02-23 06:32:03 +0100
committerJason A. Donenfeld2016-02-23 15:00:05 +0100
commit1892cd9a603e1eda206c40efb576bd75b7532be6 (patch)
tree05d6ad5f434cbe2493fb2625b9bd0d34912b0a9c
parenta9e9dfc55f5c57a4065be77c320224f524a9c820 (diff)
downloadcgit-1892cd9a603e1eda206c40efb576bd75b7532be6.tar.gz
cgit-1892cd9a603e1eda206c40efb576bd75b7532be6.tar.bz2
cgit-1892cd9a603e1eda206c40efb576bd75b7532be6.zip
md2html: Do syntax highlighting too
-rwxr-xr-xfilters/html-converters/md2html6
1 files changed, 5 insertions, 1 deletions
diff --git a/filters/html-converters/md2html b/filters/html-converters/md2html
index 67141ba..c8ee7d9 100755
--- a/filters/html-converters/md2html
+++ b/filters/html-converters/md2html
@@ -1,5 +1,6 @@
1#!/usr/bin/env python 1#!/usr/bin/env python
2import markdown 2import markdown
3from pygments.formatters import HtmlFormatter
3print(''' 4print('''
4<style> 5<style>
5.markdown-body { 6.markdown-body {
@@ -277,9 +278,12 @@ print('''
277 background-color: transparent; 278 background-color: transparent;
278 border: none; 279 border: none;
279} 280}
281''')
282print(HtmlFormatter(style='pastie').get_style_defs('.highlight'))
283print('''
280</style> 284</style>
281''') 285''')
282print("<div class='markdown-body'>") 286print("<div class='markdown-body'>")
283# Note: you may want to run this through bleach for sanitization 287# Note: you may want to run this through bleach for sanitization
284markdown.markdownFromFile(output_format="html5") 288markdown.markdownFromFile(output_format="html5", extensions=["markdown.extensions.fenced_code", "markdown.extensions.codehilite", "markdown.extensions.tables"], extension_configs={"markdown.extensions.codehilite":{"css_class":"highlight"}})
285print("</div>") 289print("</div>")