Improve list output

master
Drew DeVault 7 years ago
parent bd924fa2ec
commit 84e46ded31
  1. 4
      Makefile
  2. 19
      src/main.c

@ -1,6 +1,6 @@
VERSION=1.0.0 VERSION=1.0.0
CC=cc CC=cc
CFLAGS=-DVERSION='"$(VERSION)"' -Wall -Wextra -Werror -Wno-unused-parameter -std=c99 -pedantic CFLAGS=-DVERSION='"$(VERSION)"' -Wall -Wextra -Werror -Wno-unused-parameter
LDFLAGS=-static LDFLAGS=-static
INCLUDE=-Iinclude INCLUDE=-Iinclude
PREFIX=/usr/local PREFIX=/usr/local
@ -23,7 +23,7 @@ OBJECTS=\
.build/%.o: src/%.c .build/%.o: src/%.c
@mkdir -p .build @mkdir -p .build
$(CC) -std=c99 -c -o $@ $(CFLAGS) $(INCLUDE) $< $(CC) -std=c99 -pedantic -c -o $@ $(CFLAGS) $(INCLUDE) $<
scdoc: $(OBJECTS) scdoc: $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $^ $(CC) $(LDFLAGS) -o $@ $^

@ -171,18 +171,29 @@ static int parse_indent(struct parser *p, int *indent, bool write) {
} else if (i != *indent && ch == '\t') { } else if (i != *indent && ch == '\t') {
parser_fatal(p, "Indented by an amount greater than 1"); parser_fatal(p, "Indented by an amount greater than 1");
} }
}
*indent = i; *indent = i;
}
return i; return i;
} }
static void list_header(struct parser *p, const char *sym) {
roff_macro(p, "RS", "4", NULL);
fprintf(p->output, ".ie n \\{\\\n");
fprintf(p->output, "\\h'-04'%s\\h'+03'\\c\n", sym);
fprintf(p->output, ".\\}\n");
fprintf(p->output, ".el \\{\\\n");
roff_macro(p, "IP", sym, "4", NULL);
fprintf(p->output, ".\\}\n");
}
static void parse_list(struct parser *p, int *indent) { static void parse_list(struct parser *p, int *indent) {
uint32_t ch; uint32_t ch;
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");
} }
roff_macro(p, "IP", "\\(bu", "4", NULL); list_header(p, "\\(bu");
parse_text(p); parse_text(p);
roff_macro(p, "RE", NULL);
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) {
@ -195,9 +206,9 @@ static void parse_list(struct parser *p, int *indent) {
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");
} }
fprintf(p->output, ".sp -1\n"); list_header(p, "\\(bu");
roff_macro(p, "IP", "\\(bu", "4", NULL);
parse_text(p); parse_text(p);
roff_macro(p, "RE", NULL);
break; break;
default: default:
fprintf(p->output, "\n"); fprintf(p->output, "\n");

Loading…
Cancel
Save