]> git.plutz.net Git - cgilite/commitdiff
enable block element Macros
authorPaul Hänsch <paul@plutz.net>
Thu, 18 May 2023 12:04:37 +0000 (14:04 +0200)
committerPaul Hänsch <paul@plutz.net>
Thu, 18 May 2023 12:04:37 +0000 (14:04 +0200)
markdown.awk

index fa60543b49d43ed013325bf939e2d93ed22e7a5b..b5072666de89f34c4b425211b70dd7471b0d9f21 100755 (executable)
@@ -608,6 +608,12 @@ function _block( block, LOCAL, st, len, hlvl, htxt, guard, code, indent, attrib
       return "<p>" HTML(substr(block, 1, len)) "</p>\n" _block( substr(block, len + 1) );
     }
 
+  # Macros (standalone <<macro>> calls handled as block, so they are not wrapped in paragraph)
+  } else if ( AllowMacros && match( block, /^<<(([^>]|>[^>])+)>>(\n|$)/) ) {
+    len = RLENGTH;
+    text = gensub(/^<<(([^>]|>[^>])+)>>(\n.*)?$/, "\\1", 1, block);
+    return macro(text) _block(substr(block, len + 1));
+
   # Split paragraphs
   } else if ( match( block, /(^|\n)[[:space:]]*(\n|$)/) ) {
     len = RLENGTH; st = RSTART;