From 6707a05c77b813436fb16d2da8f85b00b64dc689 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 10 Dec 2017 12:04:25 -0500 Subject: [PATCH] Add multi-line list entries --- scdoc.1.scd | 17 +++++++++++++++++ src/main.c | 14 ++++++++++++-- diff --git a/scdoc.1.scd b/scdoc.1.scd index 4a7dfcc2f03ab74c61e8627257b9772b7b3d0a51..012645b2161469e79b13472b6bae5bf73083fe48 100644 --- a/scdoc.1.scd +++ b/scdoc.1.scd @@ -78,6 +78,23 @@ - Subitem 1 - Subitem 2 - Item 3 +You may also extend long entries onto another line by giving it the same indent +level, plus two spaces. They will be rendered as a single list entry. + +``` +- Item 1 is pretty long so let's + break it up onto two lines +- Item 2 is shorter + - But its children can go on + for a while +``` + +- Item 1 is pretty long so let's + break it up onto two lines +- Item 2 is shorter + - But its children can go on + for a while + ## LITERAL TEXT You may turn off scdoc formatting and output literal text with escape codes and diff --git a/src/main.c b/src/main.c index b57c962c6d90393e223fbdd00b33c56df79702d9..e50b1d1e4a8ecd3d575c8220386546f1cb189f10 100644 --- a/src/main.c +++ b/src/main.c @@ -193,7 +193,7 @@ parser_fatal(p, "Expected space before start of list entry"); } list_header(p, "\\(bu"); parse_text(p); - roff_macro(p, "RE", NULL); + bool closed = false; do { parse_indent(p, indent, true); if ((ch = parser_getch(p)) == UTF8_INVALID) { @@ -201,14 +201,21 @@ break; } switch (ch) { case ' ': + if ((ch = parser_getch(p)) != ' ') { + parser_fatal(p, "Expected two spaces for list entry continuation"); + } + parse_text(p); break; case '-': if ((ch = parser_getch(p)) != ' ') { parser_fatal(p, "Expected space before start of list entry"); } + if (!closed) { + roff_macro(p, "RE", NULL); + } list_header(p, "\\(bu"); parse_text(p); - roff_macro(p, "RE", NULL); + closed = false; break; default: fprintf(p->output, "\n"); @@ -216,6 +223,9 @@ parser_pushch(p, ch); return; } } while (ch != UTF8_INVALID); + if (!closed) { + roff_macro(p, "RE", NULL); + } } static void parse_literal(struct parser *p, int *indent) { -- 2.48.1