From 2afd85294fcbbca71118e9f870e56b53d6af9954 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Sat, 31 May 2025 19:42:16 +0530 Subject: first commit --- md2html | 317 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 317 insertions(+) create mode 100644 md2html (limited to 'md2html') diff --git a/md2html b/md2html new file mode 100644 index 0000000..35b3c11 --- /dev/null +++ b/md2html @@ -0,0 +1,317 @@ +#!/usr/bin/env python3 + +# /usr/lib/cgit/filters/html-converters/md2html +# make sure to also install catppuccin[pygments] with pip + +import markdown +import sys +import io +from pygments.formatters import HtmlFormatter +from markdown.extensions.toc import TocExtension +from catppuccin.extras.pygments import MochaStyle + +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