X-Git-Url: https://git.danieliu.xyz/?p=pinopress.git;a=blobdiff_plain;f=modules%2Fmd;fp=modules%2Fmd;h=b2bc03869c59c48a4b4bc2a1c21d8f718fd92d72;hp=0000000000000000000000000000000000000000;hb=0edc18c28ae23dd6e5af18bbcf8725848f7b7963;hpb=03c62b630fd92a5b32920be4ee33453a3c8e8b3c diff --git a/modules/md b/modules/md new file mode 100755 index 0000000..b2bc038 --- /dev/null +++ b/modules/md @@ -0,0 +1,35 @@ +#!/bin/sed -Ef + +## markdown to html module for pinopress +## based off https://github.com/stamby/md-to-html +# input $1 - filepath to html file + +# special html characters +s/\&/\&\;/g +s//\>\;/g + +# inline styles +s/(^|[^\\\*])\*{3}([^\*]+)\*{3}([^\*]|$)/\1\2<\/em><\/strong>\3/g +s/(^|[^\\_])_{3}([^_]+)_{3}([^_]|$)/\1\2<\/em><\/strong>\3/g +s/(^|[^\\\*])\*{2}([^\*]+)\*{2}([^\*]|$)/\1\2<\/strong>\3/g +s/(^|[^\\_])_{2}([^\_]+)_{2}([^_]|$)/\1\2<\/strong>\3/g +s/(^|[^\\\*])\*([^\*]+)\*([^\*]|$)/\1\2<\/em>\3/g +s/(^|[^\\_])_([^_]+)_([^_]|$)/\1\2<\/em>\3/g +s/(^|[^\\`])`([^`]+)`([^`]|$)/\1\2<\/code>\3/g + +# img +s/!\[(.*)\]\((.*)\)/\1/g + +# links +s/\[(.*)\]\((.*)\)/\2<\/a>/g +s/\[(.*)\]/\1<\/a>/g + +# headers +s/^#{4} (.*)/

\1<\/h4>/ +s/^#{3} (.*)/

\1<\/h3>/ +s/^#{2} (.*)/

\1<\/h2>/ +s/^#} (.*)/

\1<\/h1>/ + +# html style comments +