=================================================================== RCS file: /cvs/mandoc/html.c,v retrieving revision 1.44 retrieving revision 1.48 diff -u -p -r1.44 -r1.48 --- mandoc/html.c 2009/09/21 13:42:01 1.44 +++ mandoc/html.c 2009/09/21 14:07:07 1.48 @@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.44 2009/09/21 13:42:01 kristaps Exp $ */ +/* $Id: html.c,v 1.48 2009/09/21 14:07:07 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -23,6 +23,7 @@ #include #include #include +#include #include "chars.h" #include "mdoc.h" @@ -219,12 +220,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); @@ -240,13 +241,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 */ @@ -347,7 +348,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 */ @@ -358,8 +359,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 */ @@ -423,7 +424,7 @@ html_alloc(char *outopts) return(NULL); } - while (*outopts) + while (outopts && *outopts) switch (getsubopt(&outopts, toks, &v)) { case (0): h->style = v; @@ -557,12 +558,18 @@ static void print_mdoc(MDOC_ARGS) { struct tag *t; + struct htmlpair tag; t = print_otag(h, TAG_HEAD, 0, NULL); print_mdoc_head(m, n, h); print_tagq(h, t); t = print_otag(h, TAG_BODY, 0, NULL); + + tag.key = ATTR_CLASS; + tag.val = "body"; + print_otag(h, TAG_DIV, 1, &tag); + print_mdoc_nodelist(m, n, h); print_tagq(h, t); } @@ -914,7 +921,7 @@ static void print_gen_doctype(struct html *h) { - printf("\n", DOCTYPE, DTD); + printf("", DOCTYPE, DTD); } @@ -1058,14 +1065,10 @@ mdoc_root_pre(MDOC_ARGS) "%s(%d)", m->title, m->msec); tag[0].key = ATTR_CLASS; - tag[0].val = "body"; - t = print_otag(h, TAG_DIV, 1, tag); - - tag[0].key = ATTR_CLASS; tag[0].val = "header"; tag[1].key = ATTR_STYLE; tag[1].val = "width: 100%;"; - print_otag(h, TAG_TABLE, 2, tag); + t = print_otag(h, TAG_TABLE, 2, tag); tt = print_otag(h, TAG_TR, 0, NULL); tag[0].key = ATTR_STYLE; @@ -1084,7 +1087,7 @@ mdoc_root_pre(MDOC_ARGS) tag[0].val = "width: 33%; text-align: right;"; print_otag(h, TAG_TD, 1, tag); print_text(h, b); - print_stagq(h, t); + print_tagq(h, t); return(1); } @@ -1220,19 +1223,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; @@ -1260,6 +1250,7 @@ mdoc_op_pre(MDOC_ARGS) /* XXX - this can contain block elements! */ print_text(h, "\\(lB"); + h->flags |= HTML_NOSPACE; tag.key = ATTR_CLASS; tag.val = "opt"; print_otag(h, TAG_SPAN, 1, &tag); @@ -1421,8 +1412,12 @@ mdoc_tbl_block_pre(MDOC_ARGS, int t, int w, int o, int break; } - if ( ! c && n->prev && n->prev->body->child) - bufcat("padding-top: 1em;"); + if ( ! c && MDOC_Column != t) { + if (n->prev && n->prev->body->child) + bufcat("padding-top: 1em;"); + else if (NULL == n->prev) + bufcat("padding-top: 1em;"); + } tag.key = ATTR_STYLE; tag.val = buf; @@ -2163,4 +2158,26 @@ mdoc_fn_pre(MDOC_ARGS) print_text(h, ";"); return(0); +} + + +/* ARGSUSED */ +static int +mdoc_sp_pre(MDOC_ARGS) +{ + int len; + struct htmlpair tag; + + if (MDOC_sp == n->tok) + len = n->child ? atoi(n->child->string) : 1; + else + len = 1; + + buffmt("height: %dem", len); + + tag.key = ATTR_STYLE; + tag.val = buf; + print_otag(h, TAG_DIV, 1, &tag); + return(1); + }