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

diff --combined cgilite/markdown.awk
index 249f5074b213b68511f94009b5d708db99b0b51a,7e29c572213e553df07563099cf52683ed11b960..7e29c572213e553df07563099cf52683ed11b960
@@@ -178,12 -178,12 +178,12 @@@ function inline( line, LOCAL, len, text
      return substr( line, 1, len) inline(substr(line, len + 1));
  
    # inline links
-   } else if ( match(line, "^" lii "\\([\\n\\t ]*" lid "([\\n\\t ]+" lit ")?[\\n\\t ]*\\)") ) {
+   } else if ( match(line, "^" lii "\\([\n\t ]*" lid "([\n\t ]+" lit ")?[\n\t ]*\\)") ) {
      len = RLENGTH;
      text = href = title = substr( line, 1, len);
-     sub("^\\[", "", text); sub("\\]\\([\\n\\t ]*" lid "([\\n\\t ]+" lit ")?[\\n\\t ]*\\)$", "", text);
-     sub("^" lii "\\([\\n\\t ]*", "", href); sub("([\\n\\t ]+" lit ")?[\\n\\t ]*\\)$", "", href);
-     sub("^" lii "\\([\\n\\t ]*" lid, "", title); sub("[\\n\\t ]*\\)$", "", title); sub("^[\\n\\t ]+", "", title);
+     sub("^\\[", "", text); sub("\\]\\([\n\t ]*" lid "([\n\t ]+" lit ")?[\n\t ]*\\)$", "", text);
+     sub("^" lii "\\([\n\t ]*", "", href); sub("([\n\t ]+" lit ")?[\n\t ]*\\)$", "", href);
+     sub("^" lii "\\([\n\t ]*" lid, "", title); sub("[\n\t ]*\\)$", "", title); sub("^[\n\t ]+", "", title);
  
      if ( match(href, /^<.*>$/) ) { sub(/^</, "", href); sub(/>$/, "", href); }
           if ( match(title, /^".*"$/) ) { sub(/^"/, "", title); sub(/"$/, "", title); }
      }
  
    # inline images
-   } else if ( match(line, "^!" lix "\\([\\n\\t ]*" lid "([\\n\\t ]+" lit ")?[\\n\\t ]*\\)(\\{[a-zA-Z \\t-]*\\})?") ) {
+   } else if ( match(line, "^!" lix "\\([\n\t ]*" lid "([\n\t ]+" lit ")?[\n\t ]*\\)(\\{[a-zA-Z \t-]*\\})?") ) {
      len = RLENGTH; text = href = title = attrib = substr( line, 1, len);
  
      sub("^!\\[", "", text);
-     sub("\\]\\([\\n\\t ]*" lid "([\\n\\t ]+" lit ")?[\\n\\t ]*\\)(\\{[a-zA-Z \\t-]*\\})?$", "", text);
+     sub("\\]\\([\n\t ]*" lid "([\n\t ]+" lit ")?[\n\t ]*\\)(\\{[a-zA-Z \t-]*\\})?$", "", text);
  
-     sub("^!" lix "\\([\\n\\t ]*", "", href);
-     sub("([\\n\\t ]+" lit ")?[\\n\\t ]*\\)(\\{[a-zA-Z \\t-]*\\})?$", "", href);
+     sub("^!" lix "\\([\n\t ]*", "", href);
+     sub("([\n\t ]+" lit ")?[\n\t ]*\\)(\\{[a-zA-Z \t-]*\\})?$", "", href);
  
-     sub("^!" lix "\\([\\n\\t ]*" lid, "", title);
-     sub("[\\n\\t ]*\\)(\\{[a-zA-Z \\t-]*\\})?$", "", title);
-     sub("^[\\n\\t ]+", "", title);
+     sub("^!" lix "\\([\n\t ]*" lid, "", title);
+     sub("[\n\t ]*\\)(\\{[a-zA-Z \t-]*\\})?$", "", title);
+     sub("^[\n\t ]+", "", title);
  
-     sub("^!" lix "\\([\\n\\t ]*" lid "([\\n\\t ]+" lit ")?[\\n\\t ]*\\)", "", attrib);
+     sub("^!" lix "\\([\n\t ]*" lid "([\n\t ]+" lit ")?[\n\t ]*\\)", "", attrib);
      sub(/^\{[ \t]*/, "", attrib); sub(/[ \t]*\}$/, "", attrib); gsub(/[ \t]+/, " ", attrib);
  
      if ( match(href, /^<.*>$/) ) { sub(/^</, "", href); sub(/>$/, "", href); }
@@@ -639,21 -639,21 +639,21 @@@ function _block( block, LOCAL, st, len
      return headline( n, text, 0 ) _block( substr( block, len + 1) );
  
    # block images (wrapped in <figure>)
-   } else if ( match(block, "^!" lix "\\([\\n\\t ]*" lid "([\\n\\t ]+" lit ")?[\\n\\t ]*\\)(\\{[a-zA-Z \\t-]*\\})?(\\n|$)") ) {
+   } else if ( match(block, "^!" lix "\\([\n\t ]*" lid "([\n\t ]+" lit ")?[\n\t ]*\\)(\\{[a-zA-Z \t-]*\\})?(\n|$)") ) {
      len = RLENGTH; text = href = title = attrib = substr( block, 1, len);
  
      sub("^!\\[", "", text);
-     sub("\\]\\([\\n\\t ]*" lid "([\\n\\t ]+" lit ")?[\\n\\t ]*\\)(\\{[a-zA-Z \\t-]*\\})?(\\n.*)?$", "", text);
+     sub("\\]\\([\n\t ]*" lid "([\n\t ]+" lit ")?[\n\t ]*\\)(\\{[a-zA-Z \t-]*\\})?(\n.*)?$", "", text);
  
-     sub("^!" lix "\\([\\n\\t ]*", "", href);
-     sub("([\\n\\t ]+" lit ")?[\\n\\t ]*\\)(\\{[a-zA-Z \\t-]*\\})?(\\n.*)?$", "", href);
+     sub("^!" lix "\\([\n\t ]*", "", href);
+     sub("([\n\t ]+" lit ")?[\n\t ]*\\)(\\{[a-zA-Z \t-]*\\})?(\n.*)?$", "", href);
  
-     sub("^!" lix "\\([\\n\\t ]*" lid, "", title);
-     sub("[\\n\\t ]*\\)(\\{[a-zA-Z \\t-]*\\})?(\\n.*)?$", "", title);
-     sub("^[\\n\\t ]+", "", title);
+     sub("^!" lix "\\([\n\t ]*" lid, "", title);
+     sub("[\n\t ]*\\)(\\{[a-zA-Z \t-]*\\})?(\n.*)?$", "", title);
+     sub("^[\n\t ]+", "", title);
  
-     sub("^!" lix "\\([\\n\\t ]*" lid "([\\n\\t ]+" lit ")?[\\n\\t ]*\\)", "", attrib);
-     sub("(\\n.*)?$", "", attrib);
+     sub("^!" lix "\\([\n\t ]*" lid "([\n\t ]+" lit ")?[\n\t ]*\\)", "", attrib);
+     sub("(\n.*)?$", "", attrib);
      sub(/^\{[ \t]*/, "", attrib); sub(/[ \t]*\}$/, "", attrib); gsub(/[ \t]+/, " ", attrib);
  
      if ( match(href, /^<.*>$/) ) { sub(/^</, "", href); sub(/>$/, "", href); }
@@@ -834,11 -834,11 +834,11 @@@ BEGIN 
    iea =    "\\*([^\\*[:space:]]|[^\\*[:space:]]" na "[^\\*[:space:]])\\*"     # inner <em> (asterisk)
    isa = "\\*\\*([^\\*[:space:]]|[^\\*[:space:]]" na "[^\\*[:space:]])\\*\\*"  # inner <strong> (asterisk)
  
-   lix="\\[(\\\\[^\\n]|[^]\\n\\\\[])*\\]"  # link text
-   lid="(<(\\\\[^\\n]|[^\\n<>\\\\])*>|([^<\\n\\t ()\\\\]|\\\\[^\\n])(\\\\[\\n]|[^\\n\\t ()\\\\])*)"  # link dest
-   lit="(\"(\\\\.|[^\"\\\\])*\"|'(\\\\.|[^'\\\\])*'|\\((\\\\.|[^()\\\\])*\\))"  # link text
+   lix="\\[(\\\\[^\n]|[^]\n\\\\[])*\\]"  # link text
+   lid="(<(\\\\[^\n]|[^\n<>\\\\])*>|(\\\\.|[^()\"'\\\\])+|([^<\n\t ()\\\\]|\\\\[^\n])(\\\\[\n]|[^\n\t \\(\\)\\\\])*)"  # link dest
+   lit="(\"(\\\\.|[^\"\\\\])*\"|'(\\\\.|[^'\\\\])*'|\\((\\\\.|[^\\(\\)\\\\])*\\))"  # link text
    # link text with image def
-   lii="\\[(\\\\[^\\n]|[^]\\n\\\\[])*(!" lix "\\([\\n\\t ]*" lid "([\\n\\t ]+" lit ")?[\\n\\t ]*\\))?(\\\\[^\\n]|[^]\\n\\\\[])*\\]"
+   lii="\\[(\\\\[^\n]|[^]\n\\\\[])*(!" lix "\\([\n\t ]*" lid "([\n\t ]+" lit ")?[\n\t ]*\\))?(\\\\[^\n]|[^]\n\\\\[])*\\]"
  
    # Buffering of full file ist necessary, e.g. to find reference links
    while (getline) { file = file $0 "\n"; }