source@mandoc.bsd.lv
 help / color / Atom feed
* mandoc: automatically tag .SH and .SS in man(7) terminal output in the 
@ 2020-04-04 20:34 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2020-04-04 20:34 UTC (permalink / raw)
  To: source

Log Message:
-----------
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)

Modified Files:
--------------
    mandoc:
        man_validate.c
        man_html.c
    mandoc/regress/man/IP:
        empty.out_tag
        tag.out_tag
    mandoc/regress/man/SH:
        Makefile
    mandoc/regress/man/SS:
        Makefile
    mandoc/regress/man/TP:
        tag.out_tag

Added Files:
-----------
    mandoc/regress/man/SH:
        paragraph.out_tag
    mandoc/regress/man/SS:
        paragraph.out_tag

Revision Data
-------------
--- /dev/null
+++ regress/man/SH/paragraph.out_tag
@@ -0,0 +1,4 @@
+NAME 5
+SYNOPSIS 8
+DESCRIPTION 11
+EXAMPLES 16
Index: Makefile
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/man/SH/Makefile,v
retrieving revision 1.4
retrieving revision 1.5
diff -Lregress/man/SH/Makefile -Lregress/man/SH/Makefile -u -p -r1.4 -r1.5
--- regress/man/SH/Makefile
+++ regress/man/SH/Makefile
@@ -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.
Index: man_html.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/man_html.c,v
retrieving revision 1.177
retrieving revision 1.178
diff -Lman_html.c -Lman_html.c -u -p -r1.177 -r1.178
--- man_html.c
+++ man_html.c
@@ -327,7 +327,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:
Index: man_validate.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/man_validate.c,v
retrieving revision 1.151
retrieving revision 1.152
diff -Lman_validate.c -Lman_validate.c -u -p -r1.151 -r1.152
--- man_validate.c
+++ 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) {
Index: tag.out_tag
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/man/IP/tag.out_tag,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/man/IP/tag.out_tag -Lregress/man/IP/tag.out_tag -u -p -r1.1 -r1.2
--- regress/man/IP/tag.out_tag
+++ regress/man/IP/tag.out_tag
@@ -1,2 +1,4 @@
+NAME 5
+DESCRIPTION 8
 strong 13
 weak 15
Index: empty.out_tag
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/man/IP/empty.out_tag,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/man/IP/empty.out_tag -Lregress/man/IP/empty.out_tag -u -p -r1.1 -r1.2
--- regress/man/IP/empty.out_tag
+++ regress/man/IP/empty.out_tag
@@ -1,3 +1,5 @@
+NAME 5
+DESCRIPTION 8
 tag1 15
 tag2 17
 tag 21
--- /dev/null
+++ regress/man/SS/paragraph.out_tag
@@ -0,0 +1,4 @@
+NAME 5
+DESCRIPTION 8
+First_subsection 11
+Second_subsection 16
Index: Makefile
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/man/SS/Makefile,v
retrieving revision 1.4
retrieving revision 1.5
diff -Lregress/man/SS/Makefile -Lregress/man/SS/Makefile -u -p -r1.4 -r1.5
--- regress/man/SS/Makefile
+++ regress/man/SS/Makefile
@@ -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.
Index: tag.out_tag
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/man/TP/tag.out_tag,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/man/TP/tag.out_tag -Lregress/man/TP/tag.out_tag -u -p -r1.1 -r1.2
--- regress/man/TP/tag.out_tag
+++ regress/man/TP/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 5
+DESCRIPTION 8
 plain 13
 strong 19
 weak 21
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-04 20:34 mandoc: automatically tag .SH and .SS in man(7) terminal output in the schwarze

source@mandoc.bsd.lv

Archives are clonable: git clone --mirror http://inbox.vuxu.org/mandoc-source

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.mandoc.source


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git