diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-01-10 12:53:07 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-01-10 12:53:07 +0000 |
commit | f313579fbb5a5318367521793dc24d2567da2fde (patch) | |
tree | 59f0ec418ab638218374512a8cc78a4cde422b54 /mdoc_term.c | |
parent | c8505d9515e240b816d67a5b4a08ccfd4268cb6a (diff) | |
download | mandoc-f313579fbb5a5318367521793dc24d2567da2fde.tar.gz mandoc-f313579fbb5a5318367521793dc24d2567da2fde.tar.zst mandoc-f313579fbb5a5318367521793dc24d2567da2fde.zip |
Introduce flags NODE_NOSRC and NODE_NOPRT for AST nodes.
Use them to mark generated nodes and nodes that shall not produce output.
Let -Ttree output mode display these new flags.
Use NODE_NOSRC for .Ar, .Mt, and .Pa default arguments.
Use NODE_NOPRT for .Dd, .Dt, and .Os.
These will help to make handling of text production macros more rigorous.
Diffstat (limited to 'mdoc_term.c')
-rw-r--r-- | mdoc_term.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/mdoc_term.c b/mdoc_term.c index 0f27565a..8d434999 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.336 2016/11/08 16:38:21 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.337 2017/01/10 12:53:07 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012-2016 Ingo Schwarze <schwarze@openbsd.org> @@ -285,6 +285,8 @@ terminal_mdoc(void *arg, const struct roff_man *mdoc) p->defindent = 5; term_begin(p, print_mdoc_head, print_mdoc_foot, &mdoc->meta); + while (n != NULL && n->flags & NODE_NOPRT) + n = n->next; if (n != NULL) { if (n->tok != MDOC_Sh) term_vspace(p); @@ -311,6 +313,9 @@ print_mdoc_node(DECL_ARGS) struct termpair npair; size_t offset, rmargin; + if (n->flags & NODE_NOPRT) + return; + chld = 1; offset = p->offset; rmargin = p->rmargin; @@ -564,6 +569,8 @@ print_bvspace(struct termp *p, /* Do not vspace directly after Ss/Sh. */ nn = n; + while (nn->prev != NULL && nn->prev->flags & NODE_NOPRT) + nn = nn->prev; while (nn->prev == NULL) { do { nn = nn->parent; @@ -1718,11 +1725,15 @@ termp_pf_post(DECL_ARGS) static int termp_ss_pre(DECL_ARGS) { + struct roff_node *nn; switch (n->type) { case ROFFT_BLOCK: term_newln(p); - if (n->prev) + for (nn = n->prev; nn != NULL; nn = nn->prev) + if ((nn->flags & NODE_NOPRT) == 0) + break; + if (nn != NULL) term_vspace(p); break; case ROFFT_HEAD: |