From 5cce66ba41ced00485489cd1dd09b2650458c112 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 20 Aug 2023 16:32:37 +1000 Subject: [PATCH] lib-renderline: enhance cvt() to allow > in text attributes. 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 --- lib-renderline.c | 18 +++++++++++++----- tests.d/D-test-markup | 6 +++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib-renderline.c b/lib-renderline.c index 62ebe113..a07de01a 100644 --- a/lib-renderline.c +++ b/lib-renderline.c @@ -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; } diff --git a/tests.d/D-test-markup b/tests.d/D-test-markup index df74e137..635a1773 100644 --- a/tests.d/D-test-markup +++ b/tests.d/D-test-markup @@ -1,4 +1,8 @@ This is my test file for markup Now is the time for all good men to come to the aid of the party -Now is the time for all good men to come to the aid of the party +,wrap-,right:300,left:70>Now is the time for all good men to come to the aid of the party + +LEFTMIDDLERIGHT + +This is a line that should wrap to form a paragraph with hanging indent -- 2.39.5