From 42d5f8ddfdcc19abca690eba6b3c1bc230e43079 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Fri, 13 Mar 2020 15:32:28 +0000 Subject: 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 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. --- regress/mdoc/Tg/Makefile | 8 ++++++++ regress/mdoc/Tg/warn.in | 34 ++++++++++++++++++++++++++++++++++ regress/mdoc/Tg/warn.out_ascii | 19 +++++++++++++++++++ regress/mdoc/Tg/warn.out_html | 11 +++++++++++ regress/mdoc/Tg/warn.out_lint | 6 ++++++ regress/mdoc/Tg/warn.out_markdown | 30 ++++++++++++++++++++++++++++++ regress/mdoc/Tg/warn.out_tag | 5 +++++ 7 files changed, 113 insertions(+) create mode 100644 regress/mdoc/Tg/Makefile create mode 100644 regress/mdoc/Tg/warn.in create mode 100644 regress/mdoc/Tg/warn.out_ascii create mode 100644 regress/mdoc/Tg/warn.out_html create mode 100644 regress/mdoc/Tg/warn.out_lint create mode 100644 regress/mdoc/Tg/warn.out_markdown create mode 100644 regress/mdoc/Tg/warn.out_tag (limited to 'regress/mdoc/Tg') 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 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 @@ +

initial text + + too many badstart badend whitespace

+
+

+

subtext

+
+ +
+

+

example text

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 -- cgit