From 5c00ae05f10ca5133fdb6e788369bd8081b3974b Mon Sep 17 00:00:00 2001 From: Joe Date: Sat, 30 Apr 2022 18:35:01 +0000 Subject: update --- usr/local/lib/cgit/filters/html-converters/md2html | 307 +++++++++++++++++++++ 1 file changed, 307 insertions(+) create mode 100755 usr/local/lib/cgit/filters/html-converters/md2html (limited to 'usr/local/lib/cgit') diff --git a/usr/local/lib/cgit/filters/html-converters/md2html b/usr/local/lib/cgit/filters/html-converters/md2html new file mode 100755 index 0000000..fd10340 --- /dev/null +++ b/usr/local/lib/cgit/filters/html-converters/md2html @@ -0,0 +1,307 @@ +#!/usr/local/bin/python3.8 +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