scdoc2mdoc

A fork of scdoc to output mdoc(7)
git clone git://git.sgregoratto.me/scdoc2mdoc
Log | Files | Refs | README | LICENSE

commit 6707a05c77b813436fb16d2da8f85b00b64dc689
parent 84e46ded31ebc3df3c9dd6171ee7c0c79d7af68d
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sun, 10 Dec 2017 12:04:25 -0500

Add multi-line list entries

Diffstat:
Mscdoc.1.scd | 17+++++++++++++++++
Msrc/main.c | 14++++++++++++--
2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/scdoc.1.scd b/scdoc.1.scd @@ -78,6 +78,23 @@ The result looks like this: - 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 @@ -193,7 +193,7 @@ static void parse_list(struct parser *p, int *indent) { } 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 @@ static void parse_list(struct parser *p, int *indent) { } 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 @@ static void parse_list(struct parser *p, int *indent) { return; } } while (ch != UTF8_INVALID); + if (!closed) { + roff_macro(p, "RE", NULL); + } } static void parse_literal(struct parser *p, int *indent) {