From: Paul Hänsch Date: Tue, 17 May 2022 23:26:37 +0000 (+0200) Subject: metadata blocks X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=49a67fed963936a4e88b2a8904296a16a4bbb9eb;p=cgilite metadata blocks --- diff --git a/markdown.awk b/markdown.awk index d28c7cf..b064792 100755 --- a/markdown.awk +++ b/markdown.awk @@ -56,6 +56,7 @@ # - [ ] Definition lists (php md, pandoc) # - [-] Numbered example lists (pandoc) # - [-] Metadata blocks (pandoc) +# - [x] Metadata blocks (custom) # - [x] Fenced Divs (pandoc) # # Extensions - Inline elements: @@ -279,6 +280,12 @@ function _block( block, LOCAL, st, len, hlvl, htxt, guard, code, indent, attrib } else if ( AllowHTML && match( block, /^ ? ? ?(<\/[A-Za-z][A-Za-z0-9-]*[[:space:]]*>|<[A-Za-z][A-Za-z0-9-]*([[:space:]]+[A-Za-z_:][A-Za-z0-9_\.:-]*([[:space:]]*=[[:space:]]*([[:space:]"'=<>`]+|"[^"]*"|'[^']*'))?)*[[:space:]]*\/?>)([[:space:]]*\n)([^\n]|\n[ \t]*[^\n])*(\n[[:space:]]*\n|$)/) ) { len = RLENGTH; st = RSTART; return substr(block, st, len) _block(substr(block, st + len)); + + # Metadata (custom, block starting with %something) + # Metadata is ignored but can be interpreted externally + } else if ( match(block, /^%[a-zA-Z]+([[:space:]][^\n]*)?(\n|$)(%[a-zA-Z]+([[:space:]][^\n]*)?(\n|$)|%([[:space:]][^\n]*)?(\n|$)|[ \t]+[^\n[:space:]][^\n]*(\n|$))*/) ) { + len = RLENGTH; st = RSTART; + return _block( substr( block, len + 1) ); # Blockquote (leading >) } else if ( match( block, /^> /) ) {