]> git.plutz.net Git - shellwiki/commitdiff
Merge commit 'fa80cba529dfe38c1e60f7d536bdd88b08684af1'
authorPaul Hänsch <paul@plutz.net>
Wed, 27 Mar 2024 14:56:29 +0000 (15:56 +0100)
committerPaul Hänsch <paul@plutz.net>
Wed, 27 Mar 2024 14:56:29 +0000 (15:56 +0100)
1  2 
cgilite/markdown.awk

diff --combined cgilite/markdown.awk
index c08d856da87c1e3a1b30ea4d3b8a212bfa6856d2,34879d25c22ba3498633c366374a9feeac6be943..34879d25c22ba3498633c366374a9feeac6be943
@@@ -158,18 -158,18 +158,18 @@@ function inline( line, LOCAL, len, text
      href = gensub(/^\[\[([^]|]+)(\|([^]]+))?\]\]/, "\\1", 1, substr(line, 1, len) );
      text = gensub(/^\[\[([^]|]+)(\|([^]]+))?\]\]/, "\\3", 1, substr(line, 1, len) );
      if ( ! text ) text = href;
-     return "<a href=\"" URL(href) "\">" HTML(text) "</a>" inline( substr( line, len + 1) );
+     return "<a href=\"" HTML(href) "\">" HTML(text) "</a>" inline( substr( line, len + 1) );
  
    #  quick links ("automatic links" in md doc)
    } else if ( match( line, /^<[a-zA-Z]+:\/\/([-\.[:alnum:]]+)(:[0-9]*)?(\/[^>]*)?>/ ) ) {
      len = RLENGTH;
-     href = URL( substr( line, 2, len - 2) );
+     href = HTML( substr( line, 2, len - 2) );
      return "<a href=\"" href "\">" href "</a>" inline( substr( line, len + 1) );
  
    # quick link email
    } else if ( match( line, /^<[a-zA-Z0-9.!#$%&'\''*+\/=?^_`{|}~-]+@[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*>/ ) ) {
      len = RLENGTH;
-     href = URL( substr( line, 2, len - 2) );
+     href = HTML( substr( line, 2, len - 2) );
      return "<a href=\"mailto:" href "\">" href "</a>" inline( substr( line, len + 1) );
  
    # Verbatim inline HTML
  
      gsub(/\\/, "", href); gsub(/\\/, "", title); gsub(/[\n\t]+/, " ", title);
  
-     return "<a href=\"" URL(href) "\"" (title?" title=\"" HTML(title) "\"":"") ">" \
+     return "<a href=\"" HTML(href) "\"" (title?" title=\"" HTML(title) "\"":"") ">" \
             inline( text ) "</a>" inline( substr( line, len + 1) );
  
    # reference style links
        id = gensub(/^\[([^\n]+)\] ?\[([^\n]*)\].*/, "\\2", 1, substr(line, 1, len) );
      if ( ! id ) id = text;
      if ( rl_href[id] && rl_title[id] ) {
-       return "<a href=\"" URL(rl_href[id]) "\" title=\"" HTML(rl_title[id]) "\">" inline(text) "</a>" inline( substr( line, len + 1) );
+       return "<a href=\"" HTML(rl_href[id]) "\" title=\"" HTML(rl_title[id]) "\">" inline(text) "</a>" inline( substr( line, len + 1) );
      } else if ( rl_href[id] ) {
-       return "<a href=\"" URL(rl_href[id]) "\">" inline(text) "</a>" inline( substr( line, len + 1) );
+       return "<a href=\"" HTML(rl_href[id]) "\">" inline(text) "</a>" inline( substr( line, len + 1) );
      } else {
        return "" HTML(substr(line, 1, len)) inline( substr(line, len + 1) );
      }
      gsub(/^[\t ]+$/, "", text); gsub(/\\/, "", href);
      gsub(/\\/, "", title); gsub(/[\n\t]+/, " ", title);
  
-     return "<img src=\"" URL(href, 1) "\" alt=\"" HTML(text?text:title?title:href) "\"" \
+     return "<img src=\"" HTML(href, 1) "\" alt=\"" HTML(text?text:title?title:href) "\"" \
             (title?" title=\"" HTML(title) "\"":"") (attrib?" class=\"" HTML(attrib) "\"":"") \
             ">" inline( substr( line, len + 1) );
  
        id = gensub(/^!\[([^\n]*)\] ?\[([^\n]*)\].*/, "\\2", 1, substr(line, 1, len) );
      if ( ! id ) id = text;
      if ( rl_href[id] && rl_title[id] ) {
-       return "<img src=\"" URL(rl_href[id], 1) "\" alt=\"" HTML(text) "\" title=\"" HTML(rl_title[id]) "\">" \
+       return "<img src=\"" HTML(rl_href[id], 1) "\" alt=\"" HTML(text) "\" title=\"" HTML(rl_title[id]) "\">" \
               inline( substr( line, len + 1) );
      } else if ( rl_href[id] ) {
-       return "<img src=\"" URL(rl_href[id], 1) "\" alt=\"" HTML(text) "\">" \
+       return "<img src=\"" HTML(rl_href[id], 1) "\" alt=\"" HTML(text) "\">" \
               inline( substr( line, len + 1) );
      } else {
        return "" HTML(substr(line, 1, len)) inline( substr(line, len + 1) );
@@@ -663,8 -663,8 +663,8 @@@ function _block( block, LOCAL, st, len
  
      gsub(/^[\t ]+$/, "", text); gsub(/\\/, "", href);
  
-     return "<figure data-src=\"" URL(href, 1) "\"" (attrib?" class=\"" HTML(attrib) "\"":"") ">" \
-            "<img src=\"" URL(href, 1) "\" alt=\"" HTML(text?text:title?title:href) "\"" \
+     return "<figure data-src=\"" HTML(href, 1) "\"" (attrib?" class=\"" HTML(attrib) "\"":"") ">" \
+            "<img src=\"" HTML(href, 1) "\" alt=\"" HTML(text?text:title?title:href) "\"" \
             (attrib?" class=\"" HTML(attrib) "\"":"") ">" \
             (title?"<figcaption>" inline(title) "</figcaption>":"") \
             "</figure>\n\n" \
        id = gensub(/^!\[([^\n]*)\] ?\[([^\n]*)\](\n.*)?$/, "\\2", 1, block);
      if ( ! id ) id = text;
      if ( rl_href[id] && rl_title[id] ) {
-       return "<figure data-src=\"" URL(rl_href[id], 1) "\">" \
-                "<img src=\"" URL(rl_href[id], 1) "\" alt=\"" HTML(text) "\">" \
+       return "<figure data-src=\"" HTML(rl_href[id], 1) "\">" \
+                "<img src=\"" HTML(rl_href[id], 1) "\" alt=\"" HTML(text) "\">" \
                 "<figcaption>" inline(rl_title[id]) "</figcaption>" \
               "</figure>\n\n" \
               _block( substr( block, len + 1) );
      } else if ( rl_href[id] ) {
-       return "<figure data-src=\"" URL(rl_href[id], 1) "\">" \
-                "<img src=\"" URL(rl_href[id], 1) "\" alt=\"" HTML(text) "\">" \
+       return "<figure data-src=\"" HTML(rl_href[id], 1) "\">" \
+                "<img src=\"" HTML(rl_href[id], 1) "\" alt=\"" HTML(text) "\">" \
               "</figure>\n\n" \
               _block( substr( block, len + 1) );
      } else {