From e03f6c4421e6265e6c69f785a01edfe489ff4f9c Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sat, 4 Apr 2020 20:33:33 +0000 Subject: 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) --- man_validate.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'man_validate.c') 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 * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons @@ -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) { -- cgit v1.2.3-56-ge451