From f1736dae97df089b5f97895f5b27f2d95a7c6151 Mon Sep 17 00:00:00 2001 From: Tianhao Wang Date: Thu, 26 Oct 2023 20:32:15 +0200 Subject: init --- md2html | 301 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 301 insertions(+) create mode 100755 md2html (limited to 'md2html') diff --git a/md2html b/md2html new file mode 100755 index 0000000..618d00e --- /dev/null +++ b/md2html @@ -0,0 +1,301 @@ +#!/usr/bin/env python3 +import markdown +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(''' + +''') +sys.stdout.write("
") +sys.stdout.flush() +# Note: you may want to run this through bleach for sanitization +markdown.markdownFromFile( + output_format="html5", + extensions=[ + "markdown.extensions.fenced_code", + "markdown.extensions.codehilite", + "markdown.extensions.tables", + TocExtension(anchorlink=True)], + extension_configs={ + "markdown.extensions.codehilite":{"css_class":"highlight"}}) +sys.stdout.write("
") -- cgit v1.2.3-70-g09d2