1
0
mirror of https://github.com/openbsd/src.git synced 2026-04-24 14:14:37 +00:00

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)
This commit is contained in:
schwarze
2020-04-04 20:23:06 +00:00
parent 6f986596ee
commit e9f36175df
9 changed files with 44 additions and 6 deletions

View File

@@ -1,3 +1,5 @@
NAME 5
DESCRIPTION 8
tag1 15
tag2 17
tag 21

View File

@@ -1,2 +1,4 @@
NAME 5
DESCRIPTION 8
strong 13
weak 15

View File

@@ -1,8 +1,9 @@
# $OpenBSD: Makefile,v 1.7 2020/02/27 01:25:58 schwarze Exp $
# $OpenBSD: Makefile,v 1.8 2020/04/04 20:23:07 schwarze Exp $
REGRESS_TARGETS = broken broken_eline empty_before longarg noarg paragraph vert
LINT_TARGETS = broken broken_eline empty_before noarg
HTML_TARGETS = paragraph
TAG_TARGETS = paragraph
# groff-1.22.3 defects:
# - .SH without args just before EOF causes two additional blank lines.

View File

@@ -0,0 +1,4 @@
NAME 5
SYNOPSIS 8
DESCRIPTION 11
EXAMPLES 16

View File

@@ -1,8 +1,9 @@
# $OpenBSD: Makefile,v 1.5 2020/02/27 01:25:58 schwarze Exp $
# $OpenBSD: Makefile,v 1.6 2020/04/04 20:23:07 schwarze Exp $
REGRESS_TARGETS = broken broken_eline longarg noarg paragraph vert
LINT_TARGETS = broken broken_eline noarg
HTML_TARGETS = paragraph
TAG_TARGETS = paragraph
# groff-1.22.3 defects:
# - .SS without args just before EOF causes two additional blank lines.

View File

@@ -0,0 +1,4 @@
NAME 5
DESCRIPTION 8
First_subsection 11
Second_subsection 16

View File

@@ -1,3 +1,5 @@
NAME 5
DESCRIPTION 8
plain 13
strong 19
weak 21

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: man_html.c,v 1.130 2020/03/13 00:31:05 schwarze Exp $ */
/* $OpenBSD: man_html.c,v 1.131 2020/04/04 20:23:06 schwarze Exp $ */
/*
* Copyright (c) 2013-2015, 2017-2020 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -325,7 +325,6 @@ man_SH_pre(MAN_ARGS)
print_otag(h, TAG_SECTION, "c", class);
break;
case ROFFT_HEAD:
n->flags |= NODE_ID;
print_otag_id(h, tag, class, n);
break;
case ROFFT_BODY:

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: man_validate.c,v 1.121 2020/03/13 00:31:05 schwarze Exp $ */
/* $OpenBSD: man_validate.c,v 1.122 2020/04/04 20:23:07 schwarze Exp $ */
/*
* Copyright (c) 2010, 2012-2020 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -309,9 +309,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) {