diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2020-03-13 15:32:28 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2020-03-13 15:32:28 +0000 |
commit | 42d5f8ddfdcc19abca690eba6b3c1bc230e43079 (patch) | |
tree | 9371c93d722eb8a93f7723cefc34599d43b0cffb /regress/mdoc/Tg | |
parent | 65d9edcb60637a2dacc525de8389743979e31e41 (diff) | |
download | mandoc-42d5f8ddfdcc19abca690eba6b3c1bc230e43079.tar.gz |
Split tagging into a validation part including prioritization
in tag.{h,c} and {mdoc,man}_validate.c
and into a formatting part including command line argument checking
in term_tag.{h,c}, html.c, and {mdoc|man}_{term|html}.c.
Immediate functional benefits include:
* Improved prioritization of automatic tags for .Em and .Sy.
* Avoiding bogus automatic tags when .Em, .Fn, or .Sy are explicitly tagged.
* Explicit tagging of .Er and .Fl now works in HTML output.
* Automatic tagging of .IP and .TP now works in HTML output.
But mainly, this patch provides clean earth to build further improvements on.
Technical changes:
* Main program: Write a tag file for ASCII and UTF-8 output only.
* All formatters: There is no more need to delay writing the tags.
* mdoc(7)+man(7) formatters: No more need for elaborate syntax tree inspection.
* HTML formatter: If available, use the "string" attribute as the tag.
* HTML formatter: New function to write permalinks, to reduce code duplication.
Style cleanup in the vicinity while here:
* mdoc(7) terminal formatter: To set up bold font for children,
defer to termp_bold_pre() rather than calling term_fontpush() manually.
* mdoc(7) terminal formatter: Garbage collect some duplicate functions.
* mdoc(7) HTML formatter: Unify <code> handling, delete redundant functions.
* Where possible, use switch statements rather than if cascades.
* Get rid of some more Yoda notation.
The necessity for such changes was first discussed with kn@, but i didn't
bother him with a request to review the resulting -673/+782 line patch.
Diffstat (limited to 'regress/mdoc/Tg')
-rw-r--r-- | regress/mdoc/Tg/Makefile | 8 | ||||
-rw-r--r-- | regress/mdoc/Tg/warn.in | 34 | ||||
-rw-r--r-- | regress/mdoc/Tg/warn.out_ascii | 19 | ||||
-rw-r--r-- | regress/mdoc/Tg/warn.out_html | 11 | ||||
-rw-r--r-- | regress/mdoc/Tg/warn.out_lint | 6 | ||||
-rw-r--r-- | regress/mdoc/Tg/warn.out_markdown | 30 | ||||
-rw-r--r-- | regress/mdoc/Tg/warn.out_tag | 5 |
7 files changed, 113 insertions, 0 deletions
diff --git a/regress/mdoc/Tg/Makefile b/regress/mdoc/Tg/Makefile new file mode 100644 index 00000000..7f538766 --- /dev/null +++ b/regress/mdoc/Tg/Makefile @@ -0,0 +1,8 @@ +# $OpenBSD: Makefile,v 1.1 2020/03/13 00:31:06 schwarze Exp $ + +REGRESS_TARGETS = warn +TAG_TARGETS = warn +LINT_TARGETS = warn +HTML_TARGETS = warn + +.include <bsd.regress.mk> diff --git a/regress/mdoc/Tg/warn.in b/regress/mdoc/Tg/warn.in new file mode 100644 index 00000000..af40f012 --- /dev/null +++ b/regress/mdoc/Tg/warn.in @@ -0,0 +1,34 @@ +.\" $OpenBSD: warn.in,v 1.1 2020/03/13 00:31:06 schwarze Exp $ +.Dd $Mdocdate$ +.Dt TG-WARN 1 +.Os +.Sh NAME +.Nm Tg-warn +.Nd warnings about tagging macros +.Sh DESCRIPTION +BEGINTEST +.Pp +.Tg start +initial +text +.Tg +.Ic macro +.Tg "" ignored arguments +too many +.Tg \&badstart +badstart +.Tg badend\& +badend +.Tg "white space" +whitespace +.Tg sub +.Tg double +.Ss Subsection +subtext +.Tg examples +.Sh EXAMPLES +example +text +.Pp +ENDTEST +.Tg diff --git a/regress/mdoc/Tg/warn.out_ascii b/regress/mdoc/Tg/warn.out_ascii new file mode 100644 index 00000000..8dee9aed --- /dev/null +++ b/regress/mdoc/Tg/warn.out_ascii @@ -0,0 +1,19 @@ +TG-WARN(1) General Commands Manual TG-WARN(1) + +NNAAMMEE + TTgg--wwaarrnn - warnings about tagging macros + +DDEESSCCRRIIPPTTIIOONN + BEGINTEST + + initial text mmaaccrroo too many badstart badend whitespace + + SSuubbsseeccttiioonn + subtext + +EEXXAAMMPPLLEESS + example text + + ENDTEST + +OpenBSD March 13, 2020 OpenBSD diff --git a/regress/mdoc/Tg/warn.out_html b/regress/mdoc/Tg/warn.out_html new file mode 100644 index 00000000..b4d3cf74 --- /dev/null +++ b/regress/mdoc/Tg/warn.out_html @@ -0,0 +1,11 @@ +<p class="Pp"><mark id="start"></mark>initial text + <a class="permalink" href="#macro"><code class="Ic" id="macro">macro</code></a> + too many badstart badend whitespace <mark id="sub"></mark></p> +<section class="Ss"> +<h2 class="Ss" id="double"><a class="permalink" href="#double">Subsection</a></h2> +<p class="Pp">subtext</p> +</section> +</section> +<section class="Sh"> +<h1 class="Sh" id="examples"><a class="permalink" href="#examples">EXAMPLES</a></h1> +<p class="Pp">example text</p> diff --git a/regress/mdoc/Tg/warn.out_lint b/regress/mdoc/Tg/warn.out_lint new file mode 100644 index 00000000..39c1f541 --- /dev/null +++ b/regress/mdoc/Tg/warn.out_lint @@ -0,0 +1,6 @@ +mandoc: warn.in:16:2: WARNING: skipping empty macro: Tg +mandoc: warn.in:16:8: ERROR: skipping excess arguments: Tg ... ignored +mandoc: warn.in:18:5: ERROR: skipping tag containing whitespace: Tg \&badstart +mandoc: warn.in:20:11: ERROR: skipping tag containing whitespace: Tg badend\& +mandoc: warn.in:22:10: ERROR: skipping tag containing whitespace: Tg white space +mandoc: warn.in:34:2: WARNING: skipping empty macro: Tg diff --git a/regress/mdoc/Tg/warn.out_markdown b/regress/mdoc/Tg/warn.out_markdown new file mode 100644 index 00000000..87204424 --- /dev/null +++ b/regress/mdoc/Tg/warn.out_markdown @@ -0,0 +1,30 @@ +TG-WARN(1) - General Commands Manual + +# NAME + +**Tg-warn** - warnings about tagging macros + +# DESCRIPTION + +BEGINTEST + +initial +text +**macro** +too many +badstart +badend +whitespace + +## Subsection + +subtext + +# EXAMPLES + +example +text + +ENDTEST + +OpenBSD - March 13, 2020 diff --git a/regress/mdoc/Tg/warn.out_tag b/regress/mdoc/Tg/warn.out_tag new file mode 100644 index 00000000..e1fc141c --- /dev/null +++ b/regress/mdoc/Tg/warn.out_tag @@ -0,0 +1,5 @@ +start 9 +macro 9 +sub 9 +double 11 +examples 14 |