From: Daniel Liu Date: Thu, 29 Jul 2021 02:46:42 +0000 (-0400) Subject: more advanced md script X-Git-Url: https://git.danieliu.xyz/?a=commitdiff_plain;h=00a2c5274946042785d6425a61281efa07da7e48;p=pinopress.git more advanced md script --- diff --git a/modules/md b/modules/md index 1a4ae98..3ce8979 100755 --- a/modules/md +++ b/modules/md @@ -6,16 +6,53 @@ ## md [md_filepath] # remove document meta -/^-- \w+: .+$/d - -# html style comments -//d +## matches block of -- at top of file +1,/^([^-]|-[^-]|^$)/ { + /^([^-]|-[^-]|^$)/ !{ + /^-- ?/d + } +} # special html characters s/\&/\&\;/g s//\>\;/g +# code blocks +/^ *```/ { + x + # check if hold space contains READING + # this is to see if this is the first ``` we read or no + /^ *READING/ !{ + # if it is the first one, add READING to hold space + s/.*/READING/ + x + # write opening tag + s/.*// + b + } + # if its the second ```, we are done + # first clear hold + s/.*// + x + # then write closing tag + s/.*/<\\code>/ +} + +# if we aren't reading ```, but hold space has READING in it +# that means we are currently processing a block, just ignore and +# keep going +x +/^ *READING/ { + x + b +} +x + + +# html style comments +//d + # horizontal rule s/^\s*-{3,}\s*$// @@ -44,8 +81,6 @@ s/^#{3} (.*)/

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

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

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

/ ; s/$/\n<\/p>/ diff --git a/modules/md-test b/modules/md-test index 72e244f..8f52d8f 100644 --- a/modules/md-test +++ b/modules/md-test @@ -47,3 +47,18 @@ ___bold italic text___ --- ---- --------- + +``` +this is +a code +block +write +code here +``` + +``` +another +code +block +``` +