Add multi-line list entries

master
Drew DeVault 7 years ago
parent 84e46ded31
commit 6707a05c77
  1. 17
      scdoc.1.scd
  2. 14
      src/main.c

@ -78,6 +78,23 @@ The result looks like this:
- Subitem 2 - Subitem 2
- Item 3 - 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 ## LITERAL TEXT
You may turn off scdoc formatting and output literal text with escape codes and You may turn off scdoc formatting and output literal text with escape codes and

@ -193,7 +193,7 @@ static void parse_list(struct parser *p, int *indent) {
} }
list_header(p, "\\(bu"); list_header(p, "\\(bu");
parse_text(p); parse_text(p);
roff_macro(p, "RE", NULL); bool closed = false;
do { do {
parse_indent(p, indent, true); parse_indent(p, indent, true);
if ((ch = parser_getch(p)) == UTF8_INVALID) { if ((ch = parser_getch(p)) == UTF8_INVALID) {
@ -201,14 +201,21 @@ static void parse_list(struct parser *p, int *indent) {
} }
switch (ch) { switch (ch) {
case ' ': case ' ':
if ((ch = parser_getch(p)) != ' ') {
parser_fatal(p, "Expected two spaces for list entry continuation");
}
parse_text(p);
break; break;
case '-': case '-':
if ((ch = parser_getch(p)) != ' ') { if ((ch = parser_getch(p)) != ' ') {
parser_fatal(p, "Expected space before start of list entry"); parser_fatal(p, "Expected space before start of list entry");
} }
if (!closed) {
roff_macro(p, "RE", NULL);
}
list_header(p, "\\(bu"); list_header(p, "\\(bu");
parse_text(p); parse_text(p);
roff_macro(p, "RE", NULL); closed = false;
break; break;
default: default:
fprintf(p->output, "\n"); fprintf(p->output, "\n");
@ -216,6 +223,9 @@ static void parse_list(struct parser *p, int *indent) {
return; return;
} }
} while (ch != UTF8_INVALID); } while (ch != UTF8_INVALID);
if (!closed) {
roff_macro(p, "RE", NULL);
}
} }
static void parse_literal(struct parser *p, int *indent) { static void parse_literal(struct parser *p, int *indent) {

Loading…
Cancel
Save