From 0917856ac7d1daaea1001a6aebdc37bc099c6b21 Mon Sep 17 00:00:00 2001 From: Damien Tardy-Panis Date: Tue, 19 May 2020 18:19:50 +0200 Subject: [PATCH] Fix parsing of line breaks followed by underlined text --- src/main.c | 11 +++++++---- test/line-breaks | 9 +++++++++ diff --git a/src/main.c b/src/main.c index 08bf384e0c4ba19450c78c0bb45b4240229281a4..7bb6c4204e4297558f84b99111a7e51a390d8a28 100644 --- a/src/main.c +++ b/src/main.c @@ -176,19 +176,19 @@ } p->flags ^= fmt; } -static void parse_linebreak(struct parser *p) { +static bool parse_linebreak(struct parser *p) { uint32_t plus = parser_getch(p); if (plus != '+') { fprintf(p->output, "+"); parser_pushch(p, plus); - return; + return false; } uint32_t lf = parser_getch(p); if (lf != '\n') { fprintf(p->output, "+"); parser_pushch(p, lf); parser_pushch(p, plus); - return; + return false; } uint32_t ch = parser_getch(p); if (ch == '\n') { @@ -197,6 +197,7 @@ p, "Explicit line breaks cannot be followed by a blank line"); } parser_pushch(p, ch); fprintf(p->output, "\n.br\n"); + return true; } static void parse_text(struct parser *p) { @@ -230,7 +231,9 @@ } parser_pushch(p, next); break; case '+': - parse_linebreak(p); + if (parse_linebreak(p)) { + last = '\n'; + } break; case '\n': utf8_fputch(p->output, ch); diff --git a/test/line-breaks b/test/line-breaks index e97332fe11d0e24052a4eb297e9b6a0fdc7aca33..c119bd9a175bfb00b62be8bfd8a9ae488773dc62 100755 --- a/test/line-breaks +++ b/test/line-breaks @@ -35,3 +35,12 @@ hello++world EOF end 0 + +begin "Handles underlined text following line break" +scdoc </dev/null +test(8) + +hello++ +_world_ +EOF +end 0 -- 2.48.1