=================================================================== RCS file: /cvs/mandoc/term.c,v retrieving revision 1.66 retrieving revision 1.69 diff -u -p -r1.66 -r1.69 --- mandoc/term.c 2009/03/21 13:26:30 1.66 +++ mandoc/term.c 2009/03/23 09:42:43 1.69 @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.66 2009/03/21 13:26:30 kristaps Exp $ */ +/* $Id: term.c,v 1.69 2009/03/23 09:42:43 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -56,7 +56,8 @@ #define TTYPE_LINK_ANCHOR 19 #define TTYPE_LINK_TEXT 20 #define TTYPE_REF_JOURNAL 21 -#define TTYPE_NMAX 22 +#define TTYPE_LIST 22 +#define TTYPE_NMAX 23 /* * These define "styles" for element types, like command arguments or @@ -88,7 +89,8 @@ const int ttypes[TTYPE_NMAX] = { TERMP_BOLD, /* TTYPE_DIAG */ TERMP_UNDER, /* TTYPE_LINK_ANCHOR */ TERMP_BOLD, /* TTYPE_LINK_TEXT */ - TERMP_UNDER /* TTYPE_REF_JOURNAL */ + TERMP_UNDER, /* TTYPE_REF_JOURNAL */ + TERMP_BOLD /* TTYPE_LIST */ }; static int arg_hasattr(int, const struct mdoc_node *); @@ -98,6 +100,9 @@ static int arg_getattr(int, const struct mdoc_node static size_t arg_offset(const struct mdoc_argv *); static size_t arg_width(const struct mdoc_argv *, int); static int arg_listtype(const struct mdoc_node *); +static int fmt_block_vspace(struct termp *, + const struct mdoc_node *, + const struct mdoc_node *); /* * What follows describes prefix and postfix operations for the abstract @@ -430,6 +435,36 @@ arg_getattrs(const int *keys, int *vals, /* ARGSUSED */ static int +fmt_block_vspace(struct termp *p, + const struct mdoc_node *bl, + const struct mdoc_node *node) +{ + const struct mdoc_node *n; + + term_newln(p); + + if (arg_hasattr(MDOC_Compact, bl)) + return(1); + + for (n = node; n; n = n->parent) { + if (MDOC_BLOCK != n->type) + continue; + if (MDOC_Ss == n->tok) + break; + if (MDOC_Sh == n->tok) + break; + if (NULL == n->prev) + continue; + term_vspace(p); + break; + } + + return(1); +} + + +/* ARGSUSED */ +static int termp_dq_pre(DECL_ARGS) { @@ -457,19 +492,6 @@ termp_dq_post(DECL_ARGS) /* ARGSUSED */ static int -termp_it_pre_block(DECL_ARGS) -{ - - term_newln(p); - if ( ! arg_hasattr(MDOC_Compact, node->parent->parent)) - term_vspace(p); - - return(1); -} - - -/* ARGSUSED */ -static int termp_it_pre(DECL_ARGS) { const struct mdoc_node *bl, *n; @@ -478,7 +500,7 @@ termp_it_pre(DECL_ARGS) size_t width, offset; if (MDOC_BLOCK == node->type) - return(termp_it_pre_block(p, pair, meta, node)); + return(fmt_block_vspace(p, node->parent->parent, node)); bl = node->parent->parent->parent; @@ -1171,9 +1193,9 @@ termp_fn_pre(DECL_ARGS) term_word(p, node->child->string); p->flags &= ~ttypes[TTYPE_FUNC_NAME]; + p->flags |= TERMP_NOSPACE; term_word(p, "("); - p->flags |= TERMP_NOSPACE; for (n = node->child->next; n; n = n->next) { p->flags |= ttypes[TTYPE_FUNC_ARG]; term_word(p, n->string); @@ -1231,7 +1253,7 @@ termp_fa_pre(DECL_ARGS) term_word(p, ","); } - if (node->next && node->next->tok == MDOC_Fa) + if (node->child && node->next && node->next->tok == MDOC_Fa) term_word(p, ","); return(0); @@ -1265,12 +1287,9 @@ termp_bd_pre(DECL_ARGS) * line. Blank lines are allowed. */ - if (MDOC_BLOCK == node->type) { - /* FIXME: parent prev? */ - if (node->prev) - term_vspace(p); - return(1); - } else if (MDOC_BODY != node->type) + if (MDOC_BLOCK == node->type) + return(fmt_block_vspace(p, node, node)); + else if (MDOC_BODY != node->type) return(1); if (NULL == node->parent->args)