]> git.plutz.net Git - shellwiki/commitdiff
Merge commit '8d70db1b103253dc37ba234b8c65b57a6cced077'
authorPaul Hänsch <paul@plutz.net>
Mon, 9 Oct 2023 12:01:14 +0000 (14:01 +0200)
committerPaul Hänsch <paul@plutz.net>
Mon, 9 Oct 2023 12:01:14 +0000 (14:01 +0200)
1  2 
cgilite/markdown.awk

diff --combined cgilite/markdown.awk
index 75f182746bd29d9375c7af1b1e52c39737fb2a58,249f5074b213b68511f94009b5d708db99b0b51a..249f5074b213b68511f94009b5d708db99b0b51a
@@@ -231,9 -231,10 +231,10 @@@ function inline( line, LOCAL, len, text
      else if ( match(title, /^'.*'$/) ) { sub(/^'/, "", title); sub(/'$/, "", title); }
      else if ( match(title, /^\(.*\)$/) ) { sub(/^\(/, "", title); sub(/\)$/, "", title); }
  
-     gsub(/\\/, "", href); gsub(/\\/, "", title); gsub(/[\n\t]+/, " ", title);
+     gsub(/^[\t ]+$/, "", text); gsub(/\\/, "", href);
+     gsub(/\\/, "", title); gsub(/[\n\t]+/, " ", title);
  
-     return "<img src=\"" URL(href, 1) "\" alt=\"" HTML(text) "\"" \
+     return "<img src=\"" URL(href, 1) "\" alt=\"" HTML(text?text:title?title:href) "\"" \
             (title?" title=\"" HTML(title) "\"":"") (attrib?" class=\"" HTML(attrib) "\"":"") \
             ">" inline( substr( line, len + 1) );
  
@@@ -660,10 -661,10 +661,10 @@@ function _block( block, LOCAL, st, len
      else if ( match(title, /^'.*'$/) ) { sub(/^'/, "", title); sub(/'$/, "", title); }
      else if ( match(title, /^\(.*\)$/) ) { sub(/^\(/, "", title); sub(/\)$/, "", title); }
  
-     gsub(/\\/, "", href);
+     gsub(/^[\t ]+$/, "", text); gsub(/\\/, "", href);
  
      return "<figure data-src=\"" URL(href, 1) "\"" (attrib?" class=\"" HTML(attrib) "\"":"") ">" \
-            "<img src=\"" URL(href, 1) "\" alt=\"" HTML(text) "\"" \
+            "<img src=\"" URL(href, 1) "\" alt=\"" HTML(text?text:title?title:href) "\"" \
             (attrib?" class=\"" HTML(attrib) "\"":"") ">" \
             (title?"<figcaption>" inline(title) "</figcaption>":"") \
             "</figure>\n\n" \