xref: /illumos-gate/usr/src/cmd/mandoc/mdoc_html.c (revision 4d131170)
1*4d131170SRobert Mustacchi /* $Id: mdoc_html.c,v 1.342 2021/03/30 19:26:20 schwarze Exp $ */
295c635efSGarrett D'Amore /*
3*4d131170SRobert Mustacchi  * Copyright (c) 2014-2021 Ingo Schwarze <schwarze@openbsd.org>
4260e9a87SYuri Pankov  * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
595c635efSGarrett D'Amore  *
695c635efSGarrett D'Amore  * Permission to use, copy, modify, and distribute this software for any
795c635efSGarrett D'Amore  * purpose with or without fee is hereby granted, provided that the above
895c635efSGarrett D'Amore  * copyright notice and this permission notice appear in all copies.
995c635efSGarrett D'Amore  *
10371584c2SYuri Pankov  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
1195c635efSGarrett D'Amore  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12371584c2SYuri Pankov  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
1395c635efSGarrett D'Amore  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1495c635efSGarrett D'Amore  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1595c635efSGarrett D'Amore  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1695c635efSGarrett D'Amore  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*4d131170SRobert Mustacchi  *
18*4d131170SRobert Mustacchi  * HTML formatter for mdoc(7) used by mandoc(1).
1995c635efSGarrett D'Amore  */
2095c635efSGarrett D'Amore #include "config.h"
2195c635efSGarrett D'Amore 
2295c635efSGarrett D'Amore #include <sys/types.h>
2395c635efSGarrett D'Amore 
2495c635efSGarrett D'Amore #include <assert.h>
2595c635efSGarrett D'Amore #include <ctype.h>
2695c635efSGarrett D'Amore #include <stdio.h>
2795c635efSGarrett D'Amore #include <stdlib.h>
2895c635efSGarrett D'Amore #include <string.h>
2995c635efSGarrett D'Amore #include <unistd.h>
3095c635efSGarrett D'Amore 
31260e9a87SYuri Pankov #include "mandoc_aux.h"
32c66b8046SYuri Pankov #include "mandoc.h"
33371584c2SYuri Pankov #include "roff.h"
34260e9a87SYuri Pankov #include "mdoc.h"
3595c635efSGarrett D'Amore #include "out.h"
3695c635efSGarrett D'Amore #include "html.h"
3795c635efSGarrett D'Amore #include "main.h"
3895c635efSGarrett D'Amore 
39371584c2SYuri Pankov #define	MDOC_ARGS	  const struct roff_meta *meta, \
40371584c2SYuri Pankov 			  struct roff_node *n, \
4195c635efSGarrett D'Amore 			  struct html *h
4295c635efSGarrett D'Amore 
4395c635efSGarrett D'Amore #ifndef MIN
4495c635efSGarrett D'Amore #define	MIN(a,b)	((/*CONSTCOND*/(a)<(b))?(a):(b))
4595c635efSGarrett D'Amore #endif
4695c635efSGarrett D'Amore 
47cec8643bSMichal Nowak struct	mdoc_html_act {
4895c635efSGarrett D'Amore 	int		(*pre)(MDOC_ARGS);
4995c635efSGarrett D'Amore 	void		(*post)(MDOC_ARGS);
5095c635efSGarrett D'Amore };
5195c635efSGarrett D'Amore 
526640c13bSYuri Pankov static	void		  print_mdoc_head(const struct roff_meta *,
536640c13bSYuri Pankov 				struct html *);
5495c635efSGarrett D'Amore static	void		  print_mdoc_node(MDOC_ARGS);
5595c635efSGarrett D'Amore static	void		  print_mdoc_nodelist(MDOC_ARGS);
56*4d131170SRobert Mustacchi static	void		  synopsis_pre(struct html *, struct roff_node *);
5795c635efSGarrett D'Amore 
586640c13bSYuri Pankov static	void		  mdoc_root_post(const struct roff_meta *,
596640c13bSYuri Pankov 				struct html *);
606640c13bSYuri Pankov static	int		  mdoc_root_pre(const struct roff_meta *,
616640c13bSYuri Pankov 				struct html *);
6295c635efSGarrett D'Amore 
6395c635efSGarrett D'Amore static	void		  mdoc__x_post(MDOC_ARGS);
6495c635efSGarrett D'Amore static	int		  mdoc__x_pre(MDOC_ARGS);
65cec8643bSMichal Nowak static	int		  mdoc_abort_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_cd_pre(MDOC_ARGS);
76*4d131170SRobert Mustacchi static	int		  mdoc_code_pre(MDOC_ARGS);
7795c635efSGarrett D'Amore static	int		  mdoc_d1_pre(MDOC_ARGS);
7895c635efSGarrett D'Amore static	int		  mdoc_fa_pre(MDOC_ARGS);
7995c635efSGarrett D'Amore static	int		  mdoc_fd_pre(MDOC_ARGS);
8095c635efSGarrett D'Amore static	int		  mdoc_fl_pre(MDOC_ARGS);
8195c635efSGarrett D'Amore static	int		  mdoc_fn_pre(MDOC_ARGS);
8295c635efSGarrett D'Amore static	int		  mdoc_ft_pre(MDOC_ARGS);
8395c635efSGarrett D'Amore static	int		  mdoc_em_pre(MDOC_ARGS);
84260e9a87SYuri Pankov static	void		  mdoc_eo_post(MDOC_ARGS);
85260e9a87SYuri Pankov static	int		  mdoc_eo_pre(MDOC_ARGS);
8695c635efSGarrett D'Amore static	int		  mdoc_ex_pre(MDOC_ARGS);
8795c635efSGarrett D'Amore static	void		  mdoc_fo_post(MDOC_ARGS);
8895c635efSGarrett D'Amore static	int		  mdoc_fo_pre(MDOC_ARGS);
8995c635efSGarrett D'Amore static	int		  mdoc_igndelim_pre(MDOC_ARGS);
9095c635efSGarrett D'Amore static	int		  mdoc_in_pre(MDOC_ARGS);
9195c635efSGarrett D'Amore static	int		  mdoc_it_pre(MDOC_ARGS);
9295c635efSGarrett D'Amore static	int		  mdoc_lb_pre(MDOC_ARGS);
9395c635efSGarrett D'Amore static	int		  mdoc_lk_pre(MDOC_ARGS);
9495c635efSGarrett D'Amore static	int		  mdoc_mt_pre(MDOC_ARGS);
9595c635efSGarrett D'Amore static	int		  mdoc_nd_pre(MDOC_ARGS);
9695c635efSGarrett D'Amore static	int		  mdoc_nm_pre(MDOC_ARGS);
97260e9a87SYuri Pankov static	int		  mdoc_no_pre(MDOC_ARGS);
9895c635efSGarrett D'Amore static	int		  mdoc_ns_pre(MDOC_ARGS);
9995c635efSGarrett D'Amore static	int		  mdoc_pa_pre(MDOC_ARGS);
10095c635efSGarrett D'Amore static	void		  mdoc_pf_post(MDOC_ARGS);
10195c635efSGarrett D'Amore static	int		  mdoc_pp_pre(MDOC_ARGS);
10295c635efSGarrett D'Amore static	void		  mdoc_quote_post(MDOC_ARGS);
10395c635efSGarrett D'Amore static	int		  mdoc_quote_pre(MDOC_ARGS);
10495c635efSGarrett D'Amore static	int		  mdoc_rs_pre(MDOC_ARGS);
10595c635efSGarrett D'Amore static	int		  mdoc_sh_pre(MDOC_ARGS);
106260e9a87SYuri Pankov static	int		  mdoc_skip_pre(MDOC_ARGS);
10795c635efSGarrett D'Amore static	int		  mdoc_sm_pre(MDOC_ARGS);
10895c635efSGarrett D'Amore static	int		  mdoc_ss_pre(MDOC_ARGS);
109a40ea1a7SYuri Pankov static	int		  mdoc_st_pre(MDOC_ARGS);
11095c635efSGarrett D'Amore static	int		  mdoc_sx_pre(MDOC_ARGS);
11195c635efSGarrett D'Amore static	int		  mdoc_sy_pre(MDOC_ARGS);
112*4d131170SRobert Mustacchi static	int		  mdoc_tg_pre(MDOC_ARGS);
11395c635efSGarrett D'Amore static	int		  mdoc_va_pre(MDOC_ARGS);
11495c635efSGarrett D'Amore static	int		  mdoc_vt_pre(MDOC_ARGS);
11595c635efSGarrett D'Amore static	int		  mdoc_xr_pre(MDOC_ARGS);
11695c635efSGarrett D'Amore static	int		  mdoc_xx_pre(MDOC_ARGS);
11795c635efSGarrett D'Amore 
118cec8643bSMichal Nowak static const struct mdoc_html_act mdoc_html_acts[MDOC_MAX - MDOC_Dd] = {
11995c635efSGarrett D'Amore 	{NULL, NULL}, /* Dd */
12095c635efSGarrett D'Amore 	{NULL, NULL}, /* Dt */
12195c635efSGarrett D'Amore 	{NULL, NULL}, /* Os */
12295c635efSGarrett D'Amore 	{mdoc_sh_pre, NULL }, /* Sh */
123260e9a87SYuri Pankov 	{mdoc_ss_pre, NULL }, /* Ss */
124260e9a87SYuri Pankov 	{mdoc_pp_pre, NULL}, /* Pp */
12595c635efSGarrett D'Amore 	{mdoc_d1_pre, NULL}, /* D1 */
12695c635efSGarrett D'Amore 	{mdoc_d1_pre, NULL}, /* Dl */
12795c635efSGarrett D'Amore 	{mdoc_bd_pre, NULL}, /* Bd */
12895c635efSGarrett D'Amore 	{NULL, NULL}, /* Ed */
12995c635efSGarrett D'Amore 	{mdoc_bl_pre, NULL}, /* Bl */
13095c635efSGarrett D'Amore 	{NULL, NULL}, /* El */
13195c635efSGarrett D'Amore 	{mdoc_it_pre, NULL}, /* It */
132260e9a87SYuri Pankov 	{mdoc_ad_pre, NULL}, /* Ad */
13395c635efSGarrett D'Amore 	{mdoc_an_pre, NULL}, /* An */
134c66b8046SYuri Pankov 	{mdoc_ap_pre, NULL}, /* Ap */
13595c635efSGarrett D'Amore 	{mdoc_ar_pre, NULL}, /* Ar */
13695c635efSGarrett D'Amore 	{mdoc_cd_pre, NULL}, /* Cd */
137*4d131170SRobert Mustacchi 	{mdoc_code_pre, NULL}, /* Cm */
138*4d131170SRobert Mustacchi 	{mdoc_code_pre, NULL}, /* Dv */
139*4d131170SRobert Mustacchi 	{mdoc_code_pre, NULL}, /* Er */
140*4d131170SRobert Mustacchi 	{mdoc_code_pre, NULL}, /* Ev */
14195c635efSGarrett D'Amore 	{mdoc_ex_pre, NULL}, /* Ex */
142260e9a87SYuri Pankov 	{mdoc_fa_pre, NULL}, /* Fa */
143260e9a87SYuri Pankov 	{mdoc_fd_pre, NULL}, /* Fd */
14495c635efSGarrett D'Amore 	{mdoc_fl_pre, NULL}, /* Fl */
145260e9a87SYuri Pankov 	{mdoc_fn_pre, NULL}, /* Fn */
146260e9a87SYuri Pankov 	{mdoc_ft_pre, NULL}, /* Ft */
147*4d131170SRobert Mustacchi 	{mdoc_code_pre, NULL}, /* Ic */
148260e9a87SYuri Pankov 	{mdoc_in_pre, NULL}, /* In */
149*4d131170SRobert Mustacchi 	{mdoc_code_pre, NULL}, /* Li */
150260e9a87SYuri Pankov 	{mdoc_nd_pre, NULL}, /* Nd */
151260e9a87SYuri Pankov 	{mdoc_nm_pre, NULL}, /* Nm */
15295c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Op */
153cec8643bSMichal Nowak 	{mdoc_abort_pre, NULL}, /* Ot */
15495c635efSGarrett D'Amore 	{mdoc_pa_pre, NULL}, /* Pa */
155a40ea1a7SYuri Pankov 	{mdoc_ex_pre, NULL}, /* Rv */
156a40ea1a7SYuri Pankov 	{mdoc_st_pre, NULL}, /* St */
15795c635efSGarrett D'Amore 	{mdoc_va_pre, NULL}, /* Va */
158260e9a87SYuri Pankov 	{mdoc_vt_pre, NULL}, /* Vt */
15995c635efSGarrett D'Amore 	{mdoc_xr_pre, NULL}, /* Xr */
16095c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %A */
16195c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %B */
16295c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %D */
16395c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %I */
16495c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %J */
16595c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %N */
16695c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %O */
16795c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %P */
16895c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %R */
16995c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %T */
17095c635efSGarrett D'Amore 	{mdoc__x_pre, mdoc__x_post}, /* %V */
17195c635efSGarrett D'Amore 	{NULL, NULL}, /* Ac */
17295c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Ao */
17395c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Aq */
174a40ea1a7SYuri Pankov 	{mdoc_xx_pre, NULL}, /* At */
17595c635efSGarrett D'Amore 	{NULL, NULL}, /* Bc */
176260e9a87SYuri Pankov 	{mdoc_bf_pre, NULL}, /* Bf */
17795c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Bo */
17895c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Bq */
17995c635efSGarrett D'Amore 	{mdoc_xx_pre, NULL}, /* Bsx */
180a40ea1a7SYuri Pankov 	{mdoc_xx_pre, NULL}, /* Bx */
181260e9a87SYuri Pankov 	{mdoc_skip_pre, NULL}, /* Db */
18295c635efSGarrett D'Amore 	{NULL, NULL}, /* Dc */
18395c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Do */
18495c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Dq */
18595c635efSGarrett D'Amore 	{NULL, NULL}, /* Ec */ /* FIXME: no space */
18695c635efSGarrett D'Amore 	{NULL, NULL}, /* Ef */
187260e9a87SYuri Pankov 	{mdoc_em_pre, NULL}, /* Em */
188260e9a87SYuri Pankov 	{mdoc_eo_pre, mdoc_eo_post}, /* Eo */
18995c635efSGarrett D'Amore 	{mdoc_xx_pre, NULL}, /* Fx */
190*4d131170SRobert Mustacchi 	{mdoc_no_pre, NULL}, /* Ms */
191260e9a87SYuri Pankov 	{mdoc_no_pre, NULL}, /* No */
19295c635efSGarrett D'Amore 	{mdoc_ns_pre, NULL}, /* Ns */
19395c635efSGarrett D'Amore 	{mdoc_xx_pre, NULL}, /* Nx */
19495c635efSGarrett D'Amore 	{mdoc_xx_pre, NULL}, /* Ox */
19595c635efSGarrett D'Amore 	{NULL, NULL}, /* Pc */
19695c635efSGarrett D'Amore 	{mdoc_igndelim_pre, mdoc_pf_post}, /* Pf */
19795c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Po */
19895c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Pq */
19995c635efSGarrett D'Amore 	{NULL, NULL}, /* Qc */
20095c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Ql */
20195c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Qo */
20295c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Qq */
20395c635efSGarrett D'Amore 	{NULL, NULL}, /* Re */
20495c635efSGarrett D'Amore 	{mdoc_rs_pre, NULL}, /* Rs */
20595c635efSGarrett D'Amore 	{NULL, NULL}, /* Sc */
20695c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* So */
20795c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Sq */
208260e9a87SYuri Pankov 	{mdoc_sm_pre, NULL}, /* Sm */
20995c635efSGarrett D'Amore 	{mdoc_sx_pre, NULL}, /* Sx */
21095c635efSGarrett D'Amore 	{mdoc_sy_pre, NULL}, /* Sy */
21195c635efSGarrett D'Amore 	{NULL, NULL}, /* Tn */
21295c635efSGarrett D'Amore 	{mdoc_xx_pre, NULL}, /* Ux */
21395c635efSGarrett D'Amore 	{NULL, NULL}, /* Xc */
21495c635efSGarrett D'Amore 	{NULL, NULL}, /* Xo */
215260e9a87SYuri Pankov 	{mdoc_fo_pre, mdoc_fo_post}, /* Fo */
216260e9a87SYuri Pankov 	{NULL, NULL}, /* Fc */
21795c635efSGarrett D'Amore 	{mdoc_quote_pre, mdoc_quote_post}, /* Oo */
21895c635efSGarrett D'Amore 	{NULL, NULL}, /* Oc */
21995c635efSGarrett D'Amore 	{mdoc_bk_pre, mdoc_bk_post}, /* Bk */
22095c635efSGarrett D'Amore 	{NULL, NULL}, /* Ek */
221a40ea1a7SYuri Pankov 	{NULL, NULL}, /* Bt */
22295c635efSGarrett D'Amore 	{NULL, NULL}, /* Hf */
223260e9a87SYuri Pankov 	{mdoc_em_pre, NULL}, /* Fr */
224a40ea1a7SYuri Pankov 	{NULL, NULL}, /* Ud */
22595c635efSGarrett D'Amore 	{mdoc_lb_pre, NULL}, /* Lb */
226cec8643bSMichal Nowak 	{mdoc_abort_pre, NULL}, /* Lp */
227260e9a87SYuri Pankov 	{mdoc_lk_pre, NULL}, /* Lk */
228260e9a87SYuri Pankov 	{mdoc_mt_pre, NULL}, /* Mt */
229260e9a87SYuri Pankov 	{mdoc_quote_pre, mdoc_quote_post}, /* Brq */
230260e9a87SYuri Pankov 	{mdoc_quote_pre, mdoc_quote_post}, /* Bro */
231260e9a87SYuri Pankov 	{NULL, NULL}, /* Brc */
232260e9a87SYuri Pankov 	{mdoc__x_pre, mdoc__x_post}, /* %C */
233260e9a87SYuri Pankov 	{mdoc_skip_pre, NULL}, /* Es */
234260e9a87SYuri Pankov 	{mdoc_quote_pre, mdoc_quote_post}, /* En */
235260e9a87SYuri Pankov 	{mdoc_xx_pre, NULL}, /* Dx */
236260e9a87SYuri Pankov 	{mdoc__x_pre, mdoc__x_post}, /* %Q */
237260e9a87SYuri Pankov 	{mdoc__x_pre, mdoc__x_post}, /* %U */
238260e9a87SYuri Pankov 	{NULL, NULL}, /* Ta */
239*4d131170SRobert Mustacchi 	{mdoc_tg_pre, NULL}, /* Tg */
24095c635efSGarrett D'Amore };
24195c635efSGarrett D'Amore 
24295c635efSGarrett D'Amore 
24395c635efSGarrett D'Amore /*
24495c635efSGarrett D'Amore  * See the same function in mdoc_term.c for documentation.
24595c635efSGarrett D'Amore  */
24695c635efSGarrett D'Amore static void
synopsis_pre(struct html * h,struct roff_node * n)247*4d131170SRobert Mustacchi synopsis_pre(struct html *h, struct roff_node *n)
24895c635efSGarrett D'Amore {
249*4d131170SRobert Mustacchi 	struct roff_node *np;
25095c635efSGarrett D'Amore 
251*4d131170SRobert Mustacchi 	if ((n->flags & NODE_SYNPRETTY) == 0 ||
252*4d131170SRobert Mustacchi 	    (np = roff_node_prev(n)) == NULL)
25395c635efSGarrett D'Amore 		return;
25495c635efSGarrett D'Amore 
255*4d131170SRobert Mustacchi 	if (np->tok == n->tok &&
256260e9a87SYuri Pankov 	    MDOC_Fo != n->tok &&
257260e9a87SYuri Pankov 	    MDOC_Ft != n->tok &&
258260e9a87SYuri Pankov 	    MDOC_Fn != n->tok) {
259a40ea1a7SYuri Pankov 		print_otag(h, TAG_BR, "");
26095c635efSGarrett D'Amore 		return;
26195c635efSGarrett D'Amore 	}
26295c635efSGarrett D'Amore 
263*4d131170SRobert Mustacchi 	switch (np->tok) {
264260e9a87SYuri Pankov 	case MDOC_Fd:
265260e9a87SYuri Pankov 	case MDOC_Fn:
266260e9a87SYuri Pankov 	case MDOC_Fo:
267260e9a87SYuri Pankov 	case MDOC_In:
268260e9a87SYuri Pankov 	case MDOC_Vt:
26995c635efSGarrett D'Amore 		break;
270260e9a87SYuri Pankov 	case MDOC_Ft:
271cec8643bSMichal Nowak 		if (n->tok != MDOC_Fn && n->tok != MDOC_Fo)
27295c635efSGarrett D'Amore 			break;
27395c635efSGarrett D'Amore 		/* FALLTHROUGH */
27495c635efSGarrett D'Amore 	default:
275a40ea1a7SYuri Pankov 		print_otag(h, TAG_BR, "");
276cec8643bSMichal Nowak 		return;
27795c635efSGarrett D'Amore 	}
278cec8643bSMichal Nowak 	html_close_paragraph(h);
279cec8643bSMichal Nowak 	print_otag(h, TAG_P, "c", "Pp");
28095c635efSGarrett D'Amore }
28195c635efSGarrett D'Amore 
282371584c2SYuri Pankov void
html_mdoc(void * arg,const struct roff_meta * mdoc)283cec8643bSMichal Nowak html_mdoc(void *arg, const struct roff_meta *mdoc)
28495c635efSGarrett D'Amore {
2856640c13bSYuri Pankov 	struct html		*h;
2866640c13bSYuri Pankov 	struct roff_node	*n;
2876640c13bSYuri Pankov 	struct tag		*t;
28895c635efSGarrett D'Amore 
289371584c2SYuri Pankov 	h = (struct html *)arg;
2906640c13bSYuri Pankov 	n = mdoc->first->child;
29195c635efSGarrett D'Amore 
292a40ea1a7SYuri Pankov 	if ((h->oflags & HTML_FRAGMENT) == 0) {
29395c635efSGarrett D'Amore 		print_gen_decls(h);
294a40ea1a7SYuri Pankov 		print_otag(h, TAG_HTML, "");
295cec8643bSMichal Nowak 		if (n != NULL && n->type == ROFFT_COMMENT)
2966640c13bSYuri Pankov 			print_gen_comment(h, n);
297a40ea1a7SYuri Pankov 		t = print_otag(h, TAG_HEAD, "");
298cec8643bSMichal Nowak 		print_mdoc_head(mdoc, h);
299a40ea1a7SYuri Pankov 		print_tagq(h, t);
300a40ea1a7SYuri Pankov 		print_otag(h, TAG_BODY, "");
301a40ea1a7SYuri Pankov 	}
30295c635efSGarrett D'Amore 
303cec8643bSMichal Nowak 	mdoc_root_pre(mdoc, h);
304a40ea1a7SYuri Pankov 	t = print_otag(h, TAG_DIV, "c", "manual-text");
305cec8643bSMichal Nowak 	print_mdoc_nodelist(mdoc, n, h);
30695c635efSGarrett D'Amore 	print_tagq(h, t);
307cec8643bSMichal Nowak 	mdoc_root_post(mdoc, h);
308a40ea1a7SYuri Pankov 	print_tagq(h, NULL);
30995c635efSGarrett D'Amore }
31095c635efSGarrett D'Amore 
31195c635efSGarrett D'Amore static void
print_mdoc_head(const struct roff_meta * meta,struct html * h)3126640c13bSYuri Pankov print_mdoc_head(const struct roff_meta *meta, struct html *h)
31395c635efSGarrett D'Amore {
314a40ea1a7SYuri Pankov 	char	*cp;
31595c635efSGarrett D'Amore 
31695c635efSGarrett D'Amore 	print_gen_head(h);
31795c635efSGarrett D'Amore 
318a40ea1a7SYuri Pankov 	if (meta->arch != NULL && meta->msec != NULL)
319a40ea1a7SYuri Pankov 		mandoc_asprintf(&cp, "%s(%s) (%s)", meta->title,
320a40ea1a7SYuri Pankov 		    meta->msec, meta->arch);
321a40ea1a7SYuri Pankov 	else if (meta->msec != NULL)
322a40ea1a7SYuri Pankov 		mandoc_asprintf(&cp, "%s(%s)", meta->title, meta->msec);
323a40ea1a7SYuri Pankov 	else if (meta->arch != NULL)
324a40ea1a7SYuri Pankov 		mandoc_asprintf(&cp, "%s (%s)", meta->title, meta->arch);
325a40ea1a7SYuri Pankov 	else
326a40ea1a7SYuri Pankov 		cp = mandoc_strdup(meta->title);
327a40ea1a7SYuri Pankov 
328a40ea1a7SYuri Pankov 	print_otag(h, TAG_TITLE, "");
329a40ea1a7SYuri Pankov 	print_text(h, cp);
330a40ea1a7SYuri Pankov 	free(cp);
33195c635efSGarrett D'Amore }
33295c635efSGarrett D'Amore 
33395c635efSGarrett D'Amore static void
print_mdoc_nodelist(MDOC_ARGS)33495c635efSGarrett D'Amore print_mdoc_nodelist(MDOC_ARGS)
33595c635efSGarrett D'Amore {
33695c635efSGarrett D'Amore 
337260e9a87SYuri Pankov 	while (n != NULL) {
338260e9a87SYuri Pankov 		print_mdoc_node(meta, n, h);
339260e9a87SYuri Pankov 		n = n->next;
340260e9a87SYuri Pankov 	}
34195c635efSGarrett D'Amore }
34295c635efSGarrett D'Amore 
34395c635efSGarrett D'Amore static void
print_mdoc_node(MDOC_ARGS)34495c635efSGarrett D'Amore print_mdoc_node(MDOC_ARGS)
34595c635efSGarrett D'Amore {
34695c635efSGarrett D'Amore 	struct tag	*t;
347cec8643bSMichal Nowak 	int		 child;
34895c635efSGarrett D'Amore 
3496640c13bSYuri Pankov 	if (n->type == ROFFT_COMMENT || n->flags & NODE_NOPRT)
350a40ea1a7SYuri Pankov 		return;
351a40ea1a7SYuri Pankov 
352*4d131170SRobert Mustacchi 	if ((n->flags & NODE_NOFILL) == 0)
353*4d131170SRobert Mustacchi 		html_fillmode(h, ROFF_fi);
354*4d131170SRobert Mustacchi 	else if (html_fillmode(h, ROFF_nf) == ROFF_nf &&
355*4d131170SRobert Mustacchi 	    n->tok != ROFF_fi && n->flags & NODE_LINE)
356*4d131170SRobert Mustacchi 		print_endline(h);
357cec8643bSMichal Nowak 
35895c635efSGarrett D'Amore 	child = 1;
359a40ea1a7SYuri Pankov 	n->flags &= ~NODE_ENDED;
36095c635efSGarrett D'Amore 	switch (n->type) {
361371584c2SYuri Pankov 	case ROFFT_TEXT:
362*4d131170SRobert Mustacchi 		if (n->flags & NODE_LINE) {
363*4d131170SRobert Mustacchi 			switch (*n->string) {
364*4d131170SRobert Mustacchi 			case '\0':
365*4d131170SRobert Mustacchi 				h->col = 1;
366*4d131170SRobert Mustacchi 				print_endline(h);
367*4d131170SRobert Mustacchi 				return;
368*4d131170SRobert Mustacchi 			case ' ':
369*4d131170SRobert Mustacchi 				if ((h->flags & HTML_NONEWLINE) == 0 &&
370*4d131170SRobert Mustacchi 				    (n->flags & NODE_NOFILL) == 0)
371*4d131170SRobert Mustacchi 					print_otag(h, TAG_BR, "");
372*4d131170SRobert Mustacchi 				break;
373*4d131170SRobert Mustacchi 			default:
374*4d131170SRobert Mustacchi 				break;
375*4d131170SRobert Mustacchi 			}
376*4d131170SRobert Mustacchi 		}
377cec8643bSMichal Nowak 		t = h->tag;
378cec8643bSMichal Nowak 		t->refcnt++;
379*4d131170SRobert Mustacchi 		if (n->flags & NODE_DELIMC)
38095c635efSGarrett D'Amore 			h->flags |= HTML_NOSPACE;
381*4d131170SRobert Mustacchi 		if (n->flags & NODE_HREF)
382*4d131170SRobert Mustacchi 			print_tagged_text(h, n->string, n);
383*4d131170SRobert Mustacchi 		else
384*4d131170SRobert Mustacchi 			print_text(h, n->string);
385*4d131170SRobert Mustacchi 		if (n->flags & NODE_DELIMO)
38695c635efSGarrett D'Amore 			h->flags |= HTML_NOSPACE;
387cec8643bSMichal Nowak 		break;
388371584c2SYuri Pankov 	case ROFFT_EQN:
389cec8643bSMichal Nowak 		t = h->tag;
390cec8643bSMichal Nowak 		t->refcnt++;
39195c635efSGarrett D'Amore 		print_eqn(h, n->eqn);
39295c635efSGarrett D'Amore 		break;
393371584c2SYuri Pankov 	case ROFFT_TBL:
39495c635efSGarrett D'Amore 		/*
39595c635efSGarrett D'Amore 		 * This will take care of initialising all of the table
39695c635efSGarrett D'Amore 		 * state data for the first table, then tearing it down
39795c635efSGarrett D'Amore 		 * for the last one.
39895c635efSGarrett D'Amore 		 */
39995c635efSGarrett D'Amore 		print_tbl(h, n->span);
40095c635efSGarrett D'Amore 		return;
40195c635efSGarrett D'Amore 	default:
40295c635efSGarrett D'Amore 		/*
40395c635efSGarrett D'Amore 		 * Close out the current table, if it's open, and unset
40495c635efSGarrett D'Amore 		 * the "meta" table state.  This will be reopened on the
40595c635efSGarrett D'Amore 		 * next table element.
40695c635efSGarrett D'Amore 		 */
407cec8643bSMichal Nowak 		if (h->tblt != NULL)
40895c635efSGarrett D'Amore 			print_tblclose(h);
409260e9a87SYuri Pankov 		assert(h->tblt == NULL);
410cec8643bSMichal Nowak 		t = h->tag;
411cec8643bSMichal Nowak 		t->refcnt++;
412c66b8046SYuri Pankov 		if (n->tok < ROFF_MAX) {
413c66b8046SYuri Pankov 			roff_html_pre(h, n);
414cec8643bSMichal Nowak 			t->refcnt--;
415cec8643bSMichal Nowak 			print_stagq(h, t);
416cec8643bSMichal Nowak 			return;
417c66b8046SYuri Pankov 		}
418c66b8046SYuri Pankov 		assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX);
419cec8643bSMichal Nowak 		if (mdoc_html_acts[n->tok - MDOC_Dd].pre != NULL &&
420c66b8046SYuri Pankov 		    (n->end == ENDBODY_NOT || n->child != NULL))
421cec8643bSMichal Nowak 			child = (*mdoc_html_acts[n->tok - MDOC_Dd].pre)(meta,
422cec8643bSMichal Nowak 			    n, h);
42395c635efSGarrett D'Amore 		break;
42495c635efSGarrett D'Amore 	}
42595c635efSGarrett D'Amore 
426a40ea1a7SYuri Pankov 	if (h->flags & HTML_KEEP && n->flags & NODE_LINE) {
427260e9a87SYuri Pankov 		h->flags &= ~HTML_KEEP;
428260e9a87SYuri Pankov 		h->flags |= HTML_PREKEEP;
42995c635efSGarrett D'Amore 	}
43095c635efSGarrett D'Amore 
431cec8643bSMichal Nowak 	if (child && n->child != NULL)
432698f87a4SGarrett D'Amore 		print_mdoc_nodelist(meta, n->child, h);
43395c635efSGarrett D'Amore 
434cec8643bSMichal Nowak 	t->refcnt--;
43595c635efSGarrett D'Amore 	print_stagq(h, t);
43695c635efSGarrett D'Amore 
43795c635efSGarrett D'Amore 	switch (n->type) {
438cec8643bSMichal Nowak 	case ROFFT_TEXT:
439371584c2SYuri Pankov 	case ROFFT_EQN:
44095c635efSGarrett D'Amore 		break;
44195c635efSGarrett D'Amore 	default:
442cec8643bSMichal Nowak 		if (mdoc_html_acts[n->tok - MDOC_Dd].post == NULL ||
443c66b8046SYuri Pankov 		    n->flags & NODE_ENDED)
444260e9a87SYuri Pankov 			break;
445cec8643bSMichal Nowak 		(*mdoc_html_acts[n->tok - MDOC_Dd].post)(meta, n, h);
446260e9a87SYuri Pankov 		if (n->end != ENDBODY_NOT)
447a40ea1a7SYuri Pankov 			n->body->flags |= NODE_ENDED;
44895c635efSGarrett D'Amore 		break;
44995c635efSGarrett D'Amore 	}
45095c635efSGarrett D'Amore }
45195c635efSGarrett D'Amore 
45295c635efSGarrett D'Amore static void
mdoc_root_post(const struct roff_meta * meta,struct html * h)4536640c13bSYuri Pankov mdoc_root_post(const struct roff_meta *meta, struct html *h)
45495c635efSGarrett D'Amore {
45595c635efSGarrett D'Amore 	struct tag	*t, *tt;
45695c635efSGarrett D'Amore 
457a40ea1a7SYuri Pankov 	t = print_otag(h, TAG_TABLE, "c", "foot");
458a40ea1a7SYuri Pankov 	tt = print_otag(h, TAG_TR, "");
45995c635efSGarrett D'Amore 
460a40ea1a7SYuri Pankov 	print_otag(h, TAG_TD, "c", "foot-date");
461698f87a4SGarrett D'Amore 	print_text(h, meta->date);
46295c635efSGarrett D'Amore 	print_stagq(h, tt);
46395c635efSGarrett D'Amore 
464a40ea1a7SYuri Pankov 	print_otag(h, TAG_TD, "c", "foot-os");
465698f87a4SGarrett D'Amore 	print_text(h, meta->os);
46695c635efSGarrett D'Amore 	print_tagq(h, t);
46795c635efSGarrett D'Amore }
46895c635efSGarrett D'Amore 
46995c635efSGarrett D'Amore static int
mdoc_root_pre(const struct roff_meta * meta,struct html * h)4706640c13bSYuri Pankov mdoc_root_pre(const struct roff_meta *meta, struct html *h)
47195c635efSGarrett D'Amore {
47295c635efSGarrett D'Amore 	struct tag	*t, *tt;
473260e9a87SYuri Pankov 	char		*volume, *title;
47495c635efSGarrett D'Amore 
475260e9a87SYuri Pankov 	if (NULL == meta->arch)
476260e9a87SYuri Pankov 		volume = mandoc_strdup(meta->vol);
477260e9a87SYuri Pankov 	else
478260e9a87SYuri Pankov 		mandoc_asprintf(&volume, "%s (%s)",
479260e9a87SYuri Pankov 		    meta->vol, meta->arch);
48095c635efSGarrett D'Amore 
481260e9a87SYuri Pankov 	if (NULL == meta->msec)
482260e9a87SYuri Pankov 		title = mandoc_strdup(meta->title);
483260e9a87SYuri Pankov 	else
484260e9a87SYuri Pankov 		mandoc_asprintf(&title, "%s(%s)",
485260e9a87SYuri Pankov 		    meta->title, meta->msec);
48695c635efSGarrett D'Amore 
487a40ea1a7SYuri Pankov 	t = print_otag(h, TAG_TABLE, "c", "head");
488a40ea1a7SYuri Pankov 	tt = print_otag(h, TAG_TR, "");
48995c635efSGarrett D'Amore 
490a40ea1a7SYuri Pankov 	print_otag(h, TAG_TD, "c", "head-ltitle");
49195c635efSGarrett D'Amore 	print_text(h, title);
49295c635efSGarrett D'Amore 	print_stagq(h, tt);
49395c635efSGarrett D'Amore 
494a40ea1a7SYuri Pankov 	print_otag(h, TAG_TD, "c", "head-vol");
495260e9a87SYuri Pankov 	print_text(h, volume);
49695c635efSGarrett D'Amore 	print_stagq(h, tt);
49795c635efSGarrett D'Amore 
498a40ea1a7SYuri Pankov 	print_otag(h, TAG_TD, "c", "head-rtitle");
49995c635efSGarrett D'Amore 	print_text(h, title);
50095c635efSGarrett D'Amore 	print_tagq(h, t);
501260e9a87SYuri Pankov 
502260e9a87SYuri Pankov 	free(title);
503260e9a87SYuri Pankov 	free(volume);
504371584c2SYuri Pankov 	return 1;
50595c635efSGarrett D'Amore }
50695c635efSGarrett D'Amore 
507*4d131170SRobert Mustacchi static int
mdoc_code_pre(MDOC_ARGS)508*4d131170SRobert Mustacchi mdoc_code_pre(MDOC_ARGS)
509a40ea1a7SYuri Pankov {
510*4d131170SRobert Mustacchi 	print_otag_id(h, TAG_CODE, roff_name[n->tok], n);
511*4d131170SRobert Mustacchi 	return 1;
512a40ea1a7SYuri Pankov }
513a40ea1a7SYuri Pankov 
51495c635efSGarrett D'Amore static int
mdoc_sh_pre(MDOC_ARGS)51595c635efSGarrett D'Amore mdoc_sh_pre(MDOC_ARGS)
51695c635efSGarrett D'Amore {
517cec8643bSMichal Nowak 	struct roff_node	*sn, *subn;
518cec8643bSMichal Nowak 	struct tag		*t, *tsec, *tsub;
519cec8643bSMichal Nowak 	char			*id;
520cec8643bSMichal Nowak 	int			 sc;
52195c635efSGarrett D'Amore 
522260e9a87SYuri Pankov 	switch (n->type) {
523cec8643bSMichal Nowak 	case ROFFT_BLOCK:
524cec8643bSMichal Nowak 		html_close_paragraph(h);
525cec8643bSMichal Nowak 		if ((h->oflags & HTML_TOC) == 0 ||
526cec8643bSMichal Nowak 		    h->flags & HTML_TOCDONE ||
527cec8643bSMichal Nowak 		    n->sec <= SEC_SYNOPSIS) {
528cec8643bSMichal Nowak 			print_otag(h, TAG_SECTION, "c", "Sh");
529cec8643bSMichal Nowak 			break;
530cec8643bSMichal Nowak 		}
531cec8643bSMichal Nowak 		h->flags |= HTML_TOCDONE;
532cec8643bSMichal Nowak 		sc = 0;
533cec8643bSMichal Nowak 		for (sn = n->next; sn != NULL; sn = sn->next)
534cec8643bSMichal Nowak 			if (sn->sec == SEC_CUSTOM)
535cec8643bSMichal Nowak 				if (++sc == 2)
536cec8643bSMichal Nowak 					break;
537cec8643bSMichal Nowak 		if (sc < 2)
538cec8643bSMichal Nowak 			break;
539cec8643bSMichal Nowak 		t = print_otag(h, TAG_H1, "c", "Sh");
540cec8643bSMichal Nowak 		print_text(h, "TABLE OF CONTENTS");
541cec8643bSMichal Nowak 		print_tagq(h, t);
542cec8643bSMichal Nowak 		t = print_otag(h, TAG_UL, "c", "Bl-compact");
543cec8643bSMichal Nowak 		for (sn = n; sn != NULL; sn = sn->next) {
544cec8643bSMichal Nowak 			tsec = print_otag(h, TAG_LI, "");
545cec8643bSMichal Nowak 			id = html_make_id(sn->head, 0);
546cec8643bSMichal Nowak 			tsub = print_otag(h, TAG_A, "hR", id);
547cec8643bSMichal Nowak 			free(id);
548cec8643bSMichal Nowak 			print_mdoc_nodelist(meta, sn->head->child, h);
549cec8643bSMichal Nowak 			print_tagq(h, tsub);
550cec8643bSMichal Nowak 			tsub = NULL;
551cec8643bSMichal Nowak 			for (subn = sn->body->child; subn != NULL;
552cec8643bSMichal Nowak 			    subn = subn->next) {
553cec8643bSMichal Nowak 				if (subn->tok != MDOC_Ss)
554cec8643bSMichal Nowak 					continue;
555cec8643bSMichal Nowak 				id = html_make_id(subn->head, 0);
556cec8643bSMichal Nowak 				if (id == NULL)
557cec8643bSMichal Nowak 					continue;
558cec8643bSMichal Nowak 				if (tsub == NULL)
559cec8643bSMichal Nowak 					print_otag(h, TAG_UL,
560cec8643bSMichal Nowak 					    "c", "Bl-compact");
561cec8643bSMichal Nowak 				tsub = print_otag(h, TAG_LI, "");
562cec8643bSMichal Nowak 				print_otag(h, TAG_A, "hR", id);
563cec8643bSMichal Nowak 				free(id);
564cec8643bSMichal Nowak 				print_mdoc_nodelist(meta,
565cec8643bSMichal Nowak 				    subn->head->child, h);
566cec8643bSMichal Nowak 				print_tagq(h, tsub);
567cec8643bSMichal Nowak 			}
568cec8643bSMichal Nowak 			print_tagq(h, tsec);
569cec8643bSMichal Nowak 		}
570cec8643bSMichal Nowak 		print_tagq(h, t);
571cec8643bSMichal Nowak 		print_otag(h, TAG_SECTION, "c", "Sh");
572cec8643bSMichal Nowak 		break;
573a40ea1a7SYuri Pankov 	case ROFFT_HEAD:
574*4d131170SRobert Mustacchi 		print_otag_id(h, TAG_H1, "Sh", n);
575a40ea1a7SYuri Pankov 		break;
576371584c2SYuri Pankov 	case ROFFT_BODY:
577260e9a87SYuri Pankov 		if (n->sec == SEC_AUTHORS)
578260e9a87SYuri Pankov 			h->flags &= ~(HTML_SPLIT|HTML_NOSPLIT);
579a40ea1a7SYuri Pankov 		break;
580260e9a87SYuri Pankov 	default:
581260e9a87SYuri Pankov 		break;
582260e9a87SYuri Pankov 	}
583371584c2SYuri Pankov 	return 1;
58495c635efSGarrett D'Amore }
58595c635efSGarrett D'Amore 
58695c635efSGarrett D'Amore static int
mdoc_ss_pre(MDOC_ARGS)58795c635efSGarrett D'Amore mdoc_ss_pre(MDOC_ARGS)
58895c635efSGarrett D'Amore {
589cec8643bSMichal Nowak 	switch (n->type) {
590cec8643bSMichal Nowak 	case ROFFT_BLOCK:
591cec8643bSMichal Nowak 		html_close_paragraph(h);
592cec8643bSMichal Nowak 		print_otag(h, TAG_SECTION, "c", "Ss");
593*4d131170SRobert Mustacchi 		break;
594cec8643bSMichal Nowak 	case ROFFT_HEAD:
595*4d131170SRobert Mustacchi 		print_otag_id(h, TAG_H2, "Ss", n);
596cec8643bSMichal Nowak 		break;
597cec8643bSMichal Nowak 	case ROFFT_BODY:
598*4d131170SRobert Mustacchi 		break;
599cec8643bSMichal Nowak 	default:
600cec8643bSMichal Nowak 		abort();
601cec8643bSMichal Nowak 	}
602371584c2SYuri Pankov 	return 1;
60395c635efSGarrett D'Amore }
60495c635efSGarrett D'Amore 
60595c635efSGarrett D'Amore static int
mdoc_fl_pre(MDOC_ARGS)60695c635efSGarrett D'Amore mdoc_fl_pre(MDOC_ARGS)
60795c635efSGarrett D'Amore {
608*4d131170SRobert Mustacchi 	struct roff_node	*nn;
609c66b8046SYuri Pankov 
610*4d131170SRobert Mustacchi 	print_otag_id(h, TAG_CODE, "Fl", n);
611c66b8046SYuri Pankov 	print_text(h, "\\-");
612*4d131170SRobert Mustacchi 	if (n->child != NULL ||
613*4d131170SRobert Mustacchi 	    ((nn = roff_node_next(n)) != NULL &&
614*4d131170SRobert Mustacchi 	     nn->type != ROFFT_TEXT &&
615*4d131170SRobert Mustacchi 	     (nn->flags & NODE_LINE) == 0))
61695c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
61795c635efSGarrett D'Amore 
618371584c2SYuri Pankov 	return 1;
61995c635efSGarrett D'Amore }
62095c635efSGarrett D'Amore 
621a40ea1a7SYuri Pankov static int
mdoc_nd_pre(MDOC_ARGS)622a40ea1a7SYuri Pankov mdoc_nd_pre(MDOC_ARGS)
623a40ea1a7SYuri Pankov {
624cec8643bSMichal Nowak 	switch (n->type) {
625cec8643bSMichal Nowak 	case ROFFT_BLOCK:
626371584c2SYuri Pankov 		return 1;
627cec8643bSMichal Nowak 	case ROFFT_HEAD:
628cec8643bSMichal Nowak 		return 0;
629cec8643bSMichal Nowak 	case ROFFT_BODY:
630cec8643bSMichal Nowak 		break;
631cec8643bSMichal Nowak 	default:
632cec8643bSMichal Nowak 		abort();
633cec8643bSMichal Nowak 	}
63495c635efSGarrett D'Amore 	print_text(h, "\\(em");
635*4d131170SRobert Mustacchi 	print_otag(h, TAG_SPAN, "c", "Nd");
636371584c2SYuri Pankov 	return 1;
63795c635efSGarrett D'Amore }
63895c635efSGarrett D'Amore 
63995c635efSGarrett D'Amore static int
mdoc_nm_pre(MDOC_ARGS)64095c635efSGarrett D'Amore mdoc_nm_pre(MDOC_ARGS)
64195c635efSGarrett D'Amore {
64295c635efSGarrett D'Amore 	switch (n->type) {
643cec8643bSMichal Nowak 	case ROFFT_BLOCK:
644cec8643bSMichal Nowak 		break;
645371584c2SYuri Pankov 	case ROFFT_HEAD:
646a40ea1a7SYuri Pankov 		print_otag(h, TAG_TD, "");
647371584c2SYuri Pankov 		/* FALLTHROUGH */
648371584c2SYuri Pankov 	case ROFFT_ELEM:
649cec8643bSMichal Nowak 		print_otag(h, TAG_CODE, "c", "Nm");
650371584c2SYuri Pankov 		return 1;
651371584c2SYuri Pankov 	case ROFFT_BODY:
652a40ea1a7SYuri Pankov 		print_otag(h, TAG_TD, "");
653371584c2SYuri Pankov 		return 1;
65495c635efSGarrett D'Amore 	default:
655cec8643bSMichal Nowak 		abort();
65695c635efSGarrett D'Amore 	}
657cec8643bSMichal Nowak 	html_close_paragraph(h);
65895c635efSGarrett D'Amore 	synopsis_pre(h, n);
659a40ea1a7SYuri Pankov 	print_otag(h, TAG_TABLE, "c", "Nm");
660a40ea1a7SYuri Pankov 	print_otag(h, TAG_TR, "");
661371584c2SYuri Pankov 	return 1;
66295c635efSGarrett D'Amore }
66395c635efSGarrett D'Amore 
66495c635efSGarrett D'Amore static int
mdoc_xr_pre(MDOC_ARGS)66595c635efSGarrett D'Amore mdoc_xr_pre(MDOC_ARGS)
66695c635efSGarrett D'Amore {
66795c635efSGarrett D'Amore 	if (NULL == n->child)
668371584c2SYuri Pankov 		return 0;
66995c635efSGarrett D'Amore 
670cec8643bSMichal Nowak 	if (h->base_man1)
671cec8643bSMichal Nowak 		print_otag(h, TAG_A, "chM", "Xr",
672a40ea1a7SYuri Pankov 		    n->child->string, n->child->next == NULL ?
673a40ea1a7SYuri Pankov 		    NULL : n->child->next->string);
674a40ea1a7SYuri Pankov 	else
675cec8643bSMichal Nowak 		print_otag(h, TAG_A, "c", "Xr");
67695c635efSGarrett D'Amore 
67795c635efSGarrett D'Amore 	n = n->child;
67895c635efSGarrett D'Amore 	print_text(h, n->string);
67995c635efSGarrett D'Amore 
68095c635efSGarrett D'Amore 	if (NULL == (n = n->next))
681371584c2SYuri Pankov 		return 0;
68295c635efSGarrett D'Amore 
68395c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
68495c635efSGarrett D'Amore 	print_text(h, "(");
68595c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
68695c635efSGarrett D'Amore 	print_text(h, n->string);
68795c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
68895c635efSGarrett D'Amore 	print_text(h, ")");
689371584c2SYuri Pankov 	return 0;
69095c635efSGarrett D'Amore }
69195c635efSGarrett D'Amore 
692*4d131170SRobert Mustacchi static int
mdoc_tg_pre(MDOC_ARGS)693*4d131170SRobert Mustacchi mdoc_tg_pre(MDOC_ARGS)
694*4d131170SRobert Mustacchi {
695*4d131170SRobert Mustacchi 	char	*id;
696*4d131170SRobert Mustacchi 
697*4d131170SRobert Mustacchi 	if ((id = html_make_id(n, 1)) != NULL) {
698*4d131170SRobert Mustacchi 		print_tagq(h, print_otag(h, TAG_MARK, "i", id));
699*4d131170SRobert Mustacchi 		free(id);
700*4d131170SRobert Mustacchi 	}
701*4d131170SRobert Mustacchi 	return 0;
702*4d131170SRobert Mustacchi }
703*4d131170SRobert Mustacchi 
70495c635efSGarrett D'Amore static int
mdoc_ns_pre(MDOC_ARGS)70595c635efSGarrett D'Amore mdoc_ns_pre(MDOC_ARGS)
70695c635efSGarrett D'Amore {
70795c635efSGarrett D'Amore 
708a40ea1a7SYuri Pankov 	if ( ! (NODE_LINE & n->flags))
70995c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
710371584c2SYuri Pankov 	return 1;
71195c635efSGarrett D'Amore }
71295c635efSGarrett D'Amore 
71395c635efSGarrett D'Amore static int
mdoc_ar_pre(MDOC_ARGS)71495c635efSGarrett D'Amore mdoc_ar_pre(MDOC_ARGS)
71595c635efSGarrett D'Amore {
716cec8643bSMichal Nowak 	print_otag(h, TAG_VAR, "c", "Ar");
717371584c2SYuri Pankov 	return 1;
71895c635efSGarrett D'Amore }
71995c635efSGarrett D'Amore 
72095c635efSGarrett D'Amore static int
mdoc_xx_pre(MDOC_ARGS)72195c635efSGarrett D'Amore mdoc_xx_pre(MDOC_ARGS)
72295c635efSGarrett D'Amore {
723a40ea1a7SYuri Pankov 	print_otag(h, TAG_SPAN, "c", "Ux");
724a40ea1a7SYuri Pankov 	return 1;
72595c635efSGarrett D'Amore }
72695c635efSGarrett D'Amore 
72795c635efSGarrett D'Amore static int
mdoc_it_pre(MDOC_ARGS)72895c635efSGarrett D'Amore mdoc_it_pre(MDOC_ARGS)
72995c635efSGarrett D'Amore {
730a40ea1a7SYuri Pankov 	const struct roff_node	*bl;
731a40ea1a7SYuri Pankov 	enum mdoc_list		 type;
73295c635efSGarrett D'Amore 
73395c635efSGarrett D'Amore 	bl = n->parent;
734c66b8046SYuri Pankov 	while (bl->tok != MDOC_Bl)
73595c635efSGarrett D'Amore 		bl = bl->parent;
73695c635efSGarrett D'Amore 	type = bl->norm->Bl.type;
73795c635efSGarrett D'Amore 
738a40ea1a7SYuri Pankov 	switch (type) {
739a40ea1a7SYuri Pankov 	case LIST_bullet:
740a40ea1a7SYuri Pankov 	case LIST_dash:
741a40ea1a7SYuri Pankov 	case LIST_hyphen:
742a40ea1a7SYuri Pankov 	case LIST_item:
743a40ea1a7SYuri Pankov 	case LIST_enum:
744a40ea1a7SYuri Pankov 		switch (n->type) {
745a40ea1a7SYuri Pankov 		case ROFFT_HEAD:
746371584c2SYuri Pankov 			return 0;
747a40ea1a7SYuri Pankov 		case ROFFT_BODY:
748*4d131170SRobert Mustacchi 			print_otag_id(h, TAG_LI, NULL, n);
74995c635efSGarrett D'Amore 			break;
75095c635efSGarrett D'Amore 		default:
75195c635efSGarrett D'Amore 			break;
75295c635efSGarrett D'Amore 		}
753a40ea1a7SYuri Pankov 		break;
754a40ea1a7SYuri Pankov 	case LIST_diag:
755a40ea1a7SYuri Pankov 	case LIST_hang:
756a40ea1a7SYuri Pankov 	case LIST_inset:
757a40ea1a7SYuri Pankov 	case LIST_ohang:
758a40ea1a7SYuri Pankov 		switch (n->type) {
759a40ea1a7SYuri Pankov 		case ROFFT_HEAD:
760*4d131170SRobert Mustacchi 			print_otag_id(h, TAG_DT, NULL, n);
76195c635efSGarrett D'Amore 			break;
762a40ea1a7SYuri Pankov 		case ROFFT_BODY:
7636640c13bSYuri Pankov 			print_otag(h, TAG_DD, "");
764a40ea1a7SYuri Pankov 			break;
765a40ea1a7SYuri Pankov 		default:
766a40ea1a7SYuri Pankov 			break;
767a40ea1a7SYuri Pankov 		}
768a40ea1a7SYuri Pankov 		break;
769a40ea1a7SYuri Pankov 	case LIST_tag:
770a40ea1a7SYuri Pankov 		switch (n->type) {
771a40ea1a7SYuri Pankov 		case ROFFT_HEAD:
772*4d131170SRobert Mustacchi 			print_otag_id(h, TAG_DT, NULL, n);
77395c635efSGarrett D'Amore 			break;
774a40ea1a7SYuri Pankov 		case ROFFT_BODY:
775a40ea1a7SYuri Pankov 			if (n->child == NULL) {
7766640c13bSYuri Pankov 				print_otag(h, TAG_DD, "s", "width", "auto");
777a40ea1a7SYuri Pankov 				print_text(h, "\\ ");
778a40ea1a7SYuri Pankov 			} else
7796640c13bSYuri Pankov 				print_otag(h, TAG_DD, "");
78095c635efSGarrett D'Amore 			break;
78195c635efSGarrett D'Amore 		default:
78295c635efSGarrett D'Amore 			break;
78395c635efSGarrett D'Amore 		}
784a40ea1a7SYuri Pankov 		break;
785a40ea1a7SYuri Pankov 	case LIST_column:
786a40ea1a7SYuri Pankov 		switch (n->type) {
787a40ea1a7SYuri Pankov 		case ROFFT_HEAD:
78895c635efSGarrett D'Amore 			break;
789a40ea1a7SYuri Pankov 		case ROFFT_BODY:
7906640c13bSYuri Pankov 			print_otag(h, TAG_TD, "");
79195c635efSGarrett D'Amore 			break;
792a40ea1a7SYuri Pankov 		default:
793*4d131170SRobert Mustacchi 			print_otag_id(h, TAG_TR, NULL, n);
79495c635efSGarrett D'Amore 		}
795a40ea1a7SYuri Pankov 	default:
796a40ea1a7SYuri Pankov 		break;
79795c635efSGarrett D'Amore 	}
79895c635efSGarrett D'Amore 
799371584c2SYuri Pankov 	return 1;
80095c635efSGarrett D'Amore }
80195c635efSGarrett D'Amore 
80295c635efSGarrett D'Amore static int
mdoc_bl_pre(MDOC_ARGS)80395c635efSGarrett D'Amore mdoc_bl_pre(MDOC_ARGS)
80495c635efSGarrett D'Amore {
805cec8643bSMichal Nowak 	char		 cattr[32];
806a40ea1a7SYuri Pankov 	struct mdoc_bl	*bl;
807a40ea1a7SYuri Pankov 	enum htmltag	 elemtype;
80895c635efSGarrett D'Amore 
809a40ea1a7SYuri Pankov 	switch (n->type) {
810cec8643bSMichal Nowak 	case ROFFT_BLOCK:
811cec8643bSMichal Nowak 		html_close_paragraph(h);
812cec8643bSMichal Nowak 		break;
813a40ea1a7SYuri Pankov 	case ROFFT_HEAD:
814371584c2SYuri Pankov 		return 0;
815cec8643bSMichal Nowak 	case ROFFT_BODY:
816cec8643bSMichal Nowak 		return 1;
817a40ea1a7SYuri Pankov 	default:
818cec8643bSMichal Nowak 		abort();
81995c635efSGarrett D'Amore 	}
82095c635efSGarrett D'Amore 
8216640c13bSYuri Pankov 	bl = &n->norm->Bl;
822a40ea1a7SYuri Pankov 	switch (bl->type) {
823260e9a87SYuri Pankov 	case LIST_bullet:
824a40ea1a7SYuri Pankov 		elemtype = TAG_UL;
825c66b8046SYuri Pankov 		(void)strlcpy(cattr, "Bl-bullet", sizeof(cattr));
826a40ea1a7SYuri Pankov 		break;
827260e9a87SYuri Pankov 	case LIST_dash:
828260e9a87SYuri Pankov 	case LIST_hyphen:
829a40ea1a7SYuri Pankov 		elemtype = TAG_UL;
830c66b8046SYuri Pankov 		(void)strlcpy(cattr, "Bl-dash", sizeof(cattr));
831a40ea1a7SYuri Pankov 		break;
832260e9a87SYuri Pankov 	case LIST_item:
833a40ea1a7SYuri Pankov 		elemtype = TAG_UL;
834c66b8046SYuri Pankov 		(void)strlcpy(cattr, "Bl-item", sizeof(cattr));
83595c635efSGarrett D'Amore 		break;
836260e9a87SYuri Pankov 	case LIST_enum:
837a40ea1a7SYuri Pankov 		elemtype = TAG_OL;
838c66b8046SYuri Pankov 		(void)strlcpy(cattr, "Bl-enum", sizeof(cattr));
83995c635efSGarrett D'Amore 		break;
840260e9a87SYuri Pankov 	case LIST_diag:
841a40ea1a7SYuri Pankov 		elemtype = TAG_DL;
842c66b8046SYuri Pankov 		(void)strlcpy(cattr, "Bl-diag", sizeof(cattr));
843a40ea1a7SYuri Pankov 		break;
844260e9a87SYuri Pankov 	case LIST_hang:
845a40ea1a7SYuri Pankov 		elemtype = TAG_DL;
846c66b8046SYuri Pankov 		(void)strlcpy(cattr, "Bl-hang", sizeof(cattr));
847a40ea1a7SYuri Pankov 		break;
848260e9a87SYuri Pankov 	case LIST_inset:
849a40ea1a7SYuri Pankov 		elemtype = TAG_DL;
850c66b8046SYuri Pankov 		(void)strlcpy(cattr, "Bl-inset", sizeof(cattr));
851a40ea1a7SYuri Pankov 		break;
852260e9a87SYuri Pankov 	case LIST_ohang:
853a40ea1a7SYuri Pankov 		elemtype = TAG_DL;
854c66b8046SYuri Pankov 		(void)strlcpy(cattr, "Bl-ohang", sizeof(cattr));
85595c635efSGarrett D'Amore 		break;
856a40ea1a7SYuri Pankov 	case LIST_tag:
857a40ea1a7SYuri Pankov 		if (bl->offs)
8586640c13bSYuri Pankov 			print_otag(h, TAG_DIV, "c", "Bd-indent");
859*4d131170SRobert Mustacchi 		print_otag_id(h, TAG_DL,
860*4d131170SRobert Mustacchi 		    bl->comp ? "Bl-tag Bl-compact" : "Bl-tag", n->body);
861a40ea1a7SYuri Pankov 		return 1;
862260e9a87SYuri Pankov 	case LIST_column:
863a40ea1a7SYuri Pankov 		elemtype = TAG_TABLE;
864c66b8046SYuri Pankov 		(void)strlcpy(cattr, "Bl-column", sizeof(cattr));
86595c635efSGarrett D'Amore 		break;
86695c635efSGarrett D'Amore 	default:
86795c635efSGarrett D'Amore 		abort();
86895c635efSGarrett D'Amore 	}
8696640c13bSYuri Pankov 	if (bl->offs != NULL)
8706640c13bSYuri Pankov 		(void)strlcat(cattr, " Bd-indent", sizeof(cattr));
871c66b8046SYuri Pankov 	if (bl->comp)
872c66b8046SYuri Pankov 		(void)strlcat(cattr, " Bl-compact", sizeof(cattr));
873*4d131170SRobert Mustacchi 	print_otag_id(h, elemtype, cattr, n->body);
874371584c2SYuri Pankov 	return 1;
87595c635efSGarrett D'Amore }
87695c635efSGarrett D'Amore 
87795c635efSGarrett D'Amore static int
mdoc_ex_pre(MDOC_ARGS)87895c635efSGarrett D'Amore mdoc_ex_pre(MDOC_ARGS)
87995c635efSGarrett D'Amore {
880*4d131170SRobert Mustacchi 	if (roff_node_prev(n) != NULL)
881a40ea1a7SYuri Pankov 		print_otag(h, TAG_BR, "");
882a40ea1a7SYuri Pankov 	return 1;
883a40ea1a7SYuri Pankov }
88495c635efSGarrett D'Amore 
885a40ea1a7SYuri Pankov static int
mdoc_st_pre(MDOC_ARGS)886a40ea1a7SYuri Pankov mdoc_st_pre(MDOC_ARGS)
887a40ea1a7SYuri Pankov {
888cec8643bSMichal Nowak 	print_otag(h, TAG_SPAN, "c", "St");
889a40ea1a7SYuri Pankov 	return 1;
89095c635efSGarrett D'Amore }
89195c635efSGarrett D'Amore 
89295c635efSGarrett D'Amore static int
mdoc_em_pre(MDOC_ARGS)89395c635efSGarrett D'Amore mdoc_em_pre(MDOC_ARGS)
89495c635efSGarrett D'Amore {
895*4d131170SRobert Mustacchi 	print_otag_id(h, TAG_I, "Em", n);
896371584c2SYuri Pankov 	return 1;
89795c635efSGarrett D'Amore }
89895c635efSGarrett D'Amore 
89995c635efSGarrett D'Amore static int
mdoc_d1_pre(MDOC_ARGS)90095c635efSGarrett D'Amore mdoc_d1_pre(MDOC_ARGS)
90195c635efSGarrett D'Amore {
902cec8643bSMichal Nowak 	switch (n->type) {
903cec8643bSMichal Nowak 	case ROFFT_BLOCK:
904cec8643bSMichal Nowak 		html_close_paragraph(h);
905*4d131170SRobert Mustacchi 		return 1;
906cec8643bSMichal Nowak 	case ROFFT_HEAD:
907cec8643bSMichal Nowak 		return 0;
908cec8643bSMichal Nowak 	case ROFFT_BODY:
909*4d131170SRobert Mustacchi 		break;
910cec8643bSMichal Nowak 	default:
911cec8643bSMichal Nowak 		abort();
912cec8643bSMichal Nowak 	}
913*4d131170SRobert Mustacchi 	print_otag_id(h, TAG_DIV, "Bd Bd-indent", n);
914a40ea1a7SYuri Pankov 	if (n->tok == MDOC_Dl)
915a40ea1a7SYuri Pankov 		print_otag(h, TAG_CODE, "c", "Li");
916371584c2SYuri Pankov 	return 1;
91795c635efSGarrett D'Amore }
91895c635efSGarrett D'Amore 
91995c635efSGarrett D'Amore static int
mdoc_sx_pre(MDOC_ARGS)92095c635efSGarrett D'Amore mdoc_sx_pre(MDOC_ARGS)
92195c635efSGarrett D'Amore {
922a40ea1a7SYuri Pankov 	char	*id;
92395c635efSGarrett D'Amore 
9246640c13bSYuri Pankov 	id = html_make_id(n, 0);
925cec8643bSMichal Nowak 	print_otag(h, TAG_A, "chR", "Sx", id);
926a40ea1a7SYuri Pankov 	free(id);
927371584c2SYuri Pankov 	return 1;
92895c635efSGarrett D'Amore }
92995c635efSGarrett D'Amore 
93095c635efSGarrett D'Amore static int
mdoc_bd_pre(MDOC_ARGS)93195c635efSGarrett D'Amore mdoc_bd_pre(MDOC_ARGS)
93295c635efSGarrett D'Amore {
933*4d131170SRobert Mustacchi 	char			 buf[20];
934371584c2SYuri Pankov 	struct roff_node	*nn;
935cec8643bSMichal Nowak 	int			 comp;
93695c635efSGarrett D'Amore 
937cec8643bSMichal Nowak 	switch (n->type) {
938cec8643bSMichal Nowak 	case ROFFT_BLOCK:
939cec8643bSMichal Nowak 		html_close_paragraph(h);
940371584c2SYuri Pankov 		return 1;
941cec8643bSMichal Nowak 	case ROFFT_HEAD:
942cec8643bSMichal Nowak 		return 0;
943cec8643bSMichal Nowak 	case ROFFT_BODY:
944cec8643bSMichal Nowak 		break;
945cec8643bSMichal Nowak 	default:
946cec8643bSMichal Nowak 		abort();
94795c635efSGarrett D'Amore 	}
94895c635efSGarrett D'Amore 
949cec8643bSMichal Nowak 	/* Handle preceding whitespace. */
95095c635efSGarrett D'Amore 
951cec8643bSMichal Nowak 	comp = n->norm->Bd.comp;
952cec8643bSMichal Nowak 	for (nn = n; nn != NULL && comp == 0; nn = nn->parent) {
953cec8643bSMichal Nowak 		if (nn->type != ROFFT_BLOCK)
95495c635efSGarrett D'Amore 			continue;
955cec8643bSMichal Nowak 		if (nn->tok == MDOC_Sh || nn->tok == MDOC_Ss)
956cec8643bSMichal Nowak 			comp = 1;
957*4d131170SRobert Mustacchi 		if (roff_node_prev(nn) != NULL)
95895c635efSGarrett D'Amore 			break;
95995c635efSGarrett D'Amore 	}
960cec8643bSMichal Nowak 	(void)strlcpy(buf, "Bd", sizeof(buf));
961cec8643bSMichal Nowak 	if (comp == 0)
962cec8643bSMichal Nowak 		(void)strlcat(buf, " Pp", sizeof(buf));
96395c635efSGarrett D'Amore 
964cec8643bSMichal Nowak 	/* Handle the -offset argument. */
96595c635efSGarrett D'Amore 
966cec8643bSMichal Nowak 	if (n->norm->Bd.offs != NULL &&
967cec8643bSMichal Nowak 	    strcmp(n->norm->Bd.offs, "left") != 0)
968cec8643bSMichal Nowak 		(void)strlcat(buf, " Bd-indent", sizeof(buf));
969cec8643bSMichal Nowak 
970*4d131170SRobert Mustacchi 	if (n->norm->Bd.type == DISP_literal)
971*4d131170SRobert Mustacchi 		(void)strlcat(buf, " Li", sizeof(buf));
972*4d131170SRobert Mustacchi 
973*4d131170SRobert Mustacchi 	print_otag_id(h, TAG_DIV, buf, n);
974cec8643bSMichal Nowak 	return 1;
97595c635efSGarrett D'Amore }
97695c635efSGarrett D'Amore 
97795c635efSGarrett D'Amore static int
mdoc_pa_pre(MDOC_ARGS)97895c635efSGarrett D'Amore mdoc_pa_pre(MDOC_ARGS)
97995c635efSGarrett D'Amore {
980cec8643bSMichal Nowak 	print_otag(h, TAG_SPAN, "c", "Pa");
981371584c2SYuri Pankov 	return 1;
98295c635efSGarrett D'Amore }
98395c635efSGarrett D'Amore 
98495c635efSGarrett D'Amore static int
mdoc_ad_pre(MDOC_ARGS)98595c635efSGarrett D'Amore mdoc_ad_pre(MDOC_ARGS)
98695c635efSGarrett D'Amore {
9876640c13bSYuri Pankov 	print_otag(h, TAG_SPAN, "c", "Ad");
988371584c2SYuri Pankov 	return 1;
98995c635efSGarrett D'Amore }
99095c635efSGarrett D'Amore 
99195c635efSGarrett D'Amore static int
mdoc_an_pre(MDOC_ARGS)99295c635efSGarrett D'Amore mdoc_an_pre(MDOC_ARGS)
99395c635efSGarrett D'Amore {
994260e9a87SYuri Pankov 	if (n->norm->An.auth == AUTH_split) {
995260e9a87SYuri Pankov 		h->flags &= ~HTML_NOSPLIT;
996260e9a87SYuri Pankov 		h->flags |= HTML_SPLIT;
997371584c2SYuri Pankov 		return 0;
998260e9a87SYuri Pankov 	}
999260e9a87SYuri Pankov 	if (n->norm->An.auth == AUTH_nosplit) {
1000260e9a87SYuri Pankov 		h->flags &= ~HTML_SPLIT;
1001260e9a87SYuri Pankov 		h->flags |= HTML_NOSPLIT;
1002371584c2SYuri Pankov 		return 0;
1003260e9a87SYuri Pankov 	}
1004260e9a87SYuri Pankov 
1005260e9a87SYuri Pankov 	if (h->flags & HTML_SPLIT)
1006a40ea1a7SYuri Pankov 		print_otag(h, TAG_BR, "");
1007260e9a87SYuri Pankov 
1008260e9a87SYuri Pankov 	if (n->sec == SEC_AUTHORS && ! (h->flags & HTML_NOSPLIT))
1009260e9a87SYuri Pankov 		h->flags |= HTML_SPLIT;
101095c635efSGarrett D'Amore 
1011cec8643bSMichal Nowak 	print_otag(h, TAG_SPAN, "c", "An");
1012371584c2SYuri Pankov 	return 1;
101395c635efSGarrett D'Amore }
101495c635efSGarrett D'Amore 
101595c635efSGarrett D'Amore static int
mdoc_cd_pre(MDOC_ARGS)101695c635efSGarrett D'Amore mdoc_cd_pre(MDOC_ARGS)
101795c635efSGarrett D'Amore {
101895c635efSGarrett D'Amore 	synopsis_pre(h, n);
1019cec8643bSMichal Nowak 	print_otag(h, TAG_CODE, "c", "Cd");
1020371584c2SYuri Pankov 	return 1;
102195c635efSGarrett D'Amore }
102295c635efSGarrett D'Amore 
102395c635efSGarrett D'Amore static int
mdoc_fa_pre(MDOC_ARGS)102495c635efSGarrett D'Amore mdoc_fa_pre(MDOC_ARGS)
102595c635efSGarrett D'Amore {
1026371584c2SYuri Pankov 	const struct roff_node	*nn;
102795c635efSGarrett D'Amore 	struct tag		*t;
102895c635efSGarrett D'Amore 
102995c635efSGarrett D'Amore 	if (n->parent->tok != MDOC_Fo) {
1030cec8643bSMichal Nowak 		print_otag(h, TAG_VAR, "c", "Fa");
1031371584c2SYuri Pankov 		return 1;
103295c635efSGarrett D'Amore 	}
1033*4d131170SRobert Mustacchi 	for (nn = n->child; nn != NULL; nn = nn->next) {
1034cec8643bSMichal Nowak 		t = print_otag(h, TAG_VAR, "c", "Fa");
103595c635efSGarrett D'Amore 		print_text(h, nn->string);
103695c635efSGarrett D'Amore 		print_tagq(h, t);
1037*4d131170SRobert Mustacchi 		if (nn->next != NULL) {
103895c635efSGarrett D'Amore 			h->flags |= HTML_NOSPACE;
103995c635efSGarrett D'Amore 			print_text(h, ",");
104095c635efSGarrett D'Amore 		}
104195c635efSGarrett D'Amore 	}
1042*4d131170SRobert Mustacchi 	if (n->child != NULL &&
1043*4d131170SRobert Mustacchi 	    (nn = roff_node_next(n)) != NULL &&
1044*4d131170SRobert Mustacchi 	    nn->tok == MDOC_Fa) {
104595c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
104695c635efSGarrett D'Amore 		print_text(h, ",");
104795c635efSGarrett D'Amore 	}
1048371584c2SYuri Pankov 	return 0;
104995c635efSGarrett D'Amore }
105095c635efSGarrett D'Amore 
105195c635efSGarrett D'Amore static int
mdoc_fd_pre(MDOC_ARGS)105295c635efSGarrett D'Amore mdoc_fd_pre(MDOC_ARGS)
105395c635efSGarrett D'Amore {
105495c635efSGarrett D'Amore 	struct tag	*t;
1055a40ea1a7SYuri Pankov 	char		*buf, *cp;
105695c635efSGarrett D'Amore 
105795c635efSGarrett D'Amore 	synopsis_pre(h, n);
105895c635efSGarrett D'Amore 
105995c635efSGarrett D'Amore 	if (NULL == (n = n->child))
1060371584c2SYuri Pankov 		return 0;
106195c635efSGarrett D'Amore 
1062371584c2SYuri Pankov 	assert(n->type == ROFFT_TEXT);
106395c635efSGarrett D'Amore 
106495c635efSGarrett D'Amore 	if (strcmp(n->string, "#include")) {
1065cec8643bSMichal Nowak 		print_otag(h, TAG_CODE, "c", "Fd");
1066371584c2SYuri Pankov 		return 1;
106795c635efSGarrett D'Amore 	}
106895c635efSGarrett D'Amore 
1069cec8643bSMichal Nowak 	print_otag(h, TAG_CODE, "c", "In");
107095c635efSGarrett D'Amore 	print_text(h, n->string);
107195c635efSGarrett D'Amore 
107295c635efSGarrett D'Amore 	if (NULL != (n = n->next)) {
1073371584c2SYuri Pankov 		assert(n->type == ROFFT_TEXT);
1074260e9a87SYuri Pankov 
107595c635efSGarrett D'Amore 		if (h->base_includes) {
1076a40ea1a7SYuri Pankov 			cp = n->string;
1077a40ea1a7SYuri Pankov 			if (*cp == '<' || *cp == '"')
1078a40ea1a7SYuri Pankov 				cp++;
1079a40ea1a7SYuri Pankov 			buf = mandoc_strdup(cp);
1080a40ea1a7SYuri Pankov 			cp = strchr(buf, '\0') - 1;
1081a40ea1a7SYuri Pankov 			if (cp >= buf && (*cp == '>' || *cp == '"'))
1082a40ea1a7SYuri Pankov 				*cp = '\0';
1083cec8643bSMichal Nowak 			t = print_otag(h, TAG_A, "chI", "In", buf);
1084a40ea1a7SYuri Pankov 			free(buf);
1085a40ea1a7SYuri Pankov 		} else
1086cec8643bSMichal Nowak 			t = print_otag(h, TAG_A, "c", "In");
108795c635efSGarrett D'Amore 
108895c635efSGarrett D'Amore 		print_text(h, n->string);
108995c635efSGarrett D'Amore 		print_tagq(h, t);
109095c635efSGarrett D'Amore 
109195c635efSGarrett D'Amore 		n = n->next;
109295c635efSGarrett D'Amore 	}
109395c635efSGarrett D'Amore 
109495c635efSGarrett D'Amore 	for ( ; n; n = n->next) {
1095371584c2SYuri Pankov 		assert(n->type == ROFFT_TEXT);
109695c635efSGarrett D'Amore 		print_text(h, n->string);
109795c635efSGarrett D'Amore 	}
109895c635efSGarrett D'Amore 
1099371584c2SYuri Pankov 	return 0;
110095c635efSGarrett D'Amore }
110195c635efSGarrett D'Amore 
110295c635efSGarrett D'Amore static int
mdoc_vt_pre(MDOC_ARGS)110395c635efSGarrett D'Amore mdoc_vt_pre(MDOC_ARGS)
110495c635efSGarrett D'Amore {
1105371584c2SYuri Pankov 	if (n->type == ROFFT_BLOCK) {
110695c635efSGarrett D'Amore 		synopsis_pre(h, n);
1107371584c2SYuri Pankov 		return 1;
1108371584c2SYuri Pankov 	} else if (n->type == ROFFT_ELEM) {
110995c635efSGarrett D'Amore 		synopsis_pre(h, n);
1110371584c2SYuri Pankov 	} else if (n->type == ROFFT_HEAD)
1111371584c2SYuri Pankov 		return 0;
111295c635efSGarrett D'Amore 
1113cec8643bSMichal Nowak 	print_otag(h, TAG_VAR, "c", "Vt");
1114371584c2SYuri Pankov 	return 1;
111595c635efSGarrett D'Amore }
111695c635efSGarrett D'Amore 
111795c635efSGarrett D'Amore static int
mdoc_ft_pre(MDOC_ARGS)111895c635efSGarrett D'Amore mdoc_ft_pre(MDOC_ARGS)
111995c635efSGarrett D'Amore {
112095c635efSGarrett D'Amore 	synopsis_pre(h, n);
1121cec8643bSMichal Nowak 	print_otag(h, TAG_VAR, "c", "Ft");
1122371584c2SYuri Pankov 	return 1;
112395c635efSGarrett D'Amore }
112495c635efSGarrett D'Amore 
112595c635efSGarrett D'Amore static int
mdoc_fn_pre(MDOC_ARGS)112695c635efSGarrett D'Amore mdoc_fn_pre(MDOC_ARGS)
112795c635efSGarrett D'Amore {
112895c635efSGarrett D'Amore 	struct tag	*t;
112995c635efSGarrett D'Amore 	char		 nbuf[BUFSIZ];
113095c635efSGarrett D'Amore 	const char	*sp, *ep;
1131a40ea1a7SYuri Pankov 	int		 sz, pretty;
113295c635efSGarrett D'Amore 
1133a40ea1a7SYuri Pankov 	pretty = NODE_SYNPRETTY & n->flags;
113495c635efSGarrett D'Amore 	synopsis_pre(h, n);
113595c635efSGarrett D'Amore 
113695c635efSGarrett D'Amore 	/* Split apart into type and name. */
113795c635efSGarrett D'Amore 	assert(n->child->string);
113895c635efSGarrett D'Amore 	sp = n->child->string;
113995c635efSGarrett D'Amore 
114095c635efSGarrett D'Amore 	ep = strchr(sp, ' ');
114195c635efSGarrett D'Amore 	if (NULL != ep) {
1142cec8643bSMichal Nowak 		t = print_otag(h, TAG_VAR, "c", "Ft");
1143260e9a87SYuri Pankov 
114495c635efSGarrett D'Amore 		while (ep) {
114595c635efSGarrett D'Amore 			sz = MIN((int)(ep - sp), BUFSIZ - 1);
114695c635efSGarrett D'Amore 			(void)memcpy(nbuf, sp, (size_t)sz);
114795c635efSGarrett D'Amore 			nbuf[sz] = '\0';
114895c635efSGarrett D'Amore 			print_text(h, nbuf);
114995c635efSGarrett D'Amore 			sp = ++ep;
115095c635efSGarrett D'Amore 			ep = strchr(sp, ' ');
115195c635efSGarrett D'Amore 		}
115295c635efSGarrett D'Amore 		print_tagq(h, t);
115395c635efSGarrett D'Amore 	}
115495c635efSGarrett D'Amore 
1155*4d131170SRobert Mustacchi 	t = print_otag_id(h, TAG_CODE, "Fn", n);
115695c635efSGarrett D'Amore 
1157260e9a87SYuri Pankov 	if (sp)
1158260e9a87SYuri Pankov 		print_text(h, sp);
115995c635efSGarrett D'Amore 
116095c635efSGarrett D'Amore 	print_tagq(h, t);
116195c635efSGarrett D'Amore 
116295c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
116395c635efSGarrett D'Amore 	print_text(h, "(");
116495c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
116595c635efSGarrett D'Amore 
116695c635efSGarrett D'Amore 	for (n = n->child->next; n; n = n->next) {
1167a40ea1a7SYuri Pankov 		if (NODE_SYNPRETTY & n->flags)
1168cec8643bSMichal Nowak 			t = print_otag(h, TAG_VAR, "cs", "Fa",
1169a40ea1a7SYuri Pankov 			    "white-space", "nowrap");
1170a40ea1a7SYuri Pankov 		else
1171cec8643bSMichal Nowak 			t = print_otag(h, TAG_VAR, "c", "Fa");
117295c635efSGarrett D'Amore 		print_text(h, n->string);
117395c635efSGarrett D'Amore 		print_tagq(h, t);
117495c635efSGarrett D'Amore 		if (n->next) {
117595c635efSGarrett D'Amore 			h->flags |= HTML_NOSPACE;
117695c635efSGarrett D'Amore 			print_text(h, ",");
117795c635efSGarrett D'Amore 		}
117895c635efSGarrett D'Amore 	}
117995c635efSGarrett D'Amore 
118095c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
118195c635efSGarrett D'Amore 	print_text(h, ")");
118295c635efSGarrett D'Amore 
118395c635efSGarrett D'Amore 	if (pretty) {
118495c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
118595c635efSGarrett D'Amore 		print_text(h, ";");
118695c635efSGarrett D'Amore 	}
118795c635efSGarrett D'Amore 
1188371584c2SYuri Pankov 	return 0;
118995c635efSGarrett D'Amore }
119095c635efSGarrett D'Amore 
119195c635efSGarrett D'Amore static int
mdoc_sm_pre(MDOC_ARGS)119295c635efSGarrett D'Amore mdoc_sm_pre(MDOC_ARGS)
119395c635efSGarrett D'Amore {
119495c635efSGarrett D'Amore 
1195260e9a87SYuri Pankov 	if (NULL == n->child)
1196260e9a87SYuri Pankov 		h->flags ^= HTML_NONOSPACE;
1197260e9a87SYuri Pankov 	else if (0 == strcmp("on", n->child->string))
119895c635efSGarrett D'Amore 		h->flags &= ~HTML_NONOSPACE;
1199260e9a87SYuri Pankov 	else
120095c635efSGarrett D'Amore 		h->flags |= HTML_NONOSPACE;
120195c635efSGarrett D'Amore 
1202260e9a87SYuri Pankov 	if ( ! (HTML_NONOSPACE & h->flags))
1203260e9a87SYuri Pankov 		h->flags &= ~HTML_NOSPACE;
1204260e9a87SYuri Pankov 
1205371584c2SYuri Pankov 	return 0;
120695c635efSGarrett D'Amore }
120795c635efSGarrett D'Amore 
120895c635efSGarrett D'Amore static int
mdoc_skip_pre(MDOC_ARGS)1209260e9a87SYuri Pankov mdoc_skip_pre(MDOC_ARGS)
121095c635efSGarrett D'Amore {
121195c635efSGarrett D'Amore 
1212371584c2SYuri Pankov 	return 0;
1213260e9a87SYuri Pankov }
1214260e9a87SYuri Pankov 
1215260e9a87SYuri Pankov static int
mdoc_pp_pre(MDOC_ARGS)1216260e9a87SYuri Pankov mdoc_pp_pre(MDOC_ARGS)
1217260e9a87SYuri Pankov {
1218*4d131170SRobert Mustacchi 	char	*id;
1219*4d131170SRobert Mustacchi 
1220*4d131170SRobert Mustacchi 	if (n->flags & NODE_NOFILL) {
1221*4d131170SRobert Mustacchi 		print_endline(h);
1222*4d131170SRobert Mustacchi 		if (n->flags & NODE_ID)
1223*4d131170SRobert Mustacchi 			mdoc_tg_pre(meta, n, h);
1224*4d131170SRobert Mustacchi 		else {
1225*4d131170SRobert Mustacchi 			h->col = 1;
1226*4d131170SRobert Mustacchi 			print_endline(h);
1227*4d131170SRobert Mustacchi 		}
1228*4d131170SRobert Mustacchi 	} else {
1229cec8643bSMichal Nowak 		html_close_paragraph(h);
1230*4d131170SRobert Mustacchi 		id = n->flags & NODE_ID ? html_make_id(n, 1) : NULL;
1231*4d131170SRobert Mustacchi 		print_otag(h, TAG_P, "ci", "Pp", id);
1232*4d131170SRobert Mustacchi 		free(id);
1233cec8643bSMichal Nowak 	}
1234371584c2SYuri Pankov 	return 0;
123595c635efSGarrett D'Amore }
123695c635efSGarrett D'Amore 
123795c635efSGarrett D'Amore static int
mdoc_lk_pre(MDOC_ARGS)123895c635efSGarrett D'Amore mdoc_lk_pre(MDOC_ARGS)
123995c635efSGarrett D'Amore {
1240c66b8046SYuri Pankov 	const struct roff_node *link, *descr, *punct;
1241c66b8046SYuri Pankov 	struct tag	*t;
124295c635efSGarrett D'Amore 
1243c66b8046SYuri Pankov 	if ((link = n->child) == NULL)
1244c66b8046SYuri Pankov 		return 0;
124595c635efSGarrett D'Amore 
1246c66b8046SYuri Pankov 	/* Find beginning of trailing punctuation. */
1247c66b8046SYuri Pankov 	punct = n->last;
1248c66b8046SYuri Pankov 	while (punct != link && punct->flags & NODE_DELIMC)
1249c66b8046SYuri Pankov 		punct = punct->prev;
1250c66b8046SYuri Pankov 	punct = punct->next;
1251c66b8046SYuri Pankov 
1252c66b8046SYuri Pankov 	/* Link target and link text. */
1253c66b8046SYuri Pankov 	descr = link->next;
1254c66b8046SYuri Pankov 	if (descr == punct)
1255c66b8046SYuri Pankov 		descr = link;  /* no text */
1256cec8643bSMichal Nowak 	t = print_otag(h, TAG_A, "ch", "Lk", link->string);
1257c66b8046SYuri Pankov 	do {
1258c66b8046SYuri Pankov 		if (descr->flags & (NODE_DELIMC | NODE_DELIMO))
1259c66b8046SYuri Pankov 			h->flags |= HTML_NOSPACE;
1260c66b8046SYuri Pankov 		print_text(h, descr->string);
1261c66b8046SYuri Pankov 		descr = descr->next;
1262c66b8046SYuri Pankov 	} while (descr != punct);
1263c66b8046SYuri Pankov 	print_tagq(h, t);
126495c635efSGarrett D'Amore 
1265c66b8046SYuri Pankov 	/* Trailing punctuation. */
1266c66b8046SYuri Pankov 	while (punct != NULL) {
1267c66b8046SYuri Pankov 		h->flags |= HTML_NOSPACE;
1268c66b8046SYuri Pankov 		print_text(h, punct->string);
1269c66b8046SYuri Pankov 		punct = punct->next;
1270c66b8046SYuri Pankov 	}
1271371584c2SYuri Pankov 	return 0;
127295c635efSGarrett D'Amore }
127395c635efSGarrett D'Amore 
127495c635efSGarrett D'Amore static int
mdoc_mt_pre(MDOC_ARGS)127595c635efSGarrett D'Amore mdoc_mt_pre(MDOC_ARGS)
127695c635efSGarrett D'Amore {
127795c635efSGarrett D'Amore 	struct tag	*t;
1278a40ea1a7SYuri Pankov 	char		*cp;
127995c635efSGarrett D'Amore 
128095c635efSGarrett D'Amore 	for (n = n->child; n; n = n->next) {
1281371584c2SYuri Pankov 		assert(n->type == ROFFT_TEXT);
1282a40ea1a7SYuri Pankov 		mandoc_asprintf(&cp, "mailto:%s", n->string);
1283cec8643bSMichal Nowak 		t = print_otag(h, TAG_A, "ch", "Mt", cp);
128495c635efSGarrett D'Amore 		print_text(h, n->string);
128595c635efSGarrett D'Amore 		print_tagq(h, t);
1286a40ea1a7SYuri Pankov 		free(cp);
128795c635efSGarrett D'Amore 	}
1288371584c2SYuri Pankov 	return 0;
128995c635efSGarrett D'Amore }
129095c635efSGarrett D'Amore 
129195c635efSGarrett D'Amore static int
mdoc_fo_pre(MDOC_ARGS)129295c635efSGarrett D'Amore mdoc_fo_pre(MDOC_ARGS)
129395c635efSGarrett D'Amore {
129495c635efSGarrett D'Amore 	struct tag	*t;
129595c635efSGarrett D'Amore 
1296*4d131170SRobert Mustacchi 	switch (n->type) {
1297*4d131170SRobert Mustacchi 	case ROFFT_BLOCK:
1298*4d131170SRobert Mustacchi 		synopsis_pre(h, n);
1299*4d131170SRobert Mustacchi 		return 1;
1300*4d131170SRobert Mustacchi 	case ROFFT_HEAD:
1301*4d131170SRobert Mustacchi 		if (n->child != NULL) {
1302*4d131170SRobert Mustacchi 			t = print_otag_id(h, TAG_CODE, "Fn", n);
1303*4d131170SRobert Mustacchi 			print_text(h, n->child->string);
1304*4d131170SRobert Mustacchi 			print_tagq(h, t);
1305*4d131170SRobert Mustacchi 		}
1306*4d131170SRobert Mustacchi 		return 0;
1307*4d131170SRobert Mustacchi 	case ROFFT_BODY:
130895c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
130995c635efSGarrett D'Amore 		print_text(h, "(");
131095c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
1311371584c2SYuri Pankov 		return 1;
1312*4d131170SRobert Mustacchi 	default:
1313*4d131170SRobert Mustacchi 		abort();
131495c635efSGarrett D'Amore 	}
131595c635efSGarrett D'Amore }
131695c635efSGarrett D'Amore 
131795c635efSGarrett D'Amore static void
mdoc_fo_post(MDOC_ARGS)131895c635efSGarrett D'Amore mdoc_fo_post(MDOC_ARGS)
131995c635efSGarrett D'Amore {
1320371584c2SYuri Pankov 	if (n->type != ROFFT_BODY)
132195c635efSGarrett D'Amore 		return;
132295c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
132395c635efSGarrett D'Amore 	print_text(h, ")");
132495c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
132595c635efSGarrett D'Amore 	print_text(h, ";");
132695c635efSGarrett D'Amore }
132795c635efSGarrett D'Amore 
132895c635efSGarrett D'Amore static int
mdoc_in_pre(MDOC_ARGS)132995c635efSGarrett D'Amore mdoc_in_pre(MDOC_ARGS)
133095c635efSGarrett D'Amore {
133195c635efSGarrett D'Amore 	struct tag	*t;
133295c635efSGarrett D'Amore 
133395c635efSGarrett D'Amore 	synopsis_pre(h, n);
1334cec8643bSMichal Nowak 	print_otag(h, TAG_CODE, "c", "In");
133595c635efSGarrett D'Amore 
133695c635efSGarrett D'Amore 	/*
133795c635efSGarrett D'Amore 	 * The first argument of the `In' gets special treatment as
133895c635efSGarrett D'Amore 	 * being a linked value.  Subsequent values are printed
133995c635efSGarrett D'Amore 	 * afterward.  groff does similarly.  This also handles the case
134095c635efSGarrett D'Amore 	 * of no children.
134195c635efSGarrett D'Amore 	 */
134295c635efSGarrett D'Amore 
1343a40ea1a7SYuri Pankov 	if (NODE_SYNPRETTY & n->flags && NODE_LINE & n->flags)
134495c635efSGarrett D'Amore 		print_text(h, "#include");
134595c635efSGarrett D'Amore 
134695c635efSGarrett D'Amore 	print_text(h, "<");
134795c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
134895c635efSGarrett D'Amore 
134995c635efSGarrett D'Amore 	if (NULL != (n = n->child)) {
1350371584c2SYuri Pankov 		assert(n->type == ROFFT_TEXT);
135195c635efSGarrett D'Amore 
1352a40ea1a7SYuri Pankov 		if (h->base_includes)
1353cec8643bSMichal Nowak 			t = print_otag(h, TAG_A, "chI", "In", n->string);
1354a40ea1a7SYuri Pankov 		else
1355cec8643bSMichal Nowak 			t = print_otag(h, TAG_A, "c", "In");
135695c635efSGarrett D'Amore 		print_text(h, n->string);
135795c635efSGarrett D'Amore 		print_tagq(h, t);
135895c635efSGarrett D'Amore 
135995c635efSGarrett D'Amore 		n = n->next;
136095c635efSGarrett D'Amore 	}
136195c635efSGarrett D'Amore 
136295c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
136395c635efSGarrett D'Amore 	print_text(h, ">");
136495c635efSGarrett D'Amore 
136595c635efSGarrett D'Amore 	for ( ; n; n = n->next) {
1366371584c2SYuri Pankov 		assert(n->type == ROFFT_TEXT);
136795c635efSGarrett D'Amore 		print_text(h, n->string);
136895c635efSGarrett D'Amore 	}
1369371584c2SYuri Pankov 	return 0;
137095c635efSGarrett D'Amore }
137195c635efSGarrett D'Amore 
137295c635efSGarrett D'Amore static int
mdoc_va_pre(MDOC_ARGS)137395c635efSGarrett D'Amore mdoc_va_pre(MDOC_ARGS)
137495c635efSGarrett D'Amore {
1375cec8643bSMichal Nowak 	print_otag(h, TAG_VAR, "c", "Va");
1376371584c2SYuri Pankov 	return 1;
137795c635efSGarrett D'Amore }
137895c635efSGarrett D'Amore 
137995c635efSGarrett D'Amore static int
mdoc_ap_pre(MDOC_ARGS)138095c635efSGarrett D'Amore mdoc_ap_pre(MDOC_ARGS)
138195c635efSGarrett D'Amore {
138295c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
138395c635efSGarrett D'Amore 	print_text(h, "\\(aq");
138495c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
1385371584c2SYuri Pankov 	return 1;
138695c635efSGarrett D'Amore }
138795c635efSGarrett D'Amore 
138895c635efSGarrett D'Amore static int
mdoc_bf_pre(MDOC_ARGS)138995c635efSGarrett D'Amore mdoc_bf_pre(MDOC_ARGS)
139095c635efSGarrett D'Amore {
1391a40ea1a7SYuri Pankov 	const char	*cattr;
139295c635efSGarrett D'Amore 
1393cec8643bSMichal Nowak 	switch (n->type) {
1394cec8643bSMichal Nowak 	case ROFFT_BLOCK:
1395cec8643bSMichal Nowak 		html_close_paragraph(h);
1396371584c2SYuri Pankov 		return 1;
1397cec8643bSMichal Nowak 	case ROFFT_HEAD:
1398cec8643bSMichal Nowak 		return 0;
1399cec8643bSMichal Nowak 	case ROFFT_BODY:
1400cec8643bSMichal Nowak 		break;
1401cec8643bSMichal Nowak 	default:
1402cec8643bSMichal Nowak 		abort();
1403cec8643bSMichal Nowak 	}
140495c635efSGarrett D'Amore 
1405260e9a87SYuri Pankov 	if (FONT_Em == n->norm->Bf.font)
14066640c13bSYuri Pankov 		cattr = "Bf Em";
1407260e9a87SYuri Pankov 	else if (FONT_Sy == n->norm->Bf.font)
14086640c13bSYuri Pankov 		cattr = "Bf Sy";
1409260e9a87SYuri Pankov 	else if (FONT_Li == n->norm->Bf.font)
14106640c13bSYuri Pankov 		cattr = "Bf Li";
141195c635efSGarrett D'Amore 	else
14126640c13bSYuri Pankov 		cattr = "Bf No";
1413a40ea1a7SYuri Pankov 
14146640c13bSYuri Pankov 	/* Cannot use TAG_SPAN because it may contain blocks. */
14156640c13bSYuri Pankov 	print_otag(h, TAG_DIV, "c", cattr);
1416371584c2SYuri Pankov 	return 1;
141795c635efSGarrett D'Amore }
141895c635efSGarrett D'Amore 
141995c635efSGarrett D'Amore static int
mdoc_igndelim_pre(MDOC_ARGS)142095c635efSGarrett D'Amore mdoc_igndelim_pre(MDOC_ARGS)
142195c635efSGarrett D'Amore {
142295c635efSGarrett D'Amore 	h->flags |= HTML_IGNDELIM;
1423371584c2SYuri Pankov 	return 1;
142495c635efSGarrett D'Amore }
142595c635efSGarrett D'Amore 
142695c635efSGarrett D'Amore static void
mdoc_pf_post(MDOC_ARGS)142795c635efSGarrett D'Amore mdoc_pf_post(MDOC_ARGS)
142895c635efSGarrett D'Amore {
1429a40ea1a7SYuri Pankov 	if ( ! (n->next == NULL || n->next->flags & NODE_LINE))
1430260e9a87SYuri Pankov 		h->flags |= HTML_NOSPACE;
143195c635efSGarrett D'Amore }
143295c635efSGarrett D'Amore 
143395c635efSGarrett D'Amore static int
mdoc_rs_pre(MDOC_ARGS)143495c635efSGarrett D'Amore mdoc_rs_pre(MDOC_ARGS)
143595c635efSGarrett D'Amore {
1436cec8643bSMichal Nowak 	switch (n->type) {
1437cec8643bSMichal Nowak 	case ROFFT_BLOCK:
1438cec8643bSMichal Nowak 		if (n->sec == SEC_SEE_ALSO)
1439cec8643bSMichal Nowak 			html_close_paragraph(h);
1440cec8643bSMichal Nowak 		break;
1441cec8643bSMichal Nowak 	case ROFFT_HEAD:
1442cec8643bSMichal Nowak 		return 0;
1443cec8643bSMichal Nowak 	case ROFFT_BODY:
1444cec8643bSMichal Nowak 		if (n->sec == SEC_SEE_ALSO)
1445cec8643bSMichal Nowak 			print_otag(h, TAG_P, "c", "Pp");
1446cec8643bSMichal Nowak 		print_otag(h, TAG_CITE, "c", "Rs");
1447cec8643bSMichal Nowak 		break;
1448cec8643bSMichal Nowak 	default:
1449cec8643bSMichal Nowak 		abort();
1450cec8643bSMichal Nowak 	}
1451371584c2SYuri Pankov 	return 1;
145295c635efSGarrett D'Amore }
145395c635efSGarrett D'Amore 
1454260e9a87SYuri Pankov static int
mdoc_no_pre(MDOC_ARGS)1455260e9a87SYuri Pankov mdoc_no_pre(MDOC_ARGS)
1456260e9a87SYuri Pankov {
1457*4d131170SRobert Mustacchi 	print_otag_id(h, TAG_SPAN, roff_name[n->tok], n);
1458371584c2SYuri Pankov 	return 1;
145995c635efSGarrett D'Amore }
146095c635efSGarrett D'Amore 
146195c635efSGarrett D'Amore static int
mdoc_sy_pre(MDOC_ARGS)146295c635efSGarrett D'Amore mdoc_sy_pre(MDOC_ARGS)
146395c635efSGarrett D'Amore {
1464*4d131170SRobert Mustacchi 	print_otag_id(h, TAG_B, "Sy", n);
1465371584c2SYuri Pankov 	return 1;
146695c635efSGarrett D'Amore }
146795c635efSGarrett D'Amore 
146895c635efSGarrett D'Amore static int
mdoc_lb_pre(MDOC_ARGS)146995c635efSGarrett D'Amore mdoc_lb_pre(MDOC_ARGS)
147095c635efSGarrett D'Amore {
1471*4d131170SRobert Mustacchi 	if (n->sec == SEC_LIBRARY &&
1472*4d131170SRobert Mustacchi 	    n->flags & NODE_LINE &&
1473*4d131170SRobert Mustacchi 	    roff_node_prev(n) != NULL)
1474a40ea1a7SYuri Pankov 		print_otag(h, TAG_BR, "");
147595c635efSGarrett D'Amore 
1476cec8643bSMichal Nowak 	print_otag(h, TAG_SPAN, "c", "Lb");
1477371584c2SYuri Pankov 	return 1;
147895c635efSGarrett D'Amore }
147995c635efSGarrett D'Amore 
148095c635efSGarrett D'Amore static int
mdoc__x_pre(MDOC_ARGS)148195c635efSGarrett D'Amore mdoc__x_pre(MDOC_ARGS)
148295c635efSGarrett D'Amore {
1483*4d131170SRobert Mustacchi 	struct roff_node	*nn;
1484*4d131170SRobert Mustacchi 	const char		*cattr;
1485*4d131170SRobert Mustacchi 	enum htmltag		 t;
148695c635efSGarrett D'Amore 
148795c635efSGarrett D'Amore 	t = TAG_SPAN;
148895c635efSGarrett D'Amore 
148995c635efSGarrett D'Amore 	switch (n->tok) {
1490260e9a87SYuri Pankov 	case MDOC__A:
1491a40ea1a7SYuri Pankov 		cattr = "RsA";
1492*4d131170SRobert Mustacchi 		if ((nn = roff_node_prev(n)) != NULL && nn->tok == MDOC__A &&
1493*4d131170SRobert Mustacchi 		    ((nn = roff_node_next(n)) == NULL || nn->tok != MDOC__A))
1494*4d131170SRobert Mustacchi 			print_text(h, "and");
149595c635efSGarrett D'Amore 		break;
1496260e9a87SYuri Pankov 	case MDOC__B:
149795c635efSGarrett D'Amore 		t = TAG_I;
1498a40ea1a7SYuri Pankov 		cattr = "RsB";
149995c635efSGarrett D'Amore 		break;
1500260e9a87SYuri Pankov 	case MDOC__C:
1501a40ea1a7SYuri Pankov 		cattr = "RsC";
150295c635efSGarrett D'Amore 		break;
1503260e9a87SYuri Pankov 	case MDOC__D:
1504a40ea1a7SYuri Pankov 		cattr = "RsD";
150595c635efSGarrett D'Amore 		break;
1506260e9a87SYuri Pankov 	case MDOC__I:
150795c635efSGarrett D'Amore 		t = TAG_I;
1508a40ea1a7SYuri Pankov 		cattr = "RsI";
150995c635efSGarrett D'Amore 		break;
1510260e9a87SYuri Pankov 	case MDOC__J:
151195c635efSGarrett D'Amore 		t = TAG_I;
1512a40ea1a7SYuri Pankov 		cattr = "RsJ";
151395c635efSGarrett D'Amore 		break;
1514260e9a87SYuri Pankov 	case MDOC__N:
1515a40ea1a7SYuri Pankov 		cattr = "RsN";
151695c635efSGarrett D'Amore 		break;
1517260e9a87SYuri Pankov 	case MDOC__O:
1518a40ea1a7SYuri Pankov 		cattr = "RsO";
151995c635efSGarrett D'Amore 		break;
1520260e9a87SYuri Pankov 	case MDOC__P:
1521a40ea1a7SYuri Pankov 		cattr = "RsP";
152295c635efSGarrett D'Amore 		break;
1523260e9a87SYuri Pankov 	case MDOC__Q:
1524a40ea1a7SYuri Pankov 		cattr = "RsQ";
152595c635efSGarrett D'Amore 		break;
1526260e9a87SYuri Pankov 	case MDOC__R:
1527a40ea1a7SYuri Pankov 		cattr = "RsR";
152895c635efSGarrett D'Amore 		break;
1529260e9a87SYuri Pankov 	case MDOC__T:
1530a40ea1a7SYuri Pankov 		cattr = "RsT";
153195c635efSGarrett D'Amore 		break;
1532260e9a87SYuri Pankov 	case MDOC__U:
1533a40ea1a7SYuri Pankov 		print_otag(h, TAG_A, "ch", "RsU", n->child->string);
1534a40ea1a7SYuri Pankov 		return 1;
1535260e9a87SYuri Pankov 	case MDOC__V:
1536a40ea1a7SYuri Pankov 		cattr = "RsV";
153795c635efSGarrett D'Amore 		break;
153895c635efSGarrett D'Amore 	default:
153995c635efSGarrett D'Amore 		abort();
154095c635efSGarrett D'Amore 	}
154195c635efSGarrett D'Amore 
1542a40ea1a7SYuri Pankov 	print_otag(h, t, "c", cattr);
1543371584c2SYuri Pankov 	return 1;
154495c635efSGarrett D'Amore }
154595c635efSGarrett D'Amore 
154695c635efSGarrett D'Amore static void
mdoc__x_post(MDOC_ARGS)154795c635efSGarrett D'Amore mdoc__x_post(MDOC_ARGS)
154895c635efSGarrett D'Amore {
1549*4d131170SRobert Mustacchi 	struct roff_node *nn;
155095c635efSGarrett D'Amore 
1551*4d131170SRobert Mustacchi 	if (n->tok == MDOC__A &&
1552*4d131170SRobert Mustacchi 	    (nn = roff_node_next(n)) != NULL && nn->tok == MDOC__A &&
1553*4d131170SRobert Mustacchi 	    ((nn = roff_node_next(nn)) == NULL || nn->tok != MDOC__A) &&
1554*4d131170SRobert Mustacchi 	    ((nn = roff_node_prev(n)) == NULL || nn->tok != MDOC__A))
1555*4d131170SRobert Mustacchi 		return;
155695c635efSGarrett D'Amore 
155795c635efSGarrett D'Amore 	/* TODO: %U */
155895c635efSGarrett D'Amore 
1559*4d131170SRobert Mustacchi 	if (n->parent == NULL || n->parent->tok != MDOC_Rs)
156095c635efSGarrett D'Amore 		return;
156195c635efSGarrett D'Amore 
156295c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
1563*4d131170SRobert Mustacchi 	print_text(h, roff_node_next(n) ? "," : ".");
156495c635efSGarrett D'Amore }
156595c635efSGarrett D'Amore 
156695c635efSGarrett D'Amore static int
mdoc_bk_pre(MDOC_ARGS)156795c635efSGarrett D'Amore mdoc_bk_pre(MDOC_ARGS)
156895c635efSGarrett D'Amore {
156995c635efSGarrett D'Amore 
157095c635efSGarrett D'Amore 	switch (n->type) {
1571371584c2SYuri Pankov 	case ROFFT_BLOCK:
157295c635efSGarrett D'Amore 		break;
1573371584c2SYuri Pankov 	case ROFFT_HEAD:
1574371584c2SYuri Pankov 		return 0;
1575371584c2SYuri Pankov 	case ROFFT_BODY:
1576371584c2SYuri Pankov 		if (n->parent->args != NULL || n->prev->child == NULL)
157795c635efSGarrett D'Amore 			h->flags |= HTML_PREKEEP;
157895c635efSGarrett D'Amore 		break;
157995c635efSGarrett D'Amore 	default:
158095c635efSGarrett D'Amore 		abort();
158195c635efSGarrett D'Amore 	}
158295c635efSGarrett D'Amore 
1583371584c2SYuri Pankov 	return 1;
158495c635efSGarrett D'Amore }
158595c635efSGarrett D'Amore 
158695c635efSGarrett D'Amore static void
mdoc_bk_post(MDOC_ARGS)158795c635efSGarrett D'Amore mdoc_bk_post(MDOC_ARGS)
158895c635efSGarrett D'Amore {
158995c635efSGarrett D'Amore 
1590371584c2SYuri Pankov 	if (n->type == ROFFT_BODY)
159195c635efSGarrett D'Amore 		h->flags &= ~(HTML_KEEP | HTML_PREKEEP);
159295c635efSGarrett D'Amore }
159395c635efSGarrett D'Amore 
159495c635efSGarrett D'Amore static int
mdoc_quote_pre(MDOC_ARGS)159595c635efSGarrett D'Amore mdoc_quote_pre(MDOC_ARGS)
159695c635efSGarrett D'Amore {
1597371584c2SYuri Pankov 	if (n->type != ROFFT_BODY)
1598371584c2SYuri Pankov 		return 1;
159995c635efSGarrett D'Amore 
160095c635efSGarrett D'Amore 	switch (n->tok) {
1601260e9a87SYuri Pankov 	case MDOC_Ao:
1602260e9a87SYuri Pankov 	case MDOC_Aq:
1603371584c2SYuri Pankov 		print_text(h, n->child != NULL && n->child->next == NULL &&
1604260e9a87SYuri Pankov 		    n->child->tok == MDOC_Mt ?  "<" : "\\(la");
160595c635efSGarrett D'Amore 		break;
1606260e9a87SYuri Pankov 	case MDOC_Bro:
1607260e9a87SYuri Pankov 	case MDOC_Brq:
160895c635efSGarrett D'Amore 		print_text(h, "\\(lC");
160995c635efSGarrett D'Amore 		break;
1610260e9a87SYuri Pankov 	case MDOC_Bo:
1611260e9a87SYuri Pankov 	case MDOC_Bq:
161295c635efSGarrett D'Amore 		print_text(h, "\\(lB");
161395c635efSGarrett D'Amore 		break;
1614260e9a87SYuri Pankov 	case MDOC_Oo:
1615260e9a87SYuri Pankov 	case MDOC_Op:
161695c635efSGarrett D'Amore 		print_text(h, "\\(lB");
1617cec8643bSMichal Nowak 		/*
1618cec8643bSMichal Nowak 		 * Give up on semantic markup for now.
1619cec8643bSMichal Nowak 		 * We cannot use TAG_SPAN because .Oo may contain blocks.
1620*4d131170SRobert Mustacchi 		 * We cannot use TAG_DIV because we might be in a
1621cec8643bSMichal Nowak 		 * phrasing context (like .Dl or .Pp); we cannot
1622cec8643bSMichal Nowak 		 * close out a .Pp at this point either because
1623cec8643bSMichal Nowak 		 * that would break the line.
1624cec8643bSMichal Nowak 		 */
1625cec8643bSMichal Nowak 		/* XXX print_otag(h, TAG_???, "c", "Op"); */
162695c635efSGarrett D'Amore 		break;
1627260e9a87SYuri Pankov 	case MDOC_En:
1628260e9a87SYuri Pankov 		if (NULL == n->norm->Es ||
1629260e9a87SYuri Pankov 		    NULL == n->norm->Es->child)
1630371584c2SYuri Pankov 			return 1;
1631260e9a87SYuri Pankov 		print_text(h, n->norm->Es->child->string);
163295c635efSGarrett D'Amore 		break;
1633260e9a87SYuri Pankov 	case MDOC_Do:
1634260e9a87SYuri Pankov 	case MDOC_Dq:
1635*4d131170SRobert Mustacchi 		print_text(h, "\\(lq");
1636*4d131170SRobert Mustacchi 		break;
1637260e9a87SYuri Pankov 	case MDOC_Qo:
1638260e9a87SYuri Pankov 	case MDOC_Qq:
1639*4d131170SRobert Mustacchi 		print_text(h, "\"");
164095c635efSGarrett D'Amore 		break;
1641260e9a87SYuri Pankov 	case MDOC_Po:
1642260e9a87SYuri Pankov 	case MDOC_Pq:
164395c635efSGarrett D'Amore 		print_text(h, "(");
164495c635efSGarrett D'Amore 		break;
1645260e9a87SYuri Pankov 	case MDOC_Ql:
164695c635efSGarrett D'Amore 		print_text(h, "\\(oq");
164795c635efSGarrett D'Amore 		h->flags |= HTML_NOSPACE;
1648a40ea1a7SYuri Pankov 		print_otag(h, TAG_CODE, "c", "Li");
164995c635efSGarrett D'Amore 		break;
1650260e9a87SYuri Pankov 	case MDOC_So:
1651260e9a87SYuri Pankov 	case MDOC_Sq:
165295c635efSGarrett D'Amore 		print_text(h, "\\(oq");
165395c635efSGarrett D'Amore 		break;
165495c635efSGarrett D'Amore 	default:
165595c635efSGarrett D'Amore 		abort();
165695c635efSGarrett D'Amore 	}
165795c635efSGarrett D'Amore 
165895c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
1659371584c2SYuri Pankov 	return 1;
166095c635efSGarrett D'Amore }
166195c635efSGarrett D'Amore 
166295c635efSGarrett D'Amore static void
mdoc_quote_post(MDOC_ARGS)166395c635efSGarrett D'Amore mdoc_quote_post(MDOC_ARGS)
166495c635efSGarrett D'Amore {
166595c635efSGarrett D'Amore 
1666371584c2SYuri Pankov 	if (n->type != ROFFT_BODY && n->type != ROFFT_ELEM)
166795c635efSGarrett D'Amore 		return;
166895c635efSGarrett D'Amore 
166995c635efSGarrett D'Amore 	h->flags |= HTML_NOSPACE;
167095c635efSGarrett D'Amore 
167195c635efSGarrett D'Amore 	switch (n->tok) {
1672260e9a87SYuri Pankov 	case MDOC_Ao:
1673260e9a87SYuri Pankov 	case MDOC_Aq:
1674371584c2SYuri Pankov 		print_text(h, n->child != NULL && n->child->next == NULL &&
1675260e9a87SYuri Pankov 		    n->child->tok == MDOC_Mt ?  ">" : "\\(ra");
167695c635efSGarrett D'Amore 		break;
1677260e9a87SYuri Pankov 	case MDOC_Bro:
1678260e9a87SYuri Pankov 	case MDOC_Brq:
167995c635efSGarrett D'Amore 		print_text(h, "\\(rC");
168095c635efSGarrett D'Amore 		break;
1681260e9a87SYuri Pankov 	case MDOC_Oo:
1682260e9a87SYuri Pankov 	case MDOC_Op:
1683260e9a87SYuri Pankov 	case MDOC_Bo:
1684260e9a87SYuri Pankov 	case MDOC_Bq:
168595c635efSGarrett D'Amore 		print_text(h, "\\(rB");
168695c635efSGarrett D'Amore 		break;
1687260e9a87SYuri Pankov 	case MDOC_En:
1688260e9a87SYuri Pankov 		if (n->norm->Es == NULL ||
1689260e9a87SYuri Pankov 		    n->norm->Es->child == NULL ||
1690260e9a87SYuri Pankov 		    n->norm->Es->child->next == NULL)
1691260e9a87SYuri Pankov 			h->flags &= ~HTML_NOSPACE;
1692260e9a87SYuri Pankov 		else
1693260e9a87SYuri Pankov 			print_text(h, n->norm->Es->child->next->string);
169495c635efSGarrett D'Amore 		break;
1695260e9a87SYuri Pankov 	case MDOC_Do:
1696260e9a87SYuri Pankov 	case MDOC_Dq:
169795c635efSGarrett D'Amore 		print_text(h, "\\(rq");
169895c635efSGarrett D'Amore 		break;
1699*4d131170SRobert Mustacchi 	case MDOC_Qo:
1700*4d131170SRobert Mustacchi 	case MDOC_Qq:
1701*4d131170SRobert Mustacchi 		print_text(h, "\"");
1702*4d131170SRobert Mustacchi 		break;
1703260e9a87SYuri Pankov 	case MDOC_Po:
1704260e9a87SYuri Pankov 	case MDOC_Pq:
170595c635efSGarrett D'Amore 		print_text(h, ")");
170695c635efSGarrett D'Amore 		break;
1707260e9a87SYuri Pankov 	case MDOC_Ql:
1708260e9a87SYuri Pankov 	case MDOC_So:
1709260e9a87SYuri Pankov 	case MDOC_Sq:
1710698f87a4SGarrett D'Amore 		print_text(h, "\\(cq");
171195c635efSGarrett D'Amore 		break;
171295c635efSGarrett D'Amore 	default:
171395c635efSGarrett D'Amore 		abort();
171495c635efSGarrett D'Amore 	}
171595c635efSGarrett D'Amore }
171695c635efSGarrett D'Amore 
1717260e9a87SYuri Pankov static int
mdoc_eo_pre(MDOC_ARGS)1718260e9a87SYuri Pankov mdoc_eo_pre(MDOC_ARGS)
1719260e9a87SYuri Pankov {
1720260e9a87SYuri Pankov 
1721371584c2SYuri Pankov 	if (n->type != ROFFT_BODY)
1722371584c2SYuri Pankov 		return 1;
1723260e9a87SYuri Pankov 
1724260e9a87SYuri Pankov 	if (n->end == ENDBODY_NOT &&
1725260e9a87SYuri Pankov 	    n->parent->head->child == NULL &&
1726260e9a87SYuri Pankov 	    n->child != NULL &&
1727260e9a87SYuri Pankov 	    n->child->end != ENDBODY_NOT)
1728260e9a87SYuri Pankov 		print_text(h, "\\&");
1729260e9a87SYuri Pankov 	else if (n->end != ENDBODY_NOT ? n->child != NULL :
1730260e9a87SYuri Pankov 	    n->parent->head->child != NULL && (n->child != NULL ||
1731260e9a87SYuri Pankov 	    (n->parent->tail != NULL && n->parent->tail->child != NULL)))
1732260e9a87SYuri Pankov 		h->flags |= HTML_NOSPACE;
1733371584c2SYuri Pankov 	return 1;
1734260e9a87SYuri Pankov }
173595c635efSGarrett D'Amore 
1736260e9a87SYuri Pankov static void
mdoc_eo_post(MDOC_ARGS)1737260e9a87SYuri Pankov mdoc_eo_post(MDOC_ARGS)
1738260e9a87SYuri Pankov {
1739260e9a87SYuri Pankov 	int	 body, tail;
1740260e9a87SYuri Pankov 
1741371584c2SYuri Pankov 	if (n->type != ROFFT_BODY)
1742260e9a87SYuri Pankov 		return;
1743260e9a87SYuri Pankov 
1744260e9a87SYuri Pankov 	if (n->end != ENDBODY_NOT) {
1745260e9a87SYuri Pankov 		h->flags &= ~HTML_NOSPACE;
1746260e9a87SYuri Pankov 		return;
1747260e9a87SYuri Pankov 	}
1748260e9a87SYuri Pankov 
1749260e9a87SYuri Pankov 	body = n->child != NULL || n->parent->head->child != NULL;
1750260e9a87SYuri Pankov 	tail = n->parent->tail != NULL && n->parent->tail->child != NULL;
1751260e9a87SYuri Pankov 
1752260e9a87SYuri Pankov 	if (body && tail)
1753260e9a87SYuri Pankov 		h->flags |= HTML_NOSPACE;
1754260e9a87SYuri Pankov 	else if ( ! tail)
1755260e9a87SYuri Pankov 		h->flags &= ~HTML_NOSPACE;
1756260e9a87SYuri Pankov }
1757cec8643bSMichal Nowak 
1758cec8643bSMichal Nowak static int
mdoc_abort_pre(MDOC_ARGS)1759cec8643bSMichal Nowak mdoc_abort_pre(MDOC_ARGS)
1760cec8643bSMichal Nowak {
1761cec8643bSMichal Nowak 	abort();
1762cec8643bSMichal Nowak }
1763