X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/3f9e14ada1e9cb3bb5b162f10f824336e3142440..34c30d12fc917d9853135f6e9d4c8e531efddaeb:/filters/html-converters/md2html diff --git a/filters/html-converters/md2html b/filters/html-converters/md2html index 67141ba..59f43a8 100755 --- a/filters/html-converters/md2html +++ b/filters/html-converters/md2html @@ -1,6 +1,12 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import markdown -print(''' +import sys +import io +from pygments.formatters import HtmlFormatter +from markdown.extensions.toc import TocExtension +sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8') +sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') +sys.stdout.write(''' ''') -print("
") +sys.stdout.write("
") +sys.stdout.flush() # Note: you may want to run this through bleach for sanitization -markdown.markdownFromFile(output_format="html5") -print("
") +markdown.markdownFromFile( + output_format="html5", + extensions=[ + "markdown.extensions.fenced_code", + "markdown.extensions.codehilite", + "markdown.extensions.tables", + "markdown.extensions.sane_lists", + TocExtension(anchorlink=True)], + extension_configs={ + "markdown.extensions.codehilite":{"css_class":"highlight"}}) +sys.stdout.write("
")