]> git.cameronkatri.com Git - mandoc.git/commitdiff
automatically tag .SH and .SS in man(7) terminal output
authorIngo Schwarze <schwarze@openbsd.org>
Sat, 4 Apr 2020 20:33:33 +0000 (20:33 +0000)
committerIngo Schwarze <schwarze@openbsd.org>
Sat, 4 Apr 2020 20:33:33 +0000 (20:33 +0000)
in the same way as it was done for .Sh and .Ss in mdoc(7)

man_html.c
man_validate.c
regress/man/IP/empty.out_tag
regress/man/IP/tag.out_tag
regress/man/SH/Makefile
regress/man/SH/paragraph.out_tag [new file with mode: 0644]
regress/man/SS/Makefile
regress/man/SS/paragraph.out_tag [new file with mode: 0644]
regress/man/TP/tag.out_tag

index 202df2b7da5504b0c0d0fa614fc7e070348a05f0..80f69e1ad33d1b526a7cb09ccca445069dd96c3f 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: man_html.c,v 1.177 2020/03/13 15:32:28 schwarze Exp $ */
+/* $Id: man_html.c,v 1.178 2020/04/04 20:33:33 schwarze Exp $ */
 /*
  * Copyright (c) 2013-2015, 2017-2020 Ingo Schwarze <schwarze@openbsd.org>
  * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -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 0c2ed8a47176c5a76cb3bef5bee6c580ce680e48..ee634f50600b81d4c89215e770e3221837a96b84 100644 (file)
@@ -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) {
index f35f112014ed01b7801b2431b10549763e062e58..081683cf4561d5b380dba998ffa84389fa7581d1 100644 (file)
@@ -1,3 +1,5 @@
+NAME 5
+DESCRIPTION 8
 tag1 15
 tag2 17
 tag 21
index 5be038dbbdb58a96a61085770e462ecf6dd784be..13ec09aca17f5f73a9f605e0769a91a42f99b08b 100644 (file)
@@ -1,2 +1,4 @@
+NAME 5
+DESCRIPTION 8
 strong 13
 weak 15
index f42a85b23daa28c7b23cd7d86d9c43f965ffee75..049680bcc201915c8d12e8eb1e71db691d1dbede 100644 (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.
diff --git a/regress/man/SH/paragraph.out_tag b/regress/man/SH/paragraph.out_tag
new file mode 100644 (file)
index 0000000..18a73f7
--- /dev/null
@@ -0,0 +1,4 @@
+NAME 5
+SYNOPSIS 8
+DESCRIPTION 11
+EXAMPLES 16
index edbe4c2caa28e5a7839340397630ecc9c3d10850..3a894af24ccf2aafce3ae7252c471d6d41af6f54 100644 (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.
diff --git a/regress/man/SS/paragraph.out_tag b/regress/man/SS/paragraph.out_tag
new file mode 100644 (file)
index 0000000..1545121
--- /dev/null
@@ -0,0 +1,4 @@
+NAME 5
+DESCRIPTION 8
+First_subsection 11
+Second_subsection 16
index 88f6cff83d0fa0563546717e6ac0fb8b2a93d3a6..14230d89980a7e24403fa3a561600449ecb80abc 100644 (file)
@@ -1,3 +1,5 @@
+NAME 5
+DESCRIPTION 8
 plain 13
 strong 19
 weak 21