summaryrefslogtreecommitdiffstats
path: root/tag.c
diff options
context:
space:
mode:
Diffstat (limited to 'tag.c')
-rw-r--r--tag.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/tag.c b/tag.c
index abc935ae..40a41eac 100644
--- a/tag.c
+++ b/tag.c
@@ -1,6 +1,7 @@
/* $Id$ */
/*
- * Copyright (c) 2015,2016,2018,2019,2020 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2015, 2016, 2018, 2019, 2020, 2022
+ * Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -80,7 +81,7 @@ tag_free(void)
/*
* Set a node where a term is defined,
- * unless it is already defined at a lower priority.
+ * unless the term is already defined at a lower priority.
*/
void
tag_put(const char *s, int prio, struct roff_node *n)
@@ -93,6 +94,18 @@ tag_put(const char *s, int prio, struct roff_node *n)
assert(prio <= TAG_FALLBACK);
+ /*
+ * If the node is already tagged, the existing tag is
+ * explicit and we are now about to add an implicit tag.
+ * Don't do that; just skip implicit tagging if the author
+ * specified an explicit tag.
+ */
+
+ if (n->flags & NODE_ID)
+ return;
+
+ /* Determine the implicit tag. */
+
if (s == NULL) {
if (n->child == NULL || n->child->type != ROFFT_TEXT)
return;
@@ -150,7 +163,7 @@ tag_put(const char *s, int prio, struct roff_node *n)
*/
else if (entry->prio < prio)
- return;
+ return;
/*
* If the existing entry is worse, clear it.