aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/roff.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2020-02-27 21:43:44 +0000
committerIngo Schwarze <schwarze@openbsd.org>2020-02-27 21:43:44 +0000
commitf170f4f7447172beaedf75482b2bfa599cadfb1d (patch)
tree15ae2b8147741c1e627be93a980ac12da520e96a /roff.c
parent88750dda2da444fce307d20d33700d72e7c49c7f (diff)
downloadmandoc-f170f4f7447172beaedf75482b2bfa599cadfb1d.tar.gz
mandoc-f170f4f7447172beaedf75482b2bfa599cadfb1d.tar.zst
mandoc-f170f4f7447172beaedf75482b2bfa599cadfb1d.zip
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 'roff.c')
-rw-r--r--roff.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/roff.c b/roff.c
index 017f28f9..635bbc34 100644
--- a/roff.c
+++ b/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.370 2020/02/27 01:43:52 schwarze Exp $ */
+/* $Id: roff.c,v 1.371 2020/02/27 21:43:44 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017-2020 Ingo Schwarze <schwarze@openbsd.org>
@@ -1173,7 +1173,7 @@ deroff(char **dest, const struct roff_node *n)
char *cp;
size_t sz;
- if (n->type != ROFFT_TEXT) {
+ if (n->string == NULL) {
for (n = n->child; n != NULL; n = n->next)
deroff(dest, n);
return;