From 49e39ef72a0c669adf03f15f0e54b0aceae3d563 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 10 Dec 2017 00:01:01 -0500 Subject: [PATCH] Handle escaping correctly --- src/main.c | 22 ++++++++++++++++++---- diff --git a/src/main.c b/src/main.c index 30433a5ea7482f17f88037db4d24d5c8c256e297..bbb72675e9260ba31e20daf03fd6777c8ed7d9c9 100644 --- a/src/main.c +++ b/src/main.c @@ -66,7 +66,14 @@ int i = 0; while ((ch = parser_getch(p)) != UTF8_INVALID) { switch (ch) { case '\\': - fprintf(p->output, "\\\\"); + ch = parser_getch(p); + if (ch == UTF8_INVALID) { + parser_fatal(p, "Unexpected EOF"); + } else if (ch == '\\') { + fprintf(p->output, "\\\\"); + } else { + utf8_fputch(p->output, ch); + } break; case '.': if (!i) { @@ -146,15 +153,22 @@ if (ch == UTF8_INVALID) { break; } + if (indent != 0) { + // Only text is allowed at this point + parser_pushch(p, ch); + parse_text(p); + continue; + } + switch (ch) { case '#': parse_heading(p); break; - case '\n': - roff_macro(p, "P", NULL); - break; case ' ': parser_fatal(p, "Tabs are required for indentation"); + break; + case '\n': + roff_macro(p, "P", NULL); break; default: parser_pushch(p, ch); -- 2.48.1