=================================================================== RCS file: /cvs/mandoc/mdoc_html.c,v retrieving revision 1.44 retrieving revision 1.53 diff -u -p -r1.44 -r1.53 --- mandoc/mdoc_html.c 2009/10/31 06:10:58 1.44 +++ mandoc/mdoc_html.c 2010/01/29 14:39:38 1.53 @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.44 2009/10/31 06:10:58 kristaps Exp $ */ +/* $Id: mdoc_html.c,v 1.53 2010/01/29 14:39:38 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -14,8 +14,11 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include -#include #include #include @@ -36,6 +39,10 @@ const struct mdoc_node *n, \ struct html *h +#ifndef MIN +#define MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b)) +#endif + struct htmlmdoc { int (*pre)(MDOC_ARGS); void (*post)(MDOC_ARGS); @@ -126,11 +133,6 @@ static int mdoc_vt_pre(MDOC_ARGS); static int mdoc_xr_pre(MDOC_ARGS); static int mdoc_xx_pre(MDOC_ARGS); -#ifdef __linux__ -extern size_t strlcpy(char *, const char *, size_t); -extern size_t strlcat(char *, const char *, size_t); -#endif - static const struct htmlmdoc mdocs[MDOC_MAX] = { {mdoc_ap_pre, NULL}, /* Ap */ {NULL, NULL}, /* Dd */ @@ -264,7 +266,7 @@ html_mdoc(void *arg, const struct mdoc *m) h = (struct html *)arg; - print_gen_doctype(h); + print_gen_decls(h); t = print_otag(h, TAG_HTML, 0, NULL); print_mdoc(mdoc_meta(m), mdoc_node(m), h); print_tagq(h, t); @@ -424,7 +426,7 @@ print_mdoc_node(MDOC_ARGS) break; case (MDOC_TEXT): print_text(h, n->string); - break; + return; default: if (mdocs[n->tok].pre) child = (*mdocs[n->tok].pre)(m, n, h); @@ -441,8 +443,6 @@ print_mdoc_node(MDOC_ARGS) case (MDOC_ROOT): mdoc_root_post(m, n, h); break; - case (MDOC_TEXT): - break; default: if (mdocs[n->tok].post) (*mdocs[n->tok].post)(m, n, h); @@ -663,10 +663,19 @@ mdoc_fl_pre(MDOC_ARGS) PAIR_CLASS_INIT(&tag, "flag"); print_otag(h, TAG_SPAN, 1, &tag); - if (MDOC_Fl == n->tok) { - print_text(h, "\\-"); + + /* `Cm' has no leading hyphen. */ + + if (MDOC_Cm == n->tok) + return(1); + + print_text(h, "\\-"); + + /* A blank `Fl' should incur a subsequent space. */ + + if (n->child) h->flags |= HTML_NOSPACE; - } + return(1); } @@ -725,12 +734,11 @@ mdoc_nm_pre(MDOC_ARGS) { struct htmlpair tag; - if ( ! (HTML_NEWLINE & h->flags)) - if (SEC_SYNOPSIS == n->sec) { - bufcat_style(h, "clear", "both"); - PAIR_STYLE_INIT(&tag, h); - print_otag(h, TAG_BR, 1, &tag); - } + if (SEC_SYNOPSIS == n->sec && n->prev) { + bufcat_style(h, "clear", "both"); + PAIR_STYLE_INIT(&tag, h); + print_otag(h, TAG_BR, 1, &tag); + } PAIR_CLASS_INIT(&tag, "name"); print_otag(h, TAG_SPAN, 1, &tag); @@ -810,7 +818,7 @@ mdoc_xx_pre(MDOC_ARGS) pp = "BSDI BSD/OS"; break; case (MDOC_Dx): - pp = "DragonFlyBSD"; + pp = "DragonFly"; break; case (MDOC_Fx): pp = "FreeBSD"; @@ -951,9 +959,10 @@ mdoc_it_head_pre(MDOC_ARGS, int type, struct roffsu *w switch (type) { case (MDOC_Item): - /* FALLTHROUGH */ - case (MDOC_Ohang): return(0); + case (MDOC_Ohang): + print_otag(h, TAG_DIV, 0, &tag); + return(1); case (MDOC_Column): bufcat_su(h, "min-width", width); bufcat_style(h, "clear", "none"); @@ -1067,6 +1076,8 @@ mdoc_it_pre(MDOC_ARGS) /* Override width in some cases. */ switch (type) { + case (MDOC_Ohang): + /* FALLTHROUGH */ case (MDOC_Item): /* FALLTHROUGH */ case (MDOC_Inset): @@ -1573,9 +1584,9 @@ mdoc_vt_pre(MDOC_ARGS) struct roffsu su; if (SEC_SYNOPSIS == n->sec) { - if (n->next && MDOC_Vt != n->next->tok) { + if (n->prev && MDOC_Vt != n->prev->tok) { SCALE_VS_INIT(&su, 1); - bufcat_su(h, "margin-bottom", &su); + bufcat_su(h, "margin-top", &su); PAIR_STYLE_INIT(&tag, h); print_otag(h, TAG_DIV, 1, &tag); } else