From 8f843459581548b8a806a5ab8178efc4c7cfdd89 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Sat, 10 Jul 2021 12:19:48 -0400 Subject: [PATCH] more work on md --- modules/md | 21 +++++++++++++++++++-- modules/md-test | 12 ++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) 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>/ + + diff --git a/modules/md-test b/modules/md-test index bad1c65..ec3561f 100644 --- a/modules/md-test +++ b/modules/md-test @@ -28,6 +28,18 @@ ___bold italic text___ \***should be strong**\* \*\**should be emph*\*\* +~~this is incorrect text~~ +~~~~ +\~~this should not be strikethrough\~~ + `inline code` `` \`escaped backtick\` + + + + text after + +--- +---- + --------- -- 2.20.1