From 5c00ae05f10ca5133fdb6e788369bd8081b3974b Mon Sep 17 00:00:00 2001 From: Joe Date: Sat, 30 Apr 2022 18:35:01 +0000 Subject: update --- usr/local/etc/cgitrc | 6 +- usr/local/lib/cgit/filters/html-converters/md2html | 307 +++++++++++++++++++++ 2 files changed, 308 insertions(+), 5 deletions(-) create mode 100755 usr/local/lib/cgit/filters/html-converters/md2html diff --git a/usr/local/etc/cgitrc b/usr/local/etc/cgitrc index 690a98a..e1ab198 100644 --- a/usr/local/etc/cgitrc +++ b/usr/local/etc/cgitrc @@ -59,8 +59,6 @@ readme=:README.org readme=:readme.org readme=:README.mkd readme=:readme.mkd -readme=:README.rst -readme=:readme.rst readme=:README.html readme=:readme.html readme=:README.htm @@ -75,8 +73,6 @@ readme=:INSTALL.org readme=:install.org readme=:INSTALL.mkd readme=:install.mkd -readme=:INSTALL.rst -readme=:install.rst readme=:INSTALL.html readme=:install.html readme=:INSTALL.htm @@ -86,4 +82,4 @@ readme=:install.txt readme=:INSTALL readme=:install -#scan-path=/usr/local/git +scan-path=/usr/local/git 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