From: Paul Hänsch Date: Tue, 6 Jul 2021 23:26:12 +0000 (+0200) Subject: md: inline HTML X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=4f5d122dad9b7a66bafa4fea7c340f3ea1d06fc5;p=cgilite md: inline HTML --- diff --git a/markdown.awk b/markdown.awk index d1de2c3..9c548ec 100755 --- a/markdown.awk +++ b/markdown.awk @@ -35,7 +35,8 @@ # - [x] Images / reference style images # - [x] # - [x] backslash escapes -# - [ ] Verbatim HTML inline +# - [x] Verbatim HTML inline +# - [ ] HTML escaping # # Extensions - Block elements: # ---------------------------- @@ -102,6 +103,11 @@ function inline( line, LOCAL, len, code, href, guard ) { } else if ( match(line, /^ \n/) ) { return "
\n" inline( substr(line, RLENGTH + 1) ); + # Verbatim inline HTML + } else if ( match( line, /^(|<\?([^\?]|\?[^>])*\?>|]*>|])*\]\]>|<\/[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:]]*\/?>)/) ) { + len = RLENGTH; + return substr( line, 1, len) inline(substr(line, len + 1)); + # ``code spans`` } else if ( match( line, /^`+/) ) { len = RLENGTH @@ -235,23 +241,8 @@ function _block( block, LOCAL, st, len, hlvl, htxt, guard, code, indent ) { if ( block == "" ) { return ""; - # HTML #2 - } else if ( match( block, /(^|\n) ? ? ?|$)/) ) { - len = RLENGTH; st = RSTART; - return _block(substr(block, 1, st - 1)) substr(block, st, len) _block(substr(block, st + len)); - - # HTML #3 - } else if ( match( block, /(^|\n) ? ? ?<\?([^\?]|\?[^>])*(\?>|$)/) ) { - len = RLENGTH; st = RSTART; - return _block(substr(block, 1, st - 1)) substr(block, st, len) _block(substr(block, st + len)); - - # HTML #4 - } else if ( match( block, /(^|\n) ? ? ?]*(>|$)/) ) { - len = RLENGTH; st = RSTART; - return _block(substr(block, 1, st - 1)) substr(block, st, len) _block(substr(block, st + len)); - - # HTML #5 - } else if ( match( block, /(^|\n) ? ? ?])*(\]\]>|$)/) ) { + # HTML #2 #3 #4 $5 + } else if ( match( block, /(^|\n) ? ? ?(|$)|<\?([^\?]|\?[^>])*(\?>|$)|]*(>|$)|])*(\]\]>|$))/) ) { len = RLENGTH; st = RSTART; return _block(substr(block, 1, st - 1)) substr(block, st, len) _block(substr(block, st + len)); @@ -268,7 +259,7 @@ function _block( block, LOCAL, st, len, hlvl, htxt, guard, code, indent ) { return _block(substr(block, 1, st - 1)) substr(block, st, len) _block(substr(block, st + len)); # HTML #7 - } else if ( match( block, /^ ? ? ?(<\/[A-Za-z][A-Za-z0-9-]* \t]*>|<[A-Za-z][A-Za-z0-9-]*([ \t]+[A-Za-z_:][A-Za-z0-9_\.:-]*[ \t]*=[ \t]*([[:space:]"'=<>`]+|"[^"]*"|'[^']*'))*[ \t]*\/?>)([[:space:]]*\n)([^\n]|\n[[:space:]]*[^\n])*(\n[ \t]*\n|$)/) ) { + } else if ( 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));