source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: Just like we are already doing it in HTML output, automatically
@ 2020-04-01 20:21 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2020-04-01 20:21 UTC (permalink / raw)
  To: source

Log Message:
-----------
Just like we are already doing it in HTML output, automatically tag
section and subsection headers in terminal output, too.  Even though
admittedly, commands like "/SEE" and "/   Subsec" work, too, there
is no downside, and besides, with the recent improvements in the
tagging framework, implementation cost is negligible.

Modified Files:
--------------
    mandoc:
        mdoc_html.c
        mdoc_validate.c
    mandoc/regress/mdoc/Cm:
        tag.out_tag
    mandoc/regress/mdoc/Dv:
        tag.out_tag
    mandoc/regress/mdoc/Em:
        tag.out_tag
    mandoc/regress/mdoc/Er:
        tag.out_tag
    mandoc/regress/mdoc/Ev:
        tag.out_tag
    mandoc/regress/mdoc/Fl:
        tag.out_tag
    mandoc/regress/mdoc/Fo:
        tag.out_tag
    mandoc/regress/mdoc/Ic:
        tag.out_tag
    mandoc/regress/mdoc/Li:
        tag.out_tag
    mandoc/regress/mdoc/Ms:
        tag.out_tag
    mandoc/regress/mdoc/No:
        tag.out_tag
    mandoc/regress/mdoc/Sh:
        Makefile
        tag.in
        tag.out_ascii
        tag.out_html
        tag.out_markdown
    mandoc/regress/mdoc/Sy:
        tag.out_tag
    mandoc/regress/mdoc/Tg:
        warn.out_tag

Added Files:
-----------
    mandoc/regress/mdoc/Sh:
        tag.out_lint
        tag.out_tag

Revision Data
-------------
Index: Makefile
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Sh/Makefile,v
retrieving revision 1.7
retrieving revision 1.8
diff -Lregress/mdoc/Sh/Makefile -Lregress/mdoc/Sh/Makefile -u -p -r1.7 -r1.8
--- regress/mdoc/Sh/Makefile
+++ regress/mdoc/Sh/Makefile
@@ -1,11 +1,12 @@
-# $OpenBSD: Makefile,v 1.13 2020/02/27 21:38:27 schwarze Exp $
+# $OpenBSD: Makefile,v 1.14 2020/04/01 20:10:18 schwarze Exp $
 
 REGRESS_TARGETS	 = badNAME before empty emptyNAME first nohead order
 REGRESS_TARGETS	+= orderNAME paragraph parbefore parborder punctNAME
 REGRESS_TARGETS	+= subbefore tag transp
 LINT_TARGETS	 = badNAME before empty emptyNAME first nohead order
-LINT_TARGETS	+= orderNAME parbefore parborder punctNAME subbefore
+LINT_TARGETS	+= orderNAME parbefore parborder punctNAME subbefore tag
 HTML_TARGETS	 = paragraph tag
+TAG_TARGETS	 = tag
 
 # groff-1.22.3 defects:
 # - .Pp before .Sh NAME causes a blank line before the header line
--- /dev/null
+++ regress/mdoc/Sh/tag.out_lint
@@ -0,0 +1,3 @@
+mandoc: tag.in:14:2: WARNING: duplicate section title: Sh DESCRIPTION
+mandoc: tag.in:22:7: WARNING: tab in filled text
+mandoc: tag.in:22:22: WARNING: tab in filled text
Index: tag.out_markdown
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Sh/tag.out_markdown,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Sh/tag.out_markdown -Lregress/mdoc/Sh/tag.out_markdown -u -p -r1.1 -r1.2
--- regress/mdoc/Sh/tag.out_markdown
+++ regress/mdoc/Sh/tag.out_markdown
@@ -14,6 +14,10 @@ BEGINTEST
 
 Text in the subsection.
 
+# DESCRIPTION
+
+Text in duplicate description section.
+
 # EXAMPLES
 
 Text introducing examples.
@@ -22,6 +26,14 @@ Text introducing examples.
 
 Example text.
 
+# 	 WEIRD SECTION	 
+
+Text in weird section.
+
+#  
+
+Text in section with empty header.
+
 ENDTEST
 
-OpenBSD - February 27, 2020
+OpenBSD - April 1, 2020
Index: tag.in
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Sh/tag.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Sh/tag.in -Lregress/mdoc/Sh/tag.in -u -p -r1.1 -r1.2
--- regress/mdoc/Sh/tag.in
+++ regress/mdoc/Sh/tag.in
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tag.in,v 1.1 2020/02/27 21:38:27 schwarze Exp $
+.\" $OpenBSD: tag.in,v 1.2 2020/04/01 20:10:18 schwarze Exp $
 .Dd $Mdocdate$
 .Dt SH-TAG 1
 .Os
@@ -11,11 +11,17 @@ Text in the description.
 BEGINTEST
 .Pp
 Text in the subsection.
+.Sh DESCRIPTION
+Text in duplicate description section.
 .Tg examples
 .Sh EXAMPLES
 Text introducing examples.
 .Tg example
 .Ss Subsection
 Example text.
+.Sh "\&	 WEIRD SECTION	 "
+Text in weird section.
+.Sh \ \&
+Text in section with empty header.
 .Pp
 ENDTEST
Index: tag.out_html
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Sh/tag.out_html,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Sh/tag.out_html -Lregress/mdoc/Sh/tag.out_html -u -p -r1.1 -r1.2
--- regress/mdoc/Sh/tag.out_html
+++ regress/mdoc/Sh/tag.out_html
@@ -2,8 +2,22 @@
 </section>
 </section>
 <section class="Sh">
+<h1 class="Sh" id="DESCRIPTION_2"><a class="permalink" href="#DESCRIPTION_2">DESCRIPTION</a></h1>
+<p class="Pp">Text in duplicate description section.</p>
+</section>
+<section class="Sh">
 <h1 class="Sh" id="examples"><a class="permalink" href="#examples">EXAMPLES</a></h1>
 <p class="Pp">Text introducing examples.</p>
 <section class="Ss">
 <h2 class="Ss" id="example"><a class="permalink" href="#example">Subsection</a></h2>
 <p class="Pp">Example text.</p>
+</section>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="WEIRD_SECTION"><a class="permalink" href="#WEIRD_SECTION">	
+  WEIRD SECTION	 </a></h1>
+<p class="Pp">Text in weird section.</p>
+</section>
+<section class="Sh">
+<h1 class="Sh">&#x00A0;</h1>
+<p class="Pp">Text in section with empty header.</p>
Index: tag.out_ascii
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Sh/tag.out_ascii,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Sh/tag.out_ascii -Lregress/mdoc/Sh/tag.out_ascii -u -p -r1.1 -r1.2
--- regress/mdoc/Sh/tag.out_ascii
+++ regress/mdoc/Sh/tag.out_ascii
@@ -11,12 +11,21 @@ D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
 
      Text in the subsection.
 
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+     Text in duplicate description section.
+
 E\bEX\bXA\bAM\bMP\bPL\bLE\bES\bS
      Text introducing examples.
 
    S\bSu\bub\bbs\bse\bec\bct\bti\bio\bon\bn
      Example text.
 
+      W\bWE\bEI\bIR\bRD\bD S\bSE\bEC\bCT\bTI\bIO\bON\bN
+     Text in weird section.
+
+
+     Text in section with empty header.
+
      ENDTEST
 
-OpenBSD                        February 27, 2020                       OpenBSD
+OpenBSD                          April 1, 2020                         OpenBSD
--- /dev/null
+++ regress/mdoc/Sh/tag.out_tag
@@ -0,0 +1,7 @@
+NAME 3
+DESCRIPTION 6
+Subsection 9
+DESCRIPTION 14
+examples 17
+example 20
+WEIRD_SECTION 23
Index: mdoc_html.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_html.c,v
retrieving revision 1.336
retrieving revision 1.337
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.336 -r1.337
--- mdoc_html.c
+++ mdoc_html.c
@@ -569,7 +569,6 @@ mdoc_sh_pre(MDOC_ARGS)
 		print_otag(h, TAG_SECTION, "c", "Sh");
 		break;
 	case ROFFT_HEAD:
-		n->flags |= NODE_ID;
 		print_otag_id(h, TAG_H1, "Sh", n);
 		break;
 	case ROFFT_BODY:
@@ -591,7 +590,6 @@ mdoc_ss_pre(MDOC_ARGS)
 		print_otag(h, TAG_SECTION, "c", "Ss");
 		break;
 	case ROFFT_HEAD:
-		n->flags |= NODE_ID;
 		print_otag_id(h, TAG_H2, "Ss", n);
 		break;
 	case ROFFT_BODY:
Index: mdoc_validate.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_validate.c,v
retrieving revision 1.380
retrieving revision 1.381
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.380 -r1.381
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -96,7 +96,6 @@ static	void	 post_fn(POST_ARGS);
 static	void	 post_fname(POST_ARGS);
 static	void	 post_fo(POST_ARGS);
 static	void	 post_hyph(POST_ARGS);
-static	void	 post_ignpar(POST_ARGS);
 static	void	 post_it(POST_ARGS);
 static	void	 post_lb(POST_ARGS);
 static	void	 post_nd(POST_ARGS);
@@ -109,6 +108,7 @@ static	void	 post_prevpar(POST_ARGS);
 static	void	 post_root(POST_ARGS);
 static	void	 post_rs(POST_ARGS);
 static	void	 post_rv(POST_ARGS);
+static	void	 post_section(POST_ARGS);
 static	void	 post_sh(POST_ARGS);
 static	void	 post_sh_head(POST_ARGS);
 static	void	 post_sh_name(POST_ARGS);
@@ -129,7 +129,7 @@ static	const v_post mdoc_valids[MDOC_MAX
 	post_dt,	/* Dt */
 	post_os,	/* Os */
 	post_sh,	/* Sh */
-	post_ignpar,	/* Ss */
+	post_section,	/* Ss */
 	post_par,	/* Pp */
 	post_display,	/* D1 */
 	post_display,	/* Dl */
@@ -2202,7 +2202,7 @@ post_sx(POST_ARGS)
 static void
 post_sh(POST_ARGS)
 {
-	post_ignpar(mdoc);
+	post_section(mdoc);
 
 	switch (mdoc->last->type) {
 	case ROFFT_HEAD:
@@ -2535,15 +2535,31 @@ post_xr(POST_ARGS)
 }
 
 static void
-post_ignpar(POST_ARGS)
+post_section(POST_ARGS)
 {
-	struct roff_node *np;
+	struct roff_node *n, *nch;
+	char		 *cp, *tag;
 
-	switch (mdoc->last->type) {
+	n = mdoc->last;
+	switch (n->type) {
 	case ROFFT_BLOCK:
 		post_prevpar(mdoc);
 		return;
 	case ROFFT_HEAD:
+		tag = NULL;
+		deroff(&tag, n);
+		if (tag != NULL) {
+			for (cp = tag; *cp != '\0'; cp++)
+				if (*cp == ' ')
+					*cp = '_';
+			if ((nch = n->child) != NULL &&
+			    nch->type == ROFFT_TEXT &&
+			    strcmp(nch->string, tag) == 0)
+				tag_put(NULL, TAG_WEAK, n);
+			else
+				tag_put(tag, TAG_FALLBACK, n);
+			free(tag);
+		}
 		post_delim(mdoc);
 		post_hyph(mdoc);
 		return;
@@ -2552,23 +2568,21 @@ post_ignpar(POST_ARGS)
 	default:
 		return;
 	}
-
-	if ((np = mdoc->last->child) != NULL)
-		if (np->tok == MDOC_Pp ||
-		    np->tok == ROFF_br || np->tok == ROFF_sp) {
-			mandoc_msg(MANDOCERR_PAR_SKIP, np->line, np->pos,
-			    "%s after %s", roff_name[np->tok],
-			    roff_name[mdoc->last->tok]);
-			roff_node_delete(mdoc, np);
-		}
-
-	if ((np = mdoc->last->last) != NULL)
-		if (np->tok == MDOC_Pp || np->tok == ROFF_br) {
-			mandoc_msg(MANDOCERR_PAR_SKIP, np->line, np->pos,
-			    "%s at the end of %s", roff_name[np->tok],
-			    roff_name[mdoc->last->tok]);
-			roff_node_delete(mdoc, np);
-		}
+	if ((nch = n->child) != NULL &&
+	    (nch->tok == MDOC_Pp || nch->tok == ROFF_br ||
+	     nch->tok == ROFF_sp)) {
+		mandoc_msg(MANDOCERR_PAR_SKIP, nch->line, nch->pos,
+		    "%s after %s", roff_name[nch->tok],
+		    roff_name[n->tok]);
+		roff_node_delete(mdoc, nch);
+	}
+	if ((nch = n->last) != NULL &&
+	    (nch->tok == MDOC_Pp || nch->tok == ROFF_br)) {
+		mandoc_msg(MANDOCERR_PAR_SKIP, nch->line, nch->pos,
+		    "%s at the end of %s", roff_name[nch->tok],
+		    roff_name[n->tok]);
+		roff_node_delete(mdoc, nch);
+	}
 }
 
 static void
Index: tag.out_tag
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Cm/tag.out_tag,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lregress/mdoc/Cm/tag.out_tag -Lregress/mdoc/Cm/tag.out_tag -u -p -r1.2 -r1.3
--- regress/mdoc/Cm/tag.out_tag
+++ regress/mdoc/Cm/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
 one 9
 two 9
 three 12
Index: tag.out_tag
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Dv/tag.out_tag,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Dv/tag.out_tag -Lregress/mdoc/Dv/tag.out_tag -u -p -r1.1 -r1.2
--- regress/mdoc/Dv/tag.out_tag
+++ regress/mdoc/Dv/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
 one 9
 two 9
 three 12
Index: tag.out_tag
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Em/tag.out_tag,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Em/tag.out_tag -Lregress/mdoc/Em/tag.out_tag -u -p -r1.1 -r1.2
--- regress/mdoc/Em/tag.out_tag
+++ regress/mdoc/Em/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
 one 9
 two 9
 three 12
Index: tag.out_tag
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Er/tag.out_tag,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Er/tag.out_tag -Lregress/mdoc/Er/tag.out_tag -u -p -r1.1 -r1.2
--- regress/mdoc/Er/tag.out_tag
+++ regress/mdoc/Er/tag.out_tag
@@ -1,2 +1,5 @@
+NAME 3
+DESCRIPTION 6
 two 10
+ERRORS 12
 ENOENT 13
Index: tag.out_tag
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Ev/tag.out_tag,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Ev/tag.out_tag -Lregress/mdoc/Ev/tag.out_tag -u -p -r1.1 -r1.2
--- regress/mdoc/Ev/tag.out_tag
+++ regress/mdoc/Ev/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
 one 9
 two 9
 three 12
Index: tag.out_tag
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Fl/tag.out_tag,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Fl/tag.out_tag -Lregress/mdoc/Fl/tag.out_tag -u -p -r1.1 -r1.2
--- regress/mdoc/Fl/tag.out_tag
+++ regress/mdoc/Fl/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
 a 9
 b 9
 c 12
Index: tag.out_tag
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Fo/tag.out_tag,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Fo/tag.out_tag -Lregress/mdoc/Fo/tag.out_tag -u -p -r1.1 -r1.2
--- regress/mdoc/Fo/tag.out_tag
+++ regress/mdoc/Fo/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
 first 9
 second 11
 e3 13
Index: tag.out_tag
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Ic/tag.out_tag,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Ic/tag.out_tag -Lregress/mdoc/Ic/tag.out_tag -u -p -r1.1 -r1.2
--- regress/mdoc/Ic/tag.out_tag
+++ regress/mdoc/Ic/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
 one 9
 two 9
 three 12
Index: tag.out_tag
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Li/tag.out_tag,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Li/tag.out_tag -Lregress/mdoc/Li/tag.out_tag -u -p -r1.1 -r1.2
--- regress/mdoc/Li/tag.out_tag
+++ regress/mdoc/Li/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
 one 9
 two 9
 three 12
Index: tag.out_tag
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Ms/tag.out_tag,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Ms/tag.out_tag -Lregress/mdoc/Ms/tag.out_tag -u -p -r1.1 -r1.2
--- regress/mdoc/Ms/tag.out_tag
+++ regress/mdoc/Ms/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
 one 9
 two 9
 three 12
Index: tag.out_tag
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/No/tag.out_tag,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/No/tag.out_tag -Lregress/mdoc/No/tag.out_tag -u -p -r1.1 -r1.2
--- regress/mdoc/No/tag.out_tag
+++ regress/mdoc/No/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
 one 9
 two 9
 three 12
Index: tag.out_tag
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Sy/tag.out_tag,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Sy/tag.out_tag -Lregress/mdoc/Sy/tag.out_tag -u -p -r1.1 -r1.2
--- regress/mdoc/Sy/tag.out_tag
+++ regress/mdoc/Sy/tag.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
 one 9
 two 9
 three 12
Index: warn.out_tag
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Tg/warn.out_tag,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Tg/warn.out_tag -Lregress/mdoc/Tg/warn.out_tag -u -p -r1.1 -r1.2
--- regress/mdoc/Tg/warn.out_tag
+++ regress/mdoc/Tg/warn.out_tag
@@ -1,3 +1,5 @@
+NAME 3
+DESCRIPTION 6
 start 9
 macro 9
 sub 9
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv


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

only message in thread, other threads:[~2020-04-01 20:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-01 20:21 mandoc: Just like we are already doing it in HTML output, automatically schwarze

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).