=================================================================== RCS file: /cvs/mandoc/mdoc_html.c,v retrieving revision 1.188 retrieving revision 1.191 diff -u -p -r1.188 -r1.191 --- mandoc/mdoc_html.c 2014/04/20 16:46:05 1.188 +++ mandoc/mdoc_html.c 2014/07/02 03:48:07 1.191 @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.188 2014/04/20 16:46:05 schwarze Exp $ */ +/* $Id: mdoc_html.c,v 1.191 2014/07/02 03:48:07 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2014 Ingo Schwarze @@ -29,6 +29,7 @@ #include #include "mandoc.h" +#include "mandoc_aux.h" #include "out.h" #include "html.h" #include "mdoc.h" @@ -96,7 +97,6 @@ static int mdoc_it_pre(MDOC_ARGS); static int mdoc_lb_pre(MDOC_ARGS); static int mdoc_li_pre(MDOC_ARGS); static int mdoc_lk_pre(MDOC_ARGS); -static int mdoc_ll_pre(MDOC_ARGS); static int mdoc_mt_pre(MDOC_ARGS); static int mdoc_ms_pre(MDOC_ARGS); static int mdoc_nd_pre(MDOC_ARGS); @@ -110,6 +110,7 @@ static int mdoc_quote_pre(MDOC_ARGS); static int mdoc_rs_pre(MDOC_ARGS); static int mdoc_rv_pre(MDOC_ARGS); static int mdoc_sh_pre(MDOC_ARGS); +static int mdoc_skip_pre(MDOC_ARGS); static int mdoc_sm_pre(MDOC_ARGS); static int mdoc_sp_pre(MDOC_ARGS); static int mdoc_ss_pre(MDOC_ARGS); @@ -156,7 +157,7 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = { {mdoc_nd_pre, NULL}, /* Nd */ {mdoc_nm_pre, NULL}, /* Nm */ {mdoc_quote_pre, mdoc_quote_post}, /* Op */ - {NULL, NULL}, /* Ot */ + {mdoc_ft_pre, NULL}, /* Ot */ {mdoc_pa_pre, NULL}, /* Pa */ {mdoc_rv_pre, NULL}, /* Rv */ {NULL, NULL}, /* St */ @@ -226,7 +227,7 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = { {NULL, NULL}, /* Ek */ {mdoc_bt_pre, NULL}, /* Bt */ {NULL, NULL}, /* Hf */ - {NULL, NULL}, /* Fr */ + {mdoc_em_pre, NULL}, /* Fr */ {mdoc_ud_pre, NULL}, /* Ud */ {mdoc_lb_pre, NULL}, /* Lb */ {mdoc_pp_pre, NULL}, /* Lp */ @@ -236,15 +237,15 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = { {mdoc_quote_pre, mdoc_quote_post}, /* Bro */ {NULL, NULL}, /* Brc */ {mdoc__x_pre, mdoc__x_post}, /* %C */ - {NULL, NULL}, /* Es */ /* TODO */ - {NULL, NULL}, /* En */ /* TODO */ + {mdoc_skip_pre, NULL}, /* Es */ + {mdoc_quote_pre, mdoc_quote_post}, /* En */ {mdoc_xx_pre, NULL}, /* Dx */ {mdoc__x_pre, mdoc__x_post}, /* %Q */ {mdoc_sp_pre, NULL}, /* br */ {mdoc_sp_pre, NULL}, /* sp */ {mdoc__x_pre, mdoc__x_post}, /* %U */ {NULL, NULL}, /* Ta */ - {mdoc_ll_pre, NULL}, /* ll */ + {mdoc_skip_pre, NULL}, /* ll */ }; static const char * const lists[LIST_MAX] = { @@ -516,18 +517,16 @@ mdoc_root_pre(MDOC_ARGS) { struct htmlpair tag[3]; struct tag *t, *tt; - char b[BUFSIZ], title[BUFSIZ]; + char *volume, *title; - strlcpy(b, meta->vol, BUFSIZ); + if (NULL == meta->arch) + volume = mandoc_strdup(meta->vol); + else + mandoc_asprintf(&volume, "%s (%s)", + meta->vol, meta->arch); - if (meta->arch) { - strlcat(b, " (", BUFSIZ); - strlcat(b, meta->arch, BUFSIZ); - strlcat(b, ")", BUFSIZ); - } + mandoc_asprintf(&title, "%s(%s)", meta->title, meta->msec); - snprintf(title, BUFSIZ - 1, "%s(%s)", meta->title, meta->msec); - PAIR_SUMMARY_INIT(&tag[0], "Document Header"); PAIR_CLASS_INIT(&tag[1], "head"); PAIR_INIT(&tag[2], ATTR_WIDTH, "100%"); @@ -549,7 +548,7 @@ mdoc_root_pre(MDOC_ARGS) PAIR_CLASS_INIT(&tag[0], "head-vol"); PAIR_INIT(&tag[1], ATTR_ALIGN, "center"); print_otag(h, TAG_TD, 2, tag); - print_text(h, b); + print_text(h, volume); print_stagq(h, tt); PAIR_CLASS_INIT(&tag[0], "head-rtitle"); @@ -557,6 +556,9 @@ mdoc_root_pre(MDOC_ARGS) print_otag(h, TAG_TD, 2, tag); print_text(h, title); print_tagq(h, t); + + free(title); + free(volume); return(1); } @@ -989,8 +991,8 @@ mdoc_bl_pre(MDOC_ARGS) PAIR_STYLE_INIT(&tag[0], h); assert(lists[n->norm->Bl.type]); - strlcpy(buf, "list ", BUFSIZ); - strlcat(buf, lists[n->norm->Bl.type], BUFSIZ); + (void)strlcpy(buf, "list ", BUFSIZ); + (void)strlcat(buf, lists[n->norm->Bl.type], BUFSIZ); PAIR_INIT(&tag[1], ATTR_CLASS, buf); /* Set the block's left-hand margin. */ @@ -1359,6 +1361,15 @@ mdoc_fd_pre(MDOC_ARGS) if (NULL != (n = n->next)) { assert(MDOC_TEXT == n->type); + + /* + * XXX This is broken and not easy to fix. + * When using -Oincludes, truncation may occur. + * Dynamic allocation wouldn't help because + * passing long strings to buffmt_includes() + * does not work either. + */ + strlcpy(buf, '<' == *n->string || '"' == *n->string ? n->string + 1 : n->string, BUFSIZ); @@ -1471,10 +1482,8 @@ mdoc_fn_pre(MDOC_ARGS) t = print_otag(h, TAG_B, 1, tag); - if (sp) { - strlcpy(nbuf, sp, BUFSIZ); - print_text(h, nbuf); - } + if (sp) + print_text(h, sp); print_tagq(h, t); @@ -1536,7 +1545,7 @@ mdoc_sm_pre(MDOC_ARGS) } static int -mdoc_ll_pre(MDOC_ARGS) +mdoc_skip_pre(MDOC_ARGS) { return(0); @@ -2076,6 +2085,12 @@ mdoc_quote_pre(MDOC_ARGS) PAIR_CLASS_INIT(&tag, "opt"); print_otag(h, TAG_SPAN, 1, &tag); break; + case MDOC_En: + if (NULL == n->norm->Es || + NULL == n->norm->Es->child) + return(1); + print_text(h, n->norm->Es->child->string); + break; case MDOC_Eo: break; case MDOC_Do: @@ -2119,7 +2134,8 @@ mdoc_quote_post(MDOC_ARGS) if (MDOC_BODY != n->type) return; - h->flags |= HTML_NOSPACE; + if (MDOC_En != n->tok) + h->flags |= HTML_NOSPACE; switch (n->tok) { case MDOC_Ao: @@ -2140,6 +2156,14 @@ mdoc_quote_post(MDOC_ARGS) /* FALLTHROUGH */ case MDOC_Bq: print_text(h, "\\(rB"); + break; + case MDOC_En: + if (NULL != n->norm->Es && + NULL != n->norm->Es->child && + NULL != n->norm->Es->child->next) { + h->flags |= HTML_NOSPACE; + print_text(h, n->norm->Es->child->next->string); + } break; case MDOC_Eo: break;