1*95c635efSGarrett D'Amore /* $Id: mdoc_html.c,v 1.182 2011/11/03 20:37:00 schwarze Exp $ */ 2*95c635efSGarrett D'Amore /* 3*95c635efSGarrett D'Amore * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> 4*95c635efSGarrett D'Amore * 5*95c635efSGarrett D'Amore * Permission to use, copy, modify, and distribute this software for any 6*95c635efSGarrett D'Amore * purpose with or without fee is hereby granted, provided that the above 7*95c635efSGarrett D'Amore * copyright notice and this permission notice appear in all copies. 8*95c635efSGarrett D'Amore * 9*95c635efSGarrett D'Amore * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10*95c635efSGarrett D'Amore * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11*95c635efSGarrett D'Amore * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12*95c635efSGarrett D'Amore * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13*95c635efSGarrett D'Amore * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14*95c635efSGarrett D'Amore * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15*95c635efSGarrett D'Amore * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16*95c635efSGarrett D'Amore */ 17*95c635efSGarrett D'Amore #ifdef HAVE_CONFIG_H 18*95c635efSGarrett D'Amore #include "config.h" 19*95c635efSGarrett D'Amore #endif 20*95c635efSGarrett D'Amore 21*95c635efSGarrett D'Amore #include <sys/types.h> 22*95c635efSGarrett D'Amore 23*95c635efSGarrett D'Amore #include <assert.h> 24*95c635efSGarrett D'Amore #include <ctype.h> 25*95c635efSGarrett D'Amore #include <stdio.h> 26*95c635efSGarrett D'Amore #include <stdlib.h> 27*95c635efSGarrett D'Amore #include <string.h> 28*95c635efSGarrett D'Amore #include <unistd.h> 29*95c635efSGarrett D'Amore 30*95c635efSGarrett D'Amore #include "mandoc.h" 31*95c635efSGarrett D'Amore #include "out.h" 32*95c635efSGarrett D'Amore #include "html.h" 33*95c635efSGarrett D'Amore #include "mdoc.h" 34*95c635efSGarrett D'Amore #include "main.h" 35*95c635efSGarrett D'Amore 36*95c635efSGarrett D'Amore #define INDENT 5 37*95c635efSGarrett D'Amore 38*95c635efSGarrett D'Amore #define MDOC_ARGS const struct mdoc_meta *m, \ 39*95c635efSGarrett D'Amore const struct mdoc_node *n, \ 40*95c635efSGarrett D'Amore struct html *h 41*95c635efSGarrett D'Amore 42*95c635efSGarrett D'Amore #ifndef MIN 43*95c635efSGarrett D'Amore #define MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b)) 44*95c635efSGarrett D'Amore #endif 45*95c635efSGarrett D'Amore 46*95c635efSGarrett D'Amore struct htmlmdoc { 47*95c635efSGarrett D'Amore int (*pre)(MDOC_ARGS); 48*95c635efSGarrett D'Amore void (*post)(MDOC_ARGS); 49*95c635efSGarrett D'Amore }; 50*95c635efSGarrett D'Amore 51*95c635efSGarrett D'Amore static void print_mdoc(MDOC_ARGS); 52*95c635efSGarrett D'Amore static void print_mdoc_head(MDOC_ARGS); 53*95c635efSGarrett D'Amore static void print_mdoc_node(MDOC_ARGS); 54*95c635efSGarrett D'Amore static void print_mdoc_nodelist(MDOC_ARGS); 55*95c635efSGarrett D'Amore static void synopsis_pre(struct html *, 56*95c635efSGarrett D'Amore const struct mdoc_node *); 57*95c635efSGarrett D'Amore 58*95c635efSGarrett D'Amore static void a2width(const char *, struct roffsu *); 59*95c635efSGarrett D'Amore static void a2offs(const char *, struct roffsu *); 60*95c635efSGarrett D'Amore 61*95c635efSGarrett D'Amore static void mdoc_root_post(MDOC_ARGS); 62*95c635efSGarrett D'Amore static int mdoc_root_pre(MDOC_ARGS); 63*95c635efSGarrett D'Amore 64*95c635efSGarrett D'Amore static void mdoc__x_post(MDOC_ARGS); 65*95c635efSGarrett D'Amore static int mdoc__x_pre(MDOC_ARGS); 66*95c635efSGarrett D'Amore static int mdoc_ad_pre(MDOC_ARGS); 67*95c635efSGarrett D'Amore static int mdoc_an_pre(MDOC_ARGS); 68*95c635efSGarrett D'Amore static int mdoc_ap_pre(MDOC_ARGS); 69*95c635efSGarrett D'Amore static int mdoc_ar_pre(MDOC_ARGS); 70*95c635efSGarrett D'Amore static int mdoc_bd_pre(MDOC_ARGS); 71*95c635efSGarrett D'Amore static int mdoc_bf_pre(MDOC_ARGS); 72*95c635efSGarrett D'Amore static void mdoc_bk_post(MDOC_ARGS); 73*95c635efSGarrett D'Amore static int mdoc_bk_pre(MDOC_ARGS); 74*95c635efSGarrett D'Amore static int mdoc_bl_pre(MDOC_ARGS); 75*95c635efSGarrett D'Amore static int mdoc_bt_pre(MDOC_ARGS); 76*95c635efSGarrett D'Amore static int mdoc_bx_pre(MDOC_ARGS); 77*95c635efSGarrett D'Amore static int mdoc_cd_pre(MDOC_ARGS); 78*95c635efSGarrett D'Amore static int mdoc_d1_pre(MDOC_ARGS); 79*95c635efSGarrett D'Amore static int mdoc_dv_pre(MDOC_ARGS); 80*95c635efSGarrett D'Amore static int mdoc_fa_pre(MDOC_ARGS); 81*95c635efSGarrett D'Amore static int mdoc_fd_pre(MDOC_ARGS); 82*95c635efSGarrett D'Amore static int mdoc_fl_pre(MDOC_ARGS); 83*95c635efSGarrett D'Amore static int mdoc_fn_pre(MDOC_ARGS); 84*95c635efSGarrett D'Amore static int mdoc_ft_pre(MDOC_ARGS); 85*95c635efSGarrett D'Amore static int mdoc_em_pre(MDOC_ARGS); 86*95c635efSGarrett D'Amore static int mdoc_er_pre(MDOC_ARGS); 87*95c635efSGarrett D'Amore static int mdoc_ev_pre(MDOC_ARGS); 88*95c635efSGarrett D'Amore static int mdoc_ex_pre(MDOC_ARGS); 89*95c635efSGarrett D'Amore static void mdoc_fo_post(MDOC_ARGS); 90*95c635efSGarrett D'Amore static int mdoc_fo_pre(MDOC_ARGS); 91*95c635efSGarrett D'Amore static int mdoc_ic_pre(MDOC_ARGS); 92*95c635efSGarrett D'Amore static int mdoc_igndelim_pre(MDOC_ARGS); 93*95c635efSGarrett D'Amore static int mdoc_in_pre(MDOC_ARGS); 94*95c635efSGarrett D'Amore static int mdoc_it_pre(MDOC_ARGS); 95*95c635efSGarrett D'Amore static int mdoc_lb_pre(MDOC_ARGS); 96*95c635efSGarrett D'Amore static int mdoc_li_pre(MDOC_ARGS); 97*95c635efSGarrett D'Amore static int mdoc_lk_pre(MDOC_ARGS); 98*95c635efSGarrett D'Amore static int mdoc_mt_pre(MDOC_ARGS); 99*95c635efSGarrett D'Amore static int mdoc_ms_pre(MDOC_ARGS); 100*95c635efSGarrett D'Amore static int mdoc_nd_pre(MDOC_ARGS); 101*95c635efSGarrett D'Amore static int mdoc_nm_pre(MDOC_ARGS); 102*95c635efSGarrett D'Amore static int mdoc_ns_pre(MDOC_ARGS); 103*95c635efSGarrett D'Amore static int mdoc_pa_pre(MDOC_ARGS); 104*95c635efSGarrett D'Amore static void mdoc_pf_post(MDOC_ARGS); 105*95c635efSGarrett D'Amore static int mdoc_pp_pre(MDOC_ARGS); 106*95c635efSGarrett D'Amore static void mdoc_quote_post(MDOC_ARGS); 107*95c635efSGarrett D'Amore static int mdoc_quote_pre(MDOC_ARGS); 108*95c635efSGarrett D'Amore static int mdoc_rs_pre(MDOC_ARGS); 109*95c635efSGarrett D'Amore static int mdoc_rv_pre(MDOC_ARGS); 110*95c635efSGarrett D'Amore static int mdoc_sh_pre(MDOC_ARGS); 111*95c635efSGarrett D'Amore static int mdoc_sm_pre(MDOC_ARGS); 112*95c635efSGarrett D'Amore static int mdoc_sp_pre(MDOC_ARGS); 113*95c635efSGarrett D'Amore static int mdoc_ss_pre(MDOC_ARGS); 114*95c635efSGarrett D'Amore static int mdoc_sx_pre(MDOC_ARGS); 115*95c635efSGarrett D'Amore static int mdoc_sy_pre(MDOC_ARGS); 116*95c635efSGarrett D'Amore static int mdoc_ud_pre(MDOC_ARGS); 117*95c635efSGarrett D'Amore static int mdoc_va_pre(MDOC_ARGS); 118*95c635efSGarrett D'Amore static int mdoc_vt_pre(MDOC_ARGS); 119*95c635efSGarrett D'Amore static int mdoc_xr_pre(MDOC_ARGS); 120*95c635efSGarrett D'Amore static int mdoc_xx_pre(MDOC_ARGS); 121*95c635efSGarrett D'Amore 122*95c635efSGarrett D'Amore static const struct htmlmdoc mdocs[MDOC_MAX] = { 123*95c635efSGarrett D'Amore {mdoc_ap_pre, NULL}, /* Ap */ 124*95c635efSGarrett D'Amore {NULL, NULL}, /* Dd */ 125*95c635efSGarrett D'Amore {NULL, NULL}, /* Dt */ 126*95c635efSGarrett D'Amore {NULL, NULL}, /* Os */ 127*95c635efSGarrett D'Amore {mdoc_sh_pre, NULL }, /* Sh */ 128*95c635efSGarrett D'Amore {mdoc_ss_pre, NULL }, /* Ss */ 129*95c635efSGarrett D'Amore {mdoc_pp_pre, NULL}, /* Pp */ 130*95c635efSGarrett D'Amore {mdoc_d1_pre, NULL}, /* D1 */ 131*95c635efSGarrett D'Amore {mdoc_d1_pre, NULL}, /* Dl */ 132*95c635efSGarrett D'Amore {mdoc_bd_pre, NULL}, /* Bd */ 133*95c635efSGarrett D'Amore {NULL, NULL}, /* Ed */ 134*95c635efSGarrett D'Amore {mdoc_bl_pre, NULL}, /* Bl */ 135*95c635efSGarrett D'Amore {NULL, NULL}, /* El */ 136*95c635efSGarrett D'Amore {mdoc_it_pre, NULL}, /* It */ 137*95c635efSGarrett D'Amore {mdoc_ad_pre, NULL}, /* Ad */ 138*95c635efSGarrett D'Amore {mdoc_an_pre, NULL}, /* An */ 139*95c635efSGarrett D'Amore {mdoc_ar_pre, NULL}, /* Ar */ 140*95c635efSGarrett D'Amore {mdoc_cd_pre, NULL}, /* Cd */ 141*95c635efSGarrett D'Amore {mdoc_fl_pre, NULL}, /* Cm */ 142*95c635efSGarrett D'Amore {mdoc_dv_pre, NULL}, /* Dv */ 143*95c635efSGarrett D'Amore {mdoc_er_pre, NULL}, /* Er */ 144*95c635efSGarrett D'Amore {mdoc_ev_pre, NULL}, /* Ev */ 145*95c635efSGarrett D'Amore {mdoc_ex_pre, NULL}, /* Ex */ 146*95c635efSGarrett D'Amore {mdoc_fa_pre, NULL}, /* Fa */ 147*95c635efSGarrett D'Amore {mdoc_fd_pre, NULL}, /* Fd */ 148*95c635efSGarrett D'Amore {mdoc_fl_pre, NULL}, /* Fl */ 149*95c635efSGarrett D'Amore {mdoc_fn_pre, NULL}, /* Fn */ 150*95c635efSGarrett D'Amore {mdoc_ft_pre, NULL}, /* Ft */ 151*95c635efSGarrett D'Amore {mdoc_ic_pre, NULL}, /* Ic */ 152*95c635efSGarrett D'Amore {mdoc_in_pre, NULL}, /* In */ 153*95c635efSGarrett D'Amore {mdoc_li_pre, NULL}, /* Li */ 154*95c635efSGarrett D'Amore {mdoc_nd_pre, NULL}, /* Nd */ 155*95c635efSGarrett D'Amore {mdoc_nm_pre, NULL}, /* Nm */ 156*95c635efSGarrett D'Amore {mdoc_quote_pre, mdoc_quote_post}, /* Op */ 157*95c635efSGarrett D'Amore {NULL, NULL}, /* Ot */ 158*95c635efSGarrett D'Amore {mdoc_pa_pre, NULL}, /* Pa */ 159*95c635efSGarrett D'Amore {mdoc_rv_pre, NULL}, /* Rv */ 160*95c635efSGarrett D'Amore {NULL, NULL}, /* St */ 161*95c635efSGarrett D'Amore {mdoc_va_pre, NULL}, /* Va */ 162*95c635efSGarrett D'Amore {mdoc_vt_pre, NULL}, /* Vt */ 163*95c635efSGarrett D'Amore {mdoc_xr_pre, NULL}, /* Xr */ 164*95c635efSGarrett D'Amore {mdoc__x_pre, mdoc__x_post}, /* %A */ 165*95c635efSGarrett D'Amore {mdoc__x_pre, mdoc__x_post}, /* %B */ 166*95c635efSGarrett D'Amore {mdoc__x_pre, mdoc__x_post}, /* %D */ 167*95c635efSGarrett D'Amore {mdoc__x_pre, mdoc__x_post}, /* %I */ 168*95c635efSGarrett D'Amore {mdoc__x_pre, mdoc__x_post}, /* %J */ 169*95c635efSGarrett D'Amore {mdoc__x_pre, mdoc__x_post}, /* %N */ 170*95c635efSGarrett D'Amore {mdoc__x_pre, mdoc__x_post}, /* %O */ 171*95c635efSGarrett D'Amore {mdoc__x_pre, mdoc__x_post}, /* %P */ 172*95c635efSGarrett D'Amore {mdoc__x_pre, mdoc__x_post}, /* %R */ 173*95c635efSGarrett D'Amore {mdoc__x_pre, mdoc__x_post}, /* %T */ 174*95c635efSGarrett D'Amore {mdoc__x_pre, mdoc__x_post}, /* %V */ 175*95c635efSGarrett D'Amore {NULL, NULL}, /* Ac */ 176*95c635efSGarrett D'Amore {mdoc_quote_pre, mdoc_quote_post}, /* Ao */ 177*95c635efSGarrett D'Amore {mdoc_quote_pre, mdoc_quote_post}, /* Aq */ 178*95c635efSGarrett D'Amore {NULL, NULL}, /* At */ 179*95c635efSGarrett D'Amore {NULL, NULL}, /* Bc */ 180*95c635efSGarrett D'Amore {mdoc_bf_pre, NULL}, /* Bf */ 181*95c635efSGarrett D'Amore {mdoc_quote_pre, mdoc_quote_post}, /* Bo */ 182*95c635efSGarrett D'Amore {mdoc_quote_pre, mdoc_quote_post}, /* Bq */ 183*95c635efSGarrett D'Amore {mdoc_xx_pre, NULL}, /* Bsx */ 184*95c635efSGarrett D'Amore {mdoc_bx_pre, NULL}, /* Bx */ 185*95c635efSGarrett D'Amore {NULL, NULL}, /* Db */ 186*95c635efSGarrett D'Amore {NULL, NULL}, /* Dc */ 187*95c635efSGarrett D'Amore {mdoc_quote_pre, mdoc_quote_post}, /* Do */ 188*95c635efSGarrett D'Amore {mdoc_quote_pre, mdoc_quote_post}, /* Dq */ 189*95c635efSGarrett D'Amore {NULL, NULL}, /* Ec */ /* FIXME: no space */ 190*95c635efSGarrett D'Amore {NULL, NULL}, /* Ef */ 191*95c635efSGarrett D'Amore {mdoc_em_pre, NULL}, /* Em */ 192*95c635efSGarrett D'Amore {mdoc_quote_pre, mdoc_quote_post}, /* Eo */ 193*95c635efSGarrett D'Amore {mdoc_xx_pre, NULL}, /* Fx */ 194*95c635efSGarrett D'Amore {mdoc_ms_pre, NULL}, /* Ms */ 195*95c635efSGarrett D'Amore {mdoc_igndelim_pre, NULL}, /* No */ 196*95c635efSGarrett D'Amore {mdoc_ns_pre, NULL}, /* Ns */ 197*95c635efSGarrett D'Amore {mdoc_xx_pre, NULL}, /* Nx */ 198*95c635efSGarrett D'Amore {mdoc_xx_pre, NULL}, /* Ox */ 199*95c635efSGarrett D'Amore {NULL, NULL}, /* Pc */ 200*95c635efSGarrett D'Amore {mdoc_igndelim_pre, mdoc_pf_post}, /* Pf */ 201*95c635efSGarrett D'Amore {mdoc_quote_pre, mdoc_quote_post}, /* Po */ 202*95c635efSGarrett D'Amore {mdoc_quote_pre, mdoc_quote_post}, /* Pq */ 203*95c635efSGarrett D'Amore {NULL, NULL}, /* Qc */ 204*95c635efSGarrett D'Amore {mdoc_quote_pre, mdoc_quote_post}, /* Ql */ 205*95c635efSGarrett D'Amore {mdoc_quote_pre, mdoc_quote_post}, /* Qo */ 206*95c635efSGarrett D'Amore {mdoc_quote_pre, mdoc_quote_post}, /* Qq */ 207*95c635efSGarrett D'Amore {NULL, NULL}, /* Re */ 208*95c635efSGarrett D'Amore {mdoc_rs_pre, NULL}, /* Rs */ 209*95c635efSGarrett D'Amore {NULL, NULL}, /* Sc */ 210*95c635efSGarrett D'Amore {mdoc_quote_pre, mdoc_quote_post}, /* So */ 211*95c635efSGarrett D'Amore {mdoc_quote_pre, mdoc_quote_post}, /* Sq */ 212*95c635efSGarrett D'Amore {mdoc_sm_pre, NULL}, /* Sm */ 213*95c635efSGarrett D'Amore {mdoc_sx_pre, NULL}, /* Sx */ 214*95c635efSGarrett D'Amore {mdoc_sy_pre, NULL}, /* Sy */ 215*95c635efSGarrett D'Amore {NULL, NULL}, /* Tn */ 216*95c635efSGarrett D'Amore {mdoc_xx_pre, NULL}, /* Ux */ 217*95c635efSGarrett D'Amore {NULL, NULL}, /* Xc */ 218*95c635efSGarrett D'Amore {NULL, NULL}, /* Xo */ 219*95c635efSGarrett D'Amore {mdoc_fo_pre, mdoc_fo_post}, /* Fo */ 220*95c635efSGarrett D'Amore {NULL, NULL}, /* Fc */ 221*95c635efSGarrett D'Amore {mdoc_quote_pre, mdoc_quote_post}, /* Oo */ 222*95c635efSGarrett D'Amore {NULL, NULL}, /* Oc */ 223*95c635efSGarrett D'Amore {mdoc_bk_pre, mdoc_bk_post}, /* Bk */ 224*95c635efSGarrett D'Amore {NULL, NULL}, /* Ek */ 225*95c635efSGarrett D'Amore {mdoc_bt_pre, NULL}, /* Bt */ 226*95c635efSGarrett D'Amore {NULL, NULL}, /* Hf */ 227*95c635efSGarrett D'Amore {NULL, NULL}, /* Fr */ 228*95c635efSGarrett D'Amore {mdoc_ud_pre, NULL}, /* Ud */ 229*95c635efSGarrett D'Amore {mdoc_lb_pre, NULL}, /* Lb */ 230*95c635efSGarrett D'Amore {mdoc_pp_pre, NULL}, /* Lp */ 231*95c635efSGarrett D'Amore {mdoc_lk_pre, NULL}, /* Lk */ 232*95c635efSGarrett D'Amore {mdoc_mt_pre, NULL}, /* Mt */ 233*95c635efSGarrett D'Amore {mdoc_quote_pre, mdoc_quote_post}, /* Brq */ 234*95c635efSGarrett D'Amore {mdoc_quote_pre, mdoc_quote_post}, /* Bro */ 235*95c635efSGarrett D'Amore {NULL, NULL}, /* Brc */ 236*95c635efSGarrett D'Amore {mdoc__x_pre, mdoc__x_post}, /* %C */ 237*95c635efSGarrett D'Amore {NULL, NULL}, /* Es */ /* TODO */ 238*95c635efSGarrett D'Amore {NULL, NULL}, /* En */ /* TODO */ 239*95c635efSGarrett D'Amore {mdoc_xx_pre, NULL}, /* Dx */ 240*95c635efSGarrett D'Amore {mdoc__x_pre, mdoc__x_post}, /* %Q */ 241*95c635efSGarrett D'Amore {mdoc_sp_pre, NULL}, /* br */ 242*95c635efSGarrett D'Amore {mdoc_sp_pre, NULL}, /* sp */ 243*95c635efSGarrett D'Amore {mdoc__x_pre, mdoc__x_post}, /* %U */ 244*95c635efSGarrett D'Amore {NULL, NULL}, /* Ta */ 245*95c635efSGarrett D'Amore }; 246*95c635efSGarrett D'Amore 247*95c635efSGarrett D'Amore static const char * const lists[LIST_MAX] = { 248*95c635efSGarrett D'Amore NULL, 249*95c635efSGarrett D'Amore "list-bul", 250*95c635efSGarrett D'Amore "list-col", 251*95c635efSGarrett D'Amore "list-dash", 252*95c635efSGarrett D'Amore "list-diag", 253*95c635efSGarrett D'Amore "list-enum", 254*95c635efSGarrett D'Amore "list-hang", 255*95c635efSGarrett D'Amore "list-hyph", 256*95c635efSGarrett D'Amore "list-inset", 257*95c635efSGarrett D'Amore "list-item", 258*95c635efSGarrett D'Amore "list-ohang", 259*95c635efSGarrett D'Amore "list-tag" 260*95c635efSGarrett D'Amore }; 261*95c635efSGarrett D'Amore 262*95c635efSGarrett D'Amore void 263*95c635efSGarrett D'Amore html_mdoc(void *arg, const struct mdoc *m) 264*95c635efSGarrett D'Amore { 265*95c635efSGarrett D'Amore 266*95c635efSGarrett D'Amore print_mdoc(mdoc_meta(m), mdoc_node(m), (struct html *)arg); 267*95c635efSGarrett D'Amore putchar('\n'); 268*95c635efSGarrett D'Amore } 269*95c635efSGarrett D'Amore 270*95c635efSGarrett D'Amore 271*95c635efSGarrett D'Amore /* 272*95c635efSGarrett D'Amore * Calculate the scaling unit passed in a `-width' argument. This uses 273*95c635efSGarrett D'Amore * either a native scaling unit (e.g., 1i, 2m) or the string length of 274*95c635efSGarrett D'Amore * the value. 275*95c635efSGarrett D'Amore */ 276*95c635efSGarrett D'Amore static void 277*95c635efSGarrett D'Amore a2width(const char *p, struct roffsu *su) 278*95c635efSGarrett D'Amore { 279*95c635efSGarrett D'Amore 280*95c635efSGarrett D'Amore if ( ! a2roffsu(p, su, SCALE_MAX)) { 281*95c635efSGarrett D'Amore su->unit = SCALE_BU; 282*95c635efSGarrett D'Amore su->scale = html_strlen(p); 283*95c635efSGarrett D'Amore } 284*95c635efSGarrett D'Amore } 285*95c635efSGarrett D'Amore 286*95c635efSGarrett D'Amore 287*95c635efSGarrett D'Amore /* 288*95c635efSGarrett D'Amore * See the same function in mdoc_term.c for documentation. 289*95c635efSGarrett D'Amore */ 290*95c635efSGarrett D'Amore static void 291*95c635efSGarrett D'Amore synopsis_pre(struct html *h, const struct mdoc_node *n) 292*95c635efSGarrett D'Amore { 293*95c635efSGarrett D'Amore 294*95c635efSGarrett D'Amore if (NULL == n->prev || ! (MDOC_SYNPRETTY & n->flags)) 295*95c635efSGarrett D'Amore return; 296*95c635efSGarrett D'Amore 297*95c635efSGarrett D'Amore if (n->prev->tok == n->tok && 298*95c635efSGarrett D'Amore MDOC_Fo != n->tok && 299*95c635efSGarrett D'Amore MDOC_Ft != n->tok && 300*95c635efSGarrett D'Amore MDOC_Fn != n->tok) { 301*95c635efSGarrett D'Amore print_otag(h, TAG_BR, 0, NULL); 302*95c635efSGarrett D'Amore return; 303*95c635efSGarrett D'Amore } 304*95c635efSGarrett D'Amore 305*95c635efSGarrett D'Amore switch (n->prev->tok) { 306*95c635efSGarrett D'Amore case (MDOC_Fd): 307*95c635efSGarrett D'Amore /* FALLTHROUGH */ 308*95c635efSGarrett D'Amore case (MDOC_Fn): 309*95c635efSGarrett D'Amore /* FALLTHROUGH */ 310*95c635efSGarrett D'Amore case (MDOC_Fo): 311*95c635efSGarrett D'Amore /* FALLTHROUGH */ 312*95c635efSGarrett D'Amore case (MDOC_In): 313*95c635efSGarrett D'Amore /* FALLTHROUGH */ 314*95c635efSGarrett D'Amore case (MDOC_Vt): 315*95c635efSGarrett D'Amore print_otag(h, TAG_P, 0, NULL); 316*95c635efSGarrett D'Amore break; 317*95c635efSGarrett D'Amore case (MDOC_Ft): 318*95c635efSGarrett D'Amore if (MDOC_Fn != n->tok && MDOC_Fo != n->tok) { 319*95c635efSGarrett D'Amore print_otag(h, TAG_P, 0, NULL); 320*95c635efSGarrett D'Amore break; 321*95c635efSGarrett D'Amore } 322*95c635efSGarrett D'Amore /* FALLTHROUGH */ 323*95c635efSGarrett D'Amore default: 324*95c635efSGarrett D'Amore print_otag(h, TAG_BR, 0, NULL); 325*95c635efSGarrett D'Amore break; 326*95c635efSGarrett D'Amore } 327*95c635efSGarrett D'Amore } 328*95c635efSGarrett D'Amore 329*95c635efSGarrett D'Amore 330*95c635efSGarrett D'Amore /* 331*95c635efSGarrett D'Amore * Calculate the scaling unit passed in an `-offset' argument. This 332*95c635efSGarrett D'Amore * uses either a native scaling unit (e.g., 1i, 2m), one of a set of 333*95c635efSGarrett D'Amore * predefined strings (indent, etc.), or the string length of the value. 334*95c635efSGarrett D'Amore */ 335*95c635efSGarrett D'Amore static void 336*95c635efSGarrett D'Amore a2offs(const char *p, struct roffsu *su) 337*95c635efSGarrett D'Amore { 338*95c635efSGarrett D'Amore 339*95c635efSGarrett D'Amore /* FIXME: "right"? */ 340*95c635efSGarrett D'Amore 341*95c635efSGarrett D'Amore if (0 == strcmp(p, "left")) 342*95c635efSGarrett D'Amore SCALE_HS_INIT(su, 0); 343*95c635efSGarrett D'Amore else if (0 == strcmp(p, "indent")) 344*95c635efSGarrett D'Amore SCALE_HS_INIT(su, INDENT); 345*95c635efSGarrett D'Amore else if (0 == strcmp(p, "indent-two")) 346*95c635efSGarrett D'Amore SCALE_HS_INIT(su, INDENT * 2); 347*95c635efSGarrett D'Amore else if ( ! a2roffsu(p, su, SCALE_MAX)) 348*95c635efSGarrett D'Amore SCALE_HS_INIT(su, html_strlen(p)); 349*95c635efSGarrett D'Amore } 350*95c635efSGarrett D'Amore 351*95c635efSGarrett D'Amore 352*95c635efSGarrett D'Amore static void 353*95c635efSGarrett D'Amore print_mdoc(MDOC_ARGS) 354*95c635efSGarrett D'Amore { 355*95c635efSGarrett D'Amore struct tag *t, *tt; 356*95c635efSGarrett D'Amore struct htmlpair tag; 357*95c635efSGarrett D'Amore 358*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "mandoc"); 359*95c635efSGarrett D'Amore 360*95c635efSGarrett D'Amore if ( ! (HTML_FRAGMENT & h->oflags)) { 361*95c635efSGarrett D'Amore print_gen_decls(h); 362*95c635efSGarrett D'Amore t = print_otag(h, TAG_HTML, 0, NULL); 363*95c635efSGarrett D'Amore tt = print_otag(h, TAG_HEAD, 0, NULL); 364*95c635efSGarrett D'Amore print_mdoc_head(m, n, h); 365*95c635efSGarrett D'Amore print_tagq(h, tt); 366*95c635efSGarrett D'Amore print_otag(h, TAG_BODY, 0, NULL); 367*95c635efSGarrett D'Amore print_otag(h, TAG_DIV, 1, &tag); 368*95c635efSGarrett D'Amore } else 369*95c635efSGarrett D'Amore t = print_otag(h, TAG_DIV, 1, &tag); 370*95c635efSGarrett D'Amore 371*95c635efSGarrett D'Amore print_mdoc_nodelist(m, n, h); 372*95c635efSGarrett D'Amore print_tagq(h, t); 373*95c635efSGarrett D'Amore } 374*95c635efSGarrett D'Amore 375*95c635efSGarrett D'Amore 376*95c635efSGarrett D'Amore /* ARGSUSED */ 377*95c635efSGarrett D'Amore static void 378*95c635efSGarrett D'Amore print_mdoc_head(MDOC_ARGS) 379*95c635efSGarrett D'Amore { 380*95c635efSGarrett D'Amore 381*95c635efSGarrett D'Amore print_gen_head(h); 382*95c635efSGarrett D'Amore bufinit(h); 383*95c635efSGarrett D'Amore bufcat_fmt(h, "%s(%s)", m->title, m->msec); 384*95c635efSGarrett D'Amore 385*95c635efSGarrett D'Amore if (m->arch) 386*95c635efSGarrett D'Amore bufcat_fmt(h, " (%s)", m->arch); 387*95c635efSGarrett D'Amore 388*95c635efSGarrett D'Amore print_otag(h, TAG_TITLE, 0, NULL); 389*95c635efSGarrett D'Amore print_text(h, h->buf); 390*95c635efSGarrett D'Amore } 391*95c635efSGarrett D'Amore 392*95c635efSGarrett D'Amore 393*95c635efSGarrett D'Amore static void 394*95c635efSGarrett D'Amore print_mdoc_nodelist(MDOC_ARGS) 395*95c635efSGarrett D'Amore { 396*95c635efSGarrett D'Amore 397*95c635efSGarrett D'Amore print_mdoc_node(m, n, h); 398*95c635efSGarrett D'Amore if (n->next) 399*95c635efSGarrett D'Amore print_mdoc_nodelist(m, n->next, h); 400*95c635efSGarrett D'Amore } 401*95c635efSGarrett D'Amore 402*95c635efSGarrett D'Amore 403*95c635efSGarrett D'Amore static void 404*95c635efSGarrett D'Amore print_mdoc_node(MDOC_ARGS) 405*95c635efSGarrett D'Amore { 406*95c635efSGarrett D'Amore int child; 407*95c635efSGarrett D'Amore struct tag *t; 408*95c635efSGarrett D'Amore 409*95c635efSGarrett D'Amore child = 1; 410*95c635efSGarrett D'Amore t = h->tags.head; 411*95c635efSGarrett D'Amore 412*95c635efSGarrett D'Amore switch (n->type) { 413*95c635efSGarrett D'Amore case (MDOC_ROOT): 414*95c635efSGarrett D'Amore child = mdoc_root_pre(m, n, h); 415*95c635efSGarrett D'Amore break; 416*95c635efSGarrett D'Amore case (MDOC_TEXT): 417*95c635efSGarrett D'Amore /* No tables in this mode... */ 418*95c635efSGarrett D'Amore assert(NULL == h->tblt); 419*95c635efSGarrett D'Amore 420*95c635efSGarrett D'Amore /* 421*95c635efSGarrett D'Amore * Make sure that if we're in a literal mode already 422*95c635efSGarrett D'Amore * (i.e., within a <PRE>) don't print the newline. 423*95c635efSGarrett D'Amore */ 424*95c635efSGarrett D'Amore if (' ' == *n->string && MDOC_LINE & n->flags) 425*95c635efSGarrett D'Amore if ( ! (HTML_LITERAL & h->flags)) 426*95c635efSGarrett D'Amore print_otag(h, TAG_BR, 0, NULL); 427*95c635efSGarrett D'Amore if (MDOC_DELIMC & n->flags) 428*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 429*95c635efSGarrett D'Amore print_text(h, n->string); 430*95c635efSGarrett D'Amore if (MDOC_DELIMO & n->flags) 431*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 432*95c635efSGarrett D'Amore return; 433*95c635efSGarrett D'Amore case (MDOC_EQN): 434*95c635efSGarrett D'Amore print_eqn(h, n->eqn); 435*95c635efSGarrett D'Amore break; 436*95c635efSGarrett D'Amore case (MDOC_TBL): 437*95c635efSGarrett D'Amore /* 438*95c635efSGarrett D'Amore * This will take care of initialising all of the table 439*95c635efSGarrett D'Amore * state data for the first table, then tearing it down 440*95c635efSGarrett D'Amore * for the last one. 441*95c635efSGarrett D'Amore */ 442*95c635efSGarrett D'Amore print_tbl(h, n->span); 443*95c635efSGarrett D'Amore return; 444*95c635efSGarrett D'Amore default: 445*95c635efSGarrett D'Amore /* 446*95c635efSGarrett D'Amore * Close out the current table, if it's open, and unset 447*95c635efSGarrett D'Amore * the "meta" table state. This will be reopened on the 448*95c635efSGarrett D'Amore * next table element. 449*95c635efSGarrett D'Amore */ 450*95c635efSGarrett D'Amore if (h->tblt) { 451*95c635efSGarrett D'Amore print_tblclose(h); 452*95c635efSGarrett D'Amore t = h->tags.head; 453*95c635efSGarrett D'Amore } 454*95c635efSGarrett D'Amore 455*95c635efSGarrett D'Amore assert(NULL == h->tblt); 456*95c635efSGarrett D'Amore if (mdocs[n->tok].pre && ENDBODY_NOT == n->end) 457*95c635efSGarrett D'Amore child = (*mdocs[n->tok].pre)(m, n, h); 458*95c635efSGarrett D'Amore break; 459*95c635efSGarrett D'Amore } 460*95c635efSGarrett D'Amore 461*95c635efSGarrett D'Amore if (HTML_KEEP & h->flags) { 462*95c635efSGarrett D'Amore if (n->prev && n->prev->line != n->line) { 463*95c635efSGarrett D'Amore h->flags &= ~HTML_KEEP; 464*95c635efSGarrett D'Amore h->flags |= HTML_PREKEEP; 465*95c635efSGarrett D'Amore } else if (NULL == n->prev) { 466*95c635efSGarrett D'Amore if (n->parent && n->parent->line != n->line) { 467*95c635efSGarrett D'Amore h->flags &= ~HTML_KEEP; 468*95c635efSGarrett D'Amore h->flags |= HTML_PREKEEP; 469*95c635efSGarrett D'Amore } 470*95c635efSGarrett D'Amore } 471*95c635efSGarrett D'Amore } 472*95c635efSGarrett D'Amore 473*95c635efSGarrett D'Amore if (child && n->child) 474*95c635efSGarrett D'Amore print_mdoc_nodelist(m, n->child, h); 475*95c635efSGarrett D'Amore 476*95c635efSGarrett D'Amore print_stagq(h, t); 477*95c635efSGarrett D'Amore 478*95c635efSGarrett D'Amore switch (n->type) { 479*95c635efSGarrett D'Amore case (MDOC_ROOT): 480*95c635efSGarrett D'Amore mdoc_root_post(m, n, h); 481*95c635efSGarrett D'Amore break; 482*95c635efSGarrett D'Amore case (MDOC_EQN): 483*95c635efSGarrett D'Amore break; 484*95c635efSGarrett D'Amore default: 485*95c635efSGarrett D'Amore if (mdocs[n->tok].post && ENDBODY_NOT == n->end) 486*95c635efSGarrett D'Amore (*mdocs[n->tok].post)(m, n, h); 487*95c635efSGarrett D'Amore break; 488*95c635efSGarrett D'Amore } 489*95c635efSGarrett D'Amore } 490*95c635efSGarrett D'Amore 491*95c635efSGarrett D'Amore /* ARGSUSED */ 492*95c635efSGarrett D'Amore static void 493*95c635efSGarrett D'Amore mdoc_root_post(MDOC_ARGS) 494*95c635efSGarrett D'Amore { 495*95c635efSGarrett D'Amore struct htmlpair tag[3]; 496*95c635efSGarrett D'Amore struct tag *t, *tt; 497*95c635efSGarrett D'Amore 498*95c635efSGarrett D'Amore PAIR_SUMMARY_INIT(&tag[0], "Document Footer"); 499*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[1], "foot"); 500*95c635efSGarrett D'Amore PAIR_INIT(&tag[2], ATTR_WIDTH, "100%"); 501*95c635efSGarrett D'Amore t = print_otag(h, TAG_TABLE, 3, tag); 502*95c635efSGarrett D'Amore PAIR_INIT(&tag[0], ATTR_WIDTH, "50%"); 503*95c635efSGarrett D'Amore print_otag(h, TAG_COL, 1, tag); 504*95c635efSGarrett D'Amore print_otag(h, TAG_COL, 1, tag); 505*95c635efSGarrett D'Amore 506*95c635efSGarrett D'Amore print_otag(h, TAG_TBODY, 0, NULL); 507*95c635efSGarrett D'Amore 508*95c635efSGarrett D'Amore tt = print_otag(h, TAG_TR, 0, NULL); 509*95c635efSGarrett D'Amore 510*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "foot-date"); 511*95c635efSGarrett D'Amore print_otag(h, TAG_TD, 1, tag); 512*95c635efSGarrett D'Amore print_text(h, m->date); 513*95c635efSGarrett D'Amore print_stagq(h, tt); 514*95c635efSGarrett D'Amore 515*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "foot-os"); 516*95c635efSGarrett D'Amore PAIR_INIT(&tag[1], ATTR_ALIGN, "right"); 517*95c635efSGarrett D'Amore print_otag(h, TAG_TD, 2, tag); 518*95c635efSGarrett D'Amore print_text(h, m->os); 519*95c635efSGarrett D'Amore print_tagq(h, t); 520*95c635efSGarrett D'Amore } 521*95c635efSGarrett D'Amore 522*95c635efSGarrett D'Amore 523*95c635efSGarrett D'Amore /* ARGSUSED */ 524*95c635efSGarrett D'Amore static int 525*95c635efSGarrett D'Amore mdoc_root_pre(MDOC_ARGS) 526*95c635efSGarrett D'Amore { 527*95c635efSGarrett D'Amore struct htmlpair tag[3]; 528*95c635efSGarrett D'Amore struct tag *t, *tt; 529*95c635efSGarrett D'Amore char b[BUFSIZ], title[BUFSIZ]; 530*95c635efSGarrett D'Amore 531*95c635efSGarrett D'Amore strlcpy(b, m->vol, BUFSIZ); 532*95c635efSGarrett D'Amore 533*95c635efSGarrett D'Amore if (m->arch) { 534*95c635efSGarrett D'Amore strlcat(b, " (", BUFSIZ); 535*95c635efSGarrett D'Amore strlcat(b, m->arch, BUFSIZ); 536*95c635efSGarrett D'Amore strlcat(b, ")", BUFSIZ); 537*95c635efSGarrett D'Amore } 538*95c635efSGarrett D'Amore 539*95c635efSGarrett D'Amore snprintf(title, BUFSIZ - 1, "%s(%s)", m->title, m->msec); 540*95c635efSGarrett D'Amore 541*95c635efSGarrett D'Amore PAIR_SUMMARY_INIT(&tag[0], "Document Header"); 542*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[1], "head"); 543*95c635efSGarrett D'Amore PAIR_INIT(&tag[2], ATTR_WIDTH, "100%"); 544*95c635efSGarrett D'Amore t = print_otag(h, TAG_TABLE, 3, tag); 545*95c635efSGarrett D'Amore PAIR_INIT(&tag[0], ATTR_WIDTH, "30%"); 546*95c635efSGarrett D'Amore print_otag(h, TAG_COL, 1, tag); 547*95c635efSGarrett D'Amore print_otag(h, TAG_COL, 1, tag); 548*95c635efSGarrett D'Amore print_otag(h, TAG_COL, 1, tag); 549*95c635efSGarrett D'Amore 550*95c635efSGarrett D'Amore print_otag(h, TAG_TBODY, 0, NULL); 551*95c635efSGarrett D'Amore 552*95c635efSGarrett D'Amore tt = print_otag(h, TAG_TR, 0, NULL); 553*95c635efSGarrett D'Amore 554*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "head-ltitle"); 555*95c635efSGarrett D'Amore print_otag(h, TAG_TD, 1, tag); 556*95c635efSGarrett D'Amore print_text(h, title); 557*95c635efSGarrett D'Amore print_stagq(h, tt); 558*95c635efSGarrett D'Amore 559*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "head-vol"); 560*95c635efSGarrett D'Amore PAIR_INIT(&tag[1], ATTR_ALIGN, "center"); 561*95c635efSGarrett D'Amore print_otag(h, TAG_TD, 2, tag); 562*95c635efSGarrett D'Amore print_text(h, b); 563*95c635efSGarrett D'Amore print_stagq(h, tt); 564*95c635efSGarrett D'Amore 565*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "head-rtitle"); 566*95c635efSGarrett D'Amore PAIR_INIT(&tag[1], ATTR_ALIGN, "right"); 567*95c635efSGarrett D'Amore print_otag(h, TAG_TD, 2, tag); 568*95c635efSGarrett D'Amore print_text(h, title); 569*95c635efSGarrett D'Amore print_tagq(h, t); 570*95c635efSGarrett D'Amore return(1); 571*95c635efSGarrett D'Amore } 572*95c635efSGarrett D'Amore 573*95c635efSGarrett D'Amore 574*95c635efSGarrett D'Amore /* ARGSUSED */ 575*95c635efSGarrett D'Amore static int 576*95c635efSGarrett D'Amore mdoc_sh_pre(MDOC_ARGS) 577*95c635efSGarrett D'Amore { 578*95c635efSGarrett D'Amore struct htmlpair tag; 579*95c635efSGarrett D'Amore 580*95c635efSGarrett D'Amore if (MDOC_BLOCK == n->type) { 581*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "section"); 582*95c635efSGarrett D'Amore print_otag(h, TAG_DIV, 1, &tag); 583*95c635efSGarrett D'Amore return(1); 584*95c635efSGarrett D'Amore } else if (MDOC_BODY == n->type) 585*95c635efSGarrett D'Amore return(1); 586*95c635efSGarrett D'Amore 587*95c635efSGarrett D'Amore bufinit(h); 588*95c635efSGarrett D'Amore bufcat(h, "x"); 589*95c635efSGarrett D'Amore 590*95c635efSGarrett D'Amore for (n = n->child; n && MDOC_TEXT == n->type; ) { 591*95c635efSGarrett D'Amore bufcat_id(h, n->string); 592*95c635efSGarrett D'Amore if (NULL != (n = n->next)) 593*95c635efSGarrett D'Amore bufcat_id(h, " "); 594*95c635efSGarrett D'Amore } 595*95c635efSGarrett D'Amore 596*95c635efSGarrett D'Amore if (NULL == n) { 597*95c635efSGarrett D'Amore PAIR_ID_INIT(&tag, h->buf); 598*95c635efSGarrett D'Amore print_otag(h, TAG_H1, 1, &tag); 599*95c635efSGarrett D'Amore } else 600*95c635efSGarrett D'Amore print_otag(h, TAG_H1, 0, NULL); 601*95c635efSGarrett D'Amore 602*95c635efSGarrett D'Amore return(1); 603*95c635efSGarrett D'Amore } 604*95c635efSGarrett D'Amore 605*95c635efSGarrett D'Amore /* ARGSUSED */ 606*95c635efSGarrett D'Amore static int 607*95c635efSGarrett D'Amore mdoc_ss_pre(MDOC_ARGS) 608*95c635efSGarrett D'Amore { 609*95c635efSGarrett D'Amore struct htmlpair tag; 610*95c635efSGarrett D'Amore 611*95c635efSGarrett D'Amore if (MDOC_BLOCK == n->type) { 612*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "subsection"); 613*95c635efSGarrett D'Amore print_otag(h, TAG_DIV, 1, &tag); 614*95c635efSGarrett D'Amore return(1); 615*95c635efSGarrett D'Amore } else if (MDOC_BODY == n->type) 616*95c635efSGarrett D'Amore return(1); 617*95c635efSGarrett D'Amore 618*95c635efSGarrett D'Amore bufinit(h); 619*95c635efSGarrett D'Amore bufcat(h, "x"); 620*95c635efSGarrett D'Amore 621*95c635efSGarrett D'Amore for (n = n->child; n && MDOC_TEXT == n->type; ) { 622*95c635efSGarrett D'Amore bufcat_id(h, n->string); 623*95c635efSGarrett D'Amore if (NULL != (n = n->next)) 624*95c635efSGarrett D'Amore bufcat_id(h, " "); 625*95c635efSGarrett D'Amore } 626*95c635efSGarrett D'Amore 627*95c635efSGarrett D'Amore if (NULL == n) { 628*95c635efSGarrett D'Amore PAIR_ID_INIT(&tag, h->buf); 629*95c635efSGarrett D'Amore print_otag(h, TAG_H2, 1, &tag); 630*95c635efSGarrett D'Amore } else 631*95c635efSGarrett D'Amore print_otag(h, TAG_H2, 0, NULL); 632*95c635efSGarrett D'Amore 633*95c635efSGarrett D'Amore return(1); 634*95c635efSGarrett D'Amore } 635*95c635efSGarrett D'Amore 636*95c635efSGarrett D'Amore 637*95c635efSGarrett D'Amore /* ARGSUSED */ 638*95c635efSGarrett D'Amore static int 639*95c635efSGarrett D'Amore mdoc_fl_pre(MDOC_ARGS) 640*95c635efSGarrett D'Amore { 641*95c635efSGarrett D'Amore struct htmlpair tag; 642*95c635efSGarrett D'Amore 643*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "flag"); 644*95c635efSGarrett D'Amore print_otag(h, TAG_B, 1, &tag); 645*95c635efSGarrett D'Amore 646*95c635efSGarrett D'Amore /* `Cm' has no leading hyphen. */ 647*95c635efSGarrett D'Amore 648*95c635efSGarrett D'Amore if (MDOC_Cm == n->tok) 649*95c635efSGarrett D'Amore return(1); 650*95c635efSGarrett D'Amore 651*95c635efSGarrett D'Amore print_text(h, "\\-"); 652*95c635efSGarrett D'Amore 653*95c635efSGarrett D'Amore if (n->child) 654*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 655*95c635efSGarrett D'Amore else if (n->next && n->next->line == n->line) 656*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 657*95c635efSGarrett D'Amore 658*95c635efSGarrett D'Amore return(1); 659*95c635efSGarrett D'Amore } 660*95c635efSGarrett D'Amore 661*95c635efSGarrett D'Amore 662*95c635efSGarrett D'Amore /* ARGSUSED */ 663*95c635efSGarrett D'Amore static int 664*95c635efSGarrett D'Amore mdoc_nd_pre(MDOC_ARGS) 665*95c635efSGarrett D'Amore { 666*95c635efSGarrett D'Amore struct htmlpair tag; 667*95c635efSGarrett D'Amore 668*95c635efSGarrett D'Amore if (MDOC_BODY != n->type) 669*95c635efSGarrett D'Amore return(1); 670*95c635efSGarrett D'Amore 671*95c635efSGarrett D'Amore /* XXX: this tag in theory can contain block elements. */ 672*95c635efSGarrett D'Amore 673*95c635efSGarrett D'Amore print_text(h, "\\(em"); 674*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "desc"); 675*95c635efSGarrett D'Amore print_otag(h, TAG_SPAN, 1, &tag); 676*95c635efSGarrett D'Amore return(1); 677*95c635efSGarrett D'Amore } 678*95c635efSGarrett D'Amore 679*95c635efSGarrett D'Amore 680*95c635efSGarrett D'Amore static int 681*95c635efSGarrett D'Amore mdoc_nm_pre(MDOC_ARGS) 682*95c635efSGarrett D'Amore { 683*95c635efSGarrett D'Amore struct htmlpair tag; 684*95c635efSGarrett D'Amore struct roffsu su; 685*95c635efSGarrett D'Amore int len; 686*95c635efSGarrett D'Amore 687*95c635efSGarrett D'Amore switch (n->type) { 688*95c635efSGarrett D'Amore case (MDOC_ELEM): 689*95c635efSGarrett D'Amore synopsis_pre(h, n); 690*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "name"); 691*95c635efSGarrett D'Amore print_otag(h, TAG_B, 1, &tag); 692*95c635efSGarrett D'Amore if (NULL == n->child && m->name) 693*95c635efSGarrett D'Amore print_text(h, m->name); 694*95c635efSGarrett D'Amore return(1); 695*95c635efSGarrett D'Amore case (MDOC_HEAD): 696*95c635efSGarrett D'Amore print_otag(h, TAG_TD, 0, NULL); 697*95c635efSGarrett D'Amore if (NULL == n->child && m->name) 698*95c635efSGarrett D'Amore print_text(h, m->name); 699*95c635efSGarrett D'Amore return(1); 700*95c635efSGarrett D'Amore case (MDOC_BODY): 701*95c635efSGarrett D'Amore print_otag(h, TAG_TD, 0, NULL); 702*95c635efSGarrett D'Amore return(1); 703*95c635efSGarrett D'Amore default: 704*95c635efSGarrett D'Amore break; 705*95c635efSGarrett D'Amore } 706*95c635efSGarrett D'Amore 707*95c635efSGarrett D'Amore synopsis_pre(h, n); 708*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "synopsis"); 709*95c635efSGarrett D'Amore print_otag(h, TAG_TABLE, 1, &tag); 710*95c635efSGarrett D'Amore 711*95c635efSGarrett D'Amore for (len = 0, n = n->child; n; n = n->next) 712*95c635efSGarrett D'Amore if (MDOC_TEXT == n->type) 713*95c635efSGarrett D'Amore len += html_strlen(n->string); 714*95c635efSGarrett D'Amore 715*95c635efSGarrett D'Amore if (0 == len && m->name) 716*95c635efSGarrett D'Amore len = html_strlen(m->name); 717*95c635efSGarrett D'Amore 718*95c635efSGarrett D'Amore SCALE_HS_INIT(&su, (double)len); 719*95c635efSGarrett D'Amore bufinit(h); 720*95c635efSGarrett D'Amore bufcat_su(h, "width", &su); 721*95c635efSGarrett D'Amore PAIR_STYLE_INIT(&tag, h); 722*95c635efSGarrett D'Amore print_otag(h, TAG_COL, 1, &tag); 723*95c635efSGarrett D'Amore print_otag(h, TAG_COL, 0, NULL); 724*95c635efSGarrett D'Amore print_otag(h, TAG_TBODY, 0, NULL); 725*95c635efSGarrett D'Amore print_otag(h, TAG_TR, 0, NULL); 726*95c635efSGarrett D'Amore return(1); 727*95c635efSGarrett D'Amore } 728*95c635efSGarrett D'Amore 729*95c635efSGarrett D'Amore 730*95c635efSGarrett D'Amore /* ARGSUSED */ 731*95c635efSGarrett D'Amore static int 732*95c635efSGarrett D'Amore mdoc_xr_pre(MDOC_ARGS) 733*95c635efSGarrett D'Amore { 734*95c635efSGarrett D'Amore struct htmlpair tag[2]; 735*95c635efSGarrett D'Amore 736*95c635efSGarrett D'Amore if (NULL == n->child) 737*95c635efSGarrett D'Amore return(0); 738*95c635efSGarrett D'Amore 739*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "link-man"); 740*95c635efSGarrett D'Amore 741*95c635efSGarrett D'Amore if (h->base_man) { 742*95c635efSGarrett D'Amore buffmt_man(h, n->child->string, 743*95c635efSGarrett D'Amore n->child->next ? 744*95c635efSGarrett D'Amore n->child->next->string : NULL); 745*95c635efSGarrett D'Amore PAIR_HREF_INIT(&tag[1], h->buf); 746*95c635efSGarrett D'Amore print_otag(h, TAG_A, 2, tag); 747*95c635efSGarrett D'Amore } else 748*95c635efSGarrett D'Amore print_otag(h, TAG_A, 1, tag); 749*95c635efSGarrett D'Amore 750*95c635efSGarrett D'Amore n = n->child; 751*95c635efSGarrett D'Amore print_text(h, n->string); 752*95c635efSGarrett D'Amore 753*95c635efSGarrett D'Amore if (NULL == (n = n->next)) 754*95c635efSGarrett D'Amore return(0); 755*95c635efSGarrett D'Amore 756*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 757*95c635efSGarrett D'Amore print_text(h, "("); 758*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 759*95c635efSGarrett D'Amore print_text(h, n->string); 760*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 761*95c635efSGarrett D'Amore print_text(h, ")"); 762*95c635efSGarrett D'Amore return(0); 763*95c635efSGarrett D'Amore } 764*95c635efSGarrett D'Amore 765*95c635efSGarrett D'Amore 766*95c635efSGarrett D'Amore /* ARGSUSED */ 767*95c635efSGarrett D'Amore static int 768*95c635efSGarrett D'Amore mdoc_ns_pre(MDOC_ARGS) 769*95c635efSGarrett D'Amore { 770*95c635efSGarrett D'Amore 771*95c635efSGarrett D'Amore if ( ! (MDOC_LINE & n->flags)) 772*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 773*95c635efSGarrett D'Amore return(1); 774*95c635efSGarrett D'Amore } 775*95c635efSGarrett D'Amore 776*95c635efSGarrett D'Amore 777*95c635efSGarrett D'Amore /* ARGSUSED */ 778*95c635efSGarrett D'Amore static int 779*95c635efSGarrett D'Amore mdoc_ar_pre(MDOC_ARGS) 780*95c635efSGarrett D'Amore { 781*95c635efSGarrett D'Amore struct htmlpair tag; 782*95c635efSGarrett D'Amore 783*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "arg"); 784*95c635efSGarrett D'Amore print_otag(h, TAG_I, 1, &tag); 785*95c635efSGarrett D'Amore return(1); 786*95c635efSGarrett D'Amore } 787*95c635efSGarrett D'Amore 788*95c635efSGarrett D'Amore 789*95c635efSGarrett D'Amore /* ARGSUSED */ 790*95c635efSGarrett D'Amore static int 791*95c635efSGarrett D'Amore mdoc_xx_pre(MDOC_ARGS) 792*95c635efSGarrett D'Amore { 793*95c635efSGarrett D'Amore const char *pp; 794*95c635efSGarrett D'Amore struct htmlpair tag; 795*95c635efSGarrett D'Amore int flags; 796*95c635efSGarrett D'Amore 797*95c635efSGarrett D'Amore switch (n->tok) { 798*95c635efSGarrett D'Amore case (MDOC_Bsx): 799*95c635efSGarrett D'Amore pp = "BSD/OS"; 800*95c635efSGarrett D'Amore break; 801*95c635efSGarrett D'Amore case (MDOC_Dx): 802*95c635efSGarrett D'Amore pp = "DragonFly"; 803*95c635efSGarrett D'Amore break; 804*95c635efSGarrett D'Amore case (MDOC_Fx): 805*95c635efSGarrett D'Amore pp = "FreeBSD"; 806*95c635efSGarrett D'Amore break; 807*95c635efSGarrett D'Amore case (MDOC_Nx): 808*95c635efSGarrett D'Amore pp = "NetBSD"; 809*95c635efSGarrett D'Amore break; 810*95c635efSGarrett D'Amore case (MDOC_Ox): 811*95c635efSGarrett D'Amore pp = "OpenBSD"; 812*95c635efSGarrett D'Amore break; 813*95c635efSGarrett D'Amore case (MDOC_Ux): 814*95c635efSGarrett D'Amore pp = "UNIX"; 815*95c635efSGarrett D'Amore break; 816*95c635efSGarrett D'Amore default: 817*95c635efSGarrett D'Amore return(1); 818*95c635efSGarrett D'Amore } 819*95c635efSGarrett D'Amore 820*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "unix"); 821*95c635efSGarrett D'Amore print_otag(h, TAG_SPAN, 1, &tag); 822*95c635efSGarrett D'Amore 823*95c635efSGarrett D'Amore print_text(h, pp); 824*95c635efSGarrett D'Amore if (n->child) { 825*95c635efSGarrett D'Amore flags = h->flags; 826*95c635efSGarrett D'Amore h->flags |= HTML_KEEP; 827*95c635efSGarrett D'Amore print_text(h, n->child->string); 828*95c635efSGarrett D'Amore h->flags = flags; 829*95c635efSGarrett D'Amore } 830*95c635efSGarrett D'Amore return(0); 831*95c635efSGarrett D'Amore } 832*95c635efSGarrett D'Amore 833*95c635efSGarrett D'Amore 834*95c635efSGarrett D'Amore /* ARGSUSED */ 835*95c635efSGarrett D'Amore static int 836*95c635efSGarrett D'Amore mdoc_bx_pre(MDOC_ARGS) 837*95c635efSGarrett D'Amore { 838*95c635efSGarrett D'Amore struct htmlpair tag; 839*95c635efSGarrett D'Amore 840*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "unix"); 841*95c635efSGarrett D'Amore print_otag(h, TAG_SPAN, 1, &tag); 842*95c635efSGarrett D'Amore 843*95c635efSGarrett D'Amore if (NULL != (n = n->child)) { 844*95c635efSGarrett D'Amore print_text(h, n->string); 845*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 846*95c635efSGarrett D'Amore print_text(h, "BSD"); 847*95c635efSGarrett D'Amore } else { 848*95c635efSGarrett D'Amore print_text(h, "BSD"); 849*95c635efSGarrett D'Amore return(0); 850*95c635efSGarrett D'Amore } 851*95c635efSGarrett D'Amore 852*95c635efSGarrett D'Amore if (NULL != (n = n->next)) { 853*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 854*95c635efSGarrett D'Amore print_text(h, "-"); 855*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 856*95c635efSGarrett D'Amore print_text(h, n->string); 857*95c635efSGarrett D'Amore } 858*95c635efSGarrett D'Amore 859*95c635efSGarrett D'Amore return(0); 860*95c635efSGarrett D'Amore } 861*95c635efSGarrett D'Amore 862*95c635efSGarrett D'Amore /* ARGSUSED */ 863*95c635efSGarrett D'Amore static int 864*95c635efSGarrett D'Amore mdoc_it_pre(MDOC_ARGS) 865*95c635efSGarrett D'Amore { 866*95c635efSGarrett D'Amore struct roffsu su; 867*95c635efSGarrett D'Amore enum mdoc_list type; 868*95c635efSGarrett D'Amore struct htmlpair tag[2]; 869*95c635efSGarrett D'Amore const struct mdoc_node *bl; 870*95c635efSGarrett D'Amore 871*95c635efSGarrett D'Amore bl = n->parent; 872*95c635efSGarrett D'Amore while (bl && MDOC_Bl != bl->tok) 873*95c635efSGarrett D'Amore bl = bl->parent; 874*95c635efSGarrett D'Amore 875*95c635efSGarrett D'Amore assert(bl); 876*95c635efSGarrett D'Amore 877*95c635efSGarrett D'Amore type = bl->norm->Bl.type; 878*95c635efSGarrett D'Amore 879*95c635efSGarrett D'Amore assert(lists[type]); 880*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], lists[type]); 881*95c635efSGarrett D'Amore 882*95c635efSGarrett D'Amore bufinit(h); 883*95c635efSGarrett D'Amore 884*95c635efSGarrett D'Amore if (MDOC_HEAD == n->type) { 885*95c635efSGarrett D'Amore switch (type) { 886*95c635efSGarrett D'Amore case(LIST_bullet): 887*95c635efSGarrett D'Amore /* FALLTHROUGH */ 888*95c635efSGarrett D'Amore case(LIST_dash): 889*95c635efSGarrett D'Amore /* FALLTHROUGH */ 890*95c635efSGarrett D'Amore case(LIST_item): 891*95c635efSGarrett D'Amore /* FALLTHROUGH */ 892*95c635efSGarrett D'Amore case(LIST_hyphen): 893*95c635efSGarrett D'Amore /* FALLTHROUGH */ 894*95c635efSGarrett D'Amore case(LIST_enum): 895*95c635efSGarrett D'Amore return(0); 896*95c635efSGarrett D'Amore case(LIST_diag): 897*95c635efSGarrett D'Amore /* FALLTHROUGH */ 898*95c635efSGarrett D'Amore case(LIST_hang): 899*95c635efSGarrett D'Amore /* FALLTHROUGH */ 900*95c635efSGarrett D'Amore case(LIST_inset): 901*95c635efSGarrett D'Amore /* FALLTHROUGH */ 902*95c635efSGarrett D'Amore case(LIST_ohang): 903*95c635efSGarrett D'Amore /* FALLTHROUGH */ 904*95c635efSGarrett D'Amore case(LIST_tag): 905*95c635efSGarrett D'Amore SCALE_VS_INIT(&su, ! bl->norm->Bl.comp); 906*95c635efSGarrett D'Amore bufcat_su(h, "margin-top", &su); 907*95c635efSGarrett D'Amore PAIR_STYLE_INIT(&tag[1], h); 908*95c635efSGarrett D'Amore print_otag(h, TAG_DT, 2, tag); 909*95c635efSGarrett D'Amore if (LIST_diag != type) 910*95c635efSGarrett D'Amore break; 911*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "diag"); 912*95c635efSGarrett D'Amore print_otag(h, TAG_B, 1, tag); 913*95c635efSGarrett D'Amore break; 914*95c635efSGarrett D'Amore case(LIST_column): 915*95c635efSGarrett D'Amore break; 916*95c635efSGarrett D'Amore default: 917*95c635efSGarrett D'Amore break; 918*95c635efSGarrett D'Amore } 919*95c635efSGarrett D'Amore } else if (MDOC_BODY == n->type) { 920*95c635efSGarrett D'Amore switch (type) { 921*95c635efSGarrett D'Amore case(LIST_bullet): 922*95c635efSGarrett D'Amore /* FALLTHROUGH */ 923*95c635efSGarrett D'Amore case(LIST_hyphen): 924*95c635efSGarrett D'Amore /* FALLTHROUGH */ 925*95c635efSGarrett D'Amore case(LIST_dash): 926*95c635efSGarrett D'Amore /* FALLTHROUGH */ 927*95c635efSGarrett D'Amore case(LIST_enum): 928*95c635efSGarrett D'Amore /* FALLTHROUGH */ 929*95c635efSGarrett D'Amore case(LIST_item): 930*95c635efSGarrett D'Amore SCALE_VS_INIT(&su, ! bl->norm->Bl.comp); 931*95c635efSGarrett D'Amore bufcat_su(h, "margin-top", &su); 932*95c635efSGarrett D'Amore PAIR_STYLE_INIT(&tag[1], h); 933*95c635efSGarrett D'Amore print_otag(h, TAG_LI, 2, tag); 934*95c635efSGarrett D'Amore break; 935*95c635efSGarrett D'Amore case(LIST_diag): 936*95c635efSGarrett D'Amore /* FALLTHROUGH */ 937*95c635efSGarrett D'Amore case(LIST_hang): 938*95c635efSGarrett D'Amore /* FALLTHROUGH */ 939*95c635efSGarrett D'Amore case(LIST_inset): 940*95c635efSGarrett D'Amore /* FALLTHROUGH */ 941*95c635efSGarrett D'Amore case(LIST_ohang): 942*95c635efSGarrett D'Amore /* FALLTHROUGH */ 943*95c635efSGarrett D'Amore case(LIST_tag): 944*95c635efSGarrett D'Amore if (NULL == bl->norm->Bl.width) { 945*95c635efSGarrett D'Amore print_otag(h, TAG_DD, 1, tag); 946*95c635efSGarrett D'Amore break; 947*95c635efSGarrett D'Amore } 948*95c635efSGarrett D'Amore a2width(bl->norm->Bl.width, &su); 949*95c635efSGarrett D'Amore bufcat_su(h, "margin-left", &su); 950*95c635efSGarrett D'Amore PAIR_STYLE_INIT(&tag[1], h); 951*95c635efSGarrett D'Amore print_otag(h, TAG_DD, 2, tag); 952*95c635efSGarrett D'Amore break; 953*95c635efSGarrett D'Amore case(LIST_column): 954*95c635efSGarrett D'Amore SCALE_VS_INIT(&su, ! bl->norm->Bl.comp); 955*95c635efSGarrett D'Amore bufcat_su(h, "margin-top", &su); 956*95c635efSGarrett D'Amore PAIR_STYLE_INIT(&tag[1], h); 957*95c635efSGarrett D'Amore print_otag(h, TAG_TD, 2, tag); 958*95c635efSGarrett D'Amore break; 959*95c635efSGarrett D'Amore default: 960*95c635efSGarrett D'Amore break; 961*95c635efSGarrett D'Amore } 962*95c635efSGarrett D'Amore } else { 963*95c635efSGarrett D'Amore switch (type) { 964*95c635efSGarrett D'Amore case (LIST_column): 965*95c635efSGarrett D'Amore print_otag(h, TAG_TR, 1, tag); 966*95c635efSGarrett D'Amore break; 967*95c635efSGarrett D'Amore default: 968*95c635efSGarrett D'Amore break; 969*95c635efSGarrett D'Amore } 970*95c635efSGarrett D'Amore } 971*95c635efSGarrett D'Amore 972*95c635efSGarrett D'Amore return(1); 973*95c635efSGarrett D'Amore } 974*95c635efSGarrett D'Amore 975*95c635efSGarrett D'Amore /* ARGSUSED */ 976*95c635efSGarrett D'Amore static int 977*95c635efSGarrett D'Amore mdoc_bl_pre(MDOC_ARGS) 978*95c635efSGarrett D'Amore { 979*95c635efSGarrett D'Amore int i; 980*95c635efSGarrett D'Amore struct htmlpair tag[3]; 981*95c635efSGarrett D'Amore struct roffsu su; 982*95c635efSGarrett D'Amore char buf[BUFSIZ]; 983*95c635efSGarrett D'Amore 984*95c635efSGarrett D'Amore bufinit(h); 985*95c635efSGarrett D'Amore 986*95c635efSGarrett D'Amore if (MDOC_BODY == n->type) { 987*95c635efSGarrett D'Amore if (LIST_column == n->norm->Bl.type) 988*95c635efSGarrett D'Amore print_otag(h, TAG_TBODY, 0, NULL); 989*95c635efSGarrett D'Amore return(1); 990*95c635efSGarrett D'Amore } 991*95c635efSGarrett D'Amore 992*95c635efSGarrett D'Amore if (MDOC_HEAD == n->type) { 993*95c635efSGarrett D'Amore if (LIST_column != n->norm->Bl.type) 994*95c635efSGarrett D'Amore return(0); 995*95c635efSGarrett D'Amore 996*95c635efSGarrett D'Amore /* 997*95c635efSGarrett D'Amore * For each column, print out the <COL> tag with our 998*95c635efSGarrett D'Amore * suggested width. The last column gets min-width, as 999*95c635efSGarrett D'Amore * in terminal mode it auto-sizes to the width of the 1000*95c635efSGarrett D'Amore * screen and we want to preserve that behaviour. 1001*95c635efSGarrett D'Amore */ 1002*95c635efSGarrett D'Amore 1003*95c635efSGarrett D'Amore for (i = 0; i < (int)n->norm->Bl.ncols; i++) { 1004*95c635efSGarrett D'Amore a2width(n->norm->Bl.cols[i], &su); 1005*95c635efSGarrett D'Amore if (i < (int)n->norm->Bl.ncols - 1) 1006*95c635efSGarrett D'Amore bufcat_su(h, "width", &su); 1007*95c635efSGarrett D'Amore else 1008*95c635efSGarrett D'Amore bufcat_su(h, "min-width", &su); 1009*95c635efSGarrett D'Amore PAIR_STYLE_INIT(&tag[0], h); 1010*95c635efSGarrett D'Amore print_otag(h, TAG_COL, 1, tag); 1011*95c635efSGarrett D'Amore } 1012*95c635efSGarrett D'Amore 1013*95c635efSGarrett D'Amore return(0); 1014*95c635efSGarrett D'Amore } 1015*95c635efSGarrett D'Amore 1016*95c635efSGarrett D'Amore SCALE_VS_INIT(&su, 0); 1017*95c635efSGarrett D'Amore bufcat_su(h, "margin-top", &su); 1018*95c635efSGarrett D'Amore bufcat_su(h, "margin-bottom", &su); 1019*95c635efSGarrett D'Amore PAIR_STYLE_INIT(&tag[0], h); 1020*95c635efSGarrett D'Amore 1021*95c635efSGarrett D'Amore assert(lists[n->norm->Bl.type]); 1022*95c635efSGarrett D'Amore strlcpy(buf, "list ", BUFSIZ); 1023*95c635efSGarrett D'Amore strlcat(buf, lists[n->norm->Bl.type], BUFSIZ); 1024*95c635efSGarrett D'Amore PAIR_INIT(&tag[1], ATTR_CLASS, buf); 1025*95c635efSGarrett D'Amore 1026*95c635efSGarrett D'Amore /* Set the block's left-hand margin. */ 1027*95c635efSGarrett D'Amore 1028*95c635efSGarrett D'Amore if (n->norm->Bl.offs) { 1029*95c635efSGarrett D'Amore a2offs(n->norm->Bl.offs, &su); 1030*95c635efSGarrett D'Amore bufcat_su(h, "margin-left", &su); 1031*95c635efSGarrett D'Amore } 1032*95c635efSGarrett D'Amore 1033*95c635efSGarrett D'Amore switch (n->norm->Bl.type) { 1034*95c635efSGarrett D'Amore case(LIST_bullet): 1035*95c635efSGarrett D'Amore /* FALLTHROUGH */ 1036*95c635efSGarrett D'Amore case(LIST_dash): 1037*95c635efSGarrett D'Amore /* FALLTHROUGH */ 1038*95c635efSGarrett D'Amore case(LIST_hyphen): 1039*95c635efSGarrett D'Amore /* FALLTHROUGH */ 1040*95c635efSGarrett D'Amore case(LIST_item): 1041*95c635efSGarrett D'Amore print_otag(h, TAG_UL, 2, tag); 1042*95c635efSGarrett D'Amore break; 1043*95c635efSGarrett D'Amore case(LIST_enum): 1044*95c635efSGarrett D'Amore print_otag(h, TAG_OL, 2, tag); 1045*95c635efSGarrett D'Amore break; 1046*95c635efSGarrett D'Amore case(LIST_diag): 1047*95c635efSGarrett D'Amore /* FALLTHROUGH */ 1048*95c635efSGarrett D'Amore case(LIST_hang): 1049*95c635efSGarrett D'Amore /* FALLTHROUGH */ 1050*95c635efSGarrett D'Amore case(LIST_inset): 1051*95c635efSGarrett D'Amore /* FALLTHROUGH */ 1052*95c635efSGarrett D'Amore case(LIST_ohang): 1053*95c635efSGarrett D'Amore /* FALLTHROUGH */ 1054*95c635efSGarrett D'Amore case(LIST_tag): 1055*95c635efSGarrett D'Amore print_otag(h, TAG_DL, 2, tag); 1056*95c635efSGarrett D'Amore break; 1057*95c635efSGarrett D'Amore case(LIST_column): 1058*95c635efSGarrett D'Amore print_otag(h, TAG_TABLE, 2, tag); 1059*95c635efSGarrett D'Amore break; 1060*95c635efSGarrett D'Amore default: 1061*95c635efSGarrett D'Amore abort(); 1062*95c635efSGarrett D'Amore /* NOTREACHED */ 1063*95c635efSGarrett D'Amore } 1064*95c635efSGarrett D'Amore 1065*95c635efSGarrett D'Amore return(1); 1066*95c635efSGarrett D'Amore } 1067*95c635efSGarrett D'Amore 1068*95c635efSGarrett D'Amore /* ARGSUSED */ 1069*95c635efSGarrett D'Amore static int 1070*95c635efSGarrett D'Amore mdoc_ex_pre(MDOC_ARGS) 1071*95c635efSGarrett D'Amore { 1072*95c635efSGarrett D'Amore struct tag *t; 1073*95c635efSGarrett D'Amore struct htmlpair tag; 1074*95c635efSGarrett D'Amore int nchild; 1075*95c635efSGarrett D'Amore 1076*95c635efSGarrett D'Amore if (n->prev) 1077*95c635efSGarrett D'Amore print_otag(h, TAG_BR, 0, NULL); 1078*95c635efSGarrett D'Amore 1079*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "utility"); 1080*95c635efSGarrett D'Amore 1081*95c635efSGarrett D'Amore print_text(h, "The"); 1082*95c635efSGarrett D'Amore 1083*95c635efSGarrett D'Amore nchild = n->nchild; 1084*95c635efSGarrett D'Amore for (n = n->child; n; n = n->next) { 1085*95c635efSGarrett D'Amore assert(MDOC_TEXT == n->type); 1086*95c635efSGarrett D'Amore 1087*95c635efSGarrett D'Amore t = print_otag(h, TAG_B, 1, &tag); 1088*95c635efSGarrett D'Amore print_text(h, n->string); 1089*95c635efSGarrett D'Amore print_tagq(h, t); 1090*95c635efSGarrett D'Amore 1091*95c635efSGarrett D'Amore if (nchild > 2 && n->next) { 1092*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 1093*95c635efSGarrett D'Amore print_text(h, ","); 1094*95c635efSGarrett D'Amore } 1095*95c635efSGarrett D'Amore 1096*95c635efSGarrett D'Amore if (n->next && NULL == n->next->next) 1097*95c635efSGarrett D'Amore print_text(h, "and"); 1098*95c635efSGarrett D'Amore } 1099*95c635efSGarrett D'Amore 1100*95c635efSGarrett D'Amore if (nchild > 1) 1101*95c635efSGarrett D'Amore print_text(h, "utilities exit"); 1102*95c635efSGarrett D'Amore else 1103*95c635efSGarrett D'Amore print_text(h, "utility exits"); 1104*95c635efSGarrett D'Amore 1105*95c635efSGarrett D'Amore print_text(h, "0 on success, and >0 if an error occurs."); 1106*95c635efSGarrett D'Amore return(0); 1107*95c635efSGarrett D'Amore } 1108*95c635efSGarrett D'Amore 1109*95c635efSGarrett D'Amore 1110*95c635efSGarrett D'Amore /* ARGSUSED */ 1111*95c635efSGarrett D'Amore static int 1112*95c635efSGarrett D'Amore mdoc_em_pre(MDOC_ARGS) 1113*95c635efSGarrett D'Amore { 1114*95c635efSGarrett D'Amore struct htmlpair tag; 1115*95c635efSGarrett D'Amore 1116*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "emph"); 1117*95c635efSGarrett D'Amore print_otag(h, TAG_SPAN, 1, &tag); 1118*95c635efSGarrett D'Amore return(1); 1119*95c635efSGarrett D'Amore } 1120*95c635efSGarrett D'Amore 1121*95c635efSGarrett D'Amore 1122*95c635efSGarrett D'Amore /* ARGSUSED */ 1123*95c635efSGarrett D'Amore static int 1124*95c635efSGarrett D'Amore mdoc_d1_pre(MDOC_ARGS) 1125*95c635efSGarrett D'Amore { 1126*95c635efSGarrett D'Amore struct htmlpair tag[2]; 1127*95c635efSGarrett D'Amore struct roffsu su; 1128*95c635efSGarrett D'Amore 1129*95c635efSGarrett D'Amore if (MDOC_BLOCK != n->type) 1130*95c635efSGarrett D'Amore return(1); 1131*95c635efSGarrett D'Amore 1132*95c635efSGarrett D'Amore SCALE_VS_INIT(&su, 0); 1133*95c635efSGarrett D'Amore bufinit(h); 1134*95c635efSGarrett D'Amore bufcat_su(h, "margin-top", &su); 1135*95c635efSGarrett D'Amore bufcat_su(h, "margin-bottom", &su); 1136*95c635efSGarrett D'Amore PAIR_STYLE_INIT(&tag[0], h); 1137*95c635efSGarrett D'Amore print_otag(h, TAG_BLOCKQUOTE, 1, tag); 1138*95c635efSGarrett D'Amore 1139*95c635efSGarrett D'Amore /* BLOCKQUOTE needs a block body. */ 1140*95c635efSGarrett D'Amore 1141*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "display"); 1142*95c635efSGarrett D'Amore print_otag(h, TAG_DIV, 1, tag); 1143*95c635efSGarrett D'Amore 1144*95c635efSGarrett D'Amore if (MDOC_Dl == n->tok) { 1145*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "lit"); 1146*95c635efSGarrett D'Amore print_otag(h, TAG_CODE, 1, tag); 1147*95c635efSGarrett D'Amore } 1148*95c635efSGarrett D'Amore 1149*95c635efSGarrett D'Amore return(1); 1150*95c635efSGarrett D'Amore } 1151*95c635efSGarrett D'Amore 1152*95c635efSGarrett D'Amore 1153*95c635efSGarrett D'Amore /* ARGSUSED */ 1154*95c635efSGarrett D'Amore static int 1155*95c635efSGarrett D'Amore mdoc_sx_pre(MDOC_ARGS) 1156*95c635efSGarrett D'Amore { 1157*95c635efSGarrett D'Amore struct htmlpair tag[2]; 1158*95c635efSGarrett D'Amore 1159*95c635efSGarrett D'Amore bufinit(h); 1160*95c635efSGarrett D'Amore bufcat(h, "#x"); 1161*95c635efSGarrett D'Amore 1162*95c635efSGarrett D'Amore for (n = n->child; n; ) { 1163*95c635efSGarrett D'Amore bufcat_id(h, n->string); 1164*95c635efSGarrett D'Amore if (NULL != (n = n->next)) 1165*95c635efSGarrett D'Amore bufcat_id(h, " "); 1166*95c635efSGarrett D'Amore } 1167*95c635efSGarrett D'Amore 1168*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "link-sec"); 1169*95c635efSGarrett D'Amore PAIR_HREF_INIT(&tag[1], h->buf); 1170*95c635efSGarrett D'Amore 1171*95c635efSGarrett D'Amore print_otag(h, TAG_I, 1, tag); 1172*95c635efSGarrett D'Amore print_otag(h, TAG_A, 2, tag); 1173*95c635efSGarrett D'Amore return(1); 1174*95c635efSGarrett D'Amore } 1175*95c635efSGarrett D'Amore 1176*95c635efSGarrett D'Amore 1177*95c635efSGarrett D'Amore /* ARGSUSED */ 1178*95c635efSGarrett D'Amore static int 1179*95c635efSGarrett D'Amore mdoc_bd_pre(MDOC_ARGS) 1180*95c635efSGarrett D'Amore { 1181*95c635efSGarrett D'Amore struct htmlpair tag[2]; 1182*95c635efSGarrett D'Amore int comp, sv; 1183*95c635efSGarrett D'Amore const struct mdoc_node *nn; 1184*95c635efSGarrett D'Amore struct roffsu su; 1185*95c635efSGarrett D'Amore 1186*95c635efSGarrett D'Amore if (MDOC_HEAD == n->type) 1187*95c635efSGarrett D'Amore return(0); 1188*95c635efSGarrett D'Amore 1189*95c635efSGarrett D'Amore if (MDOC_BLOCK == n->type) { 1190*95c635efSGarrett D'Amore comp = n->norm->Bd.comp; 1191*95c635efSGarrett D'Amore for (nn = n; nn && ! comp; nn = nn->parent) { 1192*95c635efSGarrett D'Amore if (MDOC_BLOCK != nn->type) 1193*95c635efSGarrett D'Amore continue; 1194*95c635efSGarrett D'Amore if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok) 1195*95c635efSGarrett D'Amore comp = 1; 1196*95c635efSGarrett D'Amore if (nn->prev) 1197*95c635efSGarrett D'Amore break; 1198*95c635efSGarrett D'Amore } 1199*95c635efSGarrett D'Amore if ( ! comp) 1200*95c635efSGarrett D'Amore print_otag(h, TAG_P, 0, NULL); 1201*95c635efSGarrett D'Amore return(1); 1202*95c635efSGarrett D'Amore } 1203*95c635efSGarrett D'Amore 1204*95c635efSGarrett D'Amore SCALE_HS_INIT(&su, 0); 1205*95c635efSGarrett D'Amore if (n->norm->Bd.offs) 1206*95c635efSGarrett D'Amore a2offs(n->norm->Bd.offs, &su); 1207*95c635efSGarrett D'Amore 1208*95c635efSGarrett D'Amore bufinit(h); 1209*95c635efSGarrett D'Amore bufcat_su(h, "margin-left", &su); 1210*95c635efSGarrett D'Amore PAIR_STYLE_INIT(&tag[0], h); 1211*95c635efSGarrett D'Amore 1212*95c635efSGarrett D'Amore if (DISP_unfilled != n->norm->Bd.type && 1213*95c635efSGarrett D'Amore DISP_literal != n->norm->Bd.type) { 1214*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[1], "display"); 1215*95c635efSGarrett D'Amore print_otag(h, TAG_DIV, 2, tag); 1216*95c635efSGarrett D'Amore return(1); 1217*95c635efSGarrett D'Amore } 1218*95c635efSGarrett D'Amore 1219*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[1], "lit display"); 1220*95c635efSGarrett D'Amore print_otag(h, TAG_PRE, 2, tag); 1221*95c635efSGarrett D'Amore 1222*95c635efSGarrett D'Amore /* This can be recursive: save & set our literal state. */ 1223*95c635efSGarrett D'Amore 1224*95c635efSGarrett D'Amore sv = h->flags & HTML_LITERAL; 1225*95c635efSGarrett D'Amore h->flags |= HTML_LITERAL; 1226*95c635efSGarrett D'Amore 1227*95c635efSGarrett D'Amore for (nn = n->child; nn; nn = nn->next) { 1228*95c635efSGarrett D'Amore print_mdoc_node(m, nn, h); 1229*95c635efSGarrett D'Amore /* 1230*95c635efSGarrett D'Amore * If the printed node flushes its own line, then we 1231*95c635efSGarrett D'Amore * needn't do it here as well. This is hacky, but the 1232*95c635efSGarrett D'Amore * notion of selective eoln whitespace is pretty dumb 1233*95c635efSGarrett D'Amore * anyway, so don't sweat it. 1234*95c635efSGarrett D'Amore */ 1235*95c635efSGarrett D'Amore switch (nn->tok) { 1236*95c635efSGarrett D'Amore case (MDOC_Sm): 1237*95c635efSGarrett D'Amore /* FALLTHROUGH */ 1238*95c635efSGarrett D'Amore case (MDOC_br): 1239*95c635efSGarrett D'Amore /* FALLTHROUGH */ 1240*95c635efSGarrett D'Amore case (MDOC_sp): 1241*95c635efSGarrett D'Amore /* FALLTHROUGH */ 1242*95c635efSGarrett D'Amore case (MDOC_Bl): 1243*95c635efSGarrett D'Amore /* FALLTHROUGH */ 1244*95c635efSGarrett D'Amore case (MDOC_D1): 1245*95c635efSGarrett D'Amore /* FALLTHROUGH */ 1246*95c635efSGarrett D'Amore case (MDOC_Dl): 1247*95c635efSGarrett D'Amore /* FALLTHROUGH */ 1248*95c635efSGarrett D'Amore case (MDOC_Lp): 1249*95c635efSGarrett D'Amore /* FALLTHROUGH */ 1250*95c635efSGarrett D'Amore case (MDOC_Pp): 1251*95c635efSGarrett D'Amore continue; 1252*95c635efSGarrett D'Amore default: 1253*95c635efSGarrett D'Amore break; 1254*95c635efSGarrett D'Amore } 1255*95c635efSGarrett D'Amore if (nn->next && nn->next->line == nn->line) 1256*95c635efSGarrett D'Amore continue; 1257*95c635efSGarrett D'Amore else if (nn->next) 1258*95c635efSGarrett D'Amore print_text(h, "\n"); 1259*95c635efSGarrett D'Amore 1260*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 1261*95c635efSGarrett D'Amore } 1262*95c635efSGarrett D'Amore 1263*95c635efSGarrett D'Amore if (0 == sv) 1264*95c635efSGarrett D'Amore h->flags &= ~HTML_LITERAL; 1265*95c635efSGarrett D'Amore 1266*95c635efSGarrett D'Amore return(0); 1267*95c635efSGarrett D'Amore } 1268*95c635efSGarrett D'Amore 1269*95c635efSGarrett D'Amore 1270*95c635efSGarrett D'Amore /* ARGSUSED */ 1271*95c635efSGarrett D'Amore static int 1272*95c635efSGarrett D'Amore mdoc_pa_pre(MDOC_ARGS) 1273*95c635efSGarrett D'Amore { 1274*95c635efSGarrett D'Amore struct htmlpair tag; 1275*95c635efSGarrett D'Amore 1276*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "file"); 1277*95c635efSGarrett D'Amore print_otag(h, TAG_I, 1, &tag); 1278*95c635efSGarrett D'Amore return(1); 1279*95c635efSGarrett D'Amore } 1280*95c635efSGarrett D'Amore 1281*95c635efSGarrett D'Amore 1282*95c635efSGarrett D'Amore /* ARGSUSED */ 1283*95c635efSGarrett D'Amore static int 1284*95c635efSGarrett D'Amore mdoc_ad_pre(MDOC_ARGS) 1285*95c635efSGarrett D'Amore { 1286*95c635efSGarrett D'Amore struct htmlpair tag; 1287*95c635efSGarrett D'Amore 1288*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "addr"); 1289*95c635efSGarrett D'Amore print_otag(h, TAG_I, 1, &tag); 1290*95c635efSGarrett D'Amore return(1); 1291*95c635efSGarrett D'Amore } 1292*95c635efSGarrett D'Amore 1293*95c635efSGarrett D'Amore 1294*95c635efSGarrett D'Amore /* ARGSUSED */ 1295*95c635efSGarrett D'Amore static int 1296*95c635efSGarrett D'Amore mdoc_an_pre(MDOC_ARGS) 1297*95c635efSGarrett D'Amore { 1298*95c635efSGarrett D'Amore struct htmlpair tag; 1299*95c635efSGarrett D'Amore 1300*95c635efSGarrett D'Amore /* TODO: -split and -nosplit (see termp_an_pre()). */ 1301*95c635efSGarrett D'Amore 1302*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "author"); 1303*95c635efSGarrett D'Amore print_otag(h, TAG_SPAN, 1, &tag); 1304*95c635efSGarrett D'Amore return(1); 1305*95c635efSGarrett D'Amore } 1306*95c635efSGarrett D'Amore 1307*95c635efSGarrett D'Amore 1308*95c635efSGarrett D'Amore /* ARGSUSED */ 1309*95c635efSGarrett D'Amore static int 1310*95c635efSGarrett D'Amore mdoc_cd_pre(MDOC_ARGS) 1311*95c635efSGarrett D'Amore { 1312*95c635efSGarrett D'Amore struct htmlpair tag; 1313*95c635efSGarrett D'Amore 1314*95c635efSGarrett D'Amore synopsis_pre(h, n); 1315*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "config"); 1316*95c635efSGarrett D'Amore print_otag(h, TAG_B, 1, &tag); 1317*95c635efSGarrett D'Amore return(1); 1318*95c635efSGarrett D'Amore } 1319*95c635efSGarrett D'Amore 1320*95c635efSGarrett D'Amore 1321*95c635efSGarrett D'Amore /* ARGSUSED */ 1322*95c635efSGarrett D'Amore static int 1323*95c635efSGarrett D'Amore mdoc_dv_pre(MDOC_ARGS) 1324*95c635efSGarrett D'Amore { 1325*95c635efSGarrett D'Amore struct htmlpair tag; 1326*95c635efSGarrett D'Amore 1327*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "define"); 1328*95c635efSGarrett D'Amore print_otag(h, TAG_SPAN, 1, &tag); 1329*95c635efSGarrett D'Amore return(1); 1330*95c635efSGarrett D'Amore } 1331*95c635efSGarrett D'Amore 1332*95c635efSGarrett D'Amore 1333*95c635efSGarrett D'Amore /* ARGSUSED */ 1334*95c635efSGarrett D'Amore static int 1335*95c635efSGarrett D'Amore mdoc_ev_pre(MDOC_ARGS) 1336*95c635efSGarrett D'Amore { 1337*95c635efSGarrett D'Amore struct htmlpair tag; 1338*95c635efSGarrett D'Amore 1339*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "env"); 1340*95c635efSGarrett D'Amore print_otag(h, TAG_SPAN, 1, &tag); 1341*95c635efSGarrett D'Amore return(1); 1342*95c635efSGarrett D'Amore } 1343*95c635efSGarrett D'Amore 1344*95c635efSGarrett D'Amore 1345*95c635efSGarrett D'Amore /* ARGSUSED */ 1346*95c635efSGarrett D'Amore static int 1347*95c635efSGarrett D'Amore mdoc_er_pre(MDOC_ARGS) 1348*95c635efSGarrett D'Amore { 1349*95c635efSGarrett D'Amore struct htmlpair tag; 1350*95c635efSGarrett D'Amore 1351*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "errno"); 1352*95c635efSGarrett D'Amore print_otag(h, TAG_SPAN, 1, &tag); 1353*95c635efSGarrett D'Amore return(1); 1354*95c635efSGarrett D'Amore } 1355*95c635efSGarrett D'Amore 1356*95c635efSGarrett D'Amore 1357*95c635efSGarrett D'Amore /* ARGSUSED */ 1358*95c635efSGarrett D'Amore static int 1359*95c635efSGarrett D'Amore mdoc_fa_pre(MDOC_ARGS) 1360*95c635efSGarrett D'Amore { 1361*95c635efSGarrett D'Amore const struct mdoc_node *nn; 1362*95c635efSGarrett D'Amore struct htmlpair tag; 1363*95c635efSGarrett D'Amore struct tag *t; 1364*95c635efSGarrett D'Amore 1365*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "farg"); 1366*95c635efSGarrett D'Amore if (n->parent->tok != MDOC_Fo) { 1367*95c635efSGarrett D'Amore print_otag(h, TAG_I, 1, &tag); 1368*95c635efSGarrett D'Amore return(1); 1369*95c635efSGarrett D'Amore } 1370*95c635efSGarrett D'Amore 1371*95c635efSGarrett D'Amore for (nn = n->child; nn; nn = nn->next) { 1372*95c635efSGarrett D'Amore t = print_otag(h, TAG_I, 1, &tag); 1373*95c635efSGarrett D'Amore print_text(h, nn->string); 1374*95c635efSGarrett D'Amore print_tagq(h, t); 1375*95c635efSGarrett D'Amore if (nn->next) { 1376*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 1377*95c635efSGarrett D'Amore print_text(h, ","); 1378*95c635efSGarrett D'Amore } 1379*95c635efSGarrett D'Amore } 1380*95c635efSGarrett D'Amore 1381*95c635efSGarrett D'Amore if (n->child && n->next && n->next->tok == MDOC_Fa) { 1382*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 1383*95c635efSGarrett D'Amore print_text(h, ","); 1384*95c635efSGarrett D'Amore } 1385*95c635efSGarrett D'Amore 1386*95c635efSGarrett D'Amore return(0); 1387*95c635efSGarrett D'Amore } 1388*95c635efSGarrett D'Amore 1389*95c635efSGarrett D'Amore 1390*95c635efSGarrett D'Amore /* ARGSUSED */ 1391*95c635efSGarrett D'Amore static int 1392*95c635efSGarrett D'Amore mdoc_fd_pre(MDOC_ARGS) 1393*95c635efSGarrett D'Amore { 1394*95c635efSGarrett D'Amore struct htmlpair tag[2]; 1395*95c635efSGarrett D'Amore char buf[BUFSIZ]; 1396*95c635efSGarrett D'Amore size_t sz; 1397*95c635efSGarrett D'Amore int i; 1398*95c635efSGarrett D'Amore struct tag *t; 1399*95c635efSGarrett D'Amore 1400*95c635efSGarrett D'Amore synopsis_pre(h, n); 1401*95c635efSGarrett D'Amore 1402*95c635efSGarrett D'Amore if (NULL == (n = n->child)) 1403*95c635efSGarrett D'Amore return(0); 1404*95c635efSGarrett D'Amore 1405*95c635efSGarrett D'Amore assert(MDOC_TEXT == n->type); 1406*95c635efSGarrett D'Amore 1407*95c635efSGarrett D'Amore if (strcmp(n->string, "#include")) { 1408*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "macro"); 1409*95c635efSGarrett D'Amore print_otag(h, TAG_B, 1, tag); 1410*95c635efSGarrett D'Amore return(1); 1411*95c635efSGarrett D'Amore } 1412*95c635efSGarrett D'Amore 1413*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "includes"); 1414*95c635efSGarrett D'Amore print_otag(h, TAG_B, 1, tag); 1415*95c635efSGarrett D'Amore print_text(h, n->string); 1416*95c635efSGarrett D'Amore 1417*95c635efSGarrett D'Amore if (NULL != (n = n->next)) { 1418*95c635efSGarrett D'Amore assert(MDOC_TEXT == n->type); 1419*95c635efSGarrett D'Amore strlcpy(buf, '<' == *n->string || '"' == *n->string ? 1420*95c635efSGarrett D'Amore n->string + 1 : n->string, BUFSIZ); 1421*95c635efSGarrett D'Amore 1422*95c635efSGarrett D'Amore sz = strlen(buf); 1423*95c635efSGarrett D'Amore if (sz && ('>' == buf[sz - 1] || '"' == buf[sz - 1])) 1424*95c635efSGarrett D'Amore buf[sz - 1] = '\0'; 1425*95c635efSGarrett D'Amore 1426*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "link-includes"); 1427*95c635efSGarrett D'Amore 1428*95c635efSGarrett D'Amore i = 1; 1429*95c635efSGarrett D'Amore if (h->base_includes) { 1430*95c635efSGarrett D'Amore buffmt_includes(h, buf); 1431*95c635efSGarrett D'Amore PAIR_HREF_INIT(&tag[i], h->buf); 1432*95c635efSGarrett D'Amore i++; 1433*95c635efSGarrett D'Amore } 1434*95c635efSGarrett D'Amore 1435*95c635efSGarrett D'Amore t = print_otag(h, TAG_A, i, tag); 1436*95c635efSGarrett D'Amore print_text(h, n->string); 1437*95c635efSGarrett D'Amore print_tagq(h, t); 1438*95c635efSGarrett D'Amore 1439*95c635efSGarrett D'Amore n = n->next; 1440*95c635efSGarrett D'Amore } 1441*95c635efSGarrett D'Amore 1442*95c635efSGarrett D'Amore for ( ; n; n = n->next) { 1443*95c635efSGarrett D'Amore assert(MDOC_TEXT == n->type); 1444*95c635efSGarrett D'Amore print_text(h, n->string); 1445*95c635efSGarrett D'Amore } 1446*95c635efSGarrett D'Amore 1447*95c635efSGarrett D'Amore return(0); 1448*95c635efSGarrett D'Amore } 1449*95c635efSGarrett D'Amore 1450*95c635efSGarrett D'Amore 1451*95c635efSGarrett D'Amore /* ARGSUSED */ 1452*95c635efSGarrett D'Amore static int 1453*95c635efSGarrett D'Amore mdoc_vt_pre(MDOC_ARGS) 1454*95c635efSGarrett D'Amore { 1455*95c635efSGarrett D'Amore struct htmlpair tag; 1456*95c635efSGarrett D'Amore 1457*95c635efSGarrett D'Amore if (MDOC_BLOCK == n->type) { 1458*95c635efSGarrett D'Amore synopsis_pre(h, n); 1459*95c635efSGarrett D'Amore return(1); 1460*95c635efSGarrett D'Amore } else if (MDOC_ELEM == n->type) { 1461*95c635efSGarrett D'Amore synopsis_pre(h, n); 1462*95c635efSGarrett D'Amore } else if (MDOC_HEAD == n->type) 1463*95c635efSGarrett D'Amore return(0); 1464*95c635efSGarrett D'Amore 1465*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "type"); 1466*95c635efSGarrett D'Amore print_otag(h, TAG_SPAN, 1, &tag); 1467*95c635efSGarrett D'Amore return(1); 1468*95c635efSGarrett D'Amore } 1469*95c635efSGarrett D'Amore 1470*95c635efSGarrett D'Amore 1471*95c635efSGarrett D'Amore /* ARGSUSED */ 1472*95c635efSGarrett D'Amore static int 1473*95c635efSGarrett D'Amore mdoc_ft_pre(MDOC_ARGS) 1474*95c635efSGarrett D'Amore { 1475*95c635efSGarrett D'Amore struct htmlpair tag; 1476*95c635efSGarrett D'Amore 1477*95c635efSGarrett D'Amore synopsis_pre(h, n); 1478*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "ftype"); 1479*95c635efSGarrett D'Amore print_otag(h, TAG_I, 1, &tag); 1480*95c635efSGarrett D'Amore return(1); 1481*95c635efSGarrett D'Amore } 1482*95c635efSGarrett D'Amore 1483*95c635efSGarrett D'Amore 1484*95c635efSGarrett D'Amore /* ARGSUSED */ 1485*95c635efSGarrett D'Amore static int 1486*95c635efSGarrett D'Amore mdoc_fn_pre(MDOC_ARGS) 1487*95c635efSGarrett D'Amore { 1488*95c635efSGarrett D'Amore struct tag *t; 1489*95c635efSGarrett D'Amore struct htmlpair tag[2]; 1490*95c635efSGarrett D'Amore char nbuf[BUFSIZ]; 1491*95c635efSGarrett D'Amore const char *sp, *ep; 1492*95c635efSGarrett D'Amore int sz, i, pretty; 1493*95c635efSGarrett D'Amore 1494*95c635efSGarrett D'Amore pretty = MDOC_SYNPRETTY & n->flags; 1495*95c635efSGarrett D'Amore synopsis_pre(h, n); 1496*95c635efSGarrett D'Amore 1497*95c635efSGarrett D'Amore /* Split apart into type and name. */ 1498*95c635efSGarrett D'Amore assert(n->child->string); 1499*95c635efSGarrett D'Amore sp = n->child->string; 1500*95c635efSGarrett D'Amore 1501*95c635efSGarrett D'Amore ep = strchr(sp, ' '); 1502*95c635efSGarrett D'Amore if (NULL != ep) { 1503*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "ftype"); 1504*95c635efSGarrett D'Amore t = print_otag(h, TAG_I, 1, tag); 1505*95c635efSGarrett D'Amore 1506*95c635efSGarrett D'Amore while (ep) { 1507*95c635efSGarrett D'Amore sz = MIN((int)(ep - sp), BUFSIZ - 1); 1508*95c635efSGarrett D'Amore (void)memcpy(nbuf, sp, (size_t)sz); 1509*95c635efSGarrett D'Amore nbuf[sz] = '\0'; 1510*95c635efSGarrett D'Amore print_text(h, nbuf); 1511*95c635efSGarrett D'Amore sp = ++ep; 1512*95c635efSGarrett D'Amore ep = strchr(sp, ' '); 1513*95c635efSGarrett D'Amore } 1514*95c635efSGarrett D'Amore print_tagq(h, t); 1515*95c635efSGarrett D'Amore } 1516*95c635efSGarrett D'Amore 1517*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "fname"); 1518*95c635efSGarrett D'Amore 1519*95c635efSGarrett D'Amore /* 1520*95c635efSGarrett D'Amore * FIXME: only refer to IDs that we know exist. 1521*95c635efSGarrett D'Amore */ 1522*95c635efSGarrett D'Amore 1523*95c635efSGarrett D'Amore #if 0 1524*95c635efSGarrett D'Amore if (MDOC_SYNPRETTY & n->flags) { 1525*95c635efSGarrett D'Amore nbuf[0] = '\0'; 1526*95c635efSGarrett D'Amore html_idcat(nbuf, sp, BUFSIZ); 1527*95c635efSGarrett D'Amore PAIR_ID_INIT(&tag[1], nbuf); 1528*95c635efSGarrett D'Amore } else { 1529*95c635efSGarrett D'Amore strlcpy(nbuf, "#", BUFSIZ); 1530*95c635efSGarrett D'Amore html_idcat(nbuf, sp, BUFSIZ); 1531*95c635efSGarrett D'Amore PAIR_HREF_INIT(&tag[1], nbuf); 1532*95c635efSGarrett D'Amore } 1533*95c635efSGarrett D'Amore #endif 1534*95c635efSGarrett D'Amore 1535*95c635efSGarrett D'Amore t = print_otag(h, TAG_B, 1, tag); 1536*95c635efSGarrett D'Amore 1537*95c635efSGarrett D'Amore if (sp) { 1538*95c635efSGarrett D'Amore strlcpy(nbuf, sp, BUFSIZ); 1539*95c635efSGarrett D'Amore print_text(h, nbuf); 1540*95c635efSGarrett D'Amore } 1541*95c635efSGarrett D'Amore 1542*95c635efSGarrett D'Amore print_tagq(h, t); 1543*95c635efSGarrett D'Amore 1544*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 1545*95c635efSGarrett D'Amore print_text(h, "("); 1546*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 1547*95c635efSGarrett D'Amore 1548*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "farg"); 1549*95c635efSGarrett D'Amore bufinit(h); 1550*95c635efSGarrett D'Amore bufcat_style(h, "white-space", "nowrap"); 1551*95c635efSGarrett D'Amore PAIR_STYLE_INIT(&tag[1], h); 1552*95c635efSGarrett D'Amore 1553*95c635efSGarrett D'Amore for (n = n->child->next; n; n = n->next) { 1554*95c635efSGarrett D'Amore i = 1; 1555*95c635efSGarrett D'Amore if (MDOC_SYNPRETTY & n->flags) 1556*95c635efSGarrett D'Amore i = 2; 1557*95c635efSGarrett D'Amore t = print_otag(h, TAG_I, i, tag); 1558*95c635efSGarrett D'Amore print_text(h, n->string); 1559*95c635efSGarrett D'Amore print_tagq(h, t); 1560*95c635efSGarrett D'Amore if (n->next) { 1561*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 1562*95c635efSGarrett D'Amore print_text(h, ","); 1563*95c635efSGarrett D'Amore } 1564*95c635efSGarrett D'Amore } 1565*95c635efSGarrett D'Amore 1566*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 1567*95c635efSGarrett D'Amore print_text(h, ")"); 1568*95c635efSGarrett D'Amore 1569*95c635efSGarrett D'Amore if (pretty) { 1570*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 1571*95c635efSGarrett D'Amore print_text(h, ";"); 1572*95c635efSGarrett D'Amore } 1573*95c635efSGarrett D'Amore 1574*95c635efSGarrett D'Amore return(0); 1575*95c635efSGarrett D'Amore } 1576*95c635efSGarrett D'Amore 1577*95c635efSGarrett D'Amore 1578*95c635efSGarrett D'Amore /* ARGSUSED */ 1579*95c635efSGarrett D'Amore static int 1580*95c635efSGarrett D'Amore mdoc_sm_pre(MDOC_ARGS) 1581*95c635efSGarrett D'Amore { 1582*95c635efSGarrett D'Amore 1583*95c635efSGarrett D'Amore assert(n->child && MDOC_TEXT == n->child->type); 1584*95c635efSGarrett D'Amore if (0 == strcmp("on", n->child->string)) { 1585*95c635efSGarrett D'Amore /* 1586*95c635efSGarrett D'Amore * FIXME: no p->col to check. Thus, if we have 1587*95c635efSGarrett D'Amore * .Bd -literal 1588*95c635efSGarrett D'Amore * .Sm off 1589*95c635efSGarrett D'Amore * 1 2 1590*95c635efSGarrett D'Amore * .Sm on 1591*95c635efSGarrett D'Amore * 3 1592*95c635efSGarrett D'Amore * .Ed 1593*95c635efSGarrett D'Amore * the "3" is preceded by a space. 1594*95c635efSGarrett D'Amore */ 1595*95c635efSGarrett D'Amore h->flags &= ~HTML_NOSPACE; 1596*95c635efSGarrett D'Amore h->flags &= ~HTML_NONOSPACE; 1597*95c635efSGarrett D'Amore } else 1598*95c635efSGarrett D'Amore h->flags |= HTML_NONOSPACE; 1599*95c635efSGarrett D'Amore 1600*95c635efSGarrett D'Amore return(0); 1601*95c635efSGarrett D'Amore } 1602*95c635efSGarrett D'Amore 1603*95c635efSGarrett D'Amore /* ARGSUSED */ 1604*95c635efSGarrett D'Amore static int 1605*95c635efSGarrett D'Amore mdoc_pp_pre(MDOC_ARGS) 1606*95c635efSGarrett D'Amore { 1607*95c635efSGarrett D'Amore 1608*95c635efSGarrett D'Amore print_otag(h, TAG_P, 0, NULL); 1609*95c635efSGarrett D'Amore return(0); 1610*95c635efSGarrett D'Amore 1611*95c635efSGarrett D'Amore } 1612*95c635efSGarrett D'Amore 1613*95c635efSGarrett D'Amore /* ARGSUSED */ 1614*95c635efSGarrett D'Amore static int 1615*95c635efSGarrett D'Amore mdoc_sp_pre(MDOC_ARGS) 1616*95c635efSGarrett D'Amore { 1617*95c635efSGarrett D'Amore struct roffsu su; 1618*95c635efSGarrett D'Amore struct htmlpair tag; 1619*95c635efSGarrett D'Amore 1620*95c635efSGarrett D'Amore SCALE_VS_INIT(&su, 1); 1621*95c635efSGarrett D'Amore 1622*95c635efSGarrett D'Amore if (MDOC_sp == n->tok) { 1623*95c635efSGarrett D'Amore if (NULL != (n = n->child)) 1624*95c635efSGarrett D'Amore if ( ! a2roffsu(n->string, &su, SCALE_VS)) 1625*95c635efSGarrett D'Amore SCALE_VS_INIT(&su, atoi(n->string)); 1626*95c635efSGarrett D'Amore } else 1627*95c635efSGarrett D'Amore su.scale = 0; 1628*95c635efSGarrett D'Amore 1629*95c635efSGarrett D'Amore bufinit(h); 1630*95c635efSGarrett D'Amore bufcat_su(h, "height", &su); 1631*95c635efSGarrett D'Amore PAIR_STYLE_INIT(&tag, h); 1632*95c635efSGarrett D'Amore print_otag(h, TAG_DIV, 1, &tag); 1633*95c635efSGarrett D'Amore 1634*95c635efSGarrett D'Amore /* So the div isn't empty: */ 1635*95c635efSGarrett D'Amore print_text(h, "\\~"); 1636*95c635efSGarrett D'Amore 1637*95c635efSGarrett D'Amore return(0); 1638*95c635efSGarrett D'Amore 1639*95c635efSGarrett D'Amore } 1640*95c635efSGarrett D'Amore 1641*95c635efSGarrett D'Amore /* ARGSUSED */ 1642*95c635efSGarrett D'Amore static int 1643*95c635efSGarrett D'Amore mdoc_lk_pre(MDOC_ARGS) 1644*95c635efSGarrett D'Amore { 1645*95c635efSGarrett D'Amore struct htmlpair tag[2]; 1646*95c635efSGarrett D'Amore 1647*95c635efSGarrett D'Amore if (NULL == (n = n->child)) 1648*95c635efSGarrett D'Amore return(0); 1649*95c635efSGarrett D'Amore 1650*95c635efSGarrett D'Amore assert(MDOC_TEXT == n->type); 1651*95c635efSGarrett D'Amore 1652*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "link-ext"); 1653*95c635efSGarrett D'Amore PAIR_HREF_INIT(&tag[1], n->string); 1654*95c635efSGarrett D'Amore 1655*95c635efSGarrett D'Amore print_otag(h, TAG_A, 2, tag); 1656*95c635efSGarrett D'Amore 1657*95c635efSGarrett D'Amore if (NULL == n->next) 1658*95c635efSGarrett D'Amore print_text(h, n->string); 1659*95c635efSGarrett D'Amore 1660*95c635efSGarrett D'Amore for (n = n->next; n; n = n->next) 1661*95c635efSGarrett D'Amore print_text(h, n->string); 1662*95c635efSGarrett D'Amore 1663*95c635efSGarrett D'Amore return(0); 1664*95c635efSGarrett D'Amore } 1665*95c635efSGarrett D'Amore 1666*95c635efSGarrett D'Amore 1667*95c635efSGarrett D'Amore /* ARGSUSED */ 1668*95c635efSGarrett D'Amore static int 1669*95c635efSGarrett D'Amore mdoc_mt_pre(MDOC_ARGS) 1670*95c635efSGarrett D'Amore { 1671*95c635efSGarrett D'Amore struct htmlpair tag[2]; 1672*95c635efSGarrett D'Amore struct tag *t; 1673*95c635efSGarrett D'Amore 1674*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "link-mail"); 1675*95c635efSGarrett D'Amore 1676*95c635efSGarrett D'Amore for (n = n->child; n; n = n->next) { 1677*95c635efSGarrett D'Amore assert(MDOC_TEXT == n->type); 1678*95c635efSGarrett D'Amore 1679*95c635efSGarrett D'Amore bufinit(h); 1680*95c635efSGarrett D'Amore bufcat(h, "mailto:"); 1681*95c635efSGarrett D'Amore bufcat(h, n->string); 1682*95c635efSGarrett D'Amore 1683*95c635efSGarrett D'Amore PAIR_HREF_INIT(&tag[1], h->buf); 1684*95c635efSGarrett D'Amore t = print_otag(h, TAG_A, 2, tag); 1685*95c635efSGarrett D'Amore print_text(h, n->string); 1686*95c635efSGarrett D'Amore print_tagq(h, t); 1687*95c635efSGarrett D'Amore } 1688*95c635efSGarrett D'Amore 1689*95c635efSGarrett D'Amore return(0); 1690*95c635efSGarrett D'Amore } 1691*95c635efSGarrett D'Amore 1692*95c635efSGarrett D'Amore 1693*95c635efSGarrett D'Amore /* ARGSUSED */ 1694*95c635efSGarrett D'Amore static int 1695*95c635efSGarrett D'Amore mdoc_fo_pre(MDOC_ARGS) 1696*95c635efSGarrett D'Amore { 1697*95c635efSGarrett D'Amore struct htmlpair tag; 1698*95c635efSGarrett D'Amore struct tag *t; 1699*95c635efSGarrett D'Amore 1700*95c635efSGarrett D'Amore if (MDOC_BODY == n->type) { 1701*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 1702*95c635efSGarrett D'Amore print_text(h, "("); 1703*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 1704*95c635efSGarrett D'Amore return(1); 1705*95c635efSGarrett D'Amore } else if (MDOC_BLOCK == n->type) { 1706*95c635efSGarrett D'Amore synopsis_pre(h, n); 1707*95c635efSGarrett D'Amore return(1); 1708*95c635efSGarrett D'Amore } 1709*95c635efSGarrett D'Amore 1710*95c635efSGarrett D'Amore /* XXX: we drop non-initial arguments as per groff. */ 1711*95c635efSGarrett D'Amore 1712*95c635efSGarrett D'Amore assert(n->child); 1713*95c635efSGarrett D'Amore assert(n->child->string); 1714*95c635efSGarrett D'Amore 1715*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "fname"); 1716*95c635efSGarrett D'Amore t = print_otag(h, TAG_B, 1, &tag); 1717*95c635efSGarrett D'Amore print_text(h, n->child->string); 1718*95c635efSGarrett D'Amore print_tagq(h, t); 1719*95c635efSGarrett D'Amore return(0); 1720*95c635efSGarrett D'Amore } 1721*95c635efSGarrett D'Amore 1722*95c635efSGarrett D'Amore 1723*95c635efSGarrett D'Amore /* ARGSUSED */ 1724*95c635efSGarrett D'Amore static void 1725*95c635efSGarrett D'Amore mdoc_fo_post(MDOC_ARGS) 1726*95c635efSGarrett D'Amore { 1727*95c635efSGarrett D'Amore 1728*95c635efSGarrett D'Amore if (MDOC_BODY != n->type) 1729*95c635efSGarrett D'Amore return; 1730*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 1731*95c635efSGarrett D'Amore print_text(h, ")"); 1732*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 1733*95c635efSGarrett D'Amore print_text(h, ";"); 1734*95c635efSGarrett D'Amore } 1735*95c635efSGarrett D'Amore 1736*95c635efSGarrett D'Amore 1737*95c635efSGarrett D'Amore /* ARGSUSED */ 1738*95c635efSGarrett D'Amore static int 1739*95c635efSGarrett D'Amore mdoc_in_pre(MDOC_ARGS) 1740*95c635efSGarrett D'Amore { 1741*95c635efSGarrett D'Amore struct tag *t; 1742*95c635efSGarrett D'Amore struct htmlpair tag[2]; 1743*95c635efSGarrett D'Amore int i; 1744*95c635efSGarrett D'Amore 1745*95c635efSGarrett D'Amore synopsis_pre(h, n); 1746*95c635efSGarrett D'Amore 1747*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "includes"); 1748*95c635efSGarrett D'Amore print_otag(h, TAG_B, 1, tag); 1749*95c635efSGarrett D'Amore 1750*95c635efSGarrett D'Amore /* 1751*95c635efSGarrett D'Amore * The first argument of the `In' gets special treatment as 1752*95c635efSGarrett D'Amore * being a linked value. Subsequent values are printed 1753*95c635efSGarrett D'Amore * afterward. groff does similarly. This also handles the case 1754*95c635efSGarrett D'Amore * of no children. 1755*95c635efSGarrett D'Amore */ 1756*95c635efSGarrett D'Amore 1757*95c635efSGarrett D'Amore if (MDOC_SYNPRETTY & n->flags && MDOC_LINE & n->flags) 1758*95c635efSGarrett D'Amore print_text(h, "#include"); 1759*95c635efSGarrett D'Amore 1760*95c635efSGarrett D'Amore print_text(h, "<"); 1761*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 1762*95c635efSGarrett D'Amore 1763*95c635efSGarrett D'Amore if (NULL != (n = n->child)) { 1764*95c635efSGarrett D'Amore assert(MDOC_TEXT == n->type); 1765*95c635efSGarrett D'Amore 1766*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "link-includes"); 1767*95c635efSGarrett D'Amore 1768*95c635efSGarrett D'Amore i = 1; 1769*95c635efSGarrett D'Amore if (h->base_includes) { 1770*95c635efSGarrett D'Amore buffmt_includes(h, n->string); 1771*95c635efSGarrett D'Amore PAIR_HREF_INIT(&tag[i], h->buf); 1772*95c635efSGarrett D'Amore i++; 1773*95c635efSGarrett D'Amore } 1774*95c635efSGarrett D'Amore 1775*95c635efSGarrett D'Amore t = print_otag(h, TAG_A, i, tag); 1776*95c635efSGarrett D'Amore print_text(h, n->string); 1777*95c635efSGarrett D'Amore print_tagq(h, t); 1778*95c635efSGarrett D'Amore 1779*95c635efSGarrett D'Amore n = n->next; 1780*95c635efSGarrett D'Amore } 1781*95c635efSGarrett D'Amore 1782*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 1783*95c635efSGarrett D'Amore print_text(h, ">"); 1784*95c635efSGarrett D'Amore 1785*95c635efSGarrett D'Amore for ( ; n; n = n->next) { 1786*95c635efSGarrett D'Amore assert(MDOC_TEXT == n->type); 1787*95c635efSGarrett D'Amore print_text(h, n->string); 1788*95c635efSGarrett D'Amore } 1789*95c635efSGarrett D'Amore 1790*95c635efSGarrett D'Amore return(0); 1791*95c635efSGarrett D'Amore } 1792*95c635efSGarrett D'Amore 1793*95c635efSGarrett D'Amore 1794*95c635efSGarrett D'Amore /* ARGSUSED */ 1795*95c635efSGarrett D'Amore static int 1796*95c635efSGarrett D'Amore mdoc_ic_pre(MDOC_ARGS) 1797*95c635efSGarrett D'Amore { 1798*95c635efSGarrett D'Amore struct htmlpair tag; 1799*95c635efSGarrett D'Amore 1800*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "cmd"); 1801*95c635efSGarrett D'Amore print_otag(h, TAG_B, 1, &tag); 1802*95c635efSGarrett D'Amore return(1); 1803*95c635efSGarrett D'Amore } 1804*95c635efSGarrett D'Amore 1805*95c635efSGarrett D'Amore 1806*95c635efSGarrett D'Amore /* ARGSUSED */ 1807*95c635efSGarrett D'Amore static int 1808*95c635efSGarrett D'Amore mdoc_rv_pre(MDOC_ARGS) 1809*95c635efSGarrett D'Amore { 1810*95c635efSGarrett D'Amore struct htmlpair tag; 1811*95c635efSGarrett D'Amore struct tag *t; 1812*95c635efSGarrett D'Amore int nchild; 1813*95c635efSGarrett D'Amore 1814*95c635efSGarrett D'Amore if (n->prev) 1815*95c635efSGarrett D'Amore print_otag(h, TAG_BR, 0, NULL); 1816*95c635efSGarrett D'Amore 1817*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "fname"); 1818*95c635efSGarrett D'Amore 1819*95c635efSGarrett D'Amore print_text(h, "The"); 1820*95c635efSGarrett D'Amore 1821*95c635efSGarrett D'Amore nchild = n->nchild; 1822*95c635efSGarrett D'Amore for (n = n->child; n; n = n->next) { 1823*95c635efSGarrett D'Amore assert(MDOC_TEXT == n->type); 1824*95c635efSGarrett D'Amore 1825*95c635efSGarrett D'Amore t = print_otag(h, TAG_B, 1, &tag); 1826*95c635efSGarrett D'Amore print_text(h, n->string); 1827*95c635efSGarrett D'Amore print_tagq(h, t); 1828*95c635efSGarrett D'Amore 1829*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 1830*95c635efSGarrett D'Amore print_text(h, "()"); 1831*95c635efSGarrett D'Amore 1832*95c635efSGarrett D'Amore if (nchild > 2 && n->next) { 1833*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 1834*95c635efSGarrett D'Amore print_text(h, ","); 1835*95c635efSGarrett D'Amore } 1836*95c635efSGarrett D'Amore 1837*95c635efSGarrett D'Amore if (n->next && NULL == n->next->next) 1838*95c635efSGarrett D'Amore print_text(h, "and"); 1839*95c635efSGarrett D'Amore } 1840*95c635efSGarrett D'Amore 1841*95c635efSGarrett D'Amore if (nchild > 1) 1842*95c635efSGarrett D'Amore print_text(h, "functions return"); 1843*95c635efSGarrett D'Amore else 1844*95c635efSGarrett D'Amore print_text(h, "function returns"); 1845*95c635efSGarrett D'Amore 1846*95c635efSGarrett D'Amore print_text(h, "the value 0 if successful; otherwise the value " 1847*95c635efSGarrett D'Amore "-1 is returned and the global variable"); 1848*95c635efSGarrett D'Amore 1849*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "var"); 1850*95c635efSGarrett D'Amore t = print_otag(h, TAG_B, 1, &tag); 1851*95c635efSGarrett D'Amore print_text(h, "errno"); 1852*95c635efSGarrett D'Amore print_tagq(h, t); 1853*95c635efSGarrett D'Amore print_text(h, "is set to indicate the error."); 1854*95c635efSGarrett D'Amore return(0); 1855*95c635efSGarrett D'Amore } 1856*95c635efSGarrett D'Amore 1857*95c635efSGarrett D'Amore 1858*95c635efSGarrett D'Amore /* ARGSUSED */ 1859*95c635efSGarrett D'Amore static int 1860*95c635efSGarrett D'Amore mdoc_va_pre(MDOC_ARGS) 1861*95c635efSGarrett D'Amore { 1862*95c635efSGarrett D'Amore struct htmlpair tag; 1863*95c635efSGarrett D'Amore 1864*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "var"); 1865*95c635efSGarrett D'Amore print_otag(h, TAG_B, 1, &tag); 1866*95c635efSGarrett D'Amore return(1); 1867*95c635efSGarrett D'Amore } 1868*95c635efSGarrett D'Amore 1869*95c635efSGarrett D'Amore 1870*95c635efSGarrett D'Amore /* ARGSUSED */ 1871*95c635efSGarrett D'Amore static int 1872*95c635efSGarrett D'Amore mdoc_ap_pre(MDOC_ARGS) 1873*95c635efSGarrett D'Amore { 1874*95c635efSGarrett D'Amore 1875*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 1876*95c635efSGarrett D'Amore print_text(h, "\\(aq"); 1877*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 1878*95c635efSGarrett D'Amore return(1); 1879*95c635efSGarrett D'Amore } 1880*95c635efSGarrett D'Amore 1881*95c635efSGarrett D'Amore 1882*95c635efSGarrett D'Amore /* ARGSUSED */ 1883*95c635efSGarrett D'Amore static int 1884*95c635efSGarrett D'Amore mdoc_bf_pre(MDOC_ARGS) 1885*95c635efSGarrett D'Amore { 1886*95c635efSGarrett D'Amore struct htmlpair tag[2]; 1887*95c635efSGarrett D'Amore struct roffsu su; 1888*95c635efSGarrett D'Amore 1889*95c635efSGarrett D'Amore if (MDOC_HEAD == n->type) 1890*95c635efSGarrett D'Amore return(0); 1891*95c635efSGarrett D'Amore else if (MDOC_BODY != n->type) 1892*95c635efSGarrett D'Amore return(1); 1893*95c635efSGarrett D'Amore 1894*95c635efSGarrett D'Amore if (FONT_Em == n->norm->Bf.font) 1895*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "emph"); 1896*95c635efSGarrett D'Amore else if (FONT_Sy == n->norm->Bf.font) 1897*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "symb"); 1898*95c635efSGarrett D'Amore else if (FONT_Li == n->norm->Bf.font) 1899*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "lit"); 1900*95c635efSGarrett D'Amore else 1901*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "none"); 1902*95c635efSGarrett D'Amore 1903*95c635efSGarrett D'Amore /* 1904*95c635efSGarrett D'Amore * We want this to be inline-formatted, but needs to be div to 1905*95c635efSGarrett D'Amore * accept block children. 1906*95c635efSGarrett D'Amore */ 1907*95c635efSGarrett D'Amore bufinit(h); 1908*95c635efSGarrett D'Amore bufcat_style(h, "display", "inline"); 1909*95c635efSGarrett D'Amore SCALE_HS_INIT(&su, 1); 1910*95c635efSGarrett D'Amore /* Needs a left-margin for spacing. */ 1911*95c635efSGarrett D'Amore bufcat_su(h, "margin-left", &su); 1912*95c635efSGarrett D'Amore PAIR_STYLE_INIT(&tag[1], h); 1913*95c635efSGarrett D'Amore print_otag(h, TAG_DIV, 2, tag); 1914*95c635efSGarrett D'Amore return(1); 1915*95c635efSGarrett D'Amore } 1916*95c635efSGarrett D'Amore 1917*95c635efSGarrett D'Amore 1918*95c635efSGarrett D'Amore /* ARGSUSED */ 1919*95c635efSGarrett D'Amore static int 1920*95c635efSGarrett D'Amore mdoc_ms_pre(MDOC_ARGS) 1921*95c635efSGarrett D'Amore { 1922*95c635efSGarrett D'Amore struct htmlpair tag; 1923*95c635efSGarrett D'Amore 1924*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "symb"); 1925*95c635efSGarrett D'Amore print_otag(h, TAG_SPAN, 1, &tag); 1926*95c635efSGarrett D'Amore return(1); 1927*95c635efSGarrett D'Amore } 1928*95c635efSGarrett D'Amore 1929*95c635efSGarrett D'Amore 1930*95c635efSGarrett D'Amore /* ARGSUSED */ 1931*95c635efSGarrett D'Amore static int 1932*95c635efSGarrett D'Amore mdoc_igndelim_pre(MDOC_ARGS) 1933*95c635efSGarrett D'Amore { 1934*95c635efSGarrett D'Amore 1935*95c635efSGarrett D'Amore h->flags |= HTML_IGNDELIM; 1936*95c635efSGarrett D'Amore return(1); 1937*95c635efSGarrett D'Amore } 1938*95c635efSGarrett D'Amore 1939*95c635efSGarrett D'Amore 1940*95c635efSGarrett D'Amore /* ARGSUSED */ 1941*95c635efSGarrett D'Amore static void 1942*95c635efSGarrett D'Amore mdoc_pf_post(MDOC_ARGS) 1943*95c635efSGarrett D'Amore { 1944*95c635efSGarrett D'Amore 1945*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 1946*95c635efSGarrett D'Amore } 1947*95c635efSGarrett D'Amore 1948*95c635efSGarrett D'Amore 1949*95c635efSGarrett D'Amore /* ARGSUSED */ 1950*95c635efSGarrett D'Amore static int 1951*95c635efSGarrett D'Amore mdoc_rs_pre(MDOC_ARGS) 1952*95c635efSGarrett D'Amore { 1953*95c635efSGarrett D'Amore struct htmlpair tag; 1954*95c635efSGarrett D'Amore 1955*95c635efSGarrett D'Amore if (MDOC_BLOCK != n->type) 1956*95c635efSGarrett D'Amore return(1); 1957*95c635efSGarrett D'Amore 1958*95c635efSGarrett D'Amore if (n->prev && SEC_SEE_ALSO == n->sec) 1959*95c635efSGarrett D'Amore print_otag(h, TAG_P, 0, NULL); 1960*95c635efSGarrett D'Amore 1961*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "ref"); 1962*95c635efSGarrett D'Amore print_otag(h, TAG_SPAN, 1, &tag); 1963*95c635efSGarrett D'Amore return(1); 1964*95c635efSGarrett D'Amore } 1965*95c635efSGarrett D'Amore 1966*95c635efSGarrett D'Amore 1967*95c635efSGarrett D'Amore 1968*95c635efSGarrett D'Amore /* ARGSUSED */ 1969*95c635efSGarrett D'Amore static int 1970*95c635efSGarrett D'Amore mdoc_li_pre(MDOC_ARGS) 1971*95c635efSGarrett D'Amore { 1972*95c635efSGarrett D'Amore struct htmlpair tag; 1973*95c635efSGarrett D'Amore 1974*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "lit"); 1975*95c635efSGarrett D'Amore print_otag(h, TAG_CODE, 1, &tag); 1976*95c635efSGarrett D'Amore return(1); 1977*95c635efSGarrett D'Amore } 1978*95c635efSGarrett D'Amore 1979*95c635efSGarrett D'Amore 1980*95c635efSGarrett D'Amore /* ARGSUSED */ 1981*95c635efSGarrett D'Amore static int 1982*95c635efSGarrett D'Amore mdoc_sy_pre(MDOC_ARGS) 1983*95c635efSGarrett D'Amore { 1984*95c635efSGarrett D'Amore struct htmlpair tag; 1985*95c635efSGarrett D'Amore 1986*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "symb"); 1987*95c635efSGarrett D'Amore print_otag(h, TAG_SPAN, 1, &tag); 1988*95c635efSGarrett D'Amore return(1); 1989*95c635efSGarrett D'Amore } 1990*95c635efSGarrett D'Amore 1991*95c635efSGarrett D'Amore 1992*95c635efSGarrett D'Amore /* ARGSUSED */ 1993*95c635efSGarrett D'Amore static int 1994*95c635efSGarrett D'Amore mdoc_bt_pre(MDOC_ARGS) 1995*95c635efSGarrett D'Amore { 1996*95c635efSGarrett D'Amore 1997*95c635efSGarrett D'Amore print_text(h, "is currently in beta test."); 1998*95c635efSGarrett D'Amore return(0); 1999*95c635efSGarrett D'Amore } 2000*95c635efSGarrett D'Amore 2001*95c635efSGarrett D'Amore 2002*95c635efSGarrett D'Amore /* ARGSUSED */ 2003*95c635efSGarrett D'Amore static int 2004*95c635efSGarrett D'Amore mdoc_ud_pre(MDOC_ARGS) 2005*95c635efSGarrett D'Amore { 2006*95c635efSGarrett D'Amore 2007*95c635efSGarrett D'Amore print_text(h, "currently under development."); 2008*95c635efSGarrett D'Amore return(0); 2009*95c635efSGarrett D'Amore } 2010*95c635efSGarrett D'Amore 2011*95c635efSGarrett D'Amore 2012*95c635efSGarrett D'Amore /* ARGSUSED */ 2013*95c635efSGarrett D'Amore static int 2014*95c635efSGarrett D'Amore mdoc_lb_pre(MDOC_ARGS) 2015*95c635efSGarrett D'Amore { 2016*95c635efSGarrett D'Amore struct htmlpair tag; 2017*95c635efSGarrett D'Amore 2018*95c635efSGarrett D'Amore if (SEC_LIBRARY == n->sec && MDOC_LINE & n->flags && n->prev) 2019*95c635efSGarrett D'Amore print_otag(h, TAG_BR, 0, NULL); 2020*95c635efSGarrett D'Amore 2021*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "lib"); 2022*95c635efSGarrett D'Amore print_otag(h, TAG_SPAN, 1, &tag); 2023*95c635efSGarrett D'Amore return(1); 2024*95c635efSGarrett D'Amore } 2025*95c635efSGarrett D'Amore 2026*95c635efSGarrett D'Amore 2027*95c635efSGarrett D'Amore /* ARGSUSED */ 2028*95c635efSGarrett D'Amore static int 2029*95c635efSGarrett D'Amore mdoc__x_pre(MDOC_ARGS) 2030*95c635efSGarrett D'Amore { 2031*95c635efSGarrett D'Amore struct htmlpair tag[2]; 2032*95c635efSGarrett D'Amore enum htmltag t; 2033*95c635efSGarrett D'Amore 2034*95c635efSGarrett D'Amore t = TAG_SPAN; 2035*95c635efSGarrett D'Amore 2036*95c635efSGarrett D'Amore switch (n->tok) { 2037*95c635efSGarrett D'Amore case(MDOC__A): 2038*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "ref-auth"); 2039*95c635efSGarrett D'Amore if (n->prev && MDOC__A == n->prev->tok) 2040*95c635efSGarrett D'Amore if (NULL == n->next || MDOC__A != n->next->tok) 2041*95c635efSGarrett D'Amore print_text(h, "and"); 2042*95c635efSGarrett D'Amore break; 2043*95c635efSGarrett D'Amore case(MDOC__B): 2044*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "ref-book"); 2045*95c635efSGarrett D'Amore t = TAG_I; 2046*95c635efSGarrett D'Amore break; 2047*95c635efSGarrett D'Amore case(MDOC__C): 2048*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "ref-city"); 2049*95c635efSGarrett D'Amore break; 2050*95c635efSGarrett D'Amore case(MDOC__D): 2051*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "ref-date"); 2052*95c635efSGarrett D'Amore break; 2053*95c635efSGarrett D'Amore case(MDOC__I): 2054*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "ref-issue"); 2055*95c635efSGarrett D'Amore t = TAG_I; 2056*95c635efSGarrett D'Amore break; 2057*95c635efSGarrett D'Amore case(MDOC__J): 2058*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "ref-jrnl"); 2059*95c635efSGarrett D'Amore t = TAG_I; 2060*95c635efSGarrett D'Amore break; 2061*95c635efSGarrett D'Amore case(MDOC__N): 2062*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "ref-num"); 2063*95c635efSGarrett D'Amore break; 2064*95c635efSGarrett D'Amore case(MDOC__O): 2065*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "ref-opt"); 2066*95c635efSGarrett D'Amore break; 2067*95c635efSGarrett D'Amore case(MDOC__P): 2068*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "ref-page"); 2069*95c635efSGarrett D'Amore break; 2070*95c635efSGarrett D'Amore case(MDOC__Q): 2071*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "ref-corp"); 2072*95c635efSGarrett D'Amore break; 2073*95c635efSGarrett D'Amore case(MDOC__R): 2074*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "ref-rep"); 2075*95c635efSGarrett D'Amore break; 2076*95c635efSGarrett D'Amore case(MDOC__T): 2077*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "ref-title"); 2078*95c635efSGarrett D'Amore break; 2079*95c635efSGarrett D'Amore case(MDOC__U): 2080*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "link-ref"); 2081*95c635efSGarrett D'Amore break; 2082*95c635efSGarrett D'Amore case(MDOC__V): 2083*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag[0], "ref-vol"); 2084*95c635efSGarrett D'Amore break; 2085*95c635efSGarrett D'Amore default: 2086*95c635efSGarrett D'Amore abort(); 2087*95c635efSGarrett D'Amore /* NOTREACHED */ 2088*95c635efSGarrett D'Amore } 2089*95c635efSGarrett D'Amore 2090*95c635efSGarrett D'Amore if (MDOC__U != n->tok) { 2091*95c635efSGarrett D'Amore print_otag(h, t, 1, tag); 2092*95c635efSGarrett D'Amore return(1); 2093*95c635efSGarrett D'Amore } 2094*95c635efSGarrett D'Amore 2095*95c635efSGarrett D'Amore PAIR_HREF_INIT(&tag[1], n->child->string); 2096*95c635efSGarrett D'Amore print_otag(h, TAG_A, 2, tag); 2097*95c635efSGarrett D'Amore 2098*95c635efSGarrett D'Amore return(1); 2099*95c635efSGarrett D'Amore } 2100*95c635efSGarrett D'Amore 2101*95c635efSGarrett D'Amore 2102*95c635efSGarrett D'Amore /* ARGSUSED */ 2103*95c635efSGarrett D'Amore static void 2104*95c635efSGarrett D'Amore mdoc__x_post(MDOC_ARGS) 2105*95c635efSGarrett D'Amore { 2106*95c635efSGarrett D'Amore 2107*95c635efSGarrett D'Amore if (MDOC__A == n->tok && n->next && MDOC__A == n->next->tok) 2108*95c635efSGarrett D'Amore if (NULL == n->next->next || MDOC__A != n->next->next->tok) 2109*95c635efSGarrett D'Amore if (NULL == n->prev || MDOC__A != n->prev->tok) 2110*95c635efSGarrett D'Amore return; 2111*95c635efSGarrett D'Amore 2112*95c635efSGarrett D'Amore /* TODO: %U */ 2113*95c635efSGarrett D'Amore 2114*95c635efSGarrett D'Amore if (NULL == n->parent || MDOC_Rs != n->parent->tok) 2115*95c635efSGarrett D'Amore return; 2116*95c635efSGarrett D'Amore 2117*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 2118*95c635efSGarrett D'Amore print_text(h, n->next ? "," : "."); 2119*95c635efSGarrett D'Amore } 2120*95c635efSGarrett D'Amore 2121*95c635efSGarrett D'Amore 2122*95c635efSGarrett D'Amore /* ARGSUSED */ 2123*95c635efSGarrett D'Amore static int 2124*95c635efSGarrett D'Amore mdoc_bk_pre(MDOC_ARGS) 2125*95c635efSGarrett D'Amore { 2126*95c635efSGarrett D'Amore 2127*95c635efSGarrett D'Amore switch (n->type) { 2128*95c635efSGarrett D'Amore case (MDOC_BLOCK): 2129*95c635efSGarrett D'Amore break; 2130*95c635efSGarrett D'Amore case (MDOC_HEAD): 2131*95c635efSGarrett D'Amore return(0); 2132*95c635efSGarrett D'Amore case (MDOC_BODY): 2133*95c635efSGarrett D'Amore if (n->parent->args || 0 == n->prev->nchild) 2134*95c635efSGarrett D'Amore h->flags |= HTML_PREKEEP; 2135*95c635efSGarrett D'Amore break; 2136*95c635efSGarrett D'Amore default: 2137*95c635efSGarrett D'Amore abort(); 2138*95c635efSGarrett D'Amore /* NOTREACHED */ 2139*95c635efSGarrett D'Amore } 2140*95c635efSGarrett D'Amore 2141*95c635efSGarrett D'Amore return(1); 2142*95c635efSGarrett D'Amore } 2143*95c635efSGarrett D'Amore 2144*95c635efSGarrett D'Amore 2145*95c635efSGarrett D'Amore /* ARGSUSED */ 2146*95c635efSGarrett D'Amore static void 2147*95c635efSGarrett D'Amore mdoc_bk_post(MDOC_ARGS) 2148*95c635efSGarrett D'Amore { 2149*95c635efSGarrett D'Amore 2150*95c635efSGarrett D'Amore if (MDOC_BODY == n->type) 2151*95c635efSGarrett D'Amore h->flags &= ~(HTML_KEEP | HTML_PREKEEP); 2152*95c635efSGarrett D'Amore } 2153*95c635efSGarrett D'Amore 2154*95c635efSGarrett D'Amore 2155*95c635efSGarrett D'Amore /* ARGSUSED */ 2156*95c635efSGarrett D'Amore static int 2157*95c635efSGarrett D'Amore mdoc_quote_pre(MDOC_ARGS) 2158*95c635efSGarrett D'Amore { 2159*95c635efSGarrett D'Amore struct htmlpair tag; 2160*95c635efSGarrett D'Amore 2161*95c635efSGarrett D'Amore if (MDOC_BODY != n->type) 2162*95c635efSGarrett D'Amore return(1); 2163*95c635efSGarrett D'Amore 2164*95c635efSGarrett D'Amore switch (n->tok) { 2165*95c635efSGarrett D'Amore case (MDOC_Ao): 2166*95c635efSGarrett D'Amore /* FALLTHROUGH */ 2167*95c635efSGarrett D'Amore case (MDOC_Aq): 2168*95c635efSGarrett D'Amore print_text(h, "\\(la"); 2169*95c635efSGarrett D'Amore break; 2170*95c635efSGarrett D'Amore case (MDOC_Bro): 2171*95c635efSGarrett D'Amore /* FALLTHROUGH */ 2172*95c635efSGarrett D'Amore case (MDOC_Brq): 2173*95c635efSGarrett D'Amore print_text(h, "\\(lC"); 2174*95c635efSGarrett D'Amore break; 2175*95c635efSGarrett D'Amore case (MDOC_Bo): 2176*95c635efSGarrett D'Amore /* FALLTHROUGH */ 2177*95c635efSGarrett D'Amore case (MDOC_Bq): 2178*95c635efSGarrett D'Amore print_text(h, "\\(lB"); 2179*95c635efSGarrett D'Amore break; 2180*95c635efSGarrett D'Amore case (MDOC_Oo): 2181*95c635efSGarrett D'Amore /* FALLTHROUGH */ 2182*95c635efSGarrett D'Amore case (MDOC_Op): 2183*95c635efSGarrett D'Amore print_text(h, "\\(lB"); 2184*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 2185*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "opt"); 2186*95c635efSGarrett D'Amore print_otag(h, TAG_SPAN, 1, &tag); 2187*95c635efSGarrett D'Amore break; 2188*95c635efSGarrett D'Amore case (MDOC_Eo): 2189*95c635efSGarrett D'Amore break; 2190*95c635efSGarrett D'Amore case (MDOC_Do): 2191*95c635efSGarrett D'Amore /* FALLTHROUGH */ 2192*95c635efSGarrett D'Amore case (MDOC_Dq): 2193*95c635efSGarrett D'Amore /* FALLTHROUGH */ 2194*95c635efSGarrett D'Amore case (MDOC_Qo): 2195*95c635efSGarrett D'Amore /* FALLTHROUGH */ 2196*95c635efSGarrett D'Amore case (MDOC_Qq): 2197*95c635efSGarrett D'Amore print_text(h, "\\(lq"); 2198*95c635efSGarrett D'Amore break; 2199*95c635efSGarrett D'Amore case (MDOC_Po): 2200*95c635efSGarrett D'Amore /* FALLTHROUGH */ 2201*95c635efSGarrett D'Amore case (MDOC_Pq): 2202*95c635efSGarrett D'Amore print_text(h, "("); 2203*95c635efSGarrett D'Amore break; 2204*95c635efSGarrett D'Amore case (MDOC_Ql): 2205*95c635efSGarrett D'Amore print_text(h, "\\(oq"); 2206*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 2207*95c635efSGarrett D'Amore PAIR_CLASS_INIT(&tag, "lit"); 2208*95c635efSGarrett D'Amore print_otag(h, TAG_CODE, 1, &tag); 2209*95c635efSGarrett D'Amore break; 2210*95c635efSGarrett D'Amore case (MDOC_So): 2211*95c635efSGarrett D'Amore /* FALLTHROUGH */ 2212*95c635efSGarrett D'Amore case (MDOC_Sq): 2213*95c635efSGarrett D'Amore print_text(h, "\\(oq"); 2214*95c635efSGarrett D'Amore break; 2215*95c635efSGarrett D'Amore default: 2216*95c635efSGarrett D'Amore abort(); 2217*95c635efSGarrett D'Amore /* NOTREACHED */ 2218*95c635efSGarrett D'Amore } 2219*95c635efSGarrett D'Amore 2220*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 2221*95c635efSGarrett D'Amore return(1); 2222*95c635efSGarrett D'Amore } 2223*95c635efSGarrett D'Amore 2224*95c635efSGarrett D'Amore 2225*95c635efSGarrett D'Amore /* ARGSUSED */ 2226*95c635efSGarrett D'Amore static void 2227*95c635efSGarrett D'Amore mdoc_quote_post(MDOC_ARGS) 2228*95c635efSGarrett D'Amore { 2229*95c635efSGarrett D'Amore 2230*95c635efSGarrett D'Amore if (MDOC_BODY != n->type) 2231*95c635efSGarrett D'Amore return; 2232*95c635efSGarrett D'Amore 2233*95c635efSGarrett D'Amore h->flags |= HTML_NOSPACE; 2234*95c635efSGarrett D'Amore 2235*95c635efSGarrett D'Amore switch (n->tok) { 2236*95c635efSGarrett D'Amore case (MDOC_Ao): 2237*95c635efSGarrett D'Amore /* FALLTHROUGH */ 2238*95c635efSGarrett D'Amore case (MDOC_Aq): 2239*95c635efSGarrett D'Amore print_text(h, "\\(ra"); 2240*95c635efSGarrett D'Amore break; 2241*95c635efSGarrett D'Amore case (MDOC_Bro): 2242*95c635efSGarrett D'Amore /* FALLTHROUGH */ 2243*95c635efSGarrett D'Amore case (MDOC_Brq): 2244*95c635efSGarrett D'Amore print_text(h, "\\(rC"); 2245*95c635efSGarrett D'Amore break; 2246*95c635efSGarrett D'Amore case (MDOC_Oo): 2247*95c635efSGarrett D'Amore /* FALLTHROUGH */ 2248*95c635efSGarrett D'Amore case (MDOC_Op): 2249*95c635efSGarrett D'Amore /* FALLTHROUGH */ 2250*95c635efSGarrett D'Amore case (MDOC_Bo): 2251*95c635efSGarrett D'Amore /* FALLTHROUGH */ 2252*95c635efSGarrett D'Amore case (MDOC_Bq): 2253*95c635efSGarrett D'Amore print_text(h, "\\(rB"); 2254*95c635efSGarrett D'Amore break; 2255*95c635efSGarrett D'Amore case (MDOC_Eo): 2256*95c635efSGarrett D'Amore break; 2257*95c635efSGarrett D'Amore case (MDOC_Qo): 2258*95c635efSGarrett D'Amore /* FALLTHROUGH */ 2259*95c635efSGarrett D'Amore case (MDOC_Qq): 2260*95c635efSGarrett D'Amore /* FALLTHROUGH */ 2261*95c635efSGarrett D'Amore case (MDOC_Do): 2262*95c635efSGarrett D'Amore /* FALLTHROUGH */ 2263*95c635efSGarrett D'Amore case (MDOC_Dq): 2264*95c635efSGarrett D'Amore print_text(h, "\\(rq"); 2265*95c635efSGarrett D'Amore break; 2266*95c635efSGarrett D'Amore case (MDOC_Po): 2267*95c635efSGarrett D'Amore /* FALLTHROUGH */ 2268*95c635efSGarrett D'Amore case (MDOC_Pq): 2269*95c635efSGarrett D'Amore print_text(h, ")"); 2270*95c635efSGarrett D'Amore break; 2271*95c635efSGarrett D'Amore case (MDOC_Ql): 2272*95c635efSGarrett D'Amore /* FALLTHROUGH */ 2273*95c635efSGarrett D'Amore case (MDOC_So): 2274*95c635efSGarrett D'Amore /* FALLTHROUGH */ 2275*95c635efSGarrett D'Amore case (MDOC_Sq): 2276*95c635efSGarrett D'Amore print_text(h, "\\(aq"); 2277*95c635efSGarrett D'Amore break; 2278*95c635efSGarrett D'Amore default: 2279*95c635efSGarrett D'Amore abort(); 2280*95c635efSGarrett D'Amore /* NOTREACHED */ 2281*95c635efSGarrett D'Amore } 2282*95c635efSGarrett D'Amore } 2283*95c635efSGarrett D'Amore 2284*95c635efSGarrett D'Amore 2285