]> git.plutz.net Git - cgilite/commitdiff
improved attribute parsing in headlines
authorPaul Hänsch <paul@plutz.net>
Tue, 15 Sep 2026 15:48:58 +0000 (17:48 +0200)
committerPaul Hänsch <paul@plutz.net>
Tue, 15 Sep 2026 15:48:58 +0000 (17:48 +0200)
markdown.awk

index d1f6616dd7aa7e93131230a25edc950900ecab5c..b60285e68f2b4c613c2c066a94094da6f5004dc7 100755 (executable)
@@ -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);