about summary refs log tree commit diff stats
path: root/filters
diff options
context:
space:
mode:
Diffstat (limited to 'filters')
-rwxr-xr-xfilters/html-converters/md2html17
1 files changed, 11 insertions, 6 deletions
diff --git a/filters/html-converters/md2html b/filters/html-converters/md2html index c8ee7d9..ebf3856 100755 --- a/filters/html-converters/md2html +++ b/filters/html-converters/md2html
@@ -1,7 +1,11 @@
1#!/usr/bin/env python 1#!/usr/bin/env python3
2import markdown 2import markdown
3import sys
4import io
3from pygments.formatters import HtmlFormatter 5from pygments.formatters import HtmlFormatter
4print(''' 6sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8')
7sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
8sys.stdout.write('''
5<style> 9<style>
6.markdown-body { 10.markdown-body {
7 font-size: 14px; 11 font-size: 14px;
@@ -279,11 +283,12 @@ print('''
279 border: none; 283 border: none;
280} 284}
281''') 285''')
282print(HtmlFormatter(style='pastie').get_style_defs('.highlight')) 286sys.stdout.write(HtmlFormatter(style='pastie').get_style_defs('.highlight'))
283print(''' 287sys.stdout.write('''
284</style> 288</style>
285''') 289''')
286print("<div class='markdown-body'>") 290sys.stdout.write("<div class='markdown-body'>")
291sys.stdout.flush()
287# Note: you may want to run this through bleach for sanitization 292# Note: you may want to run this through bleach for sanitization
288markdown.markdownFromFile(output_format="html5", extensions=["markdown.extensions.fenced_code", "markdown.extensions.codehilite", "markdown.extensions.tables"], extension_configs={"markdown.extensions.codehilite":{"css_class":"highlight"}}) 293markdown.markdownFromFile(output_format="html5", extensions=["markdown.extensions.fenced_code", "markdown.extensions.codehilite", "markdown.extensions.tables"], extension_configs={"markdown.extensions.codehilite":{"css_class":"highlight"}})
289print("</div>") 294sys.stdout.write("</div>")