Improve indentation handling

master 1.0.1
Drew DeVault 7 years ago
parent 9eb8e9bc2c
commit 175c566cea
  1. 3
      scdoc.1.scd
  2. 12
      src/main.c

@ -55,7 +55,8 @@ the output. Indented lines may not contain headers.
You may use multiple lines and most _formatting_.
Deindent to return to normal.
Deindent to return to normal, or indent again to increase your indentation
depth.
## LISTS

@ -157,13 +157,19 @@ static int parse_indent(struct parser *p, int *indent, bool write) {
++i;
}
parser_pushch(p, ch);
if (ch == '\n' && *indent != 0) {
// Don't change indent when we encounter empty lines
return *indent;
}
if (write) {
if (i == *indent - 1) {
roff_macro(p, "RE", NULL);
if (i < *indent) {
for (int j = *indent; i < j; --j) {
roff_macro(p, "RE", NULL);
}
} else if (i == *indent + 1) {
roff_macro(p, "RS", "4", NULL);
} else if (i != *indent && ch == '\t') {
parser_fatal(p, "(De)indented by an amount greater than 1");
parser_fatal(p, "Indented by an amount greater than 1");
}
}
*indent = i;

Loading…
Cancel
Save