=================================================================== RCS file: /cvs/mandoc/mdoc_html.c,v retrieving revision 1.168 retrieving revision 1.177 diff -u -p -r1.168 -r1.177 --- mandoc/mdoc_html.c 2011/05/17 11:34:31 1.168 +++ mandoc/mdoc_html.c 2011/08/18 09:16:01 1.177 @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.168 2011/05/17 11:34:31 kristaps Exp $ */ +/* $Id: mdoc_html.c,v 1.177 2011/08/18 09:16:01 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * @@ -34,7 +34,6 @@ #include "main.h" #define INDENT 5 -#define HALFINDENT 3 #define MDOC_ARGS const struct mdoc_meta *m, \ const struct mdoc_node *n, \ @@ -353,10 +352,8 @@ a2offs(const char *p, struct roffsu *su) SCALE_HS_INIT(su, INDENT); else if (0 == strcmp(p, "indent-two")) SCALE_HS_INIT(su, INDENT * 2); - else if ( ! a2roffsu(p, su, SCALE_MAX)) { - su->unit = SCALE_BU; - su->scale = html_strlen(p); - } + else if ( ! a2roffsu(p, su, SCALE_MAX)) + SCALE_HS_INIT(su, html_strlen(p)); } @@ -407,7 +404,6 @@ print_mdoc_node(MDOC_ARGS) { int child; struct tag *t; - struct htmlpair tag; child = 1; t = h->tags.head; @@ -434,9 +430,7 @@ print_mdoc_node(MDOC_ARGS) h->flags |= HTML_NOSPACE; return; case (MDOC_EQN): - PAIR_CLASS_INIT(&tag, "eqn"); - print_otag(h, TAG_SPAN, 1, &tag); - print_text(h, n->eqn->data); + print_eqn(h, n->eqn); break; case (MDOC_TBL): /* @@ -610,18 +604,23 @@ mdoc_sh_pre(MDOC_ARGS) return(1); bufinit(h); - for (n = n->child; n; n = n->next) { + bufcat(h, "x"); + + for (n = n->child; n && MDOC_TEXT == n->type; ) { bufcat_id(h, n->string); - if (n->next) + if (NULL != (n = n->next)) bufcat_id(h, " "); } - PAIR_ID_INIT(&tag, h->buf); - print_otag(h, TAG_H1, 1, &tag); + if (NULL == n) { + PAIR_ID_INIT(&tag, h->buf); + print_otag(h, TAG_H1, 1, &tag); + } else + print_otag(h, TAG_H1, 0, NULL); + return(1); } - /* ARGSUSED */ static int mdoc_ss_pre(MDOC_ARGS) @@ -636,14 +635,20 @@ mdoc_ss_pre(MDOC_ARGS) return(1); bufinit(h); - for (n = n->child; n; n = n->next) { + bufcat(h, "x"); + + for (n = n->child; n && MDOC_TEXT == n->type; ) { bufcat_id(h, n->string); - if (n->next) + if (NULL != (n = n->next)) bufcat_id(h, " "); } - PAIR_ID_INIT(&tag, h->buf); - print_otag(h, TAG_H2, 1, &tag); + if (NULL == n) { + PAIR_ID_INIT(&tag, h->buf); + print_otag(h, TAG_H2, 1, &tag); + } else + print_otag(h, TAG_H2, 0, NULL); + return(1); } @@ -1171,9 +1176,11 @@ mdoc_sx_pre(MDOC_ARGS) struct htmlpair tag[2]; bufinit(h); - for (n = n->child; n; n = n->next) { + bufcat(h, "#x"); + + for (n = n->child; n; ) { bufcat_id(h, n->string); - if (n->next) + if (NULL != (n = n->next)) bufcat_id(h, " "); } @@ -1632,8 +1639,9 @@ mdoc_sp_pre(MDOC_ARGS) SCALE_VS_INIT(&su, 1); if (MDOC_sp == n->tok) { - if (n->child) - a2roffsu(n->child->string, &su, SCALE_VS); + if (NULL != (n = n->child)) + if ( ! a2roffsu(n->string, &su, SCALE_VS)) + SCALE_VS_INIT(&su, atoi(n->string)); } else su.scale = 0; @@ -1665,11 +1673,12 @@ mdoc_lk_pre(MDOC_ARGS) print_otag(h, TAG_A, 2, tag); - for (n = n->next; n; n = n->next) { - assert(MDOC_TEXT == n->type); + if (NULL == n->next) print_text(h, n->string); - } + for (n = n->next; n; n = n->next) + print_text(h, n->string); + return(0); } @@ -1982,7 +1991,7 @@ mdoc_li_pre(MDOC_ARGS) struct htmlpair tag; PAIR_CLASS_INIT(&tag, "lit"); - print_otag(h, TAG_SPAN, 1, &tag); + print_otag(h, TAG_CODE, 1, &tag); return(1); }