summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/mdoc_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2020-02-27 21:38:28 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2020-02-27 21:38:28 +0000
commit90125c0d0616065ac86e41e8a4972b3b73f61bf4 (patch)
tree5ed29449f400030d01535f26586ee3b69be8f743 /usr.bin/mandoc/mdoc_term.c
parent224a0398c9757c21eb1f548b2fd698b7f37ffcbe (diff)
Fully support explicit tagging of .Sh and .Ss.
This fixes the offset of two lines in terminal output and this improves HTML output by putting the id= attribute and <a> element into the respective <h1> or <h2> element rather than writing an additional <mark> element. To that end, introduce node flags NODE_ID (to make the node a link target, for example by writing an HTML id= attribute or by calling tag_put()) and NODE_HREF (to make the node a link source, used only in HTML output, used only to write an <a class="permalink"> element). In particular: * In the validator, generalize the concept of the "next node" such that it also works before .Sh and .Ss. * If the first argument of .Tg is empty, don't forget to complain if there are additional arguments, which will be ignored. * In the terminal formatter, support writing of explicit tags for all kinds of nodes, not just for .Tg. * In deroff(), allow nodes to have an explicit string representation even when they aren't text nodes. Use this for explicitly tagged section headers. Suprisingly, this is sufficient to make HTML output work, without explicit code changes in the HTML formatter. * In syntax tree output, display NODE_ID and NODE_HREF.
Diffstat (limited to 'usr.bin/mandoc/mdoc_term.c')
-rw-r--r--usr.bin/mandoc/mdoc_term.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c
index dab449d9da4..54252473702 100644
--- a/usr.bin/mandoc/mdoc_term.c
+++ b/usr.bin/mandoc/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_term.c,v 1.276 2020/02/27 01:25:57 schwarze Exp $ */
+/* $OpenBSD: mdoc_term.c,v 1.277 2020/02/27 21:38:27 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2020 Ingo Schwarze <schwarze@openbsd.org>
@@ -115,7 +115,6 @@ static int termp_pp_pre(DECL_ARGS);
static int termp_ss_pre(DECL_ARGS);
static int termp_sy_pre(DECL_ARGS);
static int termp_tag_pre(DECL_ARGS);
-static int termp_tg_pre(DECL_ARGS);
static int termp_under_pre(DECL_ARGS);
static int termp_vt_pre(DECL_ARGS);
static int termp_xr_pre(DECL_ARGS);
@@ -242,7 +241,7 @@ static const struct mdoc_term_act mdoc_term_acts[MDOC_MAX - MDOC_Dd] = {
{ NULL, termp____post }, /* %Q */
{ NULL, termp____post }, /* %U */
{ NULL, NULL }, /* Ta */
- { termp_tg_pre, NULL }, /* Tg */
+ { termp_skip_pre, NULL }, /* Tg */
};
static int fn_prio = TAG_STRONG;
@@ -339,6 +338,10 @@ print_mdoc_node(DECL_ARGS)
memset(&npair, 0, sizeof(struct termpair));
npair.ppair = pair;
+ if (n->flags & NODE_ID)
+ tag_put(n->string == NULL ? n->child->string : n->string,
+ TAG_MANUAL, p->line);
+
/*
* Keeps only work until the end of a line. If a keep was
* invoked in a prior line, revert it to PREKEEP.
@@ -2064,13 +2067,6 @@ termp_tag_pre(DECL_ARGS)
}
static int
-termp_tg_pre(DECL_ARGS)
-{
- tag_put(n->child->string, TAG_MANUAL, p->line);
- return 0;
-}
-
-static int
termp_abort_pre(DECL_ARGS)
{
abort();