X-Git-Url: https://git.danieliu.xyz/?p=pinopress.git;a=blobdiff_plain;f=modules%2Fmd;fp=modules%2Fmd;h=5dbcc41d12e71a4b6d3d7f52fae4689334c50957;hp=b2bc03869c59c48a4b4bc2a1c21d8f718fd92d72;hb=8f843459581548b8a806a5ab8178efc4c7cfdd89;hpb=0edc18c28ae23dd6e5af18bbcf8725848f7b7963 diff --git a/modules/md b/modules/md index b2bc038..5dbcc41 100755 --- a/modules/md +++ b/modules/md @@ -4,11 +4,19 @@ ## based off https://github.com/stamby/md-to-html # input $1 - filepath to html file +# parse header of document + +# html style comments +s///g + # special html characters s/\&/\&\;/g s//\>\;/g +# horizontal rule +s/^\s*-{3,}\s*$// + # inline styles s/(^|[^\\\*])\*{3}([^\*]+)\*{3}([^\*]|$)/\1\2<\/em><\/strong>\3/g s/(^|[^\\_])_{3}([^_]+)_{3}([^_]|$)/\1\2<\/em><\/strong>\3/g @@ -17,8 +25,9 @@ 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 +s/(^|[^\\~])~{2}([^~]+)~{2}([^~]|$)/\1\2<\/del>\3/g -# img +# images s/!\[(.*)\]\((.*)\)/\1/g # links @@ -26,10 +35,18 @@ s/\[(.*)\]\((.*)\)/\2<\/a>/g s/\[(.*)\]/\1<\/a>/g # headers +s/^#{6} (.*)/
\1<\/h6>/ +s/^#{5} (.*)/
\1<\/h5>/ s/^#{4} (.*)/

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

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

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

\1<\/h1>/ -# html style comments +# code block + +# paragraphs + +# /./{H;$!d} ; x ; s/^/\n

/ ; s/$/\n<\/p>/ + +