=================================================================== RCS file: /cvs/mandoc/html.c,v retrieving revision 1.46 retrieving revision 1.50 diff -u -p -r1.46 -r1.50 --- mandoc/html.c 2009/09/21 13:44:56 1.46 +++ mandoc/html.c 2009/09/21 14:40:31 1.50 @@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.46 2009/09/21 13:44:56 kristaps Exp $ */ +/* $Id: html.c,v 1.50 2009/09/21 14:40:31 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -167,8 +167,6 @@ static void print_mdoc(MDOC_ARGS); static void print_mdoc_head(MDOC_ARGS); static void print_mdoc_node(MDOC_ARGS); static void print_mdoc_nodelist(MDOC_ARGS); -static void print_man(MAN_ARGS); -static void print_man_head(MAN_ARGS); static struct tag *print_otag(struct html *, enum htmltag, int, const struct htmlpair *); static void print_tagq(struct html *, const struct tag *); @@ -220,12 +218,12 @@ static int mdoc_ns_pre(MDOC_ARGS); static void mdoc_op_post(MDOC_ARGS); static int mdoc_op_pre(MDOC_ARGS); static int mdoc_pa_pre(MDOC_ARGS); -static int mdoc_pp_pre(MDOC_ARGS); static void mdoc_pq_post(MDOC_ARGS); static int mdoc_pq_pre(MDOC_ARGS); static void mdoc_qq_post(MDOC_ARGS); static int mdoc_qq_pre(MDOC_ARGS); static int mdoc_sh_pre(MDOC_ARGS); +static int mdoc_sp_pre(MDOC_ARGS); static void mdoc_sq_post(MDOC_ARGS); static int mdoc_sq_pre(MDOC_ARGS); static int mdoc_ss_pre(MDOC_ARGS); @@ -241,13 +239,13 @@ extern size_t strlcat(char *, const char *, size_ #endif static const struct htmlmdoc mdocs[MDOC_MAX] = { - {mdoc_pp_pre, NULL}, /* Ap */ + {NULL, NULL}, /* Ap */ {NULL, NULL}, /* Dd */ {NULL, NULL}, /* Dt */ {NULL, NULL}, /* Os */ {mdoc_sh_pre, NULL }, /* Sh */ {mdoc_ss_pre, NULL }, /* Ss */ - {mdoc_pp_pre, NULL}, /* Pp */ + {mdoc_sp_pre, NULL}, /* Pp */ {mdoc_d1_pre, NULL}, /* D1 */ {mdoc_d1_pre, NULL}, /* Dl */ {mdoc_bd_pre, NULL}, /* Bd */ @@ -348,7 +346,7 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = { {NULL, NULL}, /* Fr */ {NULL, NULL}, /* Ud */ {NULL, NULL}, /* Lb */ - {NULL, NULL}, /* Lp */ + {mdoc_sp_pre, NULL}, /* Lp */ {NULL, NULL}, /* Lk */ {NULL, NULL}, /* Mt */ {NULL, NULL}, /* Brq */ @@ -359,8 +357,8 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = { {NULL, NULL}, /* En */ {mdoc_xx_pre, NULL}, /* Dx */ {NULL, NULL}, /* %Q */ - {NULL, NULL}, /* br */ - {NULL, NULL}, /* sp */ + {mdoc_sp_pre, NULL}, /* br */ + {mdoc_sp_pre, NULL}, /* sp */ }; static char buf[BUFSIZ]; /* XXX */ @@ -386,20 +384,10 @@ html_mdoc(void *arg, const struct mdoc *m) } +/* ARGSUSED */ void html_man(void *arg, const struct man *m) { - struct html *h; - struct tag *t; - - h = (struct html *)arg; - - print_gen_doctype(h); - t = print_otag(h, TAG_HTML, 0, NULL); - print_man(man_meta(m), man_node(m), h); - print_tagq(h, t); - - printf("\n"); } @@ -424,7 +412,7 @@ html_alloc(char *outopts) return(NULL); } - while (*outopts) + while (outopts && *outopts) switch (getsubopt(&outopts, toks, &v)) { case (0): h->style = v; @@ -616,10 +604,21 @@ print_gen_head(struct html *h) static void print_mdoc_head(MDOC_ARGS) { + char b[BUFSIZ]; print_gen_head(h); + + (void)snprintf(b, BUFSIZ - 1, + "%s(%d)", m->title, m->msec); + + if (m->arch) { + (void)strlcat(b, " (", BUFSIZ); + (void)strlcat(b, m->arch, BUFSIZ); + (void)strlcat(b, ")", BUFSIZ); + } + print_otag(h, TAG_TITLE, 0, NULL); - print_text(h, m->title); + print_text(h, b); } @@ -679,32 +678,6 @@ print_mdoc_node(MDOC_ARGS) static void -print_man(MAN_ARGS) -{ - struct tag *t; - - t = print_otag(h, TAG_HEAD, 0, NULL); - print_man_head(m, n, h); - print_tagq(h, t); - - t = print_otag(h, TAG_BODY, 0, NULL); - /*print_man_body(m, n, h);*/ - print_tagq(h, t); -} - - -/* ARGSUSED */ -static void -print_man_head(MAN_ARGS) -{ - - print_gen_head(h); - print_otag(h, TAG_TITLE, 0, NULL); - print_text(h, m->title); -} - - -static void print_spec(struct html *h, const char *p, int len) { const char *rhs; @@ -1223,19 +1196,6 @@ mdoc_fl_pre(MDOC_ARGS) /* ARGSUSED */ static int -mdoc_pp_pre(MDOC_ARGS) -{ - struct htmlpair tag; - - tag.key = ATTR_STYLE; - tag.val = "clear: both; height: 1em;"; - print_otag(h, TAG_DIV, 1, &tag); - return(0); -} - - -/* ARGSUSED */ -static int mdoc_nd_pre(MDOC_ARGS) { struct htmlpair tag; @@ -2171,4 +2131,32 @@ mdoc_fn_pre(MDOC_ARGS) print_text(h, ";"); return(0); +} + + +/* ARGSUSED */ +static int +mdoc_sp_pre(MDOC_ARGS) +{ + int len; + struct htmlpair tag; + + switch (n->tok) { + case (MDOC_sp): + len = n->child ? atoi(n->child->string) : 1; + break; + case (MDOC_br): + len = 0; + break; + default: + len = 1; + break; + } + + buffmt("height: %dem", len); + tag.key = ATTR_STYLE; + tag.val = buf; + print_otag(h, TAG_DIV, 1, &tag); + return(1); + }