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 | b0911daecba940ec62df1e631a2f8a01d7ffe641 (patch) | |
tree | 46f9e09923d3ddcc524aa04bdc519661509a8142 /mdoc_term.c | |
parent | 6a8c332380e498f7df739486f006b1a0d4bb4623 (diff) | |
download | mandoc-b0911daecba940ec62df1e631a2f8a01d7ffe641.tar.gz |
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 | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/mdoc_term.c b/mdoc_term.c index 97923a3d..6cdf9d84 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -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: |