]> git.neil.brown.name Git - edlib.git/commitdiff
lib-renderline: enhance cvt() to allow > in text attributes.
authorNeilBrown <neil@brown.name>
Sun, 20 Aug 2023 06:32:37 +0000 (16:32 +1000)
committerNeilBrown <neil@brown.name>
Sun, 20 Aug 2023 22:47:19 +0000 (08:47 +1000)
This is not particularly useful, but I wanted a '>' in a wrap-head for
testing, and I couldn't.  So I made it possible.

Signed-off-by: NeilBrown <neil@brown.name>
lib-renderline.c
tests.d/D-test-markup

index 62ebe1133fb6610ba31ca547b558e1b1fdc56be9..a07de01a274824995be0a572ec1f076abc2e39af 100644 (file)
@@ -1229,7 +1229,7 @@ static char *cvt(char *str safe)
         *    < stuff > to soh stuff stx
         *    </> to ack ack etx
         */
-       char *c;
+       char *c, *c1;
        for (c = str; *c; c += 1) {
                if (c[0] == soh || c[0] == ack)
                        break;
@@ -1249,11 +1249,19 @@ static char *cvt(char *str safe)
                        continue;
                }
                c[0] = soh;
-               while (c[0] && c[1] != '>')
-                       c++;
-               if (!c[0])
+               c += 1;
+               c1 = c;
+               while (*c && *c != '>') {
+                       if (*c == '\\' &&
+                           (c[1] == '\\' || c[1] == '>'))
+                               c++;
+                       *c1++ = *c++;
+               }
+               while (c1 < c)
+                       *c1++ = ack;
+               if (!*c)
                        break;
-               c[1] = stx;
+               *c = stx;
        }
        return str;
 }
index df74e1371467e11d9456b720db1a2c518623e966..635a1773071b191ee49dcbdddded42eeb057ccda 100644 (file)
@@ -1,4 +1,8 @@
 <space-above:40,space-below:10,20,fg:blue,bg:yellow,center>This is my test file for markup</>
 <word-wrap,wrap-tail:,wrap-head:-),wrap-,right:400,left:70>Now is the time for all good men to come to the aid of the party</a>
 
-<wrap-tail:,wrap-head:-),wrap-,right:400,left:70>Now is the time for all good men to come to the aid of the party</a>
+<wrap-tail:,wrap-head:-\>,wrap-,right:300,left:70>Now is the time for all good men to come to the aid of the party</a>
+
+LEFT<ctab,bg:green>MIDDLE</><rtab>RIGHT
+
+<word-wrap,tab:40,wrap-margin,right:300><tab:0>This is a line that should wrap to form a paragraph with hanging indent</>