aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_validate.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2020-04-26 21:41:07 +0000
committerIngo Schwarze <schwarze@openbsd.org>2020-04-26 21:41:07 +0000
commitdb42cb7f0b926817aff8c41cac4ad993a3db85aa (patch)
tree1d71c079f6f40e5c9b428d1a9116a445dbe86d16 /mdoc_validate.c
parentaea55337f3f72f530978a5e20d38888df13d5b2b (diff)
downloadmandoc-db42cb7f0b926817aff8c41cac4ad993a3db85aa.tar.gz
mandoc-db42cb7f0b926817aff8c41cac4ad993a3db85aa.tar.zst
mandoc-db42cb7f0b926817aff8c41cac4ad993a3db85aa.zip
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 'mdoc_validate.c')
-rw-r--r--mdoc_validate.c28
1 files changed, 26 insertions, 2 deletions
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 <schwarze@openbsd.org>
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -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 */
@@ -1628,6 +1629,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;