=================================================================== RCS file: /cvs/mandoc/mdoc_html.c,v retrieving revision 1.207 retrieving revision 1.212 diff -u -p -r1.207 -r1.212 --- mandoc/mdoc_html.c 2014/09/27 11:17:19 1.207 +++ mandoc/mdoc_html.c 2014/11/27 16:20:31 1.212 @@ -1,6 +1,6 @@ -/* $Id: mdoc_html.c,v 1.207 2014/09/27 11:17:19 kristaps Exp $ */ +/* $Id: mdoc_html.c,v 1.212 2014/11/27 16:20:31 schwarze Exp $ */ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2014 Kristaps Dzonsons + * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons * Copyright (c) 2014 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any @@ -56,7 +56,6 @@ static void synopsis_pre(struct html *, const struct mdoc_node *); static void a2width(const char *, struct roffsu *); -static void a2offs(const char *, struct roffsu *); static void mdoc_root_post(MDOC_ARGS); static int mdoc_root_pre(MDOC_ARGS); @@ -99,6 +98,7 @@ static int mdoc_mt_pre(MDOC_ARGS); static int mdoc_ms_pre(MDOC_ARGS); static int mdoc_nd_pre(MDOC_ARGS); static int mdoc_nm_pre(MDOC_ARGS); +static int mdoc_no_pre(MDOC_ARGS); static int mdoc_ns_pre(MDOC_ARGS); static int mdoc_pa_pre(MDOC_ARGS); static void mdoc_pf_post(MDOC_ARGS); @@ -183,7 +183,7 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = { {mdoc_quote_pre, mdoc_quote_post}, /* Bq */ {mdoc_xx_pre, NULL}, /* Bsx */ {mdoc_bx_pre, NULL}, /* Bx */ - {NULL, NULL}, /* Db */ + {mdoc_skip_pre, NULL}, /* Db */ {NULL, NULL}, /* Dc */ {mdoc_quote_pre, mdoc_quote_post}, /* Do */ {mdoc_quote_pre, mdoc_quote_post}, /* Dq */ @@ -193,7 +193,7 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = { {mdoc_quote_pre, mdoc_quote_post}, /* Eo */ {mdoc_xx_pre, NULL}, /* Fx */ {mdoc_ms_pre, NULL}, /* Ms */ - {mdoc_igndelim_pre, NULL}, /* No */ + {mdoc_no_pre, NULL}, /* No */ {mdoc_ns_pre, NULL}, /* Ns */ {mdoc_xx_pre, NULL}, /* Nx */ {mdoc_xx_pre, NULL}, /* Ox */ @@ -281,7 +281,7 @@ a2width(const char *p, struct roffsu *su) { if ( ! a2roffsu(p, su, SCALE_MAX)) { - su->unit = SCALE_BU; + su->unit = SCALE_EN; su->scale = html_strlen(p); } } @@ -328,28 +328,7 @@ synopsis_pre(struct html *h, const struct mdoc_node *n } } -/* - * Calculate the scaling unit passed in an `-offset' argument. This - * uses either a native scaling unit (e.g., 1i, 2m), one of a set of - * predefined strings (indent, etc.), or the string length of the value. - */ static void -a2offs(const char *p, struct roffsu *su) -{ - - /* FIXME: "right"? */ - - if (0 == strcmp(p, "left")) - SCALE_HS_INIT(su, 0); - else if (0 == strcmp(p, "indent")) - 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)) - SCALE_HS_INIT(su, html_strlen(p)); -} - -static void print_mdoc(MDOC_ARGS) { struct tag *t, *tt; @@ -994,7 +973,7 @@ mdoc_bl_pre(MDOC_ARGS) /* Set the block's left-hand margin. */ if (n->norm->Bl.offs) { - a2offs(n->norm->Bl.offs, &su); + a2width(n->norm->Bl.offs, &su); bufcat_su(h, "margin-left", &su); } @@ -1160,10 +1139,18 @@ mdoc_bd_pre(MDOC_ARGS) return(1); } - SCALE_HS_INIT(&su, 0); - if (n->norm->Bd.offs) - a2offs(n->norm->Bd.offs, &su); + /* Handle the -offset argument. */ + if (n->norm->Bd.offs == NULL || + ! strcmp(n->norm->Bd.offs, "left")) + SCALE_HS_INIT(&su, 0); + else if ( ! strcmp(n->norm->Bd.offs, "indent")) + SCALE_HS_INIT(&su, INDENT); + else if ( ! strcmp(n->norm->Bd.offs, "indent-two")) + SCALE_HS_INIT(&su, INDENT * 2); + else + a2width(n->norm->Bd.offs, &su); + bufinit(h); bufcat_su(h, "margin-left", &su); PAIR_STYLE_INIT(&tag[0], h); @@ -1898,6 +1885,16 @@ mdoc_rs_pre(MDOC_ARGS) } static int +mdoc_no_pre(MDOC_ARGS) +{ + struct htmlpair tag; + + PAIR_CLASS_INIT(&tag, "none"); + print_otag(h, TAG_CODE, 1, &tag); + return(1); +} + +static int mdoc_li_pre(MDOC_ARGS) { struct htmlpair tag; @@ -2078,7 +2075,8 @@ mdoc_quote_pre(MDOC_ARGS) case MDOC_Ao: /* FALLTHROUGH */ case MDOC_Aq: - print_text(h, "\\(la"); + print_text(h, n->parent->prev != NULL && + n->parent->prev->tok == MDOC_An ? "<" : "\\(la"); break; case MDOC_Bro: /* FALLTHROUGH */ @@ -2154,7 +2152,8 @@ mdoc_quote_post(MDOC_ARGS) case MDOC_Ao: /* FALLTHROUGH */ case MDOC_Aq: - print_text(h, "\\(ra"); + print_text(h, n->parent->prev != NULL && + n->parent->prev->tok == MDOC_An ? ">" : "\\(ra"); break; case MDOC_Bro: /* FALLTHROUGH */