From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: automatically tag .SH and .SS in man(7) terminal output in the
Date: Sat, 4 Apr 2020 15:34:08 -0500 (EST) [thread overview]
Message-ID: <11ff3624730706a4@mandoc.bsd.lv> (raw)
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
reply other threads:[~2020-04-04 20:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11ff3624730706a4@mandoc.bsd.lv \
--to=schwarze@mandoc.bsd.lv \
--cc=source@mandoc.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).