xref: /titanic_52/usr/src/cmd/mandoc/mdoc_html.c (revision 698f87a48e2e945bfe5493ce168e0d0ae1cedd5c)
1*698f87a4SGarrett D'Amore /*	$Id: mdoc_html.c,v 1.186 2013/12/24 20:45:27 schwarze Exp $ */
295c635efSGarrett D'Amore /*
395c635efSGarrett D'Amore  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
495c635efSGarrett D'Amore  *
595c635efSGarrett D'Amore  * Permission to use, copy, modify, and distribute this software for any
695c635efSGarrett D'Amore  * purpose with or without fee is hereby granted, provided that the above
795c635efSGarrett D'Amore  * copyright notice and this permission notice appear in all copies.
895c635efSGarrett D'Amore  *
995c635efSGarrett D'Amore  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1095c635efSGarrett D'Amore  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1195c635efSGarrett D'Amore  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1295c635efSGarrett D'Amore  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1395c635efSGarrett D'Amore  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1495c635efSGarrett D'Amore  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1595c635efSGarrett D'Amore  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1695c635efSGarrett D'Amore  */
1795c635efSGarrett D'Amore #ifdef HAVE_CONFIG_H
1895c635efSGarrett D'Amore #include "config.h"
1995c635efSGarrett D'Amore #endif
2095c635efSGarrett D'Amore 
2195c635efSGarrett D'Amore #include <sys/types.h>
2295c635efSGarrett D'Amore 
2395c635efSGarrett D'Amore #include <assert.h>
2495c635efSGarrett D'Amore #include <ctype.h>
2595c635efSGarrett D'Amore #include <stdio.h>
2695c635efSGarrett D'Amore #include <stdlib.h>
2795c635efSGarrett D'Amore #include <string.h>
2895c635efSGarrett D'Amore #include <unistd.h>
2995c635efSGarrett D'Amore 
3095c635efSGarrett D'Amore #include "mandoc.h"
3195c635efSGarrett D'Amore #include "out.h"
3295c635efSGarrett D'Amore #include "html.h"
3395c635efSGarrett D'Amore #include "mdoc.h"
3495c635efSGarrett D'Amore #include "main.h"
3595c635efSGarrett D'Amore 
3695c635efSGarrett D'Amore #define	INDENT		 5
3795c635efSGarrett D'Amore 
38*698f87a4SGarrett D'Amore #define	MDOC_ARGS	  const struct mdoc_meta *meta, \
3995c635efSGarrett D'Amore 			  const struct mdoc_node *n, \
4095c635efSGarrett D'Amore 			  struct html *h
4195c635efSGarrett D'Amore 
4295c635efSGarrett D'Amore #ifndef MIN
4395c635efSGarrett D'Amore #define	MIN(a,b)	((/*CONSTCOND*/(a)<(b))?(a):(b))
4495c635efSGarrett D'Amore #endif
4595c635efSGarrett D'Amore 
4695c635efSGarrett D'Amore struct	htmlmdoc {
4795c635efSGarrett D'Amore 	int		(*pre)(MDOC_ARGS);
4895c635efSGarrett D'Amore 	void		(*post)(MDOC_ARGS);
4995c635efSGarrett D'Amore };
5095c635efSGarrett D'Amore 
5195c635efSGarrett D'Amore static	void		  print_mdoc(MDOC_ARGS);
5295c635efSGarrett D'Amore static	void		  print_mdoc_head(MDOC_ARGS);
5395c635efSGarrett D'Amore static	void		  print_mdoc_node(MDOC_ARGS);
5495c635efSGarrett D'Amore static	void		  print_mdoc_nodelist(MDOC_ARGS);
5595c635efSGarrett D'Amore static	void	  	  synopsis_pre(struct html *,
5695c635efSGarrett D'Amore 				const struct mdoc_node *);
5795c635efSGarrett D'Amore 
5895c635efSGarrett D'Amore static	void		  a2width(const char *, struct roffsu *);
5995c635efSGarrett D'Amore static	void		  a2offs(const char *, struct roffsu *);
6095c635efSGarrett D'Amore 
6195c635efSGarrett D'Amore static	void		  mdoc_root_post(MDOC_ARGS);
6295c635efSGarrett D'Amore static	int		  mdoc_root_pre(MDOC_ARGS);
6395c635efSGarrett D'Amore 
6495c635efSGarrett D'Amore static	void		  mdoc__x_post(MDOC_ARGS);
6595c635efSGarrett D'Amore static	int		  mdoc__x_pre(MDOC_ARGS);
6695c635efSGarrett D'Amore static	int		  mdoc_ad_pre(MDOC_ARGS);
6795c635efSGarrett D'Amore static	int		  mdoc_an_pre(MDOC_ARGS);
6895c635efSGarrett D'Amore static	int		  mdoc_ap_pre(MDOC_ARGS);
6995c635efSGarrett D'Amore static	int		  mdoc_ar_pre(MDOC_ARGS);
7095c635efSGarrett D'Amore static	int		  mdoc_bd_pre(MDOC_ARGS);
7195c635efSGarrett D'Amore static	int		  mdoc_bf_pre(MDOC_ARGS);
7295c635efSGarrett D'Amore static	void		  mdoc_bk_post(MDOC_ARGS);
7395c635efSGarrett D'Amore static	int		  mdoc_bk_pre(MDOC_ARGS);
7495c635efSGarrett D'Amore static	int		  mdoc_bl_pre(MDOC_ARGS);
7595c635efSGarrett D'Amore static	int		  mdoc_bt_pre(MDOC_ARGS);
7695c635efSGarrett D'Amore static	int		  mdoc_bx_pre(MDOC_ARGS);
7795c635efSGarrett D'Amore static	int		  mdoc_cd_pre(MDOC_ARGS);
7895c635efSGarrett D'Amore static	int		  mdoc_d1_pre(MDOC_ARGS);
7995c635efSGarrett D'Amore static	int		  mdoc_dv_pre(MDOC_ARGS);
8095c635efSGarrett D'Amore static	int		  mdoc_fa_pre(MDOC_ARGS);
8195c635efSGarrett D'Amore static	int		  mdoc_fd_pre(MDOC_ARGS);
8295c635efSGarrett D'Amore static	int		  mdoc_fl_pre(MDOC_ARGS);
8395c635efSGarrett D'Amore static	int		  mdoc_fn_pre(MDOC_ARGS);
8495c635efSGarrett D'Amore static	int		  mdoc_ft_pre(MDOC_ARGS);
8595c635efSGarrett D'Amore static	int		  mdoc_em_pre(MDOC_ARGS);
8695c635efSGarrett D'Amore static	int		  mdoc_er_pre(MDOC_ARGS);
8795c635efSGarrett D'Amore static	int		  mdoc_ev_pre(MDOC_ARGS);
8895c635efSGarrett D'Amore static	int		  mdoc_ex_pre(MDOC_ARGS);
8995c635efSGarrett D'Amore static	void		  mdoc_fo_post(MDOC_ARGS);
9095c635efSGarrett D'Amore static	int		  mdoc_fo_pre(MDOC_ARGS);
9195c635efSGarrett D'Amore static	int		  mdoc_ic_pre(MDOC_ARGS);
9295c635efSGarrett D'Amore static	int		  mdoc_igndelim_pre(MDOC_ARGS);
9395c635efSGarrett D'Amore static	int		  mdoc_in_pre(MDOC_ARGS);
9495c635efSGarrett D'Amore static	int		  mdoc_it_pre(MDOC_ARGS);
9595c635efSGarrett D'Amore static	int		  mdoc_lb_pre(MDOC_ARGS);
9695c635efSGarrett D'Amore static	int		  mdoc_li_pre(MDOC_ARGS);
9795c635efSGarrett D'Amore static	int		  mdoc_lk_pre(MDOC_ARGS);
9895c635efSGarrett D'Amore static	int		  mdoc_mt_pre(MDOC_ARGS);
9995c635efSGarrett D'Amore static	int		  mdoc_ms_pre(MDOC_ARGS);
10095c635efSGarrett D'Amore static	int		  mdoc_nd_pre(MDOC_ARGS);
10195c635efSGarrett D'Amore static	int		  mdoc_nm_pre(MDOC_ARGS);
10295c635efSGarrett D'Amore static	int		  mdoc_ns_pre(MDOC_ARGS);
10395c635efSGarrett D'Amore static	int		  mdoc_pa_pre(MDOC_ARGS);
10495c635efSGarrett D'Amore static	void		  mdoc_pf_post(MDOC_ARGS);
10595c635efSGarrett D'Amore static	int		  mdoc_pp_pre(MDOC_ARGS);
10695c635efSGarrett D'Amore static	void		  mdoc_quote_post(MDOC_ARGS);
10795c635efSGarrett D'Amore static	int		  mdoc_quote_pre(MDOC_ARGS);
10895c635efSGarrett D'Amore static	int		  mdoc_rs_pre(MDOC_ARGS);
10995c635efSGarrett D'Amore static	int		  mdoc_rv_pre(MDOC_ARGS);
11095c635efSGarrett D'Amore static	int		  mdoc_sh_pre(MDOC_ARGS);
11195c635efSGarrett D'Amore static	int		  mdoc_sm_pre(MDOC_ARGS);
11295c635efSGarrett D'Amore static	int		  mdoc_sp_pre(MDOC_ARGS);
11395c635efSGarrett D'Amore static	int		  mdoc_ss_pre(MDOC_ARGS);
11495c635efSGarrett D'Amore static	int		  mdoc_sx_pre(MDOC_ARGS);
11595c635efSGarrett D'Amore static	int		  mdoc_sy_pre(MDOC_ARGS);
11695c635efSGarrett D'Amore static	int		  mdoc_ud_pre(MDOC_ARGS);
11795c635efSGarrett D'Amore static	int		  mdoc_va_pre(MDOC_ARGS);
11895c635efSGarrett D'Amore static	int		  mdoc_vt_pre(MDOC_ARGS);
11995c635efSGarrett D'Amore static	int		  mdoc_xr_pre(MDOC_ARGS);
12095c635efSGarrett D'Amore static	int		  mdoc_xx_pre(MDOC_ARGS);
12195c635efSGarrett D'Amore 
12295c635efSGarrett D'Amore static	const struct htmlmdoc mdocs[MDOC_MAX] = {
12395c635efSGarrett D'Amore 	{mdoc_ap_pre, NULL}, /* Ap */
12495c635efSGarrett D'Amore 	{NULL, NULL}, /* Dd */
12595c635efSGarrett D'Amore 	{NULL, NULL}, /* Dt */
12695c635efSGarrett D'Amore 	{NULL, NULL}, /* Os */
12795c635efSGarrett D'Amore 	{mdoc_sh_pre, NULL }, /* Sh */
12895c635efSGarrett D'Amore 	{mdoc_ss_pre, NULL }, /* Ss */
12995c635efSGarrett D'Amore 	{mdoc_pp_pre, NULL}, /* Pp */
13095c635efSGarrett D'Amore 	{mdoc_d1_pre, NULL}, /* D1 */
13195c635efSGarrett D'Amore 	{mdoc_d1_pre, NULL}, /* Dl */
13295c635efSGarrett D'Amore 	{mdoc_bd_pre, NULL}, /* Bd */
13395c635efSGarrett D'Amore 	{NULL, NULL}, /* Ed */
13495c635efSGarrett D'Amore 	{mdoc_bl_pre, NULL}, /* Bl */
13595c635efSGarrett D'Amore 	{NULL, NULL}, /* El */
13695c635efSGarrett D'Amore 	{mdoc_it_pre, NULL}, /* It */
13795c635efSGarrett D'Amore 	{mdoc_ad_pre, NULL}, /* Ad */
13895c635efSGarrett D'Amore 	{mdoc_an_pre, NULL}, /* An */
13995c635efSGarrett D'Amore 	{mdoc_ar_pre, NULL}, /* Ar */
14095c635efSGarrett D'Amore 	{mdoc_cd_pre, NULL}, /* Cd */
14195c635efSGarrett D'Amore 	{mdoc_fl_pre, NULL}, /* Cm */
14295c635efSGarrett D'Amore 	{mdoc_dv_pre, NULL}, /* Dv */
14395c635efSGarrett D'Amore 	{mdoc_er_pre, NULL}, /* Er */
14495c635efSGarrett D'Amore 	{mdoc_ev_pre, NULL}, /* Ev */
14595c635efSGarrett D'Amore 	{mdoc_ex_pre, NULL}, /* Ex */
14695c635efSGarrett D'Amore 	{mdoc_fa_pre, NULL}, /* Fa */
14795c635efSGarrett D'Amore 	{mdoc_fd_pre, NULL}, /* Fd */
14895c635efSGarrett D'Amore 	{mdoc_fl_pre, NULL}, /* Fl */
14995c635efSGarrett D'Amore 	{mdoc_fn_pre, NULL}, /* Fn */
15095c635efSGarrett D'Amore 	{mdoc_ft_pre, NULL}, /* Ft */
15195c635efSGarrett D'Amore 	{mdoc_ic_pre, NULL}, /* Ic */
15295c635efSGarrett D'Amore 	{mdoc_in_pre, NULL}, /* In */
15395c635efSGarrett D'Amore 	{mdoc_li_pre, NULL}, /* Li */
15495c635efSGarrett D'Amore 	{mdoc_nd_pre, NULL}, /* Nd */
15595c635efSGarrett D'Amore 	{mdoc_nm_pre, NULL}, /* Nm */
15695c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Op */
15795c635efSGarrett D'Amore 	{NULL, NULL}, /* Ot */
15895c635efSGarrett D'Amore 	{mdoc_pa_pre, NULL}, /* Pa */
15995c635efSGarrett D'Amore 	{mdoc_rv_pre, NULL}, /* Rv */
16095c635efSGarrett D'Amore 	{NULL, NULL}, /* St */
16195c635efSGarrett D'Amore 	{mdoc_va_pre, NULL}, /* Va */
16295c635efSGarrett D'Amore 	{mdoc_vt_pre, NULL}, /* Vt */
16395c635efSGarrett D'Amore 	{mdoc_xr_pre, NULL}, /* Xr */
16495c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %A */
16595c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %B */
16695c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %D */
16795c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %I */
16895c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %J */
16995c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %N */
17095c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %O */
17195c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %P */
17295c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %R */
17395c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %T */
17495c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %V */
17595c635efSGarrett D'Amore 	{NULL, NULL}, /* Ac */
17695c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Ao */
17795c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Aq */
17895c635efSGarrett D'Amore 	{NULL, NULL}, /* At */
17995c635efSGarrett D'Amore 	{NULL, NULL}, /* Bc */
18095c635efSGarrett D'Amore 	{mdoc_bf_pre, NULL}, /* Bf */
18195c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Bo */
18295c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Bq */
18395c635efSGarrett D'Amore 	{mdoc_xx_pre, NULL}, /* Bsx */
18495c635efSGarrett D'Amore 	{mdoc_bx_pre, NULL}, /* Bx */
18595c635efSGarrett D'Amore 	{NULL, NULL}, /* Db */
18695c635efSGarrett D'Amore 	{NULL, NULL}, /* Dc */
18795c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Do */
18895c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Dq */
18995c635efSGarrett D'Amore 	{NULL, NULL}, /* Ec */ /* FIXME: no space */
19095c635efSGarrett D'Amore 	{NULL, NULL}, /* Ef */
19195c635efSGarrett D'Amore 	{mdoc_em_pre, NULL}, /* Em */
19295c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Eo */
19395c635efSGarrett D'Amore 	{mdoc_xx_pre, NULL}, /* Fx */
19495c635efSGarrett D'Amore 	{mdoc_ms_pre, NULL}, /* Ms */
19595c635efSGarrett D'Amore 	{mdoc_igndelim_pre, NULL}, /* No */
19695c635efSGarrett D'Amore 	{mdoc_ns_pre, NULL}, /* Ns */
19795c635efSGarrett D'Amore 	{mdoc_xx_pre, NULL}, /* Nx */
19895c635efSGarrett D'Amore 	{mdoc_xx_pre, NULL}, /* Ox */
19995c635efSGarrett D'Amore 	{NULL, NULL}, /* Pc */
20095c635efSGarrett D'Amore 	{mdoc_igndelim_pre, mdoc_pf_post}, /* Pf */
20195c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Po */
20295c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Pq */
20395c635efSGarrett D'Amore 	{NULL, NULL}, /* Qc */
20495c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Ql */
20595c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Qo */
20695c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Qq */
20795c635efSGarrett D'Amore 	{NULL, NULL}, /* Re */
20895c635efSGarrett D'Amore 	{mdoc_rs_pre, NULL}, /* Rs */
20995c635efSGarrett D'Amore 	{NULL, NULL}, /* Sc */
21095c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* So */
21195c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Sq */
21295c635efSGarrett D'Amore 	{mdoc_sm_pre, NULL}, /* Sm */
21395c635efSGarrett D'Amore 	{mdoc_sx_pre, NULL}, /* Sx */
21495c635efSGarrett D'Amore 	{mdoc_sy_pre, NULL}, /* Sy */
21595c635efSGarrett D'Amore 	{NULL, NULL}, /* Tn */
21695c635efSGarrett D'Amore 	{mdoc_xx_pre, NULL}, /* Ux */
21795c635efSGarrett D'Amore 	{NULL, NULL}, /* Xc */
21895c635efSGarrett D'Amore 	{NULL, NULL}, /* Xo */
21995c635efSGarrett D'Amore 	{mdoc_fo_pre, mdoc_fo_post}, /* Fo */
22095c635efSGarrett D'Amore 	{NULL, NULL}, /* Fc */
22195c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Oo */
22295c635efSGarrett D'Amore 	{NULL, NULL}, /* Oc */
22395c635efSGarrett D'Amore 	{mdoc_bk_pre, mdoc_bk_post}, /* Bk */
22495c635efSGarrett D'Amore 	{NULL, NULL}, /* Ek */
22595c635efSGarrett D'Amore 	{mdoc_bt_pre, NULL}, /* Bt */
22695c635efSGarrett D'Amore 	{NULL, NULL}, /* Hf */
22795c635efSGarrett D'Amore 	{NULL, NULL}, /* Fr */
22895c635efSGarrett D'Amore 	{mdoc_ud_pre, NULL}, /* Ud */
22995c635efSGarrett D'Amore 	{mdoc_lb_pre, NULL}, /* Lb */
23095c635efSGarrett D'Amore 	{mdoc_pp_pre, NULL}, /* Lp */
23195c635efSGarrett D'Amore 	{mdoc_lk_pre, NULL}, /* Lk */
23295c635efSGarrett D'Amore 	{mdoc_mt_pre, NULL}, /* Mt */
23395c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Brq */
23495c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Bro */
23595c635efSGarrett D'Amore 	{NULL, NULL}, /* Brc */
23695c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %C */
23795c635efSGarrett D'Amore 	{NULL, NULL}, /* Es */  /* TODO */
23895c635efSGarrett D'Amore 	{NULL, NULL}, /* En */  /* TODO */
23995c635efSGarrett D'Amore 	{mdoc_xx_pre, NULL}, /* Dx */
24095c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %Q */
24195c635efSGarrett D'Amore 	{mdoc_sp_pre, NULL}, /* br */
24295c635efSGarrett D'Amore 	{mdoc_sp_pre, NULL}, /* sp */
24395c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %U */
24495c635efSGarrett D'Amore 	{NULL, NULL}, /* Ta */
24595c635efSGarrett D'Amore };
24695c635efSGarrett D'Amore 
24795c635efSGarrett D'Amore static	const char * const lists[LIST_MAX] = {
24895c635efSGarrett D'Amore 	NULL,
24995c635efSGarrett D'Amore 	"list-bul",
25095c635efSGarrett D'Amore 	"list-col",
25195c635efSGarrett D'Amore 	"list-dash",
25295c635efSGarrett D'Amore 	"list-diag",
25395c635efSGarrett D'Amore 	"list-enum",
25495c635efSGarrett D'Amore 	"list-hang",
25595c635efSGarrett D'Amore 	"list-hyph",
25695c635efSGarrett D'Amore 	"list-inset",
25795c635efSGarrett D'Amore 	"list-item",
25895c635efSGarrett D'Amore 	"list-ohang",
25995c635efSGarrett D'Amore 	"list-tag"
26095c635efSGarrett D'Amore };
26195c635efSGarrett D'Amore 
26295c635efSGarrett D'Amore void
263*698f87a4SGarrett D'Amore html_mdoc(void *arg, const struct mdoc *mdoc)
26495c635efSGarrett D'Amore {
26595c635efSGarrett D'Amore 
266*698f87a4SGarrett D'Amore 	print_mdoc(mdoc_meta(mdoc), mdoc_node(mdoc),
267*698f87a4SGarrett D'Amore 			(struct html *)arg);
26895c635efSGarrett D'Amore 	putchar('\n');
26995c635efSGarrett D'Amore }
27095c635efSGarrett D'Amore 
27195c635efSGarrett D'Amore 
27295c635efSGarrett D'Amore /*
27395c635efSGarrett D'Amore  * Calculate the scaling unit passed in a `-width' argument.  This uses
27495c635efSGarrett D'Amore  * either a native scaling unit (e.g., 1i, 2m) or the string length of
27595c635efSGarrett D'Amore  * the value.
27695c635efSGarrett D'Amore  */
27795c635efSGarrett D'Amore static void
27895c635efSGarrett D'Amore a2width(const char *p, struct roffsu *su)
27995c635efSGarrett D'Amore {
28095c635efSGarrett D'Amore 
28195c635efSGarrett D'Amore 	if ( ! a2roffsu(p, su, SCALE_MAX)) {
28295c635efSGarrett D'Amore 		su->unit = SCALE_BU;
28395c635efSGarrett D'Amore 		su->scale = html_strlen(p);
28495c635efSGarrett D'Amore 	}
28595c635efSGarrett D'Amore }
28695c635efSGarrett D'Amore 
28795c635efSGarrett D'Amore 
28895c635efSGarrett D'Amore /*
28995c635efSGarrett D'Amore  * See the same function in mdoc_term.c for documentation.
29095c635efSGarrett D'Amore  */
29195c635efSGarrett D'Amore static void
29295c635efSGarrett D'Amore synopsis_pre(struct html *h, const struct mdoc_node *n)
29395c635efSGarrett D'Amore {
29495c635efSGarrett D'Amore 
29595c635efSGarrett D'Amore 	if (NULL == n->prev || ! (MDOC_SYNPRETTY & n->flags))
29695c635efSGarrett D'Amore 		return;
29795c635efSGarrett D'Amore 
29895c635efSGarrett D'Amore 	if (n->prev->tok == n->tok &&
29995c635efSGarrett D'Amore 			MDOC_Fo != n->tok &&
30095c635efSGarrett D'Amore 			MDOC_Ft != n->tok &&
30195c635efSGarrett D'Amore 			MDOC_Fn != n->tok) {
30295c635efSGarrett D'Amore 		print_otag(h, TAG_BR, 0, NULL);
30395c635efSGarrett D'Amore 		return;
30495c635efSGarrett D'Amore 	}
30595c635efSGarrett D'Amore 
30695c635efSGarrett D'Amore 	switch (n->prev->tok) {
30795c635efSGarrett D'Amore 	case (MDOC_Fd):
30895c635efSGarrett D'Amore 		/* FALLTHROUGH */
30995c635efSGarrett D'Amore 	case (MDOC_Fn):
31095c635efSGarrett D'Amore 		/* FALLTHROUGH */
31195c635efSGarrett D'Amore 	case (MDOC_Fo):
31295c635efSGarrett D'Amore 		/* FALLTHROUGH */
31395c635efSGarrett D'Amore 	case (MDOC_In):
31495c635efSGarrett D'Amore 		/* FALLTHROUGH */
31595c635efSGarrett D'Amore 	case (MDOC_Vt):
31695c635efSGarrett D'Amore 		print_otag(h, TAG_P, 0, NULL);
31795c635efSGarrett D'Amore 		break;
31895c635efSGarrett D'Amore 	case (MDOC_Ft):
31995c635efSGarrett D'Amore 		if (MDOC_Fn != n->tok && MDOC_Fo != n->tok) {
32095c635efSGarrett D'Amore 			print_otag(h, TAG_P, 0, NULL);
32195c635efSGarrett D'Amore 			break;
32295c635efSGarrett D'Amore 		}
32395c635efSGarrett D'Amore 		/* FALLTHROUGH */
32495c635efSGarrett D'Amore 	default:
32595c635efSGarrett D'Amore 		print_otag(h, TAG_BR, 0, NULL);
32695c635efSGarrett D'Amore 		break;
32795c635efSGarrett D'Amore 	}
32895c635efSGarrett D'Amore }
32995c635efSGarrett D'Amore 
33095c635efSGarrett D'Amore 
33195c635efSGarrett D'Amore /*
33295c635efSGarrett D'Amore  * Calculate the scaling unit passed in an `-offset' argument.  This
33395c635efSGarrett D'Amore  * uses either a native scaling unit (e.g., 1i, 2m), one of a set of
33495c635efSGarrett D'Amore  * predefined strings (indent, etc.), or the string length of the value.
33595c635efSGarrett D'Amore  */
33695c635efSGarrett D'Amore static void
33795c635efSGarrett D'Amore a2offs(const char *p, struct roffsu *su)
33895c635efSGarrett D'Amore {
33995c635efSGarrett D'Amore 
34095c635efSGarrett D'Amore 	/* FIXME: "right"? */
34195c635efSGarrett D'Amore 
34295c635efSGarrett D'Amore 	if (0 == strcmp(p, "left"))
34395c635efSGarrett D'Amore 		SCALE_HS_INIT(su, 0);
34495c635efSGarrett D'Amore 	else if (0 == strcmp(p, "indent"))
34595c635efSGarrett D'Amore 		SCALE_HS_INIT(su, INDENT);
34695c635efSGarrett D'Amore 	else if (0 == strcmp(p, "indent-two"))
34795c635efSGarrett D'Amore 		SCALE_HS_INIT(su, INDENT * 2);
34895c635efSGarrett D'Amore 	else if ( ! a2roffsu(p, su, SCALE_MAX))
34995c635efSGarrett D'Amore 		SCALE_HS_INIT(su, html_strlen(p));
35095c635efSGarrett D'Amore }
35195c635efSGarrett D'Amore 
35295c635efSGarrett D'Amore 
35395c635efSGarrett D'Amore static void
35495c635efSGarrett D'Amore print_mdoc(MDOC_ARGS)
35595c635efSGarrett D'Amore {
35695c635efSGarrett D'Amore 	struct tag	*t, *tt;
35795c635efSGarrett D'Amore 	struct htmlpair	 tag;
35895c635efSGarrett D'Amore 
35995c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "mandoc");
36095c635efSGarrett D'Amore 
36195c635efSGarrett D'Amore 	if ( ! (HTML_FRAGMENT & h->oflags)) {
36295c635efSGarrett D'Amore 		print_gen_decls(h);
36395c635efSGarrett D'Amore 		t = print_otag(h, TAG_HTML, 0, NULL);
36495c635efSGarrett D'Amore 		tt = print_otag(h, TAG_HEAD, 0, NULL);
365*698f87a4SGarrett D'Amore 		print_mdoc_head(meta, n, h);
36695c635efSGarrett D'Amore 		print_tagq(h, tt);
36795c635efSGarrett D'Amore 		print_otag(h, TAG_BODY, 0, NULL);
36895c635efSGarrett D'Amore 		print_otag(h, TAG_DIV, 1, &tag);
36995c635efSGarrett D'Amore 	} else
37095c635efSGarrett D'Amore 		t = print_otag(h, TAG_DIV, 1, &tag);
37195c635efSGarrett D'Amore 
372*698f87a4SGarrett D'Amore 	print_mdoc_nodelist(meta, n, h);
37395c635efSGarrett D'Amore 	print_tagq(h, t);
37495c635efSGarrett D'Amore }
37595c635efSGarrett D'Amore 
37695c635efSGarrett D'Amore 
37795c635efSGarrett D'Amore /* ARGSUSED */
37895c635efSGarrett D'Amore static void
37995c635efSGarrett D'Amore print_mdoc_head(MDOC_ARGS)
38095c635efSGarrett D'Amore {
38195c635efSGarrett D'Amore 
38295c635efSGarrett D'Amore 	print_gen_head(h);
38395c635efSGarrett D'Amore 	bufinit(h);
384*698f87a4SGarrett D'Amore 	bufcat_fmt(h, "%s(%s)", meta->title, meta->msec);
38595c635efSGarrett D'Amore 
386*698f87a4SGarrett D'Amore 	if (meta->arch)
387*698f87a4SGarrett D'Amore 		bufcat_fmt(h, " (%s)", meta->arch);
38895c635efSGarrett D'Amore 
38995c635efSGarrett D'Amore 	print_otag(h, TAG_TITLE, 0, NULL);
39095c635efSGarrett D'Amore 	print_text(h, h->buf);
39195c635efSGarrett D'Amore }
39295c635efSGarrett D'Amore 
39395c635efSGarrett D'Amore 
39495c635efSGarrett D'Amore static void
39595c635efSGarrett D'Amore print_mdoc_nodelist(MDOC_ARGS)
39695c635efSGarrett D'Amore {
39795c635efSGarrett D'Amore 
398*698f87a4SGarrett D'Amore 	print_mdoc_node(meta, n, h);
39995c635efSGarrett D'Amore 	if (n->next)
400*698f87a4SGarrett D'Amore 		print_mdoc_nodelist(meta, n->next, h);
40195c635efSGarrett D'Amore }
40295c635efSGarrett D'Amore 
40395c635efSGarrett D'Amore 
40495c635efSGarrett D'Amore static void
40595c635efSGarrett D'Amore print_mdoc_node(MDOC_ARGS)
40695c635efSGarrett D'Amore {
40795c635efSGarrett D'Amore 	int		 child;
40895c635efSGarrett D'Amore 	struct tag	*t;
40995c635efSGarrett D'Amore 
41095c635efSGarrett D'Amore 	child = 1;
41195c635efSGarrett D'Amore 	t = h->tags.head;
41295c635efSGarrett D'Amore 
41395c635efSGarrett D'Amore 	switch (n->type) {
41495c635efSGarrett D'Amore 	case (MDOC_ROOT):
415*698f87a4SGarrett D'Amore 		child = mdoc_root_pre(meta, n, h);
41695c635efSGarrett D'Amore 		break;
41795c635efSGarrett D'Amore 	case (MDOC_TEXT):
41895c635efSGarrett D'Amore 		/* No tables in this mode... */
41995c635efSGarrett D'Amore 		assert(NULL == h->tblt);
42095c635efSGarrett D'Amore 
42195c635efSGarrett D'Amore 		/*
42295c635efSGarrett D'Amore 		 * Make sure that if we're in a literal mode already
42395c635efSGarrett D'Amore 		 * (i.e., within a <PRE>) don't print the newline.
42495c635efSGarrett D'Amore 		 */
42595c635efSGarrett D'Amore 		if (' ' == *n->string && MDOC_LINE & n->flags)
42695c635efSGarrett D'Amore 			if ( ! (HTML_LITERAL & h->flags))
42795c635efSGarrett D'Amore 				print_otag(h, TAG_BR, 0, NULL);
42895c635efSGarrett D'Amore 		if (MDOC_DELIMC & n->flags)
42995c635efSGarrett D'Amore 			h->flags |= HTML_NOSPACE;
43095c635efSGarrett D'Amore 		print_text(h, n->string);
43195c635efSGarrett D'Amore 		if (MDOC_DELIMO & n->flags)
43295c635efSGarrett D'Amore 			h->flags |= HTML_NOSPACE;
43395c635efSGarrett D'Amore 		return;
43495c635efSGarrett D'Amore 	case (MDOC_EQN):
43595c635efSGarrett D'Amore 		print_eqn(h, n->eqn);
43695c635efSGarrett D'Amore 		break;
43795c635efSGarrett D'Amore 	case (MDOC_TBL):
43895c635efSGarrett D'Amore 		/*
43995c635efSGarrett D'Amore 		 * This will take care of initialising all of the table
44095c635efSGarrett D'Amore 		 * state data for the first table, then tearing it down
44195c635efSGarrett D'Amore 		 * for the last one.
44295c635efSGarrett D'Amore 		 */
44395c635efSGarrett D'Amore 		print_tbl(h, n->span);
44495c635efSGarrett D'Amore 		return;
44595c635efSGarrett D'Amore 	default:
44695c635efSGarrett D'Amore 		/*
44795c635efSGarrett D'Amore 		 * Close out the current table, if it's open, and unset
44895c635efSGarrett D'Amore 		 * the "meta" table state.  This will be reopened on the
44995c635efSGarrett D'Amore 		 * next table element.
45095c635efSGarrett D'Amore 		 */
45195c635efSGarrett D'Amore 		if (h->tblt) {
45295c635efSGarrett D'Amore 			print_tblclose(h);
45395c635efSGarrett D'Amore 			t = h->tags.head;
45495c635efSGarrett D'Amore 		}
45595c635efSGarrett D'Amore 
45695c635efSGarrett D'Amore 		assert(NULL == h->tblt);
45795c635efSGarrett D'Amore 		if (mdocs[n->tok].pre && ENDBODY_NOT == n->end)
458*698f87a4SGarrett D'Amore 			child = (*mdocs[n->tok].pre)(meta, n, h);
45995c635efSGarrett D'Amore 		break;
46095c635efSGarrett D'Amore 	}
46195c635efSGarrett D'Amore 
46295c635efSGarrett D'Amore 	if (HTML_KEEP & h->flags) {
463*698f87a4SGarrett D'Amore 		if (n->prev ? (n->prev->lastline != n->line) :
464*698f87a4SGarrett D'Amore 		    (n->parent && n->parent->line != n->line)) {
46595c635efSGarrett D'Amore 			h->flags &= ~HTML_KEEP;
46695c635efSGarrett D'Amore 			h->flags |= HTML_PREKEEP;
46795c635efSGarrett D'Amore 		}
46895c635efSGarrett D'Amore 	}
46995c635efSGarrett D'Amore 
47095c635efSGarrett D'Amore 	if (child && n->child)
471*698f87a4SGarrett D'Amore 		print_mdoc_nodelist(meta, n->child, h);
47295c635efSGarrett D'Amore 
47395c635efSGarrett D'Amore 	print_stagq(h, t);
47495c635efSGarrett D'Amore 
47595c635efSGarrett D'Amore 	switch (n->type) {
47695c635efSGarrett D'Amore 	case (MDOC_ROOT):
477*698f87a4SGarrett D'Amore 		mdoc_root_post(meta, n, h);
47895c635efSGarrett D'Amore 		break;
47995c635efSGarrett D'Amore 	case (MDOC_EQN):
48095c635efSGarrett D'Amore 		break;
48195c635efSGarrett D'Amore 	default:
48295c635efSGarrett D'Amore 		if (mdocs[n->tok].post && ENDBODY_NOT == n->end)
483*698f87a4SGarrett D'Amore 			(*mdocs[n->tok].post)(meta, n, h);
48495c635efSGarrett D'Amore 		break;
48595c635efSGarrett D'Amore 	}
48695c635efSGarrett D'Amore }
48795c635efSGarrett D'Amore 
48895c635efSGarrett D'Amore /* ARGSUSED */
48995c635efSGarrett D'Amore static void
49095c635efSGarrett D'Amore mdoc_root_post(MDOC_ARGS)
49195c635efSGarrett D'Amore {
49295c635efSGarrett D'Amore 	struct htmlpair	 tag[3];
49395c635efSGarrett D'Amore 	struct tag	*t, *tt;
49495c635efSGarrett D'Amore 
49595c635efSGarrett D'Amore 	PAIR_SUMMARY_INIT(&tag[0], "Document Footer");
49695c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag[1], "foot");
49795c635efSGarrett D'Amore 	PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
49895c635efSGarrett D'Amore 	t = print_otag(h, TAG_TABLE, 3, tag);
49995c635efSGarrett D'Amore 	PAIR_INIT(&tag[0], ATTR_WIDTH, "50%");
50095c635efSGarrett D'Amore 	print_otag(h, TAG_COL, 1, tag);
50195c635efSGarrett D'Amore 	print_otag(h, TAG_COL, 1, tag);
50295c635efSGarrett D'Amore 
50395c635efSGarrett D'Amore 	print_otag(h, TAG_TBODY, 0, NULL);
50495c635efSGarrett D'Amore 
50595c635efSGarrett D'Amore 	tt = print_otag(h, TAG_TR, 0, NULL);
50695c635efSGarrett D'Amore 
50795c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag[0], "foot-date");
50895c635efSGarrett D'Amore 	print_otag(h, TAG_TD, 1, tag);
509*698f87a4SGarrett D'Amore 	print_text(h, meta->date);
51095c635efSGarrett D'Amore 	print_stagq(h, tt);
51195c635efSGarrett D'Amore 
51295c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag[0], "foot-os");
51395c635efSGarrett D'Amore 	PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
51495c635efSGarrett D'Amore 	print_otag(h, TAG_TD, 2, tag);
515*698f87a4SGarrett D'Amore 	print_text(h, meta->os);
51695c635efSGarrett D'Amore 	print_tagq(h, t);
51795c635efSGarrett D'Amore }
51895c635efSGarrett D'Amore 
51995c635efSGarrett D'Amore 
52095c635efSGarrett D'Amore /* ARGSUSED */
52195c635efSGarrett D'Amore static int
52295c635efSGarrett D'Amore mdoc_root_pre(MDOC_ARGS)
52395c635efSGarrett D'Amore {
52495c635efSGarrett D'Amore 	struct htmlpair	 tag[3];
52595c635efSGarrett D'Amore 	struct tag	*t, *tt;
52695c635efSGarrett D'Amore 	char		 b[BUFSIZ], title[BUFSIZ];
52795c635efSGarrett D'Amore 
528*698f87a4SGarrett D'Amore 	strlcpy(b, meta->vol, BUFSIZ);
52995c635efSGarrett D'Amore 
530*698f87a4SGarrett D'Amore 	if (meta->arch) {
53195c635efSGarrett D'Amore 		strlcat(b, " (", BUFSIZ);
532*698f87a4SGarrett D'Amore 		strlcat(b, meta->arch, BUFSIZ);
53395c635efSGarrett D'Amore 		strlcat(b, ")", BUFSIZ);
53495c635efSGarrett D'Amore 	}
53595c635efSGarrett D'Amore 
536*698f87a4SGarrett D'Amore 	snprintf(title, BUFSIZ - 1, "%s(%s)", meta->title, meta->msec);
53795c635efSGarrett D'Amore 
53895c635efSGarrett D'Amore 	PAIR_SUMMARY_INIT(&tag[0], "Document Header");
53995c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag[1], "head");
54095c635efSGarrett D'Amore 	PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
54195c635efSGarrett D'Amore 	t = print_otag(h, TAG_TABLE, 3, tag);
54295c635efSGarrett D'Amore 	PAIR_INIT(&tag[0], ATTR_WIDTH, "30%");
54395c635efSGarrett D'Amore 	print_otag(h, TAG_COL, 1, tag);
54495c635efSGarrett D'Amore 	print_otag(h, TAG_COL, 1, tag);
54595c635efSGarrett D'Amore 	print_otag(h, TAG_COL, 1, tag);
54695c635efSGarrett D'Amore 
54795c635efSGarrett D'Amore 	print_otag(h, TAG_TBODY, 0, NULL);
54895c635efSGarrett D'Amore 
54995c635efSGarrett D'Amore 	tt = print_otag(h, TAG_TR, 0, NULL);
55095c635efSGarrett D'Amore 
55195c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag[0], "head-ltitle");
55295c635efSGarrett D'Amore 	print_otag(h, TAG_TD, 1, tag);
55395c635efSGarrett D'Amore 	print_text(h, title);
55495c635efSGarrett D'Amore 	print_stagq(h, tt);
55595c635efSGarrett D'Amore 
55695c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag[0], "head-vol");
55795c635efSGarrett D'Amore 	PAIR_INIT(&tag[1], ATTR_ALIGN, "center");
55895c635efSGarrett D'Amore 	print_otag(h, TAG_TD, 2, tag);
55995c635efSGarrett D'Amore 	print_text(h, b);
56095c635efSGarrett D'Amore 	print_stagq(h, tt);
56195c635efSGarrett D'Amore 
56295c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag[0], "head-rtitle");
56395c635efSGarrett D'Amore 	PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
56495c635efSGarrett D'Amore 	print_otag(h, TAG_TD, 2, tag);
56595c635efSGarrett D'Amore 	print_text(h, title);
56695c635efSGarrett D'Amore 	print_tagq(h, t);
56795c635efSGarrett D'Amore 	return(1);
56895c635efSGarrett D'Amore }
56995c635efSGarrett D'Amore 
57095c635efSGarrett D'Amore 
57195c635efSGarrett D'Amore /* ARGSUSED */
57295c635efSGarrett D'Amore static int
57395c635efSGarrett D'Amore mdoc_sh_pre(MDOC_ARGS)
57495c635efSGarrett D'Amore {
57595c635efSGarrett D'Amore 	struct htmlpair	 tag;
57695c635efSGarrett D'Amore 
57795c635efSGarrett D'Amore 	if (MDOC_BLOCK == n->type) {
57895c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag, "section");
57995c635efSGarrett D'Amore 		print_otag(h, TAG_DIV, 1, &tag);
58095c635efSGarrett D'Amore 		return(1);
58195c635efSGarrett D'Amore 	} else if (MDOC_BODY == n->type)
58295c635efSGarrett D'Amore 		return(1);
58395c635efSGarrett D'Amore 
58495c635efSGarrett D'Amore 	bufinit(h);
58595c635efSGarrett D'Amore 	bufcat(h, "x");
58695c635efSGarrett D'Amore 
58795c635efSGarrett D'Amore 	for (n = n->child; n && MDOC_TEXT == n->type; ) {
58895c635efSGarrett D'Amore 		bufcat_id(h, n->string);
58995c635efSGarrett D'Amore 		if (NULL != (n = n->next))
59095c635efSGarrett D'Amore 			bufcat_id(h, " ");
59195c635efSGarrett D'Amore 	}
59295c635efSGarrett D'Amore 
59395c635efSGarrett D'Amore 	if (NULL == n) {
59495c635efSGarrett D'Amore 		PAIR_ID_INIT(&tag, h->buf);
59595c635efSGarrett D'Amore 		print_otag(h, TAG_H1, 1, &tag);
59695c635efSGarrett D'Amore 	} else
59795c635efSGarrett D'Amore 		print_otag(h, TAG_H1, 0, NULL);
59895c635efSGarrett D'Amore 
59995c635efSGarrett D'Amore 	return(1);
60095c635efSGarrett D'Amore }
60195c635efSGarrett D'Amore 
60295c635efSGarrett D'Amore /* ARGSUSED */
60395c635efSGarrett D'Amore static int
60495c635efSGarrett D'Amore mdoc_ss_pre(MDOC_ARGS)
60595c635efSGarrett D'Amore {
60695c635efSGarrett D'Amore 	struct htmlpair	 tag;
60795c635efSGarrett D'Amore 
60895c635efSGarrett D'Amore 	if (MDOC_BLOCK == n->type) {
60995c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag, "subsection");
61095c635efSGarrett D'Amore 		print_otag(h, TAG_DIV, 1, &tag);
61195c635efSGarrett D'Amore 		return(1);
61295c635efSGarrett D'Amore 	} else if (MDOC_BODY == n->type)
61395c635efSGarrett D'Amore 		return(1);
61495c635efSGarrett D'Amore 
61595c635efSGarrett D'Amore 	bufinit(h);
61695c635efSGarrett D'Amore 	bufcat(h, "x");
61795c635efSGarrett D'Amore 
61895c635efSGarrett D'Amore 	for (n = n->child; n && MDOC_TEXT == n->type; ) {
61995c635efSGarrett D'Amore 		bufcat_id(h, n->string);
62095c635efSGarrett D'Amore 		if (NULL != (n = n->next))
62195c635efSGarrett D'Amore 			bufcat_id(h, " ");
62295c635efSGarrett D'Amore 	}
62395c635efSGarrett D'Amore 
62495c635efSGarrett D'Amore 	if (NULL == n) {
62595c635efSGarrett D'Amore 		PAIR_ID_INIT(&tag, h->buf);
62695c635efSGarrett D'Amore 		print_otag(h, TAG_H2, 1, &tag);
62795c635efSGarrett D'Amore 	} else
62895c635efSGarrett D'Amore 		print_otag(h, TAG_H2, 0, NULL);
62995c635efSGarrett D'Amore 
63095c635efSGarrett D'Amore 	return(1);
63195c635efSGarrett D'Amore }
63295c635efSGarrett D'Amore 
63395c635efSGarrett D'Amore 
63495c635efSGarrett D'Amore /* ARGSUSED */
63595c635efSGarrett D'Amore static int
63695c635efSGarrett D'Amore mdoc_fl_pre(MDOC_ARGS)
63795c635efSGarrett D'Amore {
63895c635efSGarrett D'Amore 	struct htmlpair	 tag;
63995c635efSGarrett D'Amore 
64095c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "flag");
64195c635efSGarrett D'Amore 	print_otag(h, TAG_B, 1, &tag);
64295c635efSGarrett D'Amore 
64395c635efSGarrett D'Amore 	/* `Cm' has no leading hyphen. */
64495c635efSGarrett D'Amore 
64595c635efSGarrett D'Amore 	if (MDOC_Cm == n->tok)
64695c635efSGarrett D'Amore 		return(1);
64795c635efSGarrett D'Amore 
64895c635efSGarrett D'Amore 	print_text(h, "\\-");
64995c635efSGarrett D'Amore 
65095c635efSGarrett D'Amore 	if (n->child)
65195c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
65295c635efSGarrett D'Amore 	else if (n->next && n->next->line == n->line)
65395c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
65495c635efSGarrett D'Amore 
65595c635efSGarrett D'Amore 	return(1);
65695c635efSGarrett D'Amore }
65795c635efSGarrett D'Amore 
65895c635efSGarrett D'Amore 
65995c635efSGarrett D'Amore /* ARGSUSED */
66095c635efSGarrett D'Amore static int
66195c635efSGarrett D'Amore mdoc_nd_pre(MDOC_ARGS)
66295c635efSGarrett D'Amore {
66395c635efSGarrett D'Amore 	struct htmlpair	 tag;
66495c635efSGarrett D'Amore 
66595c635efSGarrett D'Amore 	if (MDOC_BODY != n->type)
66695c635efSGarrett D'Amore 		return(1);
66795c635efSGarrett D'Amore 
66895c635efSGarrett D'Amore 	/* XXX: this tag in theory can contain block elements. */
66995c635efSGarrett D'Amore 
67095c635efSGarrett D'Amore 	print_text(h, "\\(em");
67195c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "desc");
67295c635efSGarrett D'Amore 	print_otag(h, TAG_SPAN, 1, &tag);
67395c635efSGarrett D'Amore 	return(1);
67495c635efSGarrett D'Amore }
67595c635efSGarrett D'Amore 
67695c635efSGarrett D'Amore 
67795c635efSGarrett D'Amore static int
67895c635efSGarrett D'Amore mdoc_nm_pre(MDOC_ARGS)
67995c635efSGarrett D'Amore {
68095c635efSGarrett D'Amore 	struct htmlpair	 tag;
68195c635efSGarrett D'Amore 	struct roffsu	 su;
68295c635efSGarrett D'Amore 	int		 len;
68395c635efSGarrett D'Amore 
68495c635efSGarrett D'Amore 	switch (n->type) {
68595c635efSGarrett D'Amore 	case (MDOC_ELEM):
68695c635efSGarrett D'Amore 		synopsis_pre(h, n);
68795c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag, "name");
68895c635efSGarrett D'Amore 		print_otag(h, TAG_B, 1, &tag);
689*698f87a4SGarrett D'Amore 		if (NULL == n->child && meta->name)
690*698f87a4SGarrett D'Amore 			print_text(h, meta->name);
69195c635efSGarrett D'Amore 		return(1);
69295c635efSGarrett D'Amore 	case (MDOC_HEAD):
69395c635efSGarrett D'Amore 		print_otag(h, TAG_TD, 0, NULL);
694*698f87a4SGarrett D'Amore 		if (NULL == n->child && meta->name)
695*698f87a4SGarrett D'Amore 			print_text(h, meta->name);
69695c635efSGarrett D'Amore 		return(1);
69795c635efSGarrett D'Amore 	case (MDOC_BODY):
69895c635efSGarrett D'Amore 		print_otag(h, TAG_TD, 0, NULL);
69995c635efSGarrett D'Amore 		return(1);
70095c635efSGarrett D'Amore 	default:
70195c635efSGarrett D'Amore 		break;
70295c635efSGarrett D'Amore 	}
70395c635efSGarrett D'Amore 
70495c635efSGarrett D'Amore 	synopsis_pre(h, n);
70595c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "synopsis");
70695c635efSGarrett D'Amore 	print_otag(h, TAG_TABLE, 1, &tag);
70795c635efSGarrett D'Amore 
70895c635efSGarrett D'Amore 	for (len = 0, n = n->child; n; n = n->next)
70995c635efSGarrett D'Amore 		if (MDOC_TEXT == n->type)
71095c635efSGarrett D'Amore 			len += html_strlen(n->string);
71195c635efSGarrett D'Amore 
712*698f87a4SGarrett D'Amore 	if (0 == len && meta->name)
713*698f87a4SGarrett D'Amore 		len = html_strlen(meta->name);
71495c635efSGarrett D'Amore 
71595c635efSGarrett D'Amore 	SCALE_HS_INIT(&su, (double)len);
71695c635efSGarrett D'Amore 	bufinit(h);
71795c635efSGarrett D'Amore 	bufcat_su(h, "width", &su);
71895c635efSGarrett D'Amore 	PAIR_STYLE_INIT(&tag, h);
71995c635efSGarrett D'Amore 	print_otag(h, TAG_COL, 1, &tag);
72095c635efSGarrett D'Amore 	print_otag(h, TAG_COL, 0, NULL);
72195c635efSGarrett D'Amore 	print_otag(h, TAG_TBODY, 0, NULL);
72295c635efSGarrett D'Amore 	print_otag(h, TAG_TR, 0, NULL);
72395c635efSGarrett D'Amore 	return(1);
72495c635efSGarrett D'Amore }
72595c635efSGarrett D'Amore 
72695c635efSGarrett D'Amore 
72795c635efSGarrett D'Amore /* ARGSUSED */
72895c635efSGarrett D'Amore static int
72995c635efSGarrett D'Amore mdoc_xr_pre(MDOC_ARGS)
73095c635efSGarrett D'Amore {
73195c635efSGarrett D'Amore 	struct htmlpair	 tag[2];
73295c635efSGarrett D'Amore 
73395c635efSGarrett D'Amore 	if (NULL == n->child)
73495c635efSGarrett D'Amore 		return(0);
73595c635efSGarrett D'Amore 
73695c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag[0], "link-man");
73795c635efSGarrett D'Amore 
73895c635efSGarrett D'Amore 	if (h->base_man) {
73995c635efSGarrett D'Amore 		buffmt_man(h, n->child->string,
74095c635efSGarrett D'Amore 				n->child->next ?
74195c635efSGarrett D'Amore 				n->child->next->string : NULL);
74295c635efSGarrett D'Amore 		PAIR_HREF_INIT(&tag[1], h->buf);
74395c635efSGarrett D'Amore 		print_otag(h, TAG_A, 2, tag);
74495c635efSGarrett D'Amore 	} else
74595c635efSGarrett D'Amore 		print_otag(h, TAG_A, 1, tag);
74695c635efSGarrett D'Amore 
74795c635efSGarrett D'Amore 	n = n->child;
74895c635efSGarrett D'Amore 	print_text(h, n->string);
74995c635efSGarrett D'Amore 
75095c635efSGarrett D'Amore 	if (NULL == (n = n->next))
75195c635efSGarrett D'Amore 		return(0);
75295c635efSGarrett D'Amore 
75395c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
75495c635efSGarrett D'Amore 	print_text(h, "(");
75595c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
75695c635efSGarrett D'Amore 	print_text(h, n->string);
75795c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
75895c635efSGarrett D'Amore 	print_text(h, ")");
75995c635efSGarrett D'Amore 	return(0);
76095c635efSGarrett D'Amore }
76195c635efSGarrett D'Amore 
76295c635efSGarrett D'Amore 
76395c635efSGarrett D'Amore /* ARGSUSED */
76495c635efSGarrett D'Amore static int
76595c635efSGarrett D'Amore mdoc_ns_pre(MDOC_ARGS)
76695c635efSGarrett D'Amore {
76795c635efSGarrett D'Amore 
76895c635efSGarrett D'Amore 	if ( ! (MDOC_LINE & n->flags))
76995c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
77095c635efSGarrett D'Amore 	return(1);
77195c635efSGarrett D'Amore }
77295c635efSGarrett D'Amore 
77395c635efSGarrett D'Amore 
77495c635efSGarrett D'Amore /* ARGSUSED */
77595c635efSGarrett D'Amore static int
77695c635efSGarrett D'Amore mdoc_ar_pre(MDOC_ARGS)
77795c635efSGarrett D'Amore {
77895c635efSGarrett D'Amore 	struct htmlpair tag;
77995c635efSGarrett D'Amore 
78095c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "arg");
78195c635efSGarrett D'Amore 	print_otag(h, TAG_I, 1, &tag);
78295c635efSGarrett D'Amore 	return(1);
78395c635efSGarrett D'Amore }
78495c635efSGarrett D'Amore 
78595c635efSGarrett D'Amore 
78695c635efSGarrett D'Amore /* ARGSUSED */
78795c635efSGarrett D'Amore static int
78895c635efSGarrett D'Amore mdoc_xx_pre(MDOC_ARGS)
78995c635efSGarrett D'Amore {
79095c635efSGarrett D'Amore 	const char	*pp;
79195c635efSGarrett D'Amore 	struct htmlpair	 tag;
79295c635efSGarrett D'Amore 	int		 flags;
79395c635efSGarrett D'Amore 
79495c635efSGarrett D'Amore 	switch (n->tok) {
79595c635efSGarrett D'Amore 	case (MDOC_Bsx):
79695c635efSGarrett D'Amore 		pp = "BSD/OS";
79795c635efSGarrett D'Amore 		break;
79895c635efSGarrett D'Amore 	case (MDOC_Dx):
79995c635efSGarrett D'Amore 		pp = "DragonFly";
80095c635efSGarrett D'Amore 		break;
80195c635efSGarrett D'Amore 	case (MDOC_Fx):
80295c635efSGarrett D'Amore 		pp = "FreeBSD";
80395c635efSGarrett D'Amore 		break;
80495c635efSGarrett D'Amore 	case (MDOC_Nx):
80595c635efSGarrett D'Amore 		pp = "NetBSD";
80695c635efSGarrett D'Amore 		break;
80795c635efSGarrett D'Amore 	case (MDOC_Ox):
80895c635efSGarrett D'Amore 		pp = "OpenBSD";
80995c635efSGarrett D'Amore 		break;
81095c635efSGarrett D'Amore 	case (MDOC_Ux):
81195c635efSGarrett D'Amore 		pp = "UNIX";
81295c635efSGarrett D'Amore 		break;
81395c635efSGarrett D'Amore 	default:
81495c635efSGarrett D'Amore 		return(1);
81595c635efSGarrett D'Amore 	}
81695c635efSGarrett D'Amore 
81795c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "unix");
81895c635efSGarrett D'Amore 	print_otag(h, TAG_SPAN, 1, &tag);
81995c635efSGarrett D'Amore 
82095c635efSGarrett D'Amore 	print_text(h, pp);
82195c635efSGarrett D'Amore 	if (n->child) {
82295c635efSGarrett D'Amore 		flags = h->flags;
82395c635efSGarrett D'Amore 		h->flags |= HTML_KEEP;
82495c635efSGarrett D'Amore 		print_text(h, n->child->string);
82595c635efSGarrett D'Amore 		h->flags = flags;
82695c635efSGarrett D'Amore 	}
82795c635efSGarrett D'Amore 	return(0);
82895c635efSGarrett D'Amore }
82995c635efSGarrett D'Amore 
83095c635efSGarrett D'Amore 
83195c635efSGarrett D'Amore /* ARGSUSED */
83295c635efSGarrett D'Amore static int
83395c635efSGarrett D'Amore mdoc_bx_pre(MDOC_ARGS)
83495c635efSGarrett D'Amore {
83595c635efSGarrett D'Amore 	struct htmlpair	 tag;
83695c635efSGarrett D'Amore 
83795c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "unix");
83895c635efSGarrett D'Amore 	print_otag(h, TAG_SPAN, 1, &tag);
83995c635efSGarrett D'Amore 
84095c635efSGarrett D'Amore 	if (NULL != (n = n->child)) {
84195c635efSGarrett D'Amore 		print_text(h, n->string);
84295c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
84395c635efSGarrett D'Amore 		print_text(h, "BSD");
84495c635efSGarrett D'Amore 	} else {
84595c635efSGarrett D'Amore 		print_text(h, "BSD");
84695c635efSGarrett D'Amore 		return(0);
84795c635efSGarrett D'Amore 	}
84895c635efSGarrett D'Amore 
84995c635efSGarrett D'Amore 	if (NULL != (n = n->next)) {
85095c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
85195c635efSGarrett D'Amore 		print_text(h, "-");
85295c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
85395c635efSGarrett D'Amore 		print_text(h, n->string);
85495c635efSGarrett D'Amore 	}
85595c635efSGarrett D'Amore 
85695c635efSGarrett D'Amore 	return(0);
85795c635efSGarrett D'Amore }
85895c635efSGarrett D'Amore 
85995c635efSGarrett D'Amore /* ARGSUSED */
86095c635efSGarrett D'Amore static int
86195c635efSGarrett D'Amore mdoc_it_pre(MDOC_ARGS)
86295c635efSGarrett D'Amore {
86395c635efSGarrett D'Amore 	struct roffsu	 su;
86495c635efSGarrett D'Amore 	enum mdoc_list	 type;
86595c635efSGarrett D'Amore 	struct htmlpair	 tag[2];
86695c635efSGarrett D'Amore 	const struct mdoc_node *bl;
86795c635efSGarrett D'Amore 
86895c635efSGarrett D'Amore 	bl = n->parent;
86995c635efSGarrett D'Amore 	while (bl && MDOC_Bl != bl->tok)
87095c635efSGarrett D'Amore 		bl = bl->parent;
87195c635efSGarrett D'Amore 
87295c635efSGarrett D'Amore 	assert(bl);
87395c635efSGarrett D'Amore 
87495c635efSGarrett D'Amore 	type = bl->norm->Bl.type;
87595c635efSGarrett D'Amore 
87695c635efSGarrett D'Amore 	assert(lists[type]);
87795c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag[0], lists[type]);
87895c635efSGarrett D'Amore 
87995c635efSGarrett D'Amore 	bufinit(h);
88095c635efSGarrett D'Amore 
88195c635efSGarrett D'Amore 	if (MDOC_HEAD == n->type) {
88295c635efSGarrett D'Amore 		switch (type) {
88395c635efSGarrett D'Amore 		case(LIST_bullet):
88495c635efSGarrett D'Amore 			/* FALLTHROUGH */
88595c635efSGarrett D'Amore 		case(LIST_dash):
88695c635efSGarrett D'Amore 			/* FALLTHROUGH */
88795c635efSGarrett D'Amore 		case(LIST_item):
88895c635efSGarrett D'Amore 			/* FALLTHROUGH */
88995c635efSGarrett D'Amore 		case(LIST_hyphen):
89095c635efSGarrett D'Amore 			/* FALLTHROUGH */
89195c635efSGarrett D'Amore 		case(LIST_enum):
89295c635efSGarrett D'Amore 			return(0);
89395c635efSGarrett D'Amore 		case(LIST_diag):
89495c635efSGarrett D'Amore 			/* FALLTHROUGH */
89595c635efSGarrett D'Amore 		case(LIST_hang):
89695c635efSGarrett D'Amore 			/* FALLTHROUGH */
89795c635efSGarrett D'Amore 		case(LIST_inset):
89895c635efSGarrett D'Amore 			/* FALLTHROUGH */
89995c635efSGarrett D'Amore 		case(LIST_ohang):
90095c635efSGarrett D'Amore 			/* FALLTHROUGH */
90195c635efSGarrett D'Amore 		case(LIST_tag):
90295c635efSGarrett D'Amore 			SCALE_VS_INIT(&su, ! bl->norm->Bl.comp);
90395c635efSGarrett D'Amore 			bufcat_su(h, "margin-top", &su);
90495c635efSGarrett D'Amore 			PAIR_STYLE_INIT(&tag[1], h);
90595c635efSGarrett D'Amore 			print_otag(h, TAG_DT, 2, tag);
90695c635efSGarrett D'Amore 			if (LIST_diag != type)
90795c635efSGarrett D'Amore 				break;
90895c635efSGarrett D'Amore 			PAIR_CLASS_INIT(&tag[0], "diag");
90995c635efSGarrett D'Amore 			print_otag(h, TAG_B, 1, tag);
91095c635efSGarrett D'Amore 			break;
91195c635efSGarrett D'Amore 		case(LIST_column):
91295c635efSGarrett D'Amore 			break;
91395c635efSGarrett D'Amore 		default:
91495c635efSGarrett D'Amore 			break;
91595c635efSGarrett D'Amore 		}
91695c635efSGarrett D'Amore 	} else if (MDOC_BODY == n->type) {
91795c635efSGarrett D'Amore 		switch (type) {
91895c635efSGarrett D'Amore 		case(LIST_bullet):
91995c635efSGarrett D'Amore 			/* FALLTHROUGH */
92095c635efSGarrett D'Amore 		case(LIST_hyphen):
92195c635efSGarrett D'Amore 			/* FALLTHROUGH */
92295c635efSGarrett D'Amore 		case(LIST_dash):
92395c635efSGarrett D'Amore 			/* FALLTHROUGH */
92495c635efSGarrett D'Amore 		case(LIST_enum):
92595c635efSGarrett D'Amore 			/* FALLTHROUGH */
92695c635efSGarrett D'Amore 		case(LIST_item):
92795c635efSGarrett D'Amore 			SCALE_VS_INIT(&su, ! bl->norm->Bl.comp);
92895c635efSGarrett D'Amore 			bufcat_su(h, "margin-top", &su);
92995c635efSGarrett D'Amore 			PAIR_STYLE_INIT(&tag[1], h);
93095c635efSGarrett D'Amore 			print_otag(h, TAG_LI, 2, tag);
93195c635efSGarrett D'Amore 			break;
93295c635efSGarrett D'Amore 		case(LIST_diag):
93395c635efSGarrett D'Amore 			/* FALLTHROUGH */
93495c635efSGarrett D'Amore 		case(LIST_hang):
93595c635efSGarrett D'Amore 			/* FALLTHROUGH */
93695c635efSGarrett D'Amore 		case(LIST_inset):
93795c635efSGarrett D'Amore 			/* FALLTHROUGH */
93895c635efSGarrett D'Amore 		case(LIST_ohang):
93995c635efSGarrett D'Amore 			/* FALLTHROUGH */
94095c635efSGarrett D'Amore 		case(LIST_tag):
94195c635efSGarrett D'Amore 			if (NULL == bl->norm->Bl.width) {
94295c635efSGarrett D'Amore 				print_otag(h, TAG_DD, 1, tag);
94395c635efSGarrett D'Amore 				break;
94495c635efSGarrett D'Amore 			}
94595c635efSGarrett D'Amore 			a2width(bl->norm->Bl.width, &su);
94695c635efSGarrett D'Amore 			bufcat_su(h, "margin-left", &su);
94795c635efSGarrett D'Amore 			PAIR_STYLE_INIT(&tag[1], h);
94895c635efSGarrett D'Amore 			print_otag(h, TAG_DD, 2, tag);
94995c635efSGarrett D'Amore 			break;
95095c635efSGarrett D'Amore 		case(LIST_column):
95195c635efSGarrett D'Amore 			SCALE_VS_INIT(&su, ! bl->norm->Bl.comp);
95295c635efSGarrett D'Amore 			bufcat_su(h, "margin-top", &su);
95395c635efSGarrett D'Amore 			PAIR_STYLE_INIT(&tag[1], h);
95495c635efSGarrett D'Amore 			print_otag(h, TAG_TD, 2, tag);
95595c635efSGarrett D'Amore 			break;
95695c635efSGarrett D'Amore 		default:
95795c635efSGarrett D'Amore 			break;
95895c635efSGarrett D'Amore 		}
95995c635efSGarrett D'Amore 	} else {
96095c635efSGarrett D'Amore 		switch (type) {
96195c635efSGarrett D'Amore 		case (LIST_column):
96295c635efSGarrett D'Amore 			print_otag(h, TAG_TR, 1, tag);
96395c635efSGarrett D'Amore 			break;
96495c635efSGarrett D'Amore 		default:
96595c635efSGarrett D'Amore 			break;
96695c635efSGarrett D'Amore 		}
96795c635efSGarrett D'Amore 	}
96895c635efSGarrett D'Amore 
96995c635efSGarrett D'Amore 	return(1);
97095c635efSGarrett D'Amore }
97195c635efSGarrett D'Amore 
97295c635efSGarrett D'Amore /* ARGSUSED */
97395c635efSGarrett D'Amore static int
97495c635efSGarrett D'Amore mdoc_bl_pre(MDOC_ARGS)
97595c635efSGarrett D'Amore {
97695c635efSGarrett D'Amore 	int		 i;
97795c635efSGarrett D'Amore 	struct htmlpair	 tag[3];
97895c635efSGarrett D'Amore 	struct roffsu	 su;
97995c635efSGarrett D'Amore 	char		 buf[BUFSIZ];
98095c635efSGarrett D'Amore 
98195c635efSGarrett D'Amore 	if (MDOC_BODY == n->type) {
98295c635efSGarrett D'Amore 		if (LIST_column == n->norm->Bl.type)
98395c635efSGarrett D'Amore 			print_otag(h, TAG_TBODY, 0, NULL);
98495c635efSGarrett D'Amore 		return(1);
98595c635efSGarrett D'Amore 	}
98695c635efSGarrett D'Amore 
98795c635efSGarrett D'Amore 	if (MDOC_HEAD == n->type) {
98895c635efSGarrett D'Amore 		if (LIST_column != n->norm->Bl.type)
98995c635efSGarrett D'Amore 			return(0);
99095c635efSGarrett D'Amore 
99195c635efSGarrett D'Amore 		/*
99295c635efSGarrett D'Amore 		 * For each column, print out the <COL> tag with our
99395c635efSGarrett D'Amore 		 * suggested width.  The last column gets min-width, as
99495c635efSGarrett D'Amore 		 * in terminal mode it auto-sizes to the width of the
99595c635efSGarrett D'Amore 		 * screen and we want to preserve that behaviour.
99695c635efSGarrett D'Amore 		 */
99795c635efSGarrett D'Amore 
99895c635efSGarrett D'Amore 		for (i = 0; i < (int)n->norm->Bl.ncols; i++) {
999*698f87a4SGarrett D'Amore 			bufinit(h);
100095c635efSGarrett D'Amore 			a2width(n->norm->Bl.cols[i], &su);
100195c635efSGarrett D'Amore 			if (i < (int)n->norm->Bl.ncols - 1)
100295c635efSGarrett D'Amore 				bufcat_su(h, "width", &su);
100395c635efSGarrett D'Amore 			else
100495c635efSGarrett D'Amore 				bufcat_su(h, "min-width", &su);
100595c635efSGarrett D'Amore 			PAIR_STYLE_INIT(&tag[0], h);
100695c635efSGarrett D'Amore 			print_otag(h, TAG_COL, 1, tag);
100795c635efSGarrett D'Amore 		}
100895c635efSGarrett D'Amore 
100995c635efSGarrett D'Amore 		return(0);
101095c635efSGarrett D'Amore 	}
101195c635efSGarrett D'Amore 
101295c635efSGarrett D'Amore 	SCALE_VS_INIT(&su, 0);
1013*698f87a4SGarrett D'Amore 	bufinit(h);
101495c635efSGarrett D'Amore 	bufcat_su(h, "margin-top", &su);
101595c635efSGarrett D'Amore 	bufcat_su(h, "margin-bottom", &su);
101695c635efSGarrett D'Amore 	PAIR_STYLE_INIT(&tag[0], h);
101795c635efSGarrett D'Amore 
101895c635efSGarrett D'Amore 	assert(lists[n->norm->Bl.type]);
101995c635efSGarrett D'Amore 	strlcpy(buf, "list ", BUFSIZ);
102095c635efSGarrett D'Amore 	strlcat(buf, lists[n->norm->Bl.type], BUFSIZ);
102195c635efSGarrett D'Amore 	PAIR_INIT(&tag[1], ATTR_CLASS, buf);
102295c635efSGarrett D'Amore 
102395c635efSGarrett D'Amore 	/* Set the block's left-hand margin. */
102495c635efSGarrett D'Amore 
102595c635efSGarrett D'Amore 	if (n->norm->Bl.offs) {
102695c635efSGarrett D'Amore 		a2offs(n->norm->Bl.offs, &su);
102795c635efSGarrett D'Amore 		bufcat_su(h, "margin-left", &su);
102895c635efSGarrett D'Amore 	}
102995c635efSGarrett D'Amore 
103095c635efSGarrett D'Amore 	switch (n->norm->Bl.type) {
103195c635efSGarrett D'Amore 	case(LIST_bullet):
103295c635efSGarrett D'Amore 		/* FALLTHROUGH */
103395c635efSGarrett D'Amore 	case(LIST_dash):
103495c635efSGarrett D'Amore 		/* FALLTHROUGH */
103595c635efSGarrett D'Amore 	case(LIST_hyphen):
103695c635efSGarrett D'Amore 		/* FALLTHROUGH */
103795c635efSGarrett D'Amore 	case(LIST_item):
103895c635efSGarrett D'Amore 		print_otag(h, TAG_UL, 2, tag);
103995c635efSGarrett D'Amore 		break;
104095c635efSGarrett D'Amore 	case(LIST_enum):
104195c635efSGarrett D'Amore 		print_otag(h, TAG_OL, 2, tag);
104295c635efSGarrett D'Amore 		break;
104395c635efSGarrett D'Amore 	case(LIST_diag):
104495c635efSGarrett D'Amore 		/* FALLTHROUGH */
104595c635efSGarrett D'Amore 	case(LIST_hang):
104695c635efSGarrett D'Amore 		/* FALLTHROUGH */
104795c635efSGarrett D'Amore 	case(LIST_inset):
104895c635efSGarrett D'Amore 		/* FALLTHROUGH */
104995c635efSGarrett D'Amore 	case(LIST_ohang):
105095c635efSGarrett D'Amore 		/* FALLTHROUGH */
105195c635efSGarrett D'Amore 	case(LIST_tag):
105295c635efSGarrett D'Amore 		print_otag(h, TAG_DL, 2, tag);
105395c635efSGarrett D'Amore 		break;
105495c635efSGarrett D'Amore 	case(LIST_column):
105595c635efSGarrett D'Amore 		print_otag(h, TAG_TABLE, 2, tag);
105695c635efSGarrett D'Amore 		break;
105795c635efSGarrett D'Amore 	default:
105895c635efSGarrett D'Amore 		abort();
105995c635efSGarrett D'Amore 		/* NOTREACHED */
106095c635efSGarrett D'Amore 	}
106195c635efSGarrett D'Amore 
106295c635efSGarrett D'Amore 	return(1);
106395c635efSGarrett D'Amore }
106495c635efSGarrett D'Amore 
106595c635efSGarrett D'Amore /* ARGSUSED */
106695c635efSGarrett D'Amore static int
106795c635efSGarrett D'Amore mdoc_ex_pre(MDOC_ARGS)
106895c635efSGarrett D'Amore {
106995c635efSGarrett D'Amore 	struct tag	*t;
107095c635efSGarrett D'Amore 	struct htmlpair	 tag;
107195c635efSGarrett D'Amore 	int		 nchild;
107295c635efSGarrett D'Amore 
107395c635efSGarrett D'Amore 	if (n->prev)
107495c635efSGarrett D'Amore 		print_otag(h, TAG_BR, 0, NULL);
107595c635efSGarrett D'Amore 
107695c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "utility");
107795c635efSGarrett D'Amore 
107895c635efSGarrett D'Amore 	print_text(h, "The");
107995c635efSGarrett D'Amore 
108095c635efSGarrett D'Amore 	nchild = n->nchild;
108195c635efSGarrett D'Amore 	for (n = n->child; n; n = n->next) {
108295c635efSGarrett D'Amore 		assert(MDOC_TEXT == n->type);
108395c635efSGarrett D'Amore 
108495c635efSGarrett D'Amore 		t = print_otag(h, TAG_B, 1, &tag);
108595c635efSGarrett D'Amore 		print_text(h, n->string);
108695c635efSGarrett D'Amore 		print_tagq(h, t);
108795c635efSGarrett D'Amore 
108895c635efSGarrett D'Amore 		if (nchild > 2 && n->next) {
108995c635efSGarrett D'Amore 			h->flags |= HTML_NOSPACE;
109095c635efSGarrett D'Amore 			print_text(h, ",");
109195c635efSGarrett D'Amore 		}
109295c635efSGarrett D'Amore 
109395c635efSGarrett D'Amore 		if (n->next && NULL == n->next->next)
109495c635efSGarrett D'Amore 			print_text(h, "and");
109595c635efSGarrett D'Amore 	}
109695c635efSGarrett D'Amore 
109795c635efSGarrett D'Amore 	if (nchild > 1)
109895c635efSGarrett D'Amore 		print_text(h, "utilities exit");
109995c635efSGarrett D'Amore 	else
110095c635efSGarrett D'Amore 		print_text(h, "utility exits");
110195c635efSGarrett D'Amore 
110295c635efSGarrett D'Amore        	print_text(h, "0 on success, and >0 if an error occurs.");
110395c635efSGarrett D'Amore 	return(0);
110495c635efSGarrett D'Amore }
110595c635efSGarrett D'Amore 
110695c635efSGarrett D'Amore 
110795c635efSGarrett D'Amore /* ARGSUSED */
110895c635efSGarrett D'Amore static int
110995c635efSGarrett D'Amore mdoc_em_pre(MDOC_ARGS)
111095c635efSGarrett D'Amore {
111195c635efSGarrett D'Amore 	struct htmlpair	tag;
111295c635efSGarrett D'Amore 
111395c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "emph");
111495c635efSGarrett D'Amore 	print_otag(h, TAG_SPAN, 1, &tag);
111595c635efSGarrett D'Amore 	return(1);
111695c635efSGarrett D'Amore }
111795c635efSGarrett D'Amore 
111895c635efSGarrett D'Amore 
111995c635efSGarrett D'Amore /* ARGSUSED */
112095c635efSGarrett D'Amore static int
112195c635efSGarrett D'Amore mdoc_d1_pre(MDOC_ARGS)
112295c635efSGarrett D'Amore {
112395c635efSGarrett D'Amore 	struct htmlpair	 tag[2];
112495c635efSGarrett D'Amore 	struct roffsu	 su;
112595c635efSGarrett D'Amore 
112695c635efSGarrett D'Amore 	if (MDOC_BLOCK != n->type)
112795c635efSGarrett D'Amore 		return(1);
112895c635efSGarrett D'Amore 
112995c635efSGarrett D'Amore 	SCALE_VS_INIT(&su, 0);
113095c635efSGarrett D'Amore 	bufinit(h);
113195c635efSGarrett D'Amore 	bufcat_su(h, "margin-top", &su);
113295c635efSGarrett D'Amore 	bufcat_su(h, "margin-bottom", &su);
113395c635efSGarrett D'Amore 	PAIR_STYLE_INIT(&tag[0], h);
113495c635efSGarrett D'Amore 	print_otag(h, TAG_BLOCKQUOTE, 1, tag);
113595c635efSGarrett D'Amore 
113695c635efSGarrett D'Amore 	/* BLOCKQUOTE needs a block body. */
113795c635efSGarrett D'Amore 
113895c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag[0], "display");
113995c635efSGarrett D'Amore 	print_otag(h, TAG_DIV, 1, tag);
114095c635efSGarrett D'Amore 
114195c635efSGarrett D'Amore 	if (MDOC_Dl == n->tok) {
114295c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "lit");
114395c635efSGarrett D'Amore 		print_otag(h, TAG_CODE, 1, tag);
114495c635efSGarrett D'Amore 	}
114595c635efSGarrett D'Amore 
114695c635efSGarrett D'Amore 	return(1);
114795c635efSGarrett D'Amore }
114895c635efSGarrett D'Amore 
114995c635efSGarrett D'Amore 
115095c635efSGarrett D'Amore /* ARGSUSED */
115195c635efSGarrett D'Amore static int
115295c635efSGarrett D'Amore mdoc_sx_pre(MDOC_ARGS)
115395c635efSGarrett D'Amore {
115495c635efSGarrett D'Amore 	struct htmlpair	 tag[2];
115595c635efSGarrett D'Amore 
115695c635efSGarrett D'Amore 	bufinit(h);
115795c635efSGarrett D'Amore 	bufcat(h, "#x");
115895c635efSGarrett D'Amore 
115995c635efSGarrett D'Amore 	for (n = n->child; n; ) {
116095c635efSGarrett D'Amore 		bufcat_id(h, n->string);
116195c635efSGarrett D'Amore 		if (NULL != (n = n->next))
116295c635efSGarrett D'Amore 			bufcat_id(h, " ");
116395c635efSGarrett D'Amore 	}
116495c635efSGarrett D'Amore 
116595c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag[0], "link-sec");
116695c635efSGarrett D'Amore 	PAIR_HREF_INIT(&tag[1], h->buf);
116795c635efSGarrett D'Amore 
116895c635efSGarrett D'Amore 	print_otag(h, TAG_I, 1, tag);
116995c635efSGarrett D'Amore 	print_otag(h, TAG_A, 2, tag);
117095c635efSGarrett D'Amore 	return(1);
117195c635efSGarrett D'Amore }
117295c635efSGarrett D'Amore 
117395c635efSGarrett D'Amore 
117495c635efSGarrett D'Amore /* ARGSUSED */
117595c635efSGarrett D'Amore static int
117695c635efSGarrett D'Amore mdoc_bd_pre(MDOC_ARGS)
117795c635efSGarrett D'Amore {
117895c635efSGarrett D'Amore 	struct htmlpair	 	 tag[2];
117995c635efSGarrett D'Amore 	int		 	 comp, sv;
118095c635efSGarrett D'Amore 	const struct mdoc_node	*nn;
118195c635efSGarrett D'Amore 	struct roffsu		 su;
118295c635efSGarrett D'Amore 
118395c635efSGarrett D'Amore 	if (MDOC_HEAD == n->type)
118495c635efSGarrett D'Amore 		return(0);
118595c635efSGarrett D'Amore 
118695c635efSGarrett D'Amore 	if (MDOC_BLOCK == n->type) {
118795c635efSGarrett D'Amore 		comp = n->norm->Bd.comp;
118895c635efSGarrett D'Amore 		for (nn = n; nn && ! comp; nn = nn->parent) {
118995c635efSGarrett D'Amore 			if (MDOC_BLOCK != nn->type)
119095c635efSGarrett D'Amore 				continue;
119195c635efSGarrett D'Amore 			if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok)
119295c635efSGarrett D'Amore 				comp = 1;
119395c635efSGarrett D'Amore 			if (nn->prev)
119495c635efSGarrett D'Amore 				break;
119595c635efSGarrett D'Amore 		}
119695c635efSGarrett D'Amore 		if ( ! comp)
119795c635efSGarrett D'Amore 			print_otag(h, TAG_P, 0, NULL);
119895c635efSGarrett D'Amore 		return(1);
119995c635efSGarrett D'Amore 	}
120095c635efSGarrett D'Amore 
120195c635efSGarrett D'Amore 	SCALE_HS_INIT(&su, 0);
120295c635efSGarrett D'Amore 	if (n->norm->Bd.offs)
120395c635efSGarrett D'Amore 		a2offs(n->norm->Bd.offs, &su);
120495c635efSGarrett D'Amore 
120595c635efSGarrett D'Amore 	bufinit(h);
120695c635efSGarrett D'Amore 	bufcat_su(h, "margin-left", &su);
120795c635efSGarrett D'Amore 	PAIR_STYLE_INIT(&tag[0], h);
120895c635efSGarrett D'Amore 
120995c635efSGarrett D'Amore 	if (DISP_unfilled != n->norm->Bd.type &&
121095c635efSGarrett D'Amore 			DISP_literal != n->norm->Bd.type) {
121195c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[1], "display");
121295c635efSGarrett D'Amore 		print_otag(h, TAG_DIV, 2, tag);
121395c635efSGarrett D'Amore 		return(1);
121495c635efSGarrett D'Amore 	}
121595c635efSGarrett D'Amore 
121695c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag[1], "lit display");
121795c635efSGarrett D'Amore 	print_otag(h, TAG_PRE, 2, tag);
121895c635efSGarrett D'Amore 
121995c635efSGarrett D'Amore 	/* This can be recursive: save & set our literal state. */
122095c635efSGarrett D'Amore 
122195c635efSGarrett D'Amore 	sv = h->flags & HTML_LITERAL;
122295c635efSGarrett D'Amore 	h->flags |= HTML_LITERAL;
122395c635efSGarrett D'Amore 
122495c635efSGarrett D'Amore 	for (nn = n->child; nn; nn = nn->next) {
1225*698f87a4SGarrett D'Amore 		print_mdoc_node(meta, nn, h);
122695c635efSGarrett D'Amore 		/*
122795c635efSGarrett D'Amore 		 * If the printed node flushes its own line, then we
122895c635efSGarrett D'Amore 		 * needn't do it here as well.  This is hacky, but the
122995c635efSGarrett D'Amore 		 * notion of selective eoln whitespace is pretty dumb
123095c635efSGarrett D'Amore 		 * anyway, so don't sweat it.
123195c635efSGarrett D'Amore 		 */
123295c635efSGarrett D'Amore 		switch (nn->tok) {
123395c635efSGarrett D'Amore 		case (MDOC_Sm):
123495c635efSGarrett D'Amore 			/* FALLTHROUGH */
123595c635efSGarrett D'Amore 		case (MDOC_br):
123695c635efSGarrett D'Amore 			/* FALLTHROUGH */
123795c635efSGarrett D'Amore 		case (MDOC_sp):
123895c635efSGarrett D'Amore 			/* FALLTHROUGH */
123995c635efSGarrett D'Amore 		case (MDOC_Bl):
124095c635efSGarrett D'Amore 			/* FALLTHROUGH */
124195c635efSGarrett D'Amore 		case (MDOC_D1):
124295c635efSGarrett D'Amore 			/* FALLTHROUGH */
124395c635efSGarrett D'Amore 		case (MDOC_Dl):
124495c635efSGarrett D'Amore 			/* FALLTHROUGH */
124595c635efSGarrett D'Amore 		case (MDOC_Lp):
124695c635efSGarrett D'Amore 			/* FALLTHROUGH */
124795c635efSGarrett D'Amore 		case (MDOC_Pp):
124895c635efSGarrett D'Amore 			continue;
124995c635efSGarrett D'Amore 		default:
125095c635efSGarrett D'Amore 			break;
125195c635efSGarrett D'Amore 		}
125295c635efSGarrett D'Amore 		if (nn->next && nn->next->line == nn->line)
125395c635efSGarrett D'Amore 			continue;
125495c635efSGarrett D'Amore 		else if (nn->next)
125595c635efSGarrett D'Amore 			print_text(h, "\n");
125695c635efSGarrett D'Amore 
125795c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
125895c635efSGarrett D'Amore 	}
125995c635efSGarrett D'Amore 
126095c635efSGarrett D'Amore 	if (0 == sv)
126195c635efSGarrett D'Amore 		h->flags &= ~HTML_LITERAL;
126295c635efSGarrett D'Amore 
126395c635efSGarrett D'Amore 	return(0);
126495c635efSGarrett D'Amore }
126595c635efSGarrett D'Amore 
126695c635efSGarrett D'Amore 
126795c635efSGarrett D'Amore /* ARGSUSED */
126895c635efSGarrett D'Amore static int
126995c635efSGarrett D'Amore mdoc_pa_pre(MDOC_ARGS)
127095c635efSGarrett D'Amore {
127195c635efSGarrett D'Amore 	struct htmlpair	tag;
127295c635efSGarrett D'Amore 
127395c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "file");
127495c635efSGarrett D'Amore 	print_otag(h, TAG_I, 1, &tag);
127595c635efSGarrett D'Amore 	return(1);
127695c635efSGarrett D'Amore }
127795c635efSGarrett D'Amore 
127895c635efSGarrett D'Amore 
127995c635efSGarrett D'Amore /* ARGSUSED */
128095c635efSGarrett D'Amore static int
128195c635efSGarrett D'Amore mdoc_ad_pre(MDOC_ARGS)
128295c635efSGarrett D'Amore {
128395c635efSGarrett D'Amore 	struct htmlpair	tag;
128495c635efSGarrett D'Amore 
128595c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "addr");
128695c635efSGarrett D'Amore 	print_otag(h, TAG_I, 1, &tag);
128795c635efSGarrett D'Amore 	return(1);
128895c635efSGarrett D'Amore }
128995c635efSGarrett D'Amore 
129095c635efSGarrett D'Amore 
129195c635efSGarrett D'Amore /* ARGSUSED */
129295c635efSGarrett D'Amore static int
129395c635efSGarrett D'Amore mdoc_an_pre(MDOC_ARGS)
129495c635efSGarrett D'Amore {
129595c635efSGarrett D'Amore 	struct htmlpair	tag;
129695c635efSGarrett D'Amore 
129795c635efSGarrett D'Amore 	/* TODO: -split and -nosplit (see termp_an_pre()). */
129895c635efSGarrett D'Amore 
129995c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "author");
130095c635efSGarrett D'Amore 	print_otag(h, TAG_SPAN, 1, &tag);
130195c635efSGarrett D'Amore 	return(1);
130295c635efSGarrett D'Amore }
130395c635efSGarrett D'Amore 
130495c635efSGarrett D'Amore 
130595c635efSGarrett D'Amore /* ARGSUSED */
130695c635efSGarrett D'Amore static int
130795c635efSGarrett D'Amore mdoc_cd_pre(MDOC_ARGS)
130895c635efSGarrett D'Amore {
130995c635efSGarrett D'Amore 	struct htmlpair	tag;
131095c635efSGarrett D'Amore 
131195c635efSGarrett D'Amore 	synopsis_pre(h, n);
131295c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "config");
131395c635efSGarrett D'Amore 	print_otag(h, TAG_B, 1, &tag);
131495c635efSGarrett D'Amore 	return(1);
131595c635efSGarrett D'Amore }
131695c635efSGarrett D'Amore 
131795c635efSGarrett D'Amore 
131895c635efSGarrett D'Amore /* ARGSUSED */
131995c635efSGarrett D'Amore static int
132095c635efSGarrett D'Amore mdoc_dv_pre(MDOC_ARGS)
132195c635efSGarrett D'Amore {
132295c635efSGarrett D'Amore 	struct htmlpair	tag;
132395c635efSGarrett D'Amore 
132495c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "define");
132595c635efSGarrett D'Amore 	print_otag(h, TAG_SPAN, 1, &tag);
132695c635efSGarrett D'Amore 	return(1);
132795c635efSGarrett D'Amore }
132895c635efSGarrett D'Amore 
132995c635efSGarrett D'Amore 
133095c635efSGarrett D'Amore /* ARGSUSED */
133195c635efSGarrett D'Amore static int
133295c635efSGarrett D'Amore mdoc_ev_pre(MDOC_ARGS)
133395c635efSGarrett D'Amore {
133495c635efSGarrett D'Amore 	struct htmlpair	tag;
133595c635efSGarrett D'Amore 
133695c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "env");
133795c635efSGarrett D'Amore 	print_otag(h, TAG_SPAN, 1, &tag);
133895c635efSGarrett D'Amore 	return(1);
133995c635efSGarrett D'Amore }
134095c635efSGarrett D'Amore 
134195c635efSGarrett D'Amore 
134295c635efSGarrett D'Amore /* ARGSUSED */
134395c635efSGarrett D'Amore static int
134495c635efSGarrett D'Amore mdoc_er_pre(MDOC_ARGS)
134595c635efSGarrett D'Amore {
134695c635efSGarrett D'Amore 	struct htmlpair	tag;
134795c635efSGarrett D'Amore 
134895c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "errno");
134995c635efSGarrett D'Amore 	print_otag(h, TAG_SPAN, 1, &tag);
135095c635efSGarrett D'Amore 	return(1);
135195c635efSGarrett D'Amore }
135295c635efSGarrett D'Amore 
135395c635efSGarrett D'Amore 
135495c635efSGarrett D'Amore /* ARGSUSED */
135595c635efSGarrett D'Amore static int
135695c635efSGarrett D'Amore mdoc_fa_pre(MDOC_ARGS)
135795c635efSGarrett D'Amore {
135895c635efSGarrett D'Amore 	const struct mdoc_node	*nn;
135995c635efSGarrett D'Amore 	struct htmlpair		 tag;
136095c635efSGarrett D'Amore 	struct tag		*t;
136195c635efSGarrett D'Amore 
136295c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "farg");
136395c635efSGarrett D'Amore 	if (n->parent->tok != MDOC_Fo) {
136495c635efSGarrett D'Amore 		print_otag(h, TAG_I, 1, &tag);
136595c635efSGarrett D'Amore 		return(1);
136695c635efSGarrett D'Amore 	}
136795c635efSGarrett D'Amore 
136895c635efSGarrett D'Amore 	for (nn = n->child; nn; nn = nn->next) {
136995c635efSGarrett D'Amore 		t = print_otag(h, TAG_I, 1, &tag);
137095c635efSGarrett D'Amore 		print_text(h, nn->string);
137195c635efSGarrett D'Amore 		print_tagq(h, t);
137295c635efSGarrett D'Amore 		if (nn->next) {
137395c635efSGarrett D'Amore 			h->flags |= HTML_NOSPACE;
137495c635efSGarrett D'Amore 			print_text(h, ",");
137595c635efSGarrett D'Amore 		}
137695c635efSGarrett D'Amore 	}
137795c635efSGarrett D'Amore 
137895c635efSGarrett D'Amore 	if (n->child && n->next && n->next->tok == MDOC_Fa) {
137995c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
138095c635efSGarrett D'Amore 		print_text(h, ",");
138195c635efSGarrett D'Amore 	}
138295c635efSGarrett D'Amore 
138395c635efSGarrett D'Amore 	return(0);
138495c635efSGarrett D'Amore }
138595c635efSGarrett D'Amore 
138695c635efSGarrett D'Amore 
138795c635efSGarrett D'Amore /* ARGSUSED */
138895c635efSGarrett D'Amore static int
138995c635efSGarrett D'Amore mdoc_fd_pre(MDOC_ARGS)
139095c635efSGarrett D'Amore {
139195c635efSGarrett D'Amore 	struct htmlpair	 tag[2];
139295c635efSGarrett D'Amore 	char		 buf[BUFSIZ];
139395c635efSGarrett D'Amore 	size_t		 sz;
139495c635efSGarrett D'Amore 	int		 i;
139595c635efSGarrett D'Amore 	struct tag	*t;
139695c635efSGarrett D'Amore 
139795c635efSGarrett D'Amore 	synopsis_pre(h, n);
139895c635efSGarrett D'Amore 
139995c635efSGarrett D'Amore 	if (NULL == (n = n->child))
140095c635efSGarrett D'Amore 		return(0);
140195c635efSGarrett D'Amore 
140295c635efSGarrett D'Amore 	assert(MDOC_TEXT == n->type);
140395c635efSGarrett D'Amore 
140495c635efSGarrett D'Amore 	if (strcmp(n->string, "#include")) {
140595c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "macro");
140695c635efSGarrett D'Amore 		print_otag(h, TAG_B, 1, tag);
140795c635efSGarrett D'Amore 		return(1);
140895c635efSGarrett D'Amore 	}
140995c635efSGarrett D'Amore 
141095c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag[0], "includes");
141195c635efSGarrett D'Amore 	print_otag(h, TAG_B, 1, tag);
141295c635efSGarrett D'Amore 	print_text(h, n->string);
141395c635efSGarrett D'Amore 
141495c635efSGarrett D'Amore 	if (NULL != (n = n->next)) {
141595c635efSGarrett D'Amore 		assert(MDOC_TEXT == n->type);
141695c635efSGarrett D'Amore 		strlcpy(buf, '<' == *n->string || '"' == *n->string ?
141795c635efSGarrett D'Amore 				n->string + 1 : n->string, BUFSIZ);
141895c635efSGarrett D'Amore 
141995c635efSGarrett D'Amore 		sz = strlen(buf);
142095c635efSGarrett D'Amore 		if (sz && ('>' == buf[sz - 1] || '"' == buf[sz - 1]))
142195c635efSGarrett D'Amore 			buf[sz - 1] = '\0';
142295c635efSGarrett D'Amore 
142395c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "link-includes");
142495c635efSGarrett D'Amore 
142595c635efSGarrett D'Amore 		i = 1;
142695c635efSGarrett D'Amore 		if (h->base_includes) {
142795c635efSGarrett D'Amore 			buffmt_includes(h, buf);
142895c635efSGarrett D'Amore 			PAIR_HREF_INIT(&tag[i], h->buf);
142995c635efSGarrett D'Amore 			i++;
143095c635efSGarrett D'Amore 		}
143195c635efSGarrett D'Amore 
143295c635efSGarrett D'Amore 		t = print_otag(h, TAG_A, i, tag);
143395c635efSGarrett D'Amore 		print_text(h, n->string);
143495c635efSGarrett D'Amore 		print_tagq(h, t);
143595c635efSGarrett D'Amore 
143695c635efSGarrett D'Amore 		n = n->next;
143795c635efSGarrett D'Amore 	}
143895c635efSGarrett D'Amore 
143995c635efSGarrett D'Amore 	for ( ; n; n = n->next) {
144095c635efSGarrett D'Amore 		assert(MDOC_TEXT == n->type);
144195c635efSGarrett D'Amore 		print_text(h, n->string);
144295c635efSGarrett D'Amore 	}
144395c635efSGarrett D'Amore 
144495c635efSGarrett D'Amore 	return(0);
144595c635efSGarrett D'Amore }
144695c635efSGarrett D'Amore 
144795c635efSGarrett D'Amore 
144895c635efSGarrett D'Amore /* ARGSUSED */
144995c635efSGarrett D'Amore static int
145095c635efSGarrett D'Amore mdoc_vt_pre(MDOC_ARGS)
145195c635efSGarrett D'Amore {
145295c635efSGarrett D'Amore 	struct htmlpair	 tag;
145395c635efSGarrett D'Amore 
145495c635efSGarrett D'Amore 	if (MDOC_BLOCK == n->type) {
145595c635efSGarrett D'Amore 		synopsis_pre(h, n);
145695c635efSGarrett D'Amore 		return(1);
145795c635efSGarrett D'Amore 	} else if (MDOC_ELEM == n->type) {
145895c635efSGarrett D'Amore 		synopsis_pre(h, n);
145995c635efSGarrett D'Amore 	} else if (MDOC_HEAD == n->type)
146095c635efSGarrett D'Amore 		return(0);
146195c635efSGarrett D'Amore 
146295c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "type");
146395c635efSGarrett D'Amore 	print_otag(h, TAG_SPAN, 1, &tag);
146495c635efSGarrett D'Amore 	return(1);
146595c635efSGarrett D'Amore }
146695c635efSGarrett D'Amore 
146795c635efSGarrett D'Amore 
146895c635efSGarrett D'Amore /* ARGSUSED */
146995c635efSGarrett D'Amore static int
147095c635efSGarrett D'Amore mdoc_ft_pre(MDOC_ARGS)
147195c635efSGarrett D'Amore {
147295c635efSGarrett D'Amore 	struct htmlpair	 tag;
147395c635efSGarrett D'Amore 
147495c635efSGarrett D'Amore 	synopsis_pre(h, n);
147595c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "ftype");
147695c635efSGarrett D'Amore 	print_otag(h, TAG_I, 1, &tag);
147795c635efSGarrett D'Amore 	return(1);
147895c635efSGarrett D'Amore }
147995c635efSGarrett D'Amore 
148095c635efSGarrett D'Amore 
148195c635efSGarrett D'Amore /* ARGSUSED */
148295c635efSGarrett D'Amore static int
148395c635efSGarrett D'Amore mdoc_fn_pre(MDOC_ARGS)
148495c635efSGarrett D'Amore {
148595c635efSGarrett D'Amore 	struct tag	*t;
148695c635efSGarrett D'Amore 	struct htmlpair	 tag[2];
148795c635efSGarrett D'Amore 	char		 nbuf[BUFSIZ];
148895c635efSGarrett D'Amore 	const char	*sp, *ep;
148995c635efSGarrett D'Amore 	int		 sz, i, pretty;
149095c635efSGarrett D'Amore 
149195c635efSGarrett D'Amore 	pretty = MDOC_SYNPRETTY & n->flags;
149295c635efSGarrett D'Amore 	synopsis_pre(h, n);
149395c635efSGarrett D'Amore 
149495c635efSGarrett D'Amore 	/* Split apart into type and name. */
149595c635efSGarrett D'Amore 	assert(n->child->string);
149695c635efSGarrett D'Amore 	sp = n->child->string;
149795c635efSGarrett D'Amore 
149895c635efSGarrett D'Amore 	ep = strchr(sp, ' ');
149995c635efSGarrett D'Amore 	if (NULL != ep) {
150095c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "ftype");
150195c635efSGarrett D'Amore 		t = print_otag(h, TAG_I, 1, tag);
150295c635efSGarrett D'Amore 
150395c635efSGarrett D'Amore 		while (ep) {
150495c635efSGarrett D'Amore 			sz = MIN((int)(ep - sp), BUFSIZ - 1);
150595c635efSGarrett D'Amore 			(void)memcpy(nbuf, sp, (size_t)sz);
150695c635efSGarrett D'Amore 			nbuf[sz] = '\0';
150795c635efSGarrett D'Amore 			print_text(h, nbuf);
150895c635efSGarrett D'Amore 			sp = ++ep;
150995c635efSGarrett D'Amore 			ep = strchr(sp, ' ');
151095c635efSGarrett D'Amore 		}
151195c635efSGarrett D'Amore 		print_tagq(h, t);
151295c635efSGarrett D'Amore 	}
151395c635efSGarrett D'Amore 
151495c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag[0], "fname");
151595c635efSGarrett D'Amore 
151695c635efSGarrett D'Amore 	/*
151795c635efSGarrett D'Amore 	 * FIXME: only refer to IDs that we know exist.
151895c635efSGarrett D'Amore 	 */
151995c635efSGarrett D'Amore 
152095c635efSGarrett D'Amore #if 0
152195c635efSGarrett D'Amore 	if (MDOC_SYNPRETTY & n->flags) {
152295c635efSGarrett D'Amore 		nbuf[0] = '\0';
152395c635efSGarrett D'Amore 		html_idcat(nbuf, sp, BUFSIZ);
152495c635efSGarrett D'Amore 		PAIR_ID_INIT(&tag[1], nbuf);
152595c635efSGarrett D'Amore 	} else {
152695c635efSGarrett D'Amore 		strlcpy(nbuf, "#", BUFSIZ);
152795c635efSGarrett D'Amore 		html_idcat(nbuf, sp, BUFSIZ);
152895c635efSGarrett D'Amore 		PAIR_HREF_INIT(&tag[1], nbuf);
152995c635efSGarrett D'Amore 	}
153095c635efSGarrett D'Amore #endif
153195c635efSGarrett D'Amore 
153295c635efSGarrett D'Amore 	t = print_otag(h, TAG_B, 1, tag);
153395c635efSGarrett D'Amore 
153495c635efSGarrett D'Amore 	if (sp) {
153595c635efSGarrett D'Amore 		strlcpy(nbuf, sp, BUFSIZ);
153695c635efSGarrett D'Amore 		print_text(h, nbuf);
153795c635efSGarrett D'Amore 	}
153895c635efSGarrett D'Amore 
153995c635efSGarrett D'Amore 	print_tagq(h, t);
154095c635efSGarrett D'Amore 
154195c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
154295c635efSGarrett D'Amore 	print_text(h, "(");
154395c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
154495c635efSGarrett D'Amore 
154595c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag[0], "farg");
154695c635efSGarrett D'Amore 	bufinit(h);
154795c635efSGarrett D'Amore 	bufcat_style(h, "white-space", "nowrap");
154895c635efSGarrett D'Amore 	PAIR_STYLE_INIT(&tag[1], h);
154995c635efSGarrett D'Amore 
155095c635efSGarrett D'Amore 	for (n = n->child->next; n; n = n->next) {
155195c635efSGarrett D'Amore 		i = 1;
155295c635efSGarrett D'Amore 		if (MDOC_SYNPRETTY & n->flags)
155395c635efSGarrett D'Amore 			i = 2;
155495c635efSGarrett D'Amore 		t = print_otag(h, TAG_I, i, tag);
155595c635efSGarrett D'Amore 		print_text(h, n->string);
155695c635efSGarrett D'Amore 		print_tagq(h, t);
155795c635efSGarrett D'Amore 		if (n->next) {
155895c635efSGarrett D'Amore 			h->flags |= HTML_NOSPACE;
155995c635efSGarrett D'Amore 			print_text(h, ",");
156095c635efSGarrett D'Amore 		}
156195c635efSGarrett D'Amore 	}
156295c635efSGarrett D'Amore 
156395c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
156495c635efSGarrett D'Amore 	print_text(h, ")");
156595c635efSGarrett D'Amore 
156695c635efSGarrett D'Amore 	if (pretty) {
156795c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
156895c635efSGarrett D'Amore 		print_text(h, ";");
156995c635efSGarrett D'Amore 	}
157095c635efSGarrett D'Amore 
157195c635efSGarrett D'Amore 	return(0);
157295c635efSGarrett D'Amore }
157395c635efSGarrett D'Amore 
157495c635efSGarrett D'Amore 
157595c635efSGarrett D'Amore /* ARGSUSED */
157695c635efSGarrett D'Amore static int
157795c635efSGarrett D'Amore mdoc_sm_pre(MDOC_ARGS)
157895c635efSGarrett D'Amore {
157995c635efSGarrett D'Amore 
158095c635efSGarrett D'Amore 	assert(n->child && MDOC_TEXT == n->child->type);
158195c635efSGarrett D'Amore 	if (0 == strcmp("on", n->child->string)) {
158295c635efSGarrett D'Amore 		/*
158395c635efSGarrett D'Amore 		 * FIXME: no p->col to check.  Thus, if we have
158495c635efSGarrett D'Amore 		 *  .Bd -literal
158595c635efSGarrett D'Amore 		 *  .Sm off
158695c635efSGarrett D'Amore 		 *  1 2
158795c635efSGarrett D'Amore 		 *  .Sm on
158895c635efSGarrett D'Amore 		 *  3
158995c635efSGarrett D'Amore 		 *  .Ed
159095c635efSGarrett D'Amore 		 * the "3" is preceded by a space.
159195c635efSGarrett D'Amore 		 */
159295c635efSGarrett D'Amore 		h->flags &= ~HTML_NOSPACE;
159395c635efSGarrett D'Amore 		h->flags &= ~HTML_NONOSPACE;
159495c635efSGarrett D'Amore 	} else
159595c635efSGarrett D'Amore 		h->flags |= HTML_NONOSPACE;
159695c635efSGarrett D'Amore 
159795c635efSGarrett D'Amore 	return(0);
159895c635efSGarrett D'Amore }
159995c635efSGarrett D'Amore 
160095c635efSGarrett D'Amore /* ARGSUSED */
160195c635efSGarrett D'Amore static int
160295c635efSGarrett D'Amore mdoc_pp_pre(MDOC_ARGS)
160395c635efSGarrett D'Amore {
160495c635efSGarrett D'Amore 
160595c635efSGarrett D'Amore 	print_otag(h, TAG_P, 0, NULL);
160695c635efSGarrett D'Amore 	return(0);
160795c635efSGarrett D'Amore 
160895c635efSGarrett D'Amore }
160995c635efSGarrett D'Amore 
161095c635efSGarrett D'Amore /* ARGSUSED */
161195c635efSGarrett D'Amore static int
161295c635efSGarrett D'Amore mdoc_sp_pre(MDOC_ARGS)
161395c635efSGarrett D'Amore {
161495c635efSGarrett D'Amore 	struct roffsu	 su;
161595c635efSGarrett D'Amore 	struct htmlpair	 tag;
161695c635efSGarrett D'Amore 
161795c635efSGarrett D'Amore 	SCALE_VS_INIT(&su, 1);
161895c635efSGarrett D'Amore 
161995c635efSGarrett D'Amore 	if (MDOC_sp == n->tok) {
162095c635efSGarrett D'Amore 		if (NULL != (n = n->child))
162195c635efSGarrett D'Amore 			if ( ! a2roffsu(n->string, &su, SCALE_VS))
162295c635efSGarrett D'Amore 				SCALE_VS_INIT(&su, atoi(n->string));
162395c635efSGarrett D'Amore 	} else
162495c635efSGarrett D'Amore 		su.scale = 0;
162595c635efSGarrett D'Amore 
162695c635efSGarrett D'Amore 	bufinit(h);
162795c635efSGarrett D'Amore 	bufcat_su(h, "height", &su);
162895c635efSGarrett D'Amore 	PAIR_STYLE_INIT(&tag, h);
162995c635efSGarrett D'Amore 	print_otag(h, TAG_DIV, 1, &tag);
163095c635efSGarrett D'Amore 
163195c635efSGarrett D'Amore 	/* So the div isn't empty: */
163295c635efSGarrett D'Amore 	print_text(h, "\\~");
163395c635efSGarrett D'Amore 
163495c635efSGarrett D'Amore 	return(0);
163595c635efSGarrett D'Amore 
163695c635efSGarrett D'Amore }
163795c635efSGarrett D'Amore 
163895c635efSGarrett D'Amore /* ARGSUSED */
163995c635efSGarrett D'Amore static int
164095c635efSGarrett D'Amore mdoc_lk_pre(MDOC_ARGS)
164195c635efSGarrett D'Amore {
164295c635efSGarrett D'Amore 	struct htmlpair	 tag[2];
164395c635efSGarrett D'Amore 
164495c635efSGarrett D'Amore 	if (NULL == (n = n->child))
164595c635efSGarrett D'Amore 		return(0);
164695c635efSGarrett D'Amore 
164795c635efSGarrett D'Amore 	assert(MDOC_TEXT == n->type);
164895c635efSGarrett D'Amore 
164995c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag[0], "link-ext");
165095c635efSGarrett D'Amore 	PAIR_HREF_INIT(&tag[1], n->string);
165195c635efSGarrett D'Amore 
165295c635efSGarrett D'Amore 	print_otag(h, TAG_A, 2, tag);
165395c635efSGarrett D'Amore 
165495c635efSGarrett D'Amore 	if (NULL == n->next)
165595c635efSGarrett D'Amore 		print_text(h, n->string);
165695c635efSGarrett D'Amore 
165795c635efSGarrett D'Amore 	for (n = n->next; n; n = n->next)
165895c635efSGarrett D'Amore 		print_text(h, n->string);
165995c635efSGarrett D'Amore 
166095c635efSGarrett D'Amore 	return(0);
166195c635efSGarrett D'Amore }
166295c635efSGarrett D'Amore 
166395c635efSGarrett D'Amore 
166495c635efSGarrett D'Amore /* ARGSUSED */
166595c635efSGarrett D'Amore static int
166695c635efSGarrett D'Amore mdoc_mt_pre(MDOC_ARGS)
166795c635efSGarrett D'Amore {
166895c635efSGarrett D'Amore 	struct htmlpair	 tag[2];
166995c635efSGarrett D'Amore 	struct tag	*t;
167095c635efSGarrett D'Amore 
167195c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag[0], "link-mail");
167295c635efSGarrett D'Amore 
167395c635efSGarrett D'Amore 	for (n = n->child; n; n = n->next) {
167495c635efSGarrett D'Amore 		assert(MDOC_TEXT == n->type);
167595c635efSGarrett D'Amore 
167695c635efSGarrett D'Amore 		bufinit(h);
167795c635efSGarrett D'Amore 		bufcat(h, "mailto:");
167895c635efSGarrett D'Amore 		bufcat(h, n->string);
167995c635efSGarrett D'Amore 
168095c635efSGarrett D'Amore 		PAIR_HREF_INIT(&tag[1], h->buf);
168195c635efSGarrett D'Amore 		t = print_otag(h, TAG_A, 2, tag);
168295c635efSGarrett D'Amore 		print_text(h, n->string);
168395c635efSGarrett D'Amore 		print_tagq(h, t);
168495c635efSGarrett D'Amore 	}
168595c635efSGarrett D'Amore 
168695c635efSGarrett D'Amore 	return(0);
168795c635efSGarrett D'Amore }
168895c635efSGarrett D'Amore 
168995c635efSGarrett D'Amore 
169095c635efSGarrett D'Amore /* ARGSUSED */
169195c635efSGarrett D'Amore static int
169295c635efSGarrett D'Amore mdoc_fo_pre(MDOC_ARGS)
169395c635efSGarrett D'Amore {
169495c635efSGarrett D'Amore 	struct htmlpair	 tag;
169595c635efSGarrett D'Amore 	struct tag	*t;
169695c635efSGarrett D'Amore 
169795c635efSGarrett D'Amore 	if (MDOC_BODY == n->type) {
169895c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
169995c635efSGarrett D'Amore 		print_text(h, "(");
170095c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
170195c635efSGarrett D'Amore 		return(1);
170295c635efSGarrett D'Amore 	} else if (MDOC_BLOCK == n->type) {
170395c635efSGarrett D'Amore 		synopsis_pre(h, n);
170495c635efSGarrett D'Amore 		return(1);
170595c635efSGarrett D'Amore 	}
170695c635efSGarrett D'Amore 
170795c635efSGarrett D'Amore 	/* XXX: we drop non-initial arguments as per groff. */
170895c635efSGarrett D'Amore 
170995c635efSGarrett D'Amore 	assert(n->child);
171095c635efSGarrett D'Amore 	assert(n->child->string);
171195c635efSGarrett D'Amore 
171295c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "fname");
171395c635efSGarrett D'Amore 	t = print_otag(h, TAG_B, 1, &tag);
171495c635efSGarrett D'Amore 	print_text(h, n->child->string);
171595c635efSGarrett D'Amore 	print_tagq(h, t);
171695c635efSGarrett D'Amore 	return(0);
171795c635efSGarrett D'Amore }
171895c635efSGarrett D'Amore 
171995c635efSGarrett D'Amore 
172095c635efSGarrett D'Amore /* ARGSUSED */
172195c635efSGarrett D'Amore static void
172295c635efSGarrett D'Amore mdoc_fo_post(MDOC_ARGS)
172395c635efSGarrett D'Amore {
172495c635efSGarrett D'Amore 
172595c635efSGarrett D'Amore 	if (MDOC_BODY != n->type)
172695c635efSGarrett D'Amore 		return;
172795c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
172895c635efSGarrett D'Amore 	print_text(h, ")");
172995c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
173095c635efSGarrett D'Amore 	print_text(h, ";");
173195c635efSGarrett D'Amore }
173295c635efSGarrett D'Amore 
173395c635efSGarrett D'Amore 
173495c635efSGarrett D'Amore /* ARGSUSED */
173595c635efSGarrett D'Amore static int
173695c635efSGarrett D'Amore mdoc_in_pre(MDOC_ARGS)
173795c635efSGarrett D'Amore {
173895c635efSGarrett D'Amore 	struct tag	*t;
173995c635efSGarrett D'Amore 	struct htmlpair	 tag[2];
174095c635efSGarrett D'Amore 	int		 i;
174195c635efSGarrett D'Amore 
174295c635efSGarrett D'Amore 	synopsis_pre(h, n);
174395c635efSGarrett D'Amore 
174495c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag[0], "includes");
174595c635efSGarrett D'Amore 	print_otag(h, TAG_B, 1, tag);
174695c635efSGarrett D'Amore 
174795c635efSGarrett D'Amore 	/*
174895c635efSGarrett D'Amore 	 * The first argument of the `In' gets special treatment as
174995c635efSGarrett D'Amore 	 * being a linked value.  Subsequent values are printed
175095c635efSGarrett D'Amore 	 * afterward.  groff does similarly.  This also handles the case
175195c635efSGarrett D'Amore 	 * of no children.
175295c635efSGarrett D'Amore 	 */
175395c635efSGarrett D'Amore 
175495c635efSGarrett D'Amore 	if (MDOC_SYNPRETTY & n->flags && MDOC_LINE & n->flags)
175595c635efSGarrett D'Amore 		print_text(h, "#include");
175695c635efSGarrett D'Amore 
175795c635efSGarrett D'Amore 	print_text(h, "<");
175895c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
175995c635efSGarrett D'Amore 
176095c635efSGarrett D'Amore 	if (NULL != (n = n->child)) {
176195c635efSGarrett D'Amore 		assert(MDOC_TEXT == n->type);
176295c635efSGarrett D'Amore 
176395c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "link-includes");
176495c635efSGarrett D'Amore 
176595c635efSGarrett D'Amore 		i = 1;
176695c635efSGarrett D'Amore 		if (h->base_includes) {
176795c635efSGarrett D'Amore 			buffmt_includes(h, n->string);
176895c635efSGarrett D'Amore 			PAIR_HREF_INIT(&tag[i], h->buf);
176995c635efSGarrett D'Amore 			i++;
177095c635efSGarrett D'Amore 		}
177195c635efSGarrett D'Amore 
177295c635efSGarrett D'Amore 		t = print_otag(h, TAG_A, i, tag);
177395c635efSGarrett D'Amore 		print_text(h, n->string);
177495c635efSGarrett D'Amore 		print_tagq(h, t);
177595c635efSGarrett D'Amore 
177695c635efSGarrett D'Amore 		n = n->next;
177795c635efSGarrett D'Amore 	}
177895c635efSGarrett D'Amore 
177995c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
178095c635efSGarrett D'Amore 	print_text(h, ">");
178195c635efSGarrett D'Amore 
178295c635efSGarrett D'Amore 	for ( ; n; n = n->next) {
178395c635efSGarrett D'Amore 		assert(MDOC_TEXT == n->type);
178495c635efSGarrett D'Amore 		print_text(h, n->string);
178595c635efSGarrett D'Amore 	}
178695c635efSGarrett D'Amore 
178795c635efSGarrett D'Amore 	return(0);
178895c635efSGarrett D'Amore }
178995c635efSGarrett D'Amore 
179095c635efSGarrett D'Amore 
179195c635efSGarrett D'Amore /* ARGSUSED */
179295c635efSGarrett D'Amore static int
179395c635efSGarrett D'Amore mdoc_ic_pre(MDOC_ARGS)
179495c635efSGarrett D'Amore {
179595c635efSGarrett D'Amore 	struct htmlpair	tag;
179695c635efSGarrett D'Amore 
179795c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "cmd");
179895c635efSGarrett D'Amore 	print_otag(h, TAG_B, 1, &tag);
179995c635efSGarrett D'Amore 	return(1);
180095c635efSGarrett D'Amore }
180195c635efSGarrett D'Amore 
180295c635efSGarrett D'Amore 
180395c635efSGarrett D'Amore /* ARGSUSED */
180495c635efSGarrett D'Amore static int
180595c635efSGarrett D'Amore mdoc_rv_pre(MDOC_ARGS)
180695c635efSGarrett D'Amore {
180795c635efSGarrett D'Amore 	struct htmlpair	 tag;
180895c635efSGarrett D'Amore 	struct tag	*t;
180995c635efSGarrett D'Amore 	int		 nchild;
181095c635efSGarrett D'Amore 
181195c635efSGarrett D'Amore 	if (n->prev)
181295c635efSGarrett D'Amore 		print_otag(h, TAG_BR, 0, NULL);
181395c635efSGarrett D'Amore 
181495c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "fname");
181595c635efSGarrett D'Amore 
181695c635efSGarrett D'Amore 	print_text(h, "The");
181795c635efSGarrett D'Amore 
181895c635efSGarrett D'Amore 	nchild = n->nchild;
181995c635efSGarrett D'Amore 	for (n = n->child; n; n = n->next) {
182095c635efSGarrett D'Amore 		assert(MDOC_TEXT == n->type);
182195c635efSGarrett D'Amore 
182295c635efSGarrett D'Amore 		t = print_otag(h, TAG_B, 1, &tag);
182395c635efSGarrett D'Amore 		print_text(h, n->string);
182495c635efSGarrett D'Amore 		print_tagq(h, t);
182595c635efSGarrett D'Amore 
182695c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
182795c635efSGarrett D'Amore 		print_text(h, "()");
182895c635efSGarrett D'Amore 
182995c635efSGarrett D'Amore 		if (nchild > 2 && n->next) {
183095c635efSGarrett D'Amore 			h->flags |= HTML_NOSPACE;
183195c635efSGarrett D'Amore 			print_text(h, ",");
183295c635efSGarrett D'Amore 		}
183395c635efSGarrett D'Amore 
183495c635efSGarrett D'Amore 		if (n->next && NULL == n->next->next)
183595c635efSGarrett D'Amore 			print_text(h, "and");
183695c635efSGarrett D'Amore 	}
183795c635efSGarrett D'Amore 
183895c635efSGarrett D'Amore 	if (nchild > 1)
183995c635efSGarrett D'Amore 		print_text(h, "functions return");
184095c635efSGarrett D'Amore 	else
184195c635efSGarrett D'Amore 		print_text(h, "function returns");
184295c635efSGarrett D'Amore 
184395c635efSGarrett D'Amore        	print_text(h, "the value 0 if successful; otherwise the value "
184495c635efSGarrett D'Amore 			"-1 is returned and the global variable");
184595c635efSGarrett D'Amore 
184695c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "var");
184795c635efSGarrett D'Amore 	t = print_otag(h, TAG_B, 1, &tag);
184895c635efSGarrett D'Amore 	print_text(h, "errno");
184995c635efSGarrett D'Amore 	print_tagq(h, t);
185095c635efSGarrett D'Amore        	print_text(h, "is set to indicate the error.");
185195c635efSGarrett D'Amore 	return(0);
185295c635efSGarrett D'Amore }
185395c635efSGarrett D'Amore 
185495c635efSGarrett D'Amore 
185595c635efSGarrett D'Amore /* ARGSUSED */
185695c635efSGarrett D'Amore static int
185795c635efSGarrett D'Amore mdoc_va_pre(MDOC_ARGS)
185895c635efSGarrett D'Amore {
185995c635efSGarrett D'Amore 	struct htmlpair	tag;
186095c635efSGarrett D'Amore 
186195c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "var");
186295c635efSGarrett D'Amore 	print_otag(h, TAG_B, 1, &tag);
186395c635efSGarrett D'Amore 	return(1);
186495c635efSGarrett D'Amore }
186595c635efSGarrett D'Amore 
186695c635efSGarrett D'Amore 
186795c635efSGarrett D'Amore /* ARGSUSED */
186895c635efSGarrett D'Amore static int
186995c635efSGarrett D'Amore mdoc_ap_pre(MDOC_ARGS)
187095c635efSGarrett D'Amore {
187195c635efSGarrett D'Amore 
187295c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
187395c635efSGarrett D'Amore 	print_text(h, "\\(aq");
187495c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
187595c635efSGarrett D'Amore 	return(1);
187695c635efSGarrett D'Amore }
187795c635efSGarrett D'Amore 
187895c635efSGarrett D'Amore 
187995c635efSGarrett D'Amore /* ARGSUSED */
188095c635efSGarrett D'Amore static int
188195c635efSGarrett D'Amore mdoc_bf_pre(MDOC_ARGS)
188295c635efSGarrett D'Amore {
188395c635efSGarrett D'Amore 	struct htmlpair	 tag[2];
188495c635efSGarrett D'Amore 	struct roffsu	 su;
188595c635efSGarrett D'Amore 
188695c635efSGarrett D'Amore 	if (MDOC_HEAD == n->type)
188795c635efSGarrett D'Amore 		return(0);
188895c635efSGarrett D'Amore 	else if (MDOC_BODY != n->type)
188995c635efSGarrett D'Amore 		return(1);
189095c635efSGarrett D'Amore 
189195c635efSGarrett D'Amore 	if (FONT_Em == n->norm->Bf.font)
189295c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "emph");
189395c635efSGarrett D'Amore 	else if (FONT_Sy == n->norm->Bf.font)
189495c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "symb");
189595c635efSGarrett D'Amore 	else if (FONT_Li == n->norm->Bf.font)
189695c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "lit");
189795c635efSGarrett D'Amore 	else
189895c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "none");
189995c635efSGarrett D'Amore 
190095c635efSGarrett D'Amore 	/*
190195c635efSGarrett D'Amore 	 * We want this to be inline-formatted, but needs to be div to
190295c635efSGarrett D'Amore 	 * accept block children.
190395c635efSGarrett D'Amore 	 */
190495c635efSGarrett D'Amore 	bufinit(h);
190595c635efSGarrett D'Amore 	bufcat_style(h, "display", "inline");
190695c635efSGarrett D'Amore 	SCALE_HS_INIT(&su, 1);
190795c635efSGarrett D'Amore 	/* Needs a left-margin for spacing. */
190895c635efSGarrett D'Amore 	bufcat_su(h, "margin-left", &su);
190995c635efSGarrett D'Amore 	PAIR_STYLE_INIT(&tag[1], h);
191095c635efSGarrett D'Amore 	print_otag(h, TAG_DIV, 2, tag);
191195c635efSGarrett D'Amore 	return(1);
191295c635efSGarrett D'Amore }
191395c635efSGarrett D'Amore 
191495c635efSGarrett D'Amore 
191595c635efSGarrett D'Amore /* ARGSUSED */
191695c635efSGarrett D'Amore static int
191795c635efSGarrett D'Amore mdoc_ms_pre(MDOC_ARGS)
191895c635efSGarrett D'Amore {
191995c635efSGarrett D'Amore 	struct htmlpair	tag;
192095c635efSGarrett D'Amore 
192195c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "symb");
192295c635efSGarrett D'Amore 	print_otag(h, TAG_SPAN, 1, &tag);
192395c635efSGarrett D'Amore 	return(1);
192495c635efSGarrett D'Amore }
192595c635efSGarrett D'Amore 
192695c635efSGarrett D'Amore 
192795c635efSGarrett D'Amore /* ARGSUSED */
192895c635efSGarrett D'Amore static int
192995c635efSGarrett D'Amore mdoc_igndelim_pre(MDOC_ARGS)
193095c635efSGarrett D'Amore {
193195c635efSGarrett D'Amore 
193295c635efSGarrett D'Amore 	h->flags |= HTML_IGNDELIM;
193395c635efSGarrett D'Amore 	return(1);
193495c635efSGarrett D'Amore }
193595c635efSGarrett D'Amore 
193695c635efSGarrett D'Amore 
193795c635efSGarrett D'Amore /* ARGSUSED */
193895c635efSGarrett D'Amore static void
193995c635efSGarrett D'Amore mdoc_pf_post(MDOC_ARGS)
194095c635efSGarrett D'Amore {
194195c635efSGarrett D'Amore 
194295c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
194395c635efSGarrett D'Amore }
194495c635efSGarrett D'Amore 
194595c635efSGarrett D'Amore 
194695c635efSGarrett D'Amore /* ARGSUSED */
194795c635efSGarrett D'Amore static int
194895c635efSGarrett D'Amore mdoc_rs_pre(MDOC_ARGS)
194995c635efSGarrett D'Amore {
195095c635efSGarrett D'Amore 	struct htmlpair	 tag;
195195c635efSGarrett D'Amore 
195295c635efSGarrett D'Amore 	if (MDOC_BLOCK != n->type)
195395c635efSGarrett D'Amore 		return(1);
195495c635efSGarrett D'Amore 
195595c635efSGarrett D'Amore 	if (n->prev && SEC_SEE_ALSO == n->sec)
195695c635efSGarrett D'Amore 		print_otag(h, TAG_P, 0, NULL);
195795c635efSGarrett D'Amore 
195895c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "ref");
195995c635efSGarrett D'Amore 	print_otag(h, TAG_SPAN, 1, &tag);
196095c635efSGarrett D'Amore 	return(1);
196195c635efSGarrett D'Amore }
196295c635efSGarrett D'Amore 
196395c635efSGarrett D'Amore 
196495c635efSGarrett D'Amore 
196595c635efSGarrett D'Amore /* ARGSUSED */
196695c635efSGarrett D'Amore static int
196795c635efSGarrett D'Amore mdoc_li_pre(MDOC_ARGS)
196895c635efSGarrett D'Amore {
196995c635efSGarrett D'Amore 	struct htmlpair	tag;
197095c635efSGarrett D'Amore 
197195c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "lit");
197295c635efSGarrett D'Amore 	print_otag(h, TAG_CODE, 1, &tag);
197395c635efSGarrett D'Amore 	return(1);
197495c635efSGarrett D'Amore }
197595c635efSGarrett D'Amore 
197695c635efSGarrett D'Amore 
197795c635efSGarrett D'Amore /* ARGSUSED */
197895c635efSGarrett D'Amore static int
197995c635efSGarrett D'Amore mdoc_sy_pre(MDOC_ARGS)
198095c635efSGarrett D'Amore {
198195c635efSGarrett D'Amore 	struct htmlpair	tag;
198295c635efSGarrett D'Amore 
198395c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "symb");
198495c635efSGarrett D'Amore 	print_otag(h, TAG_SPAN, 1, &tag);
198595c635efSGarrett D'Amore 	return(1);
198695c635efSGarrett D'Amore }
198795c635efSGarrett D'Amore 
198895c635efSGarrett D'Amore 
198995c635efSGarrett D'Amore /* ARGSUSED */
199095c635efSGarrett D'Amore static int
199195c635efSGarrett D'Amore mdoc_bt_pre(MDOC_ARGS)
199295c635efSGarrett D'Amore {
199395c635efSGarrett D'Amore 
199495c635efSGarrett D'Amore 	print_text(h, "is currently in beta test.");
199595c635efSGarrett D'Amore 	return(0);
199695c635efSGarrett D'Amore }
199795c635efSGarrett D'Amore 
199895c635efSGarrett D'Amore 
199995c635efSGarrett D'Amore /* ARGSUSED */
200095c635efSGarrett D'Amore static int
200195c635efSGarrett D'Amore mdoc_ud_pre(MDOC_ARGS)
200295c635efSGarrett D'Amore {
200395c635efSGarrett D'Amore 
200495c635efSGarrett D'Amore 	print_text(h, "currently under development.");
200595c635efSGarrett D'Amore 	return(0);
200695c635efSGarrett D'Amore }
200795c635efSGarrett D'Amore 
200895c635efSGarrett D'Amore 
200995c635efSGarrett D'Amore /* ARGSUSED */
201095c635efSGarrett D'Amore static int
201195c635efSGarrett D'Amore mdoc_lb_pre(MDOC_ARGS)
201295c635efSGarrett D'Amore {
201395c635efSGarrett D'Amore 	struct htmlpair	tag;
201495c635efSGarrett D'Amore 
201595c635efSGarrett D'Amore 	if (SEC_LIBRARY == n->sec && MDOC_LINE & n->flags && n->prev)
201695c635efSGarrett D'Amore 		print_otag(h, TAG_BR, 0, NULL);
201795c635efSGarrett D'Amore 
201895c635efSGarrett D'Amore 	PAIR_CLASS_INIT(&tag, "lib");
201995c635efSGarrett D'Amore 	print_otag(h, TAG_SPAN, 1, &tag);
202095c635efSGarrett D'Amore 	return(1);
202195c635efSGarrett D'Amore }
202295c635efSGarrett D'Amore 
202395c635efSGarrett D'Amore 
202495c635efSGarrett D'Amore /* ARGSUSED */
202595c635efSGarrett D'Amore static int
202695c635efSGarrett D'Amore mdoc__x_pre(MDOC_ARGS)
202795c635efSGarrett D'Amore {
202895c635efSGarrett D'Amore 	struct htmlpair	tag[2];
202995c635efSGarrett D'Amore 	enum htmltag	t;
203095c635efSGarrett D'Amore 
203195c635efSGarrett D'Amore 	t = TAG_SPAN;
203295c635efSGarrett D'Amore 
203395c635efSGarrett D'Amore 	switch (n->tok) {
203495c635efSGarrett D'Amore 	case(MDOC__A):
203595c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "ref-auth");
203695c635efSGarrett D'Amore 		if (n->prev && MDOC__A == n->prev->tok)
203795c635efSGarrett D'Amore 			if (NULL == n->next || MDOC__A != n->next->tok)
203895c635efSGarrett D'Amore 				print_text(h, "and");
203995c635efSGarrett D'Amore 		break;
204095c635efSGarrett D'Amore 	case(MDOC__B):
204195c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "ref-book");
204295c635efSGarrett D'Amore 		t = TAG_I;
204395c635efSGarrett D'Amore 		break;
204495c635efSGarrett D'Amore 	case(MDOC__C):
204595c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "ref-city");
204695c635efSGarrett D'Amore 		break;
204795c635efSGarrett D'Amore 	case(MDOC__D):
204895c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "ref-date");
204995c635efSGarrett D'Amore 		break;
205095c635efSGarrett D'Amore 	case(MDOC__I):
205195c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "ref-issue");
205295c635efSGarrett D'Amore 		t = TAG_I;
205395c635efSGarrett D'Amore 		break;
205495c635efSGarrett D'Amore 	case(MDOC__J):
205595c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "ref-jrnl");
205695c635efSGarrett D'Amore 		t = TAG_I;
205795c635efSGarrett D'Amore 		break;
205895c635efSGarrett D'Amore 	case(MDOC__N):
205995c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "ref-num");
206095c635efSGarrett D'Amore 		break;
206195c635efSGarrett D'Amore 	case(MDOC__O):
206295c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "ref-opt");
206395c635efSGarrett D'Amore 		break;
206495c635efSGarrett D'Amore 	case(MDOC__P):
206595c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "ref-page");
206695c635efSGarrett D'Amore 		break;
206795c635efSGarrett D'Amore 	case(MDOC__Q):
206895c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "ref-corp");
206995c635efSGarrett D'Amore 		break;
207095c635efSGarrett D'Amore 	case(MDOC__R):
207195c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "ref-rep");
207295c635efSGarrett D'Amore 		break;
207395c635efSGarrett D'Amore 	case(MDOC__T):
207495c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "ref-title");
207595c635efSGarrett D'Amore 		break;
207695c635efSGarrett D'Amore 	case(MDOC__U):
207795c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "link-ref");
207895c635efSGarrett D'Amore 		break;
207995c635efSGarrett D'Amore 	case(MDOC__V):
208095c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag[0], "ref-vol");
208195c635efSGarrett D'Amore 		break;
208295c635efSGarrett D'Amore 	default:
208395c635efSGarrett D'Amore 		abort();
208495c635efSGarrett D'Amore 		/* NOTREACHED */
208595c635efSGarrett D'Amore 	}
208695c635efSGarrett D'Amore 
208795c635efSGarrett D'Amore 	if (MDOC__U != n->tok) {
208895c635efSGarrett D'Amore 		print_otag(h, t, 1, tag);
208995c635efSGarrett D'Amore 		return(1);
209095c635efSGarrett D'Amore 	}
209195c635efSGarrett D'Amore 
209295c635efSGarrett D'Amore 	PAIR_HREF_INIT(&tag[1], n->child->string);
209395c635efSGarrett D'Amore 	print_otag(h, TAG_A, 2, tag);
209495c635efSGarrett D'Amore 
209595c635efSGarrett D'Amore 	return(1);
209695c635efSGarrett D'Amore }
209795c635efSGarrett D'Amore 
209895c635efSGarrett D'Amore 
209995c635efSGarrett D'Amore /* ARGSUSED */
210095c635efSGarrett D'Amore static void
210195c635efSGarrett D'Amore mdoc__x_post(MDOC_ARGS)
210295c635efSGarrett D'Amore {
210395c635efSGarrett D'Amore 
210495c635efSGarrett D'Amore 	if (MDOC__A == n->tok && n->next && MDOC__A == n->next->tok)
210595c635efSGarrett D'Amore 		if (NULL == n->next->next || MDOC__A != n->next->next->tok)
210695c635efSGarrett D'Amore 			if (NULL == n->prev || MDOC__A != n->prev->tok)
210795c635efSGarrett D'Amore 				return;
210895c635efSGarrett D'Amore 
210995c635efSGarrett D'Amore 	/* TODO: %U */
211095c635efSGarrett D'Amore 
211195c635efSGarrett D'Amore 	if (NULL == n->parent || MDOC_Rs != n->parent->tok)
211295c635efSGarrett D'Amore 		return;
211395c635efSGarrett D'Amore 
211495c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
211595c635efSGarrett D'Amore 	print_text(h, n->next ? "," : ".");
211695c635efSGarrett D'Amore }
211795c635efSGarrett D'Amore 
211895c635efSGarrett D'Amore 
211995c635efSGarrett D'Amore /* ARGSUSED */
212095c635efSGarrett D'Amore static int
212195c635efSGarrett D'Amore mdoc_bk_pre(MDOC_ARGS)
212295c635efSGarrett D'Amore {
212395c635efSGarrett D'Amore 
212495c635efSGarrett D'Amore 	switch (n->type) {
212595c635efSGarrett D'Amore 	case (MDOC_BLOCK):
212695c635efSGarrett D'Amore 		break;
212795c635efSGarrett D'Amore 	case (MDOC_HEAD):
212895c635efSGarrett D'Amore 		return(0);
212995c635efSGarrett D'Amore 	case (MDOC_BODY):
213095c635efSGarrett D'Amore 		if (n->parent->args || 0 == n->prev->nchild)
213195c635efSGarrett D'Amore 			h->flags |= HTML_PREKEEP;
213295c635efSGarrett D'Amore 		break;
213395c635efSGarrett D'Amore 	default:
213495c635efSGarrett D'Amore 		abort();
213595c635efSGarrett D'Amore 		/* NOTREACHED */
213695c635efSGarrett D'Amore 	}
213795c635efSGarrett D'Amore 
213895c635efSGarrett D'Amore 	return(1);
213995c635efSGarrett D'Amore }
214095c635efSGarrett D'Amore 
214195c635efSGarrett D'Amore 
214295c635efSGarrett D'Amore /* ARGSUSED */
214395c635efSGarrett D'Amore static void
214495c635efSGarrett D'Amore mdoc_bk_post(MDOC_ARGS)
214595c635efSGarrett D'Amore {
214695c635efSGarrett D'Amore 
214795c635efSGarrett D'Amore 	if (MDOC_BODY == n->type)
214895c635efSGarrett D'Amore 		h->flags &= ~(HTML_KEEP | HTML_PREKEEP);
214995c635efSGarrett D'Amore }
215095c635efSGarrett D'Amore 
215195c635efSGarrett D'Amore 
215295c635efSGarrett D'Amore /* ARGSUSED */
215395c635efSGarrett D'Amore static int
215495c635efSGarrett D'Amore mdoc_quote_pre(MDOC_ARGS)
215595c635efSGarrett D'Amore {
215695c635efSGarrett D'Amore 	struct htmlpair	tag;
215795c635efSGarrett D'Amore 
215895c635efSGarrett D'Amore 	if (MDOC_BODY != n->type)
215995c635efSGarrett D'Amore 		return(1);
216095c635efSGarrett D'Amore 
216195c635efSGarrett D'Amore 	switch (n->tok) {
216295c635efSGarrett D'Amore 	case (MDOC_Ao):
216395c635efSGarrett D'Amore 		/* FALLTHROUGH */
216495c635efSGarrett D'Amore 	case (MDOC_Aq):
216595c635efSGarrett D'Amore 		print_text(h, "\\(la");
216695c635efSGarrett D'Amore 		break;
216795c635efSGarrett D'Amore 	case (MDOC_Bro):
216895c635efSGarrett D'Amore 		/* FALLTHROUGH */
216995c635efSGarrett D'Amore 	case (MDOC_Brq):
217095c635efSGarrett D'Amore 		print_text(h, "\\(lC");
217195c635efSGarrett D'Amore 		break;
217295c635efSGarrett D'Amore 	case (MDOC_Bo):
217395c635efSGarrett D'Amore 		/* FALLTHROUGH */
217495c635efSGarrett D'Amore 	case (MDOC_Bq):
217595c635efSGarrett D'Amore 		print_text(h, "\\(lB");
217695c635efSGarrett D'Amore 		break;
217795c635efSGarrett D'Amore 	case (MDOC_Oo):
217895c635efSGarrett D'Amore 		/* FALLTHROUGH */
217995c635efSGarrett D'Amore 	case (MDOC_Op):
218095c635efSGarrett D'Amore 		print_text(h, "\\(lB");
218195c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
218295c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag, "opt");
218395c635efSGarrett D'Amore 		print_otag(h, TAG_SPAN, 1, &tag);
218495c635efSGarrett D'Amore 		break;
218595c635efSGarrett D'Amore 	case (MDOC_Eo):
218695c635efSGarrett D'Amore 		break;
218795c635efSGarrett D'Amore 	case (MDOC_Do):
218895c635efSGarrett D'Amore 		/* FALLTHROUGH */
218995c635efSGarrett D'Amore 	case (MDOC_Dq):
219095c635efSGarrett D'Amore 		/* FALLTHROUGH */
219195c635efSGarrett D'Amore 	case (MDOC_Qo):
219295c635efSGarrett D'Amore 		/* FALLTHROUGH */
219395c635efSGarrett D'Amore 	case (MDOC_Qq):
219495c635efSGarrett D'Amore 		print_text(h, "\\(lq");
219595c635efSGarrett D'Amore 		break;
219695c635efSGarrett D'Amore 	case (MDOC_Po):
219795c635efSGarrett D'Amore 		/* FALLTHROUGH */
219895c635efSGarrett D'Amore 	case (MDOC_Pq):
219995c635efSGarrett D'Amore 		print_text(h, "(");
220095c635efSGarrett D'Amore 		break;
220195c635efSGarrett D'Amore 	case (MDOC_Ql):
220295c635efSGarrett D'Amore 		print_text(h, "\\(oq");
220395c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
220495c635efSGarrett D'Amore 		PAIR_CLASS_INIT(&tag, "lit");
220595c635efSGarrett D'Amore 		print_otag(h, TAG_CODE, 1, &tag);
220695c635efSGarrett D'Amore 		break;
220795c635efSGarrett D'Amore 	case (MDOC_So):
220895c635efSGarrett D'Amore 		/* FALLTHROUGH */
220995c635efSGarrett D'Amore 	case (MDOC_Sq):
221095c635efSGarrett D'Amore 		print_text(h, "\\(oq");
221195c635efSGarrett D'Amore 		break;
221295c635efSGarrett D'Amore 	default:
221395c635efSGarrett D'Amore 		abort();
221495c635efSGarrett D'Amore 		/* NOTREACHED */
221595c635efSGarrett D'Amore 	}
221695c635efSGarrett D'Amore 
221795c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
221895c635efSGarrett D'Amore 	return(1);
221995c635efSGarrett D'Amore }
222095c635efSGarrett D'Amore 
222195c635efSGarrett D'Amore 
222295c635efSGarrett D'Amore /* ARGSUSED */
222395c635efSGarrett D'Amore static void
222495c635efSGarrett D'Amore mdoc_quote_post(MDOC_ARGS)
222595c635efSGarrett D'Amore {
222695c635efSGarrett D'Amore 
222795c635efSGarrett D'Amore 	if (MDOC_BODY != n->type)
222895c635efSGarrett D'Amore 		return;
222995c635efSGarrett D'Amore 
223095c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
223195c635efSGarrett D'Amore 
223295c635efSGarrett D'Amore 	switch (n->tok) {
223395c635efSGarrett D'Amore 	case (MDOC_Ao):
223495c635efSGarrett D'Amore 		/* FALLTHROUGH */
223595c635efSGarrett D'Amore 	case (MDOC_Aq):
223695c635efSGarrett D'Amore 		print_text(h, "\\(ra");
223795c635efSGarrett D'Amore 		break;
223895c635efSGarrett D'Amore 	case (MDOC_Bro):
223995c635efSGarrett D'Amore 		/* FALLTHROUGH */
224095c635efSGarrett D'Amore 	case (MDOC_Brq):
224195c635efSGarrett D'Amore 		print_text(h, "\\(rC");
224295c635efSGarrett D'Amore 		break;
224395c635efSGarrett D'Amore 	case (MDOC_Oo):
224495c635efSGarrett D'Amore 		/* FALLTHROUGH */
224595c635efSGarrett D'Amore 	case (MDOC_Op):
224695c635efSGarrett D'Amore 		/* FALLTHROUGH */
224795c635efSGarrett D'Amore 	case (MDOC_Bo):
224895c635efSGarrett D'Amore 		/* FALLTHROUGH */
224995c635efSGarrett D'Amore 	case (MDOC_Bq):
225095c635efSGarrett D'Amore 		print_text(h, "\\(rB");
225195c635efSGarrett D'Amore 		break;
225295c635efSGarrett D'Amore 	case (MDOC_Eo):
225395c635efSGarrett D'Amore 		break;
225495c635efSGarrett D'Amore 	case (MDOC_Qo):
225595c635efSGarrett D'Amore 		/* FALLTHROUGH */
225695c635efSGarrett D'Amore 	case (MDOC_Qq):
225795c635efSGarrett D'Amore 		/* FALLTHROUGH */
225895c635efSGarrett D'Amore 	case (MDOC_Do):
225995c635efSGarrett D'Amore 		/* FALLTHROUGH */
226095c635efSGarrett D'Amore 	case (MDOC_Dq):
226195c635efSGarrett D'Amore 		print_text(h, "\\(rq");
226295c635efSGarrett D'Amore 		break;
226395c635efSGarrett D'Amore 	case (MDOC_Po):
226495c635efSGarrett D'Amore 		/* FALLTHROUGH */
226595c635efSGarrett D'Amore 	case (MDOC_Pq):
226695c635efSGarrett D'Amore 		print_text(h, ")");
226795c635efSGarrett D'Amore 		break;
226895c635efSGarrett D'Amore 	case (MDOC_Ql):
226995c635efSGarrett D'Amore 		/* FALLTHROUGH */
227095c635efSGarrett D'Amore 	case (MDOC_So):
227195c635efSGarrett D'Amore 		/* FALLTHROUGH */
227295c635efSGarrett D'Amore 	case (MDOC_Sq):
2273*698f87a4SGarrett D'Amore 		print_text(h, "\\(cq");
227495c635efSGarrett D'Amore 		break;
227595c635efSGarrett D'Amore 	default:
227695c635efSGarrett D'Amore 		abort();
227795c635efSGarrett D'Amore 		/* NOTREACHED */
227895c635efSGarrett D'Amore 	}
227995c635efSGarrett D'Amore }
228095c635efSGarrett D'Amore 
228195c635efSGarrett D'Amore 
2282