From db42cb7f0b926817aff8c41cac4ad993a3db85aa Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sun, 26 Apr 2020 21:41:07 +0000 Subject: While we do not recommend the idiom ".Fl Fl long" for long options because it is an abuse of semantic macros for device-specific presentational effects, this idiom is so widespread that it makes sense to convert it to the recommended ".Fl \-long" during the validation phase. For example, this improves HTML formatting in pages where authors have used the dubious .Fl Fl. Feature suggested by Steffen Nurpmeso on freebsd-hackers. --- TODO | 9 ++++----- mdoc_validate.c | 28 ++++++++++++++++++++++++++-- regress/mdoc/Fl/Makefile | 8 ++++---- regress/mdoc/Fl/long.in | 16 ++++++++++++++++ regress/mdoc/Fl/long.out_ascii | 14 ++++++++++++++ regress/mdoc/Fl/long.out_html | 6 ++++++ regress/mdoc/Fl/long.out_markdown | 21 +++++++++++++++++++++ regress/mdoc/Fl/long.out_tag | 4 ++++ 8 files changed, 95 insertions(+), 11 deletions(-) create mode 100644 regress/mdoc/Fl/long.in create mode 100644 regress/mdoc/Fl/long.out_ascii create mode 100644 regress/mdoc/Fl/long.out_html create mode 100644 regress/mdoc/Fl/long.out_markdown create mode 100644 regress/mdoc/Fl/long.out_tag diff --git a/TODO b/TODO index 715dbb59..ae1a1819 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ ************************************************************************ * Official mandoc TODO. -* $Id: TODO,v 1.301 2020/02/15 14:59:21 schwarze Exp $ +* $Id: TODO,v 1.302 2020/04/26 21:41:07 schwarze Exp $ ************************************************************************ Many issues are annotated for difficulty as follows: @@ -155,10 +155,6 @@ are mere guesses, and some may be wrong. uqs@ Thu, 2 Jun 2011 11:33:35 +0200 loc * exist ** algo *** size * imp ** -- In mdoc_validate.c, convert "Fl Fl opt" to "Fl \-opt". - Steffen Nurpmeso 27 Jan 2020 17:27:13 +0100 - loc * exist * algo * size * imp ** - --- missing man features ----------------------------------------------- - groff_www(7) .MTO and .URL @@ -575,6 +571,9 @@ are mere guesses, and some may be wrong. * CGI issues ************************************************************************ + - Inspect httpd(8) logs on man.openbsd.org and consider + whether logging can be improved, where bad syntax comes from, + and what needs to be done to get rid of COMPAT_OLDURI. - Enable HTTP compression by detecting gzip encoding and filtering output through libz. - Privilege separation (see OpenSSH). diff --git a/mdoc_validate.c b/mdoc_validate.c index 39c66b1f..51a4dfa3 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.386 2020/04/24 12:02:33 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.387 2020/04/26 21:41:07 schwarze Exp $ */ /* * Copyright (c) 2010-2020 Ingo Schwarze * Copyright (c) 2008-2012 Kristaps Dzonsons @@ -92,6 +92,7 @@ static void post_es(POST_ARGS); static void post_eoln(POST_ARGS); static void post_ex(POST_ARGS); static void post_fa(POST_ARGS); +static void post_fl(POST_ARGS); static void post_fn(POST_ARGS); static void post_fname(POST_ARGS); static void post_fo(POST_ARGS); @@ -150,7 +151,7 @@ static const v_post mdoc_valids[MDOC_MAX - MDOC_Dd] = { post_ex, /* Ex */ post_fa, /* Fa */ NULL, /* Fd */ - post_tag, /* Fl */ + post_fl, /* Fl */ post_fn, /* Fn */ post_delim_nb, /* Ft */ post_tag, /* Ic */ @@ -1627,6 +1628,29 @@ post_es(POST_ARGS) mdoc->last_es = mdoc->last; } +static void +post_fl(POST_ARGS) +{ + struct roff_node *n; + char *cp; + + /* + * Transform ".Fl Fl long" to ".Fl \-long", + * resulting for example in better HTML output. + */ + + n = mdoc->last; + if (n->prev != NULL && n->prev->tok == MDOC_Fl && + n->prev->child == NULL && n->child != NULL && + (n->flags & NODE_LINE) == 0) { + mandoc_asprintf(&cp, "\\-%s", n->child->string); + free(n->child->string); + n->child->string = cp; + roff_node_delete(mdoc, n->prev); + } + post_tag(mdoc); +} + static void post_xx(POST_ARGS) { diff --git a/regress/mdoc/Fl/Makefile b/regress/mdoc/Fl/Makefile index c061adef..1f1c09e8 100644 --- a/regress/mdoc/Fl/Makefile +++ b/regress/mdoc/Fl/Makefile @@ -1,9 +1,9 @@ -# $OpenBSD: Makefile,v 1.14 2020/03/13 00:31:06 schwarze Exp $ +# $OpenBSD: Makefile,v 1.15 2020/04/26 21:29:46 schwarze Exp $ -REGRESS_TARGETS = font multiarg noarg parsed punct spacing tag -TAG_TARGETS = tag +REGRESS_TARGETS = font long multiarg noarg parsed punct spacing tag +TAG_TARGETS = long tag LINT_TARGETS = punct -HTML_TARGETS = tag +HTML_TARGETS = long tag SKIP_TMAN = tag .include diff --git a/regress/mdoc/Fl/long.in b/regress/mdoc/Fl/long.in new file mode 100644 index 00000000..265a1e2a --- /dev/null +++ b/regress/mdoc/Fl/long.in @@ -0,0 +1,16 @@ +.\" $OpenBSD: long.in,v 1.1 2020/04/26 21:29:46 schwarze Exp $ +.Dd $Mdocdate: April 26 2020 $ +.Dt FL-LONG 1 +.Os +.Sh NAME +.Nm Fl-long +.Nd GNU-style long options +.Sh DESCRIPTION +BEGINTEST +.Bl -tag -width Ds +.It Fl \-long +options +.It Fl Fl long +options +.El +ENDTEST diff --git a/regress/mdoc/Fl/long.out_ascii b/regress/mdoc/Fl/long.out_ascii new file mode 100644 index 00000000..4a50ab1b --- /dev/null +++ b/regress/mdoc/Fl/long.out_ascii @@ -0,0 +1,14 @@ +FL-LONG(1) General Commands Manual FL-LONG(1) + +NNAAMMEE + FFll--lloonngg - GNU-style long options + +DDEESSCCRRIIPPTTIIOONN + BEGINTEST + + ----lloonngg options + + ----lloonngg options + ENDTEST + +OpenBSD April 26, 2020 OpenBSD diff --git a/regress/mdoc/Fl/long.out_html b/regress/mdoc/Fl/long.out_html new file mode 100644 index 00000000..6fabcfcd --- /dev/null +++ b/regress/mdoc/Fl/long.out_html @@ -0,0 +1,6 @@ +
+
+
options
+
+
options
+
diff --git a/regress/mdoc/Fl/long.out_markdown b/regress/mdoc/Fl/long.out_markdown new file mode 100644 index 00000000..3abf3e84 --- /dev/null +++ b/regress/mdoc/Fl/long.out_markdown @@ -0,0 +1,21 @@ +FL-LONG(1) - General Commands Manual + +# NAME + +**Fl-long** - GNU-style long options + +# DESCRIPTION + +BEGINTEST + +**--long** + +> options + +**--long** + +> options + +ENDTEST + +OpenBSD - April 26, 2020 diff --git a/regress/mdoc/Fl/long.out_tag b/regress/mdoc/Fl/long.out_tag new file mode 100644 index 00000000..b99cc311 --- /dev/null +++ b/regress/mdoc/Fl/long.out_tag @@ -0,0 +1,4 @@ +NAME 3 +DESCRIPTION 6 +long 9 +long 11 -- cgit v1.2.3