diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2020-04-04 20:33:33 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2020-04-04 20:33:33 +0000 |
commit | 9c50b3f3dd65454028a85113ebc01c5f1f8dabf5 (patch) | |
tree | f7778be8dcc38ab5b5be9249af0179379362db27 /man_validate.c | |
parent | 6b5bf18962a3cdfe3e6d3ee030e7a0df5c3b8cc9 (diff) | |
download | mandoc-9c50b3f3dd65454028a85113ebc01c5f1f8dabf5.tar.gz |
automatically tag .SH and .SS in man(7) terminal output
in the same way as it was done for .Sh and .Ss in mdoc(7)
Diffstat (limited to 'man_validate.c')
-rw-r--r-- | man_validate.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/man_validate.c b/man_validate.c index 4e10fb55..aedd8b82 100644 --- a/man_validate.c +++ b/man_validate.c @@ -311,9 +311,32 @@ static void post_SH(CHKARGS) { struct roff_node *nc; + char *cp, *tag; - if (n->type != ROFFT_BODY || (nc = n->child) == NULL) + nc = n->child; + switch (n->type) { + case ROFFT_HEAD: + tag = NULL; + deroff(&tag, n); + if (tag != NULL) { + for (cp = tag; *cp != '\0'; cp++) + if (*cp == ' ') + *cp = '_'; + if (nc != NULL && nc->type == ROFFT_TEXT && + strcmp(nc->string, tag) == 0) + tag_put(NULL, TAG_WEAK, n); + else + tag_put(tag, TAG_FALLBACK, n); + free(tag); + } + return; + case ROFFT_BODY: + if (nc != NULL) + break; return; + default: + return; + } if (nc->tok == MAN_PP && nc->body->child != NULL) { while (nc->body->last != NULL) { |