From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: mandoc: While we do not recommend the idiom ".Fl Fl long" for long Date: Sun, 26 Apr 2020 16:41:09 -0500 (EST) [thread overview] Message-ID: <8a57c2f3270c2455@mandoc.bsd.lv> (raw) Log Message: ----------- 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 <steffen at sdaoden dot eu> on freebsd-hackers. Modified Files: -------------- mandoc: mdoc_validate.c TODO mandoc/regress/mdoc/Fl: Makefile Added Files: ----------- mandoc/regress/mdoc/Fl: long.in long.out_ascii long.out_html long.out_markdown long.out_tag Revision Data ------------- Index: mdoc_validate.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/mdoc_validate.c,v retrieving revision 1.386 retrieving revision 1.387 diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.386 -r1.387 --- mdoc_validate.c +++ mdoc_validate.c @@ -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 post_ex, /* Ex */ post_fa, /* Fa */ NULL, /* Fd */ - post_tag, /* Fl */ + post_fl, /* Fl */ post_fn, /* Fn */ post_delim_nb, /* Ft */ post_tag, /* Ic */ @@ -1625,6 +1626,29 @@ post_es(POST_ARGS) { post_obsolete(mdoc); 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 Index: TODO =================================================================== RCS file: /home/cvs/mandoc/mandoc/TODO,v retrieving revision 1.301 retrieving revision 1.302 diff -LTODO -LTODO -u -p -r1.301 -r1.302 --- TODO +++ TODO @@ -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 <steffen@sdaoden.eu> 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). --- /dev/null +++ regress/mdoc/Fl/long.out_html @@ -0,0 +1,6 @@ +<dl class="Bl-tag"> + <dt id="long"><a class="permalink" href="#long"><code class="Fl">--long</code></a></dt> + <dd>options</dd> + <dt id="long~2"><a class="permalink" href="#long~2"><code class="Fl">--long</code></a></dt> + <dd>options</dd> +</dl> --- /dev/null +++ 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 --- /dev/null +++ regress/mdoc/Fl/long.out_ascii @@ -0,0 +1,14 @@ +FL-LONG(1) General Commands Manual FL-LONG(1) + +N\bNA\bAM\bME\bE + F\bFl\bl-\b-l\blo\bon\bng\bg - GNU-style long options + +D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN + BEGINTEST + + -\b--\b-l\blo\bon\bng\bg options + + -\b--\b-l\blo\bon\bng\bg options + ENDTEST + +OpenBSD April 26, 2020 OpenBSD Index: Makefile =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Fl/Makefile,v retrieving revision 1.7 retrieving revision 1.8 diff -Lregress/mdoc/Fl/Makefile -Lregress/mdoc/Fl/Makefile -u -p -r1.7 -r1.8 --- regress/mdoc/Fl/Makefile +++ 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 <bsd.regress.mk> --- /dev/null +++ regress/mdoc/Fl/long.out_tag @@ -0,0 +1,4 @@ +NAME 3 +DESCRIPTION 6 +long 9 +long 11 --- /dev/null +++ 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 -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv
reply other threads:[~2020-04-26 21:41 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=8a57c2f3270c2455@mandoc.bsd.lv \ --to=schwarze@mandoc.bsd.lv \ --cc=source@mandoc.bsd.lv \ --subject='Re: mandoc: While we do not recommend the idiom ".Fl Fl long" for long' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
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).