summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/mdoc_validate.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2020-04-06 09:55:51 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2020-04-06 09:55:51 +0000
commit8b440b4adf0207c9d0637b16817fda9700a8a0e9 (patch)
tree32ef9dde1ac1a79fc25501c9f0d7b80395e0a540 /usr.bin/mandoc/mdoc_validate.c
parentcd810fb4ab3cd85588a2f3e795b5c12ca43b1b28 (diff)
Support manual tagging of .Pp, .Bd, .D1, .Dl, .Bl, and .It.
In HTML output, improve the logic for writing inside permalinks: skip them when there is no child content or when there is a risk that the children might contain flow content.
Diffstat (limited to 'usr.bin/mandoc/mdoc_validate.c')
-rw-r--r--usr.bin/mandoc/mdoc_validate.c48
1 files changed, 41 insertions, 7 deletions
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index 4b22e617e22..b50a92a811b 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.297 2020/04/02 14:55:29 schwarze Exp $ */
+/* $OpenBSD: mdoc_validate.c,v 1.298 2020/04/06 09:55:49 schwarze Exp $ */
/*
* Copyright (c) 2010-2020 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -1090,6 +1090,7 @@ post_tg(POST_ARGS)
struct roff_node *n; /* The .Tg node. */
struct roff_node *nch; /* The first child of the .Tg node. */
struct roff_node *nn; /* The next node after the .Tg node. */
+ struct roff_node *np; /* The parent of the next node. */
struct roff_node *nt; /* The TEXT node containing the tag. */
size_t len; /* The number of bytes in the tag. */
@@ -1135,7 +1136,7 @@ post_tg(POST_ARGS)
}
/* By default, tag the .Tg node itself. */
- if (nn == NULL)
+ if (nn == NULL || nn->flags & NODE_ID)
nn = n;
/* Explicit tagging of specific macros. */
@@ -1143,8 +1144,41 @@ post_tg(POST_ARGS)
case MDOC_Sh:
case MDOC_Ss:
case MDOC_Fo:
- nn = nn->head;
- /* FALLTHROUGH */
+ nn = nn->head->child == NULL ? n : nn->head;
+ break;
+ case MDOC_It:
+ np = nn->parent;
+ while (np->tok != MDOC_Bl)
+ np = np->parent;
+ switch (np->norm->Bl.type) {
+ case LIST_column:
+ break;
+ case LIST_diag:
+ case LIST_hang:
+ case LIST_inset:
+ case LIST_ohang:
+ case LIST_tag:
+ nn = nn->head;
+ break;
+ case LIST_bullet:
+ case LIST_dash:
+ case LIST_enum:
+ case LIST_hyphen:
+ case LIST_item:
+ nn = nn->body->child == NULL ? n : nn->body;
+ break;
+ default:
+ abort();
+ }
+ break;
+ case MDOC_Bd:
+ case MDOC_Bl:
+ case MDOC_D1:
+ case MDOC_Dl:
+ nn = nn->body->child == NULL ? n : nn->body;
+ break;
+ case MDOC_Pp:
+ break;
case MDOC_Cm:
case MDOC_Dv:
case MDOC_Em:
@@ -1157,9 +1191,9 @@ post_tg(POST_ARGS)
case MDOC_Ms:
case MDOC_No:
case MDOC_Sy:
- if (nn->child != NULL && (nn->flags & NODE_ID) == 0)
- break;
- /* FALLTHROUGH */
+ if (nn->child == NULL)
+ nn = n;
+ break;
default:
nn = n;
break;