diff options
author | Humm <hummsmith42@gmail.com> | 2022-01-14 00:56:18 +0000 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2022-01-14 08:47:25 +0100 |
commit | 4af1e1e3a8ebfddcc11a189254d60fc4ad74cd59 (patch) | |
tree | 224f016b9ae3f83bcad70ba7e93575e4cfed1ae2 | |
parent | b16de454afc736a87c0386390c4cc91ba3cc8f29 (diff) |
simplify list output
For lists, plain old indented paragraphs are the perfect tool. To not
have vertical space between list items, we use .PD 0.
Should the many needless .PP be removed, will the .PD 0 have to be moved
after the first list item, such that that introduces vertical space
after the last paragraph.
-rw-r--r-- | src/main.c | 20 |
1 files changed, 3 insertions, 17 deletions
@@ -329,24 +329,12 @@ static int parse_indent(struct parser *p, int *indent, bool write) { } static void list_header(struct parser *p, int *num) { - fprintf(p->output, ".RS 4\n"); - fprintf(p->output, ".ie n \\{\\\n"); - if (*num == -1) { - fprintf(p->output, "\\h'-0%d'%s\\h'+03'\\c\n", - *num >= 10 ? 5 : 4, "\\(bu"); - } else { - fprintf(p->output, "\\h'-0%d'%d.\\h'+03'\\c\n", - *num >= 10 ? 5 : 4, *num); - } - fprintf(p->output, ".\\}\n"); - fprintf(p->output, ".el \\{\\\n"); if (*num == -1) { fprintf(p->output, ".IP %s 4\n", "\\(bu"); } else { fprintf(p->output, ".IP %d. 4\n", *num); *num = *num + 1; } - fprintf(p->output, ".\\}\n"); } static void parse_list(struct parser *p, int *indent, int num) { @@ -354,6 +342,7 @@ static void parse_list(struct parser *p, int *indent, int num) { if ((ch = parser_getch(p)) != ' ') { parser_fatal(p, "Expected space before start of list entry"); } + fprintf(p->output, ".PD 0\n"); list_header(p, &num); parse_text(p); do { @@ -373,18 +362,15 @@ static void parse_list(struct parser *p, int *indent, int num) { if ((ch = parser_getch(p)) != ' ') { parser_fatal(p, "Expected space before start of list entry"); } - roff_macro(p, "RE", NULL); list_header(p, &num); parse_text(p); break; default: - fprintf(p->output, "\n"); + roff_macro(p, "PD", NULL); parser_pushch(p, ch); - goto ret; + return; } } while (ch != UTF8_INVALID); -ret: - roff_macro(p, "RE", NULL); } static void parse_literal(struct parser *p, int *indent) { |