Support empty table cells

master
Jakub Kądziołka 6 years ago committed by Drew DeVault
parent 3f4de3da0a
commit 56b882d63f
  1. 4
      scdoc.5.scd
  2. 31
      src/main.c

@ -133,7 +133,7 @@ To conclude your table, add an empty line after the last row.
``` ```
[[ *Foo* [[ *Foo*
:- _Bar_ :- _Bar_
:- _Baz_ :-
| *Row 1* | *Row 1*
: Hello : Hello
:] world! :] world!
@ -144,7 +144,7 @@ To conclude your table, add an empty line after the last row.
[[ *Foo* [[ *Foo*
:- _Bar_ :- _Bar_
:- _Baz_ :-
| *Row 1* | *Row 1*
: Hello : Hello
:] world! :] world!

@ -487,21 +487,26 @@ static void parse_table(struct parser *p, uint32_t style) {
parser_fatal(p, "Expected one of '[', '-', ']', or ' '"); parser_fatal(p, "Expected one of '[', '-', ']', or ' '");
break; break;
} }
if ((ch = parser_getch(p)) != ' ') {
parser_fatal(p, "Expected ' '");
break;
}
// Read out remainder of the text
curcell->contents = str_create(); curcell->contents = str_create();
while ((ch = parser_getch(p)) != UTF8_INVALID) { switch (ch = parser_getch(p)) {
switch (ch) { case ' ':
case '\n': // Read out remainder of the text
goto commit_cell; while ((ch = parser_getch(p)) != UTF8_INVALID) {
default:; switch (ch) {
int ret = str_append_ch(curcell->contents, ch); case '\n':
assert(ret != -1); goto commit_cell;
break; 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: commit_cell:
if (strstr(curcell->contents->str, "T{") if (strstr(curcell->contents->str, "T{")

Loading…
Cancel
Save