From: Paul Hänsch Date: Tue, 15 Sep 2026 15:48:58 +0000 (+0200) Subject: improved attribute parsing in headlines X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=b233ce089870e9bf0634dd971bd6898788d09480;p=cgilite improved attribute parsing in headlines --- diff --git a/markdown.awk b/markdown.awk index d1f6616..b60285e 100755 --- a/markdown.awk +++ b/markdown.awk @@ -650,7 +650,8 @@ function _block( block, LOCAL, st, len, text, title, attrib, href, guard, code, # First Order Heading H1 + Attrib } else if ( match( block, "^([^\n]+)([ \t]*"rattr")\n===+(\n|$)" ) ) { len = RLENGTH; text = attrib = block; - sub(/([ \t]*\{([^\}\n]+)\})\n===+(\n.*)?$/, "", text); + sub("([ \t]*"rattr")\n===+(\n.*)?$", "", text); + sub(/\n===+(\n.*)?$/, "", attrib); attrib = _attr(attrib); ret = ret headline(1, text, attrib) ; block = substr( block, len + 1 ); @@ -667,7 +668,8 @@ function _block( block, LOCAL, st, len, text, title, attrib, href, guard, code, # Second Order Heading H2 + Attrib } else if ( match( block, "^([^\n]+)([ \t]*"rattr")\n---+(\n|$)" ) ) { len = RLENGTH; text = attrib = block; - sub(/([ \t]*\{([^\}\n]+)\})\n---+(\n.*)?$/, "", text); + sub("([ \t]*"rattr")\n---+(\n.*)?$", "", text); + sub(/\n---+(\n.*)?$/, "", attrib); attrib = _attr(attrib); ret = ret headline(2, text, attrib) ; block = substr( block, len + 1); @@ -686,7 +688,7 @@ function _block( block, LOCAL, st, len, text, title, attrib, href, guard, code, len = RLENGTH; text = attrib = substr(block, 1, len); match(block, /^##?#?#?#?#?[^#]/); n = RLENGTH - 1; text = substr(text, n + 1); sub(/^[ \t]*/, "", text); - sub(/[ \t]*#*([ \t]*\{([a-zA-Z \t-]*)\})(\n.*)?$/, "", text); + sub("[ \t]*#*([ \t]*"rattr")(\n.*)?$", "", text); attrib = _attr(attrib);