]> git.plutz.net Git - cgilite/commitdiff
bugfix: enable image links
authorPaul Hänsch <paul@plutz.net>
Thu, 18 May 2023 11:39:09 +0000 (13:39 +0200)
committerPaul Hänsch <paul@plutz.net>
Thu, 18 May 2023 11:39:09 +0000 (13:39 +0200)
markdown.awk

index 63bb044e8a69c13a87c58c71194ecceaf9b381b8..4f18b9ba499685017a6fcef4ab25c5a5a581c392 100755 (executable)
@@ -154,11 +154,15 @@ function inline( line, LOCAL, len, code, href, guard ) {
     return "<a href=\"mailto:" href "\">" href "</a>" inline( substr( line, len + 1) );
 
   # inline links
-  } else if ( match(line, /^\[([^]]+)\]\(([^"\)]+)([[:space:]]+"([^"]+)")?\)/) ) {
+  #                                 ,_______________________Image____________________________,
+  } else if ( match(line, /^\[([^]]+|!\[[^]]+\]\([^"\)]+([ \t]+"[^"]+")?\)(\{[a-zA-Z \t-]*\})?)\]\(([^"\)]+)([[:space:]]+"([^"]+)")?\)/) ) {
     len = RLENGTH;
-    text  = gensub(/^\[([^]]+)\]\(([^"\)]+)([[:space:]]+"([^"]+)")?\)/, "\\1", 1, substr(line, 1, len) );
-    href  = gensub(/^\[([^]]+)\]\(([^"\)]+)([[:space:]]+"([^"]+)")?\)/, "\\2", 1, substr(line, 1, len) );
-    title = gensub(/^\[([^]]+)\]\(([^"\)]+)([[:space:]]+"([^"]+)")?\)/, "\\4", 1, substr(line, 1, len) );
+    text  = gensub(/^\[([^]]+|!\[[^]]+\]\([^"\)]+([ \t]+"[^"]+")?\)(\{[a-zA-Z \t-]*\})?)\]\(([^"\)]+)([[:space:]]+"([^"]+)")?\)/, \
+                   "\\1", 1, substr(line, 1, len) );
+    href  = gensub(/^\[([^]]+|!\[[^]]+\]\([^"\)]+([ \t]+"[^"]+")?\)(\{[a-zA-Z \t-]*\})?)\]\(([^"\)]+)([[:space:]]+"([^"]+)")?\)/, \
+                   "\\4", 1, substr(line, 1, len) );
+    title = gensub(/^\[([^]]+|!\[[^]]+\]\([^"\)]+([ \t]+"[^"]+")?\)(\{[a-zA-Z \t-]*\})?)\]\(([^"\)]+)([[:space:]]+"([^"]+)")?\)/, \
+                   "\\6", 1, substr(line, 1, len) );
     if ( title ) {
       return "<a href=\"" URL(href) "\" title=\"" HTML(title) "\">" inline( text ) "</a>" inline( substr( line, len + 1) );
     } else {