From b329161df6fbf03345ccadce649151496693e18a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Fri, 30 Aug 2024 13:09:11 +0200 Subject: [PATCH] bugfix Wiki Links, bugfix regex syntax --- markdown.awk | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/markdown.awk b/markdown.awk index fcd42cf..26fc11b 100755 --- a/markdown.awk +++ b/markdown.awk @@ -155,8 +155,10 @@ function inline( line, LOCAL, len, text, code, href, guard ) { # Wiki style links } else if ( match( line, /^\[\[([^]|]+)(\|[^]]+)?\]\]/) ) { len = RLENGTH; href = text = substr(line, 1, len); - sub(/^\[\[([^]|]+)(\|([^]]+))?\]\]/, "\\1", href ); - sub(/^\[\[([^]|]+)(\|([^]]+))?\]\]/, "\\3", text ); + sub(/^\[\[/, "", href); sub(/(\|([^]]+))?\]\].*$/, "", href); + sub(/^\[\[([^]|]+)/, "", text); sub(/\]\].*$/, "", text); sub(/^\|/, "", text); + # sub(/^\[\[([^]|]+)(\|([^]]+))?\]\]/, "\\1", href ); + # sub(/^\[\[([^]|]+)(\|([^]]+))?\]\]/, "\\3", text ); if ( ! text ) text = href; return "" HTML(text) "" inline( substr( line, len + 1) ); @@ -648,7 +650,7 @@ function _block( block, LOCAL, st, len, text, title, attrib, href, guard, code, text = substr(text, n + 1); sub(/^[ \t]*/, "", text); sub(/[ \t]*#*([ \t]*\{([a-zA-Z \t-]*)\})(\n.*)?$/, "", text); sub(/^(##?#?#?#?#?)[ \t]*(([^ \t\n]+|[ \t]+[^ \t\n#]|[ \t]+#+[ \t]*[^ \t\n#])+)[ \t]*#*[ \t]*\{/, "", attrib); - sub(/\})(\n.*)?$/, "", attrib); + sub(/\}(\n.*)?$/, "", attrib); gsub(/[^a-zA-Z0-9_-]+/, " ", attrib); gsub(/(^ | $)/, "", attrib); return headline( n, text, attrib ) _block( substr( block, len + 1) ); -- 2.39.2