summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2020-04-26 21:29:47 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2020-04-26 21:29:47 +0000
commitcfceddc49125f73523ae0b8a1001f3e94ba7d468 (patch)
tree593f4d658b0401d9fa84dc9055eee5dfadcc783f /usr.bin
parentec3d6e9e43f0d249afa492f1e5ce6a25ad736c76 (diff)
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.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/mdoc_validate.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index 4ce19a77d35..34668bf8a10 100644
--- a/usr.bin/mandoc/mdoc_validate.c
+++ b/usr.bin/mandoc/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_validate.c,v 1.301 2020/04/24 11:58:02 schwarze Exp $ */
+/* $OpenBSD: mdoc_validate.c,v 1.302 2020/04/26 21:29:45 schwarze Exp $ */
/*
* Copyright (c) 2010-2020 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -90,6 +90,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);
@@ -148,7 +149,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 */
@@ -1613,6 +1614,29 @@ post_es(POST_ARGS)
}
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)
{
struct roff_node *n;