=================================================================== RCS file: /cvs/mandoc/Attic/mdoc_action.c,v retrieving revision 1.59 retrieving revision 1.62 diff -u -p -r1.59 -r1.62 --- mandoc/Attic/mdoc_action.c 2010/05/17 22:11:42 1.59 +++ mandoc/Attic/mdoc_action.c 2010/05/29 18:58:52 1.62 @@ -1,4 +1,4 @@ -/* $Id: mdoc_action.c,v 1.59 2010/05/17 22:11:42 kristaps Exp $ */ +/* $Id: mdoc_action.c,v 1.62 2010/05/29 18:58:52 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -33,7 +33,7 @@ #include "libmandoc.h" #define POST_ARGS struct mdoc *m, struct mdoc_node *n -#define PRE_ARGS struct mdoc *m, const struct mdoc_node *n +#define PRE_ARGS struct mdoc *m, struct mdoc_node *n #define NUMSIZ 32 #define DATESIZ 32 @@ -57,6 +57,7 @@ static int post_dd(POST_ARGS); static int post_display(POST_ARGS); static int post_dt(POST_ARGS); static int post_lb(POST_ARGS); +static int post_li(POST_ARGS); static int post_nm(POST_ARGS); static int post_os(POST_ARGS); static int post_pa(POST_ARGS); @@ -102,7 +103,7 @@ static const struct actions mdoc_actions[MDOC_MAX] = { { NULL, NULL }, /* Ft */ { NULL, NULL }, /* Ic */ { NULL, NULL }, /* In */ - { NULL, NULL }, /* Li */ + { NULL, post_li }, /* Li */ { NULL, NULL }, /* Nd */ { NULL, post_nm }, /* Nm */ { NULL, NULL }, /* Op */ @@ -216,7 +217,7 @@ static const enum mdoct rsord[RSORD_MAX] = { int -mdoc_action_pre(struct mdoc *m, const struct mdoc_node *n) +mdoc_action_pre(struct mdoc *m, struct mdoc_node *n) { switch (n->type) { @@ -637,11 +638,14 @@ post_bl_tagwidth(POST_ARGS) /* Defaults to ten ens. */ sz = 10; /* XXX: make this a macro value. */ - nn = n->body->child; + for (nn = n->body->child; nn; nn = nn->next) { + if (MDOC_It == nn->tok) + break; + } + if (nn) { assert(MDOC_BLOCK == nn->type); - assert(MDOC_It == nn->tok); nn = nn->head->child; if (MDOC_TEXT != nn->type) { sz = mdoc_macro2len(nn->tok); @@ -834,6 +838,27 @@ post_pa(POST_ARGS) /* + * Empty `Li' macros get an empty string to make front-ends add an extra + * space. + */ +static int +post_li(POST_ARGS) +{ + struct mdoc_node *np; + + if (n->child) + return(1); + + np = n; + m->next = MDOC_NEXT_CHILD; + if ( ! mdoc_word_alloc(m, n->line, n->pos, "")) + return(0); + m->last = np; + return(1); +} + + +/* * The `Ar' macro defaults to two strings "file ..." if no value is * provided as an argument. */ @@ -942,8 +967,63 @@ pre_offset(PRE_ARGS) static int pre_bl(PRE_ARGS) { + int pos; - return(MDOC_BLOCK == n->type ? pre_offset(m, n) : 1); + if (MDOC_BLOCK != n->type) { + assert(n->parent); + assert(MDOC_BLOCK == n->parent->type); + assert(MDOC_Bl == n->parent->tok); + assert(LIST__NONE != n->parent->data.list); + n->data.list = n->parent->data.list; + return(1); + } + + assert(LIST__NONE == n->data.list); + + for (pos = 0; pos < (int)n->args->argc; pos++) { + switch (n->args->argv[pos].arg) { + case (MDOC_Bullet): + n->data.list = LIST_bullet; + break; + case (MDOC_Dash): + n->data.list = LIST_dash; + break; + case (MDOC_Enum): + n->data.list = LIST_enum; + break; + case (MDOC_Hyphen): + n->data.list = LIST_hyphen; + break; + case (MDOC_Item): + n->data.list = LIST_item; + break; + case (MDOC_Tag): + n->data.list = LIST_tag; + break; + case (MDOC_Diag): + n->data.list = LIST_diag; + break; + case (MDOC_Hang): + n->data.list = LIST_hang; + break; + case (MDOC_Ohang): + n->data.list = LIST_ohang; + break; + case (MDOC_Inset): + n->data.list = LIST_inset; + break; + case (MDOC_Column): + n->data.list = LIST_column; + break; + default: + break; + } + if (LIST__NONE != n->data.list) + break; + } + + assert(LIST__NONE != n->data.list); + return(pre_offset(m, n)); }