=================================================================== RCS file: /cvs/mandoc/mdoc_html.c,v retrieving revision 1.237 retrieving revision 1.242 diff -u -p -r1.237 -r1.242 --- mandoc/mdoc_html.c 2015/10/06 18:32:19 1.237 +++ mandoc/mdoc_html.c 2017/01/09 12:48:58 1.242 @@ -1,7 +1,7 @@ -/* $Id: mdoc_html.c,v 1.237 2015/10/06 18:32:19 schwarze Exp $ */ +/* $Id: mdoc_html.c,v 1.242 2017/01/09 12:48:58 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons - * Copyright (c) 2014, 2015 Ingo Schwarze + * Copyright (c) 2014, 2015, 2016, 2017 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -299,13 +299,9 @@ synopsis_pre(struct html *h, const struct roff_node *n switch (n->prev->tok) { case MDOC_Fd: - /* FALLTHROUGH */ case MDOC_Fn: - /* FALLTHROUGH */ case MDOC_Fo: - /* FALLTHROUGH */ case MDOC_In: - /* FALLTHROUGH */ case MDOC_Vt: print_paragraph(h); break; @@ -546,7 +542,6 @@ mdoc_sh_pre(MDOC_ARGS) } bufinit(h); - bufcat(h, "x"); for (n = n->child; n != NULL && n->type == ROFFT_TEXT; ) { bufcat_id(h, n->string); @@ -576,7 +571,6 @@ mdoc_ss_pre(MDOC_ARGS) return 1; bufinit(h); - bufcat(h, "x"); for (n = n->child; n != NULL && n->type == ROFFT_TEXT; ) { bufcat_id(h, n->string); @@ -608,7 +602,7 @@ mdoc_fl_pre(MDOC_ARGS) print_text(h, "\\-"); - if ( ! (n->nchild == 0 && + if (!(n->child == NULL && (n->next == NULL || n->next->type == ROFFT_TEXT || n->next->flags & MDOC_LINE))) @@ -826,23 +820,15 @@ mdoc_it_pre(MDOC_ARGS) if (n->type == ROFFT_HEAD) { switch (type) { case LIST_bullet: - /* FALLTHROUGH */ case LIST_dash: - /* FALLTHROUGH */ case LIST_item: - /* FALLTHROUGH */ case LIST_hyphen: - /* FALLTHROUGH */ case LIST_enum: return 0; case LIST_diag: - /* FALLTHROUGH */ case LIST_hang: - /* FALLTHROUGH */ case LIST_inset: - /* FALLTHROUGH */ case LIST_ohang: - /* FALLTHROUGH */ case LIST_tag: SCALE_VS_INIT(&su, ! bl->norm->Bl.comp); bufcat_su(h, "margin-top", &su); @@ -861,13 +847,9 @@ mdoc_it_pre(MDOC_ARGS) } else if (n->type == ROFFT_BODY) { switch (type) { case LIST_bullet: - /* FALLTHROUGH */ case LIST_hyphen: - /* FALLTHROUGH */ case LIST_dash: - /* FALLTHROUGH */ case LIST_enum: - /* FALLTHROUGH */ case LIST_item: SCALE_VS_INIT(&su, ! bl->norm->Bl.comp); bufcat_su(h, "margin-top", &su); @@ -875,13 +857,9 @@ mdoc_it_pre(MDOC_ARGS) print_otag(h, TAG_LI, 2, tag); break; case LIST_diag: - /* FALLTHROUGH */ case LIST_hang: - /* FALLTHROUGH */ case LIST_inset: - /* FALLTHROUGH */ case LIST_ohang: - /* FALLTHROUGH */ case LIST_tag: if (NULL == bl->norm->Bl.width) { print_otag(h, TAG_DD, 1, tag); @@ -973,11 +951,8 @@ mdoc_bl_pre(MDOC_ARGS) switch (n->norm->Bl.type) { case LIST_bullet: - /* FALLTHROUGH */ case LIST_dash: - /* FALLTHROUGH */ case LIST_hyphen: - /* FALLTHROUGH */ case LIST_item: print_otag(h, TAG_UL, 2, tag); break; @@ -985,13 +960,9 @@ mdoc_bl_pre(MDOC_ARGS) print_otag(h, TAG_OL, 2, tag); break; case LIST_diag: - /* FALLTHROUGH */ case LIST_hang: - /* FALLTHROUGH */ case LIST_inset: - /* FALLTHROUGH */ case LIST_ohang: - /* FALLTHROUGH */ case LIST_tag: print_otag(h, TAG_DL, 2, tag); break; @@ -1008,9 +979,9 @@ mdoc_bl_pre(MDOC_ARGS) static int mdoc_ex_pre(MDOC_ARGS) { - struct tag *t; - struct htmlpair tag; - int nchild; + struct htmlpair tag; + struct tag *t; + struct roff_node *nch; if (n->prev) print_otag(h, TAG_BR, 0, NULL); @@ -1019,24 +990,26 @@ mdoc_ex_pre(MDOC_ARGS) print_text(h, "The"); - nchild = n->nchild; - for (n = n->child; n; n = n->next) { - assert(n->type == ROFFT_TEXT); + for (nch = n->child; nch != NULL; nch = nch->next) { + assert(nch->type == ROFFT_TEXT); t = print_otag(h, TAG_B, 1, &tag); - print_text(h, n->string); + print_text(h, nch->string); print_tagq(h, t); - if (nchild > 2 && n->next) { + if (nch->next == NULL) + continue; + + if (nch->prev != NULL || nch->next->next != NULL) { h->flags |= HTML_NOSPACE; print_text(h, ","); } - if (n->next && NULL == n->next->next) + if (nch->next->next == NULL) print_text(h, "and"); } - if (nchild > 1) + if (n->child != NULL && n->child->next != NULL) print_text(h, "utilities exit\\~0"); else print_text(h, "utility exits\\~0"); @@ -1090,7 +1063,7 @@ mdoc_sx_pre(MDOC_ARGS) struct htmlpair tag[2]; bufinit(h); - bufcat(h, "#x"); + bufcat(h, "#"); for (n = n->child; n; ) { bufcat_id(h, n->string); @@ -1148,15 +1121,15 @@ mdoc_bd_pre(MDOC_ARGS) bufcat_su(h, "margin-left", &su); PAIR_STYLE_INIT(&tag[0], h); - if (DISP_unfilled != n->norm->Bd.type && - DISP_literal != n->norm->Bd.type) { - PAIR_CLASS_INIT(&tag[1], "display"); - print_otag(h, TAG_DIV, 2, tag); + PAIR_CLASS_INIT(&tag[1], "display"); + print_otag(h, TAG_DIV, 2, tag); + + if (n->norm->Bd.type != DISP_unfilled && + n->norm->Bd.type != DISP_literal) return 1; - } - PAIR_CLASS_INIT(&tag[1], "lit display"); - print_otag(h, TAG_PRE, 2, tag); + PAIR_CLASS_INIT(&tag[0], "lit"); + print_otag(h, TAG_PRE, 1, tag); /* This can be recursive: save & set our literal state. */ @@ -1173,19 +1146,12 @@ mdoc_bd_pre(MDOC_ARGS) */ switch (nn->tok) { case MDOC_Sm: - /* FALLTHROUGH */ case MDOC_br: - /* FALLTHROUGH */ case MDOC_sp: - /* FALLTHROUGH */ case MDOC_Bl: - /* FALLTHROUGH */ case MDOC_D1: - /* FALLTHROUGH */ case MDOC_Dl: - /* FALLTHROUGH */ case MDOC_Lp: - /* FALLTHROUGH */ case MDOC_Pp: continue; default: @@ -1731,37 +1697,36 @@ mdoc_rv_pre(MDOC_ARGS) { struct htmlpair tag; struct tag *t; - int nchild; + struct roff_node *nch; if (n->prev) print_otag(h, TAG_BR, 0, NULL); PAIR_CLASS_INIT(&tag, "fname"); - nchild = n->nchild; - if (nchild > 0) { + if (n->child != NULL) { print_text(h, "The"); - for (n = n->child; n; n = n->next) { + for (nch = n->child; nch != NULL; nch = nch->next) { t = print_otag(h, TAG_B, 1, &tag); - print_text(h, n->string); + print_text(h, nch->string); print_tagq(h, t); h->flags |= HTML_NOSPACE; print_text(h, "()"); - if (n->next == NULL) + if (nch->next == NULL) continue; - if (nchild > 2) { + if (nch->prev != NULL || nch->next->next != NULL) { h->flags |= HTML_NOSPACE; print_text(h, ","); } - if (n->next->next == NULL) + if (nch->next->next == NULL) print_text(h, "and"); } - if (nchild > 1) + if (n->child != NULL && n->child->next != NULL) print_text(h, "functions return"); else print_text(h, "function returns"); @@ -1884,7 +1849,7 @@ mdoc_no_pre(MDOC_ARGS) struct htmlpair tag; PAIR_CLASS_INIT(&tag, "none"); - print_otag(h, TAG_CODE, 1, &tag); + print_otag(h, TAG_SPAN, 1, &tag); return 1; } @@ -2037,7 +2002,7 @@ mdoc_bk_pre(MDOC_ARGS) case ROFFT_HEAD: return 0; case ROFFT_BODY: - if (n->parent->args || 0 == n->prev->nchild) + if (n->parent->args != NULL || n->prev->child == NULL) h->flags |= HTML_PREKEEP; break; default: @@ -2065,23 +2030,19 @@ mdoc_quote_pre(MDOC_ARGS) switch (n->tok) { case MDOC_Ao: - /* FALLTHROUGH */ case MDOC_Aq: - print_text(h, n->nchild == 1 && + print_text(h, n->child != NULL && n->child->next == NULL && n->child->tok == MDOC_Mt ? "<" : "\\(la"); break; case MDOC_Bro: - /* FALLTHROUGH */ case MDOC_Brq: print_text(h, "\\(lC"); break; case MDOC_Bo: - /* FALLTHROUGH */ case MDOC_Bq: print_text(h, "\\(lB"); break; case MDOC_Oo: - /* FALLTHROUGH */ case MDOC_Op: print_text(h, "\\(lB"); h->flags |= HTML_NOSPACE; @@ -2095,16 +2056,12 @@ mdoc_quote_pre(MDOC_ARGS) print_text(h, n->norm->Es->child->string); break; case MDOC_Do: - /* FALLTHROUGH */ case MDOC_Dq: - /* FALLTHROUGH */ case MDOC_Qo: - /* FALLTHROUGH */ case MDOC_Qq: print_text(h, "\\(lq"); break; case MDOC_Po: - /* FALLTHROUGH */ case MDOC_Pq: print_text(h, "("); break; @@ -2115,7 +2072,6 @@ mdoc_quote_pre(MDOC_ARGS) print_otag(h, TAG_CODE, 1, &tag); break; case MDOC_So: - /* FALLTHROUGH */ case MDOC_Sq: print_text(h, "\\(oq"); break; @@ -2138,22 +2094,17 @@ mdoc_quote_post(MDOC_ARGS) switch (n->tok) { case MDOC_Ao: - /* FALLTHROUGH */ case MDOC_Aq: - print_text(h, n->nchild == 1 && + print_text(h, n->child != NULL && n->child->next == NULL && n->child->tok == MDOC_Mt ? ">" : "\\(ra"); break; case MDOC_Bro: - /* FALLTHROUGH */ case MDOC_Brq: print_text(h, "\\(rC"); break; case MDOC_Oo: - /* FALLTHROUGH */ case MDOC_Op: - /* FALLTHROUGH */ case MDOC_Bo: - /* FALLTHROUGH */ case MDOC_Bq: print_text(h, "\\(rB"); break; @@ -2166,23 +2117,17 @@ mdoc_quote_post(MDOC_ARGS) print_text(h, n->norm->Es->child->next->string); break; case MDOC_Qo: - /* FALLTHROUGH */ case MDOC_Qq: - /* FALLTHROUGH */ case MDOC_Do: - /* FALLTHROUGH */ case MDOC_Dq: print_text(h, "\\(rq"); break; case MDOC_Po: - /* FALLTHROUGH */ case MDOC_Pq: print_text(h, ")"); break; case MDOC_Ql: - /* FALLTHROUGH */ case MDOC_So: - /* FALLTHROUGH */ case MDOC_Sq: print_text(h, "\\(cq"); break;