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 +++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 08bf384..7bb6c42 100644 --- a/src/main.c +++ b/src/main.c @@ -176,19 +176,19 @@ static void parse_format(struct parser *p, enum formatting fmt) { 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 @@ static void parse_linebreak(struct parser *p) { } parser_pushch(p, ch); fprintf(p->output, "\n.br\n"); + return true; } static void parse_text(struct parser *p) { @@ -230,7 +231,9 @@ static void parse_text(struct parser *p) { 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 e97332f..c119bd9 100755 --- a/test/line-breaks +++ b/test/line-breaks @@ -35,3 +35,12 @@ test(8) hello++world EOF end 0 + +begin "Handles underlined text following line break" +scdoc </dev/null +test(8) + +hello++ +_world_ +EOF +end 0