aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_validate.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2020-01-19 18:02:00 +0000
committerIngo Schwarze <schwarze@openbsd.org>2020-01-19 18:02:00 +0000
commit23f80e14e78282088dabbf1cfe358c07030dc9e7 (patch)
treea76006eb8db0481907b44a8fb28a37ebeb628fa0 /mdoc_validate.c
parent66e8f935f05d1018898cee9e0c4ad713fc6b8673 (diff)
downloadmandoc-23f80e14e78282088dabbf1cfe358c07030dc9e7.tar.gz
mandoc-23f80e14e78282088dabbf1cfe358c07030dc9e7.tar.zst
mandoc-23f80e14e78282088dabbf1cfe358c07030dc9e7.zip
Introduce a new mdoc(7) macro .Tg ("tag") to explicitly mark a place
as defining a term. Please only use it when automatic tagging does not work. Manual page authors will not be required to add the new macro; using it remains optional. HTML output is still rudimentary in this version and will be polished later. Thanks to kn@ for reminding me that i have been considering since BSDCan 2014 whether something like this might be useful. Given that possibilities of making automatic tagging better are running out and there are still several situations where automatic tagging cannot do the job, i think the time is now ripe. Feedback and no objection from millert@; OK espie@ inoguchi@ kn@.
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r--mdoc_validate.c41
1 files changed, 39 insertions, 2 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 4ec79423..b0b6d6f3 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.376 2020/01/19 16:44:50 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.377 2020/01/19 18:02:00 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2020 Ingo Schwarze <schwarze@openbsd.org>
@@ -113,6 +113,7 @@ static void post_sm(POST_ARGS);
static void post_st(POST_ARGS);
static void post_std(POST_ARGS);
static void post_sx(POST_ARGS);
+static void post_tg(POST_ARGS);
static void post_useless(POST_ARGS);
static void post_xr(POST_ARGS);
static void post_xx(POST_ARGS);
@@ -238,6 +239,7 @@ static const v_post mdoc_valids[MDOC_MAX - MDOC_Dd] = {
NULL, /* %Q */
NULL, /* %U */
NULL, /* Ta */
+ post_tg, /* Tg */
};
#define RSORD_MAX 14 /* Number of `Rs' blocks. */
@@ -1090,6 +1092,41 @@ post_st(POST_ARGS)
}
static void
+post_tg(POST_ARGS)
+{
+ struct roff_node *n, *nch;
+ size_t len;
+
+ n = mdoc->last;
+ nch = n->child;
+ if (nch == NULL && n->next != NULL &&
+ n->next->child->type == ROFFT_TEXT) {
+ mdoc->next = ROFF_NEXT_CHILD;
+ roff_word_alloc(mdoc, n->line, n->pos, n->next->child->string);
+ nch = mdoc->last;
+ nch->flags |= NODE_NOSRC;
+ mdoc->last = n;
+ }
+ if (nch == NULL || *nch->string == '\0') {
+ mandoc_msg(MANDOCERR_MACRO_EMPTY, n->line, n->pos, "Tg");
+ roff_node_delete(mdoc, n);
+ return;
+ }
+ len = strcspn(nch->string, " \t");
+ if (nch->string[len] != '\0')
+ mandoc_msg(MANDOCERR_TG_SPC, nch->line, nch->pos + len + 1,
+ "Tg %s", nch->string);
+ if (nch->next != NULL) {
+ mandoc_msg(MANDOCERR_ARG_EXCESS, nch->next->line,
+ nch->next->pos, "Tg ... %s", nch->next->string);
+ while (nch->next != NULL)
+ roff_node_delete(mdoc, nch->next);
+ }
+ if (nch->string[len] != '\0')
+ roff_node_delete(mdoc, n);
+}
+
+static void
post_obsolete(POST_ARGS)
{
struct roff_node *n;
@@ -1754,7 +1791,7 @@ post_bl(POST_ARGS)
while (nchild != NULL) {
nnext = nchild->next;
if (nchild->tok == MDOC_It ||
- (nchild->tok == MDOC_Sm &&
+ ((nchild->tok == MDOC_Sm || nchild->tok == MDOC_Tg) &&
nnext != NULL && nnext->tok == MDOC_It)) {
nchild = nnext;
continue;