=================================================================== RCS file: /cvs/mandoc/mdoc_term.c,v retrieving revision 1.159 retrieving revision 1.163 diff -u -p -r1.159 -r1.163 --- mandoc/mdoc_term.c 2010/06/27 01:26:20 1.159 +++ mandoc/mdoc_term.c 2010/07/01 14:34:03 1.163 @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.159 2010/06/27 01:26:20 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.163 2010/07/01 14:34:03 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -325,21 +325,38 @@ print_mdoc_node(DECL_ARGS) memset(&npair, 0, sizeof(struct termpair)); npair.ppair = pair; - if (MDOC_TEXT != n->type) { - if (termacts[n->tok].pre) - chld = (*termacts[n->tok].pre)(p, &npair, m, n); - } else + if (MDOC_TEXT == n->type) term_word(p, n->string); + else if (termacts[n->tok].pre && ENDBODY_NOT == n->end) + chld = (*termacts[n->tok].pre)(p, &npair, m, n); if (chld && n->child) print_mdoc_nodelist(p, &npair, m, n->child); term_fontpopq(p, font); - if (MDOC_TEXT != n->type) - if (termacts[n->tok].post) - (*termacts[n->tok].post)(p, &npair, m, n); + if (MDOC_TEXT != n->type && + termacts[n->tok].post && + ! (MDOC_ENDED & n->flags)) { + (*termacts[n->tok].post)(p, &npair, m, n); + /* + * Explicit end tokens not only call the post + * handler, but also tell the respective block + * that it must not call the post handler again. + */ + if (n->end) + n->pending->flags |= MDOC_ENDED; + + /* + * End of line terminating an implicit block + * while an explicit block is still open. + * Continue the explicit block without spacing. + */ + if (ENDBODY_NOSPACE == n->end) + p->flags |= TERMP_NOSPACE; + } + if (MDOC_EOS & n->flags) p->flags |= TERMP_SENTENCE; @@ -1278,7 +1295,7 @@ synopsis_pre(struct termp *p, const struct mdoc_node * * Obviously, if we're not in a SYNOPSIS or no prior macros * exist, do nothing. */ - if (NULL == n->prev || SEC_SYNOPSIS != n->sec) + if (NULL == n->prev || ! (MDOC_SYNPRETTY & n->flags)) return; /* @@ -1543,7 +1560,7 @@ termp_fn_pre(DECL_ARGS) term_word(p, ")"); - if (SEC_SYNOPSIS == n->sec) + if (MDOC_SYNPRETTY & n->flags) term_word(p, ";"); return(0); @@ -1820,7 +1837,7 @@ termp_in_pre(DECL_ARGS) synopsis_pre(p, n); - if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) { + if (MDOC_SYNPRETTY & n->flags && MDOC_LINE & n->flags) { term_fontpush(p, TERMFONT_BOLD); term_word(p, "#include"); term_word(p, "<"); @@ -1839,13 +1856,13 @@ static void termp_in_post(DECL_ARGS) { - if (SEC_SYNOPSIS == n->sec) + if (MDOC_SYNPRETTY & n->flags) term_fontpush(p, TERMFONT_BOLD); p->flags |= TERMP_NOSPACE; term_word(p, ">"); - if (SEC_SYNOPSIS == n->sec) + if (MDOC_SYNPRETTY & n->flags) term_fontpop(p); } @@ -1987,7 +2004,7 @@ termp_fo_post(DECL_ARGS) p->flags |= TERMP_NOSPACE; term_word(p, ")"); - if (SEC_SYNOPSIS == n->sec) { + if (MDOC_SYNPRETTY & n->flags) { p->flags |= TERMP_NOSPACE; term_word(p, ";"); } @@ -2109,8 +2126,17 @@ static int termp_bk_pre(DECL_ARGS) { - p->flags |= TERMP_PREKEEP; - return(1); + switch (n->type) { + case (MDOC_BLOCK): + return(1); + case (MDOC_HEAD): + return(0); + case (MDOC_BODY): + p->flags |= TERMP_PREKEEP; + return(1); + default: + abort(); + } } @@ -2119,7 +2145,8 @@ static void termp_bk_post(DECL_ARGS) { - p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP); + if (MDOC_BODY == n->type) + p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP); } /* ARGSUSED */