diff options
Diffstat (limited to 'cgit/filters/about.sh')
| -rwxr-xr-x | cgit/filters/about.sh | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/cgit/filters/about.sh b/cgit/filters/about.sh index e8554b0..9455ce7 100755 --- a/cgit/filters/about.sh +++ b/cgit/filters/about.sh @@ -1,5 +1,25 @@ #!/usr/bin/env sh # About content filter -/usr/lib/cgit/filters/about-formatting.sh "$@" | /usr/lib/cgit/filters/ediblemonad/html-transform.py +set -eu +# TODO: Add toc links for headers in markdown +md_to_html() { + echo '<div class="markdown">' + md2html \ + --fpermissive-url-autolinks --fpermissive-www-autolinks \ + --flatex-math --ftasklists --ftables --funderline \ + --github - + echo '</div>' +} + +to_html() { + case "$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')" in + *.markdown|*.mdown|*.md|*.mkd) md_to_html ;; + *.htm|*.html) exec cat ;; + *) /usr/lib/cgit/filters/about-formatting.sh "$@" ;; + esac +} + +(to_html "$@" | /usr/lib/cgit/filters/ediblemonad/html-transform.py) || \ + (echo "<pre>Error rendering markdown</pre>" && cat) |
