=================================================================== RCS file: /cvs/mandoc/mdoc_term.c,v retrieving revision 1.268 retrieving revision 1.272 diff -u -p -r1.268 -r1.272 --- mandoc/mdoc_term.c 2014/07/02 03:48:07 1.268 +++ mandoc/mdoc_term.c 2014/07/29 13:58:18 1.272 @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.268 2014/07/02 03:48:07 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.272 2014/07/29 13:58:18 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze @@ -275,8 +275,11 @@ terminal_mdoc(void *arg, const struct mdoc *mdoc) term_begin(p, print_mdoc_head, print_mdoc_foot, meta); - if (n->child) + if (n->child) { + if (MDOC_Sh != n->child->tok) + term_vspace(p); print_mdoc_nodelist(p, NULL, meta, n->child); + } term_end(p); } @@ -747,7 +750,7 @@ termp_it_pre(DECL_ARGS) term_word(p, "\\ \\ "); break; case LIST_inset: - if (MDOC_BODY == n->type) + if (MDOC_BODY == n->type && n->parent->head->nchild) term_word(p, "\\ "); break; default: @@ -1568,7 +1571,7 @@ termp_fa_pre(DECL_ARGS) static int termp_bd_pre(DECL_ARGS) { - size_t tabwidth, rm, rmax; + size_t tabwidth, lm, len, rm, rmax; struct mdoc_node *nn; if (MDOC_BLOCK == n->type) { @@ -1589,18 +1592,29 @@ termp_bd_pre(DECL_ARGS) */ if (DISP_literal != n->norm->Bd.type && - DISP_unfilled != n->norm->Bd.type) + DISP_unfilled != n->norm->Bd.type && + DISP_centered != n->norm->Bd.type) return(1); tabwidth = p->tabwidth; if (DISP_literal == n->norm->Bd.type) p->tabwidth = term_len(p, 8); + lm = p->offset; rm = p->rmargin; rmax = p->maxrmargin; p->rmargin = p->maxrmargin = TERM_MAXMARGIN; for (nn = n->child; nn; nn = nn->next) { + if (DISP_centered == n->norm->Bd.type) { + if (MDOC_TEXT == nn->type) { + len = term_strlen(p, nn->string); + p->offset = len >= rm ? 0 : + lm + len >= rm ? rm - len : + (lm + rm - len) / 2; + } else + p->offset = lm; + } print_mdoc_node(p, pair, meta, nn); /* * If the printed node flushes its own line, then we @@ -2056,13 +2070,15 @@ static int termp_sm_pre(DECL_ARGS) { - assert(n->child && MDOC_TEXT == n->child->type); - if (0 == strcmp("on", n->child->string)) { - if (p->col) - p->flags &= ~TERMP_NOSPACE; + if (NULL == n->child) + p->flags ^= TERMP_NONOSPACE; + else if (0 == strcmp("on", n->child->string)) p->flags &= ~TERMP_NONOSPACE; - } else + else p->flags |= TERMP_NONOSPACE; + + if (p->col && ! (TERMP_NONOSPACE & p->flags)) + p->flags &= ~TERMP_NOSPACE; return(0); }