From: Paul Hänsch Date: Thu, 29 Aug 2024 11:22:57 +0000 (+0200) Subject: minor fix: in fenced divs and fenced code blocks, omit empty class attribute X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=ccc93a0562d36788cef3df0d9796d670486ca722;p=cgilite minor fix: in fenced divs and fenced code blocks, omit empty class attribute --- diff --git a/markdown.awk b/markdown.awk index d54d125..7e20ebb 100755 --- a/markdown.awk +++ b/markdown.awk @@ -557,10 +557,14 @@ function _block( block, LOCAL, st, len, text, title, attrib, href, guard, code, attrib = gensub(/^:::+[ \t]*\{?[ \t]*([^\}\n]*)\}?[ \t]*\n.*$/, "\\1", 1, block); gsub(/[^a-zA-Z0-9_-]+/, " ", attrib); gsub(/(^ | $)/, "", attrib); - if ( match(code, "(^|\n)" guard "+(\n|$)" ) ) { + if ( match(code, "(^|\n)" guard "+(\n|$)" ) && attrib ) { len = RLENGTH; st = RSTART; return "
" _nblock( substr(code, 1, st - 1) ) "
\n" \ _block( substr( code, st + len ) ); + } else if ( match(code, "(^|\n)" guard "+(\n|$)" ) ) { + len = RLENGTH; st = RSTART; + return "
" _nblock( substr(code, 1, st - 1) ) "
\n" \ + _block( substr( code, st + len ) ); } else { match( block, /(^|\n)[[:space:]]*(\n|$)/ ) || match( block, /$/ ); len = RLENGTH; st = RSTART; @@ -575,10 +579,14 @@ function _block( block, LOCAL, st, len, text, title, attrib, href, guard, code, attrib = gensub(/^(~~~+|```+)[ \t]*\{?[ \t]*([^\}\n]*)\}?[ \t]*\n.*$/, "\\2", 1, block); gsub(/[^a-zA-Z0-9_-]+/, " ", attrib); gsub(/(^ | $)/, "", attrib); - if ( match(code, "(^|\n)" guard "+(\n|$)" ) ) { + if ( match(code, "(^|\n)" guard "+(\n|$)" ) && attrib ) { len = RLENGTH; st = RSTART; return "
" HTML( substr(code, 1, st - 1) ) "
\n" \ _block( substr( code, st + len ) ); + } else if ( match(code, "(^|\n)" guard "+(\n|$)" ) ) { + len = RLENGTH; st = RSTART; + return "
" HTML( substr(code, 1, st - 1) ) "
\n" \ + _block( substr( code, st + len ) ); } else { match( block, /(^|\n)[[:space:]]*(\n|$)/ ) || match( block, /$/ ); len = RLENGTH; st = RSTART;