=================================================================== RCS file: /cvs/mandoc/man_html.c,v retrieving revision 1.8 retrieving revision 1.13 diff -u -p -r1.8 -r1.13 --- mandoc/man_html.c 2009/10/08 23:00:15 1.8 +++ mandoc/man_html.c 2009/10/24 05:45:04 1.13 @@ -1,4 +1,4 @@ -/* $Id: man_html.c,v 1.8 2009/10/08 23:00:15 kristaps Exp $ */ +/* $Id: man_html.c,v 1.13 2009/10/24 05:45:04 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -27,8 +27,10 @@ #include "out.h" #include "html.h" #include "man.h" +#include "main.h" /* TODO: preserve ident widths. */ +/* FIXME: have PD set the default vspace width. */ #define INDENT 5 #define HALFINDENT 3 @@ -60,6 +62,7 @@ static int man_HP_pre(MAN_ARGS); static int man_I_pre(MAN_ARGS); static int man_IP_pre(MAN_ARGS); static int man_PP_pre(MAN_ARGS); +static int man_RS_pre(MAN_ARGS); static int man_SB_pre(MAN_ARGS); static int man_SH_pre(MAN_ARGS); static int man_SM_pre(MAN_ARGS); @@ -99,9 +102,10 @@ static const struct htmlman mans[MAN_MAX] = { { NULL, NULL }, /* fi */ { NULL, NULL }, /* r */ { NULL, NULL }, /* RE */ - { NULL, NULL }, /* RS */ + { man_RS_pre, NULL }, /* RS */ { man_ign_pre, NULL }, /* DT */ { man_ign_pre, NULL }, /* UC */ + { man_ign_pre, NULL }, /* PD */ }; @@ -220,7 +224,7 @@ a2width(const struct man_node *n, struct roffsu *su) if (MAN_TEXT != n->type) return(0); - if (a2roffsu(n->string, su)) + if (a2roffsu(n->string, su, SCALE_BU)) return(1); return(0); @@ -279,16 +283,12 @@ man_root_pre(MAN_ARGS) static void man_root_post(MAN_ARGS) { - struct tm tm; struct htmlpair tag[2]; struct tag *t, *tt; - char b[BUFSIZ]; + char b[DATESIZ]; - (void)localtime_r(&m->date, &tm); + time2a(m->date, b, DATESIZ); - if (0 == strftime(b, BUFSIZ - 1, "%B %e, %Y", &tm)) - err(EXIT_FAILURE, "strftime"); - PAIR_CLASS_INIT(&tag[0], "footer"); bufcat_style(h, "width", "100%"); PAIR_STYLE_INIT(&tag[1], h); @@ -323,11 +323,9 @@ man_br_pre(MAN_ARGS) SCALE_VS_INIT(&su, 1); - if (MAN_sp == n->tok) { - su.scale = 1; - if (n->child) - a2roffsu(n->child->string, &su); - } else if (MAN_br == n->tok) + if (MAN_sp == n->tok && n->child) + a2roffsu(n->child->string, &su, SCALE_VS); + else if (MAN_br == n->tok) su.scale = 0; bufcat_su(h, "height", &su); @@ -565,6 +563,8 @@ man_IP_pre(MAN_ARGS) if (MAN_BLOCK == n->type) { bufcat_su(h, "margin-left", &su); + SCALE_VS_INIT(&su, 1); + bufcat_su(h, "margin-top", &su); bufcat_style(h, "clear", "both"); PAIR_STYLE_INIT(&tag, h); print_otag(h, TAG_DIV, 1, &tag); @@ -621,6 +621,8 @@ man_HP_pre(MAN_ARGS) if (MAN_BLOCK == n->type) { bufcat_su(h, "margin-left", &su); + SCALE_VS_INIT(&su, 1); + bufcat_su(h, "margin-top", &su); bufcat_style(h, "clear", "both"); PAIR_STYLE_INIT(&tag, h); print_otag(h, TAG_DIV, 1, &tag); @@ -667,4 +669,31 @@ man_ign_pre(MAN_ARGS) { return(0); +} + + +/* ARGSUSED */ +static int +man_RS_pre(MAN_ARGS) +{ + struct htmlpair tag; + struct roffsu su; + + if (MAN_HEAD == n->type) + return(0); + else if (MAN_BODY == n->type) + return(1); + + SCALE_HS_INIT(&su, INDENT); + bufcat_su(h, "margin-left", &su); + + if (n->head->child) { + SCALE_VS_INIT(&su, 1); + a2width(n->head->child, &su); + bufcat_su(h, "margin-top", &su); + } + + PAIR_STYLE_INIT(&tag, h); + print_otag(h, TAG_DIV, 1, &tag); + return(1); }