From 56b882d63f1409616a701eae40976aba7ef39583 Mon Sep 17 00:00:00 2001 From: Jakub Kądziołka Date: Sat, 17 Nov 2018 00:47:37 +0100 Subject: [PATCH] Support empty table cells --- scdoc.5.scd | 4 ++-- src/main.c | 31 ++++++++++++++++++------------- diff --git a/scdoc.5.scd b/scdoc.5.scd index b94952e8c1b4f2901f7c18780512fbfde496a49a..dfe5353a10279f626a10e66cca93984ebd424ee7 100644 --- a/scdoc.5.scd +++ b/scdoc.5.scd @@ -133,7 +133,7 @@ ``` [[ *Foo* :- _Bar_ -:- _Baz_ +:- | *Row 1* : Hello :] world! @@ -144,7 +144,7 @@ ``` [[ *Foo* :- _Bar_ -:- _Baz_ +:- | *Row 1* : Hello :] world! diff --git a/src/main.c b/src/main.c index 72173c6cc7a84b3788433e614ab82a15bdb1f755..10ba5877517574c58ba74c89fcdc0d170617a293 100644 --- a/src/main.c +++ b/src/main.c @@ -487,21 +487,26 @@ default: parser_fatal(p, "Expected one of '[', '-', ']', or ' '"); break; } - if ((ch = parser_getch(p)) != ' ') { - parser_fatal(p, "Expected ' '"); - break; - } - // Read out remainder of the text curcell->contents = str_create(); - while ((ch = parser_getch(p)) != UTF8_INVALID) { - switch (ch) { - case '\n': - goto commit_cell; - default:; - int ret = str_append_ch(curcell->contents, ch); - assert(ret != -1); - break; + switch (ch = parser_getch(p)) { + case ' ': + // Read out remainder of the text + while ((ch = parser_getch(p)) != UTF8_INVALID) { + switch (ch) { + case '\n': + goto commit_cell; + default:; + int ret = str_append_ch(curcell->contents, ch); + assert(ret != -1); + break; + } } + break; + case '\n': + goto commit_cell; + default: + parser_fatal(p, "Expected ' ' or a newline"); + break; } commit_cell: if (strstr(curcell->contents->str, "T{") -- 2.48.1