diff options
author | Jason A. Donenfeld | 2016-02-23 06:32:03 +0100 |
---|---|---|
committer | Jason A. Donenfeld | 2016-02-23 15:00:05 +0100 |
commit | 1892cd9a603e1eda206c40efb576bd75b7532be6 (patch) | |
tree | 05d6ad5f434cbe2493fb2625b9bd0d34912b0a9c /filters | |
parent | git: update to v2.7.2 (diff) | |
download | cgit-1892cd9a603e1eda206c40efb576bd75b7532be6.tar.gz cgit-1892cd9a603e1eda206c40efb576bd75b7532be6.zip |
md2html: Do syntax highlighting too
Diffstat (limited to 'filters')
-rwxr-xr-x | filters/html-converters/md2html | 6 |
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 |
2 | import markdown | 2 | import markdown |
3 | from pygments.formatters import HtmlFormatter | ||
3 | print(''' | 4 | print(''' |
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 | ''') | ||
282 | print(HtmlFormatter(style='pastie').get_style_defs('.highlight')) | ||
283 | print(''' | ||
280 | </style> | 284 | </style> |
281 | ''') | 285 | ''') |
282 | print("<div class='markdown-body'>") | 286 | print("<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 |
284 | markdown.markdownFromFile(output_format="html5") | 288 | markdown.markdownFromFile(output_format="html5", extensions=["markdown.extensions.fenced_code", "markdown.extensions.codehilite", "markdown.extensions.tables"], extension_configs={"markdown.extensions.codehilite":{"css_class":"highlight"}}) |
285 | print("</div>") | 289 | print("</div>") |