From 6fa71c7efadb990aad14d1c6a7833e9cae88436d Mon Sep 17 00:00:00 2001 From: Biswakalyan Bhuyan Date: Thu, 6 Apr 2023 16:39:52 +0530 Subject: cgit --- filters/html-converters/md2html | 330 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 330 insertions(+) create mode 100755 filters/html-converters/md2html (limited to 'filters/html-converters/md2html') diff --git a/filters/html-converters/md2html b/filters/html-converters/md2html new file mode 100755 index 0000000..3f5aed7 --- /dev/null +++ b/filters/html-converters/md2html @@ -0,0 +1,330 @@ +#!/usr/bin/env python3 +import markdown +import sys +import io +from pygments.formatters import HtmlFormatter +from markdown.extensions.toc import TocExtension + +# The dark style is automatically selected if the browser is in dark mode +light_style='pastie' +dark_style='monokai' + +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", + "markdown.extensions.sane_lists", + TocExtension(anchorlink=True)], + extension_configs={ + "markdown.extensions.codehilite":{"css_class":"highlight"}}) +sys.stdout.write("
") -- cgit v1.2.3-59-g8ed1b