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 | e03f6c4421e6265e6c69f785a01edfe489ff4f9c (patch) | |
tree | 14585118d6b85caaffa94cf46317a78bbbc900bc /man_validate.c | |
parent | 04879dddb6a40e58404e931790876ac21d5733fc (diff) | |
download | mandoc-e03f6c4421e6265e6c69f785a01edfe489ff4f9c.tar.gz mandoc-e03f6c4421e6265e6c69f785a01edfe489ff4f9c.tar.zst mandoc-e03f6c4421e6265e6c69f785a01edfe489ff4f9c.zip |
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 | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/man_validate.c b/man_validate.c index 0c2ed8a4..ee634f50 100644 --- a/man_validate.c +++ b/man_validate.c @@ -1,4 +1,4 @@ -/* $Id: man_validate.c,v 1.151 2020/03/13 15:32:28 schwarze Exp $ */ +/* $Id: man_validate.c,v 1.152 2020/04/04 20:33:33 schwarze Exp $ */ /* * Copyright (c) 2010, 2012-2020 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> @@ -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) { |