2021-11-15 15:35:39 +00:00
|
|
|
/* $Id: mdoc_html.c,v 1.342 2021/03/30 19:26:20 schwarze Exp $ */
|
2012-10-18 09:55:16 +00:00
|
|
|
/*
|
2021-11-15 15:35:39 +00:00
|
|
|
* Copyright (c) 2014-2021 Ingo Schwarze <schwarze@openbsd.org>
|
2014-12-02 07:34:06 +00:00
|
|
|
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
|
2012-10-18 09:55:16 +00:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
2016-01-15 23:08:59 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
|
2012-10-18 09:55:16 +00:00
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
2016-01-15 23:08:59 +00:00
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
|
2012-10-18 09:55:16 +00:00
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
2021-11-15 15:35:39 +00:00
|
|
|
*
|
|
|
|
* HTML formatter for mdoc(7) used by mandoc(1).
|
2012-10-18 09:55:16 +00:00
|
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2014-11-22 18:08:25 +00:00
|
|
|
#include "mandoc_aux.h"
|
2017-07-31 19:17:54 +00:00
|
|
|
#include "mandoc.h"
|
2016-01-15 23:08:59 +00:00
|
|
|
#include "roff.h"
|
2014-12-25 21:33:25 +00:00
|
|
|
#include "mdoc.h"
|
2012-10-18 09:55:16 +00:00
|
|
|
#include "out.h"
|
|
|
|
#include "html.h"
|
|
|
|
#include "main.h"
|
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
#define MDOC_ARGS const struct roff_meta *meta, \
|
|
|
|
struct roff_node *n, \
|
2012-10-18 09:55:16 +00:00
|
|
|
struct html *h
|
|
|
|
|
|
|
|
#ifndef MIN
|
|
|
|
#define MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b))
|
|
|
|
#endif
|
|
|
|
|
2019-03-29 13:13:30 +00:00
|
|
|
struct mdoc_html_act {
|
2012-10-18 09:55:16 +00:00
|
|
|
int (*pre)(MDOC_ARGS);
|
|
|
|
void (*post)(MDOC_ARGS);
|
|
|
|
};
|
|
|
|
|
2018-09-20 07:33:14 +00:00
|
|
|
static void print_mdoc_head(const struct roff_meta *,
|
|
|
|
struct html *);
|
2012-10-18 09:55:16 +00:00
|
|
|
static void print_mdoc_node(MDOC_ARGS);
|
|
|
|
static void print_mdoc_nodelist(MDOC_ARGS);
|
2021-11-15 15:35:39 +00:00
|
|
|
static void synopsis_pre(struct html *, struct roff_node *);
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2018-09-20 07:33:14 +00:00
|
|
|
static void mdoc_root_post(const struct roff_meta *,
|
|
|
|
struct html *);
|
|
|
|
static int mdoc_root_pre(const struct roff_meta *,
|
|
|
|
struct html *);
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
static void mdoc__x_post(MDOC_ARGS);
|
|
|
|
static int mdoc__x_pre(MDOC_ARGS);
|
2019-03-29 13:13:30 +00:00
|
|
|
static int mdoc_abort_pre(MDOC_ARGS);
|
2012-10-18 09:55:16 +00:00
|
|
|
static int mdoc_ad_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_an_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_ap_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_ar_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_bd_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_bf_pre(MDOC_ARGS);
|
|
|
|
static void mdoc_bk_post(MDOC_ARGS);
|
|
|
|
static int mdoc_bk_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_bl_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_cd_pre(MDOC_ARGS);
|
2021-11-15 15:35:39 +00:00
|
|
|
static int mdoc_code_pre(MDOC_ARGS);
|
2012-10-18 09:55:16 +00:00
|
|
|
static int mdoc_d1_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_fa_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_fd_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_fl_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_fn_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_ft_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_em_pre(MDOC_ARGS);
|
2015-03-02 16:45:41 +00:00
|
|
|
static void mdoc_eo_post(MDOC_ARGS);
|
|
|
|
static int mdoc_eo_pre(MDOC_ARGS);
|
2012-10-18 09:55:16 +00:00
|
|
|
static int mdoc_ex_pre(MDOC_ARGS);
|
|
|
|
static void mdoc_fo_post(MDOC_ARGS);
|
|
|
|
static int mdoc_fo_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_igndelim_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_in_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_it_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_lb_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_lk_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_mt_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_nd_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_nm_pre(MDOC_ARGS);
|
2014-12-02 07:34:06 +00:00
|
|
|
static int mdoc_no_pre(MDOC_ARGS);
|
2012-10-18 09:55:16 +00:00
|
|
|
static int mdoc_ns_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_pa_pre(MDOC_ARGS);
|
|
|
|
static void mdoc_pf_post(MDOC_ARGS);
|
|
|
|
static int mdoc_pp_pre(MDOC_ARGS);
|
|
|
|
static void mdoc_quote_post(MDOC_ARGS);
|
|
|
|
static int mdoc_quote_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_rs_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_sh_pre(MDOC_ARGS);
|
2014-11-22 18:08:25 +00:00
|
|
|
static int mdoc_skip_pre(MDOC_ARGS);
|
2012-10-18 09:55:16 +00:00
|
|
|
static int mdoc_sm_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_ss_pre(MDOC_ARGS);
|
2017-02-19 17:41:20 +00:00
|
|
|
static int mdoc_st_pre(MDOC_ARGS);
|
2012-10-18 09:55:16 +00:00
|
|
|
static int mdoc_sx_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_sy_pre(MDOC_ARGS);
|
2021-11-15 15:35:39 +00:00
|
|
|
static int mdoc_tg_pre(MDOC_ARGS);
|
2012-10-18 09:55:16 +00:00
|
|
|
static int mdoc_va_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_vt_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_xr_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_xx_pre(MDOC_ARGS);
|
|
|
|
|
2019-03-29 13:13:30 +00:00
|
|
|
static const struct mdoc_html_act mdoc_html_acts[MDOC_MAX - MDOC_Dd] = {
|
2012-10-18 09:55:16 +00:00
|
|
|
{NULL, NULL}, /* Dd */
|
|
|
|
{NULL, NULL}, /* Dt */
|
|
|
|
{NULL, NULL}, /* Os */
|
|
|
|
{mdoc_sh_pre, NULL }, /* Sh */
|
2014-11-22 18:08:25 +00:00
|
|
|
{mdoc_ss_pre, NULL }, /* Ss */
|
|
|
|
{mdoc_pp_pre, NULL}, /* Pp */
|
2012-10-18 09:55:16 +00:00
|
|
|
{mdoc_d1_pre, NULL}, /* D1 */
|
|
|
|
{mdoc_d1_pre, NULL}, /* Dl */
|
|
|
|
{mdoc_bd_pre, NULL}, /* Bd */
|
|
|
|
{NULL, NULL}, /* Ed */
|
|
|
|
{mdoc_bl_pre, NULL}, /* Bl */
|
|
|
|
{NULL, NULL}, /* El */
|
|
|
|
{mdoc_it_pre, NULL}, /* It */
|
2014-11-22 18:08:25 +00:00
|
|
|
{mdoc_ad_pre, NULL}, /* Ad */
|
2012-10-18 09:55:16 +00:00
|
|
|
{mdoc_an_pre, NULL}, /* An */
|
2017-06-08 19:29:07 +00:00
|
|
|
{mdoc_ap_pre, NULL}, /* Ap */
|
2012-10-18 09:55:16 +00:00
|
|
|
{mdoc_ar_pre, NULL}, /* Ar */
|
|
|
|
{mdoc_cd_pre, NULL}, /* Cd */
|
2021-11-15 15:35:39 +00:00
|
|
|
{mdoc_code_pre, NULL}, /* Cm */
|
|
|
|
{mdoc_code_pre, NULL}, /* Dv */
|
|
|
|
{mdoc_code_pre, NULL}, /* Er */
|
|
|
|
{mdoc_code_pre, NULL}, /* Ev */
|
2012-10-18 09:55:16 +00:00
|
|
|
{mdoc_ex_pre, NULL}, /* Ex */
|
2014-11-22 18:08:25 +00:00
|
|
|
{mdoc_fa_pre, NULL}, /* Fa */
|
|
|
|
{mdoc_fd_pre, NULL}, /* Fd */
|
2012-10-18 09:55:16 +00:00
|
|
|
{mdoc_fl_pre, NULL}, /* Fl */
|
2014-11-22 18:08:25 +00:00
|
|
|
{mdoc_fn_pre, NULL}, /* Fn */
|
|
|
|
{mdoc_ft_pre, NULL}, /* Ft */
|
2021-11-15 15:35:39 +00:00
|
|
|
{mdoc_code_pre, NULL}, /* Ic */
|
2014-11-22 18:08:25 +00:00
|
|
|
{mdoc_in_pre, NULL}, /* In */
|
2021-11-15 15:35:39 +00:00
|
|
|
{mdoc_code_pre, NULL}, /* Li */
|
2014-11-22 18:08:25 +00:00
|
|
|
{mdoc_nd_pre, NULL}, /* Nd */
|
|
|
|
{mdoc_nm_pre, NULL}, /* Nm */
|
2012-10-18 09:55:16 +00:00
|
|
|
{mdoc_quote_pre, mdoc_quote_post}, /* Op */
|
2019-03-29 13:13:30 +00:00
|
|
|
{mdoc_abort_pre, NULL}, /* Ot */
|
2012-10-18 09:55:16 +00:00
|
|
|
{mdoc_pa_pre, NULL}, /* Pa */
|
2017-01-21 13:01:39 +00:00
|
|
|
{mdoc_ex_pre, NULL}, /* Rv */
|
2017-02-19 17:41:20 +00:00
|
|
|
{mdoc_st_pre, NULL}, /* St */
|
2012-10-18 09:55:16 +00:00
|
|
|
{mdoc_va_pre, NULL}, /* Va */
|
2014-11-22 18:08:25 +00:00
|
|
|
{mdoc_vt_pre, NULL}, /* Vt */
|
2012-10-18 09:55:16 +00:00
|
|
|
{mdoc_xr_pre, NULL}, /* Xr */
|
|
|
|
{mdoc__x_pre, mdoc__x_post}, /* %A */
|
|
|
|
{mdoc__x_pre, mdoc__x_post}, /* %B */
|
|
|
|
{mdoc__x_pre, mdoc__x_post}, /* %D */
|
|
|
|
{mdoc__x_pre, mdoc__x_post}, /* %I */
|
|
|
|
{mdoc__x_pre, mdoc__x_post}, /* %J */
|
|
|
|
{mdoc__x_pre, mdoc__x_post}, /* %N */
|
|
|
|
{mdoc__x_pre, mdoc__x_post}, /* %O */
|
|
|
|
{mdoc__x_pre, mdoc__x_post}, /* %P */
|
|
|
|
{mdoc__x_pre, mdoc__x_post}, /* %R */
|
|
|
|
{mdoc__x_pre, mdoc__x_post}, /* %T */
|
|
|
|
{mdoc__x_pre, mdoc__x_post}, /* %V */
|
|
|
|
{NULL, NULL}, /* Ac */
|
|
|
|
{mdoc_quote_pre, mdoc_quote_post}, /* Ao */
|
|
|
|
{mdoc_quote_pre, mdoc_quote_post}, /* Aq */
|
2017-02-19 17:41:20 +00:00
|
|
|
{mdoc_xx_pre, NULL}, /* At */
|
2012-10-18 09:55:16 +00:00
|
|
|
{NULL, NULL}, /* Bc */
|
2014-11-22 18:08:25 +00:00
|
|
|
{mdoc_bf_pre, NULL}, /* Bf */
|
2012-10-18 09:55:16 +00:00
|
|
|
{mdoc_quote_pre, mdoc_quote_post}, /* Bo */
|
|
|
|
{mdoc_quote_pre, mdoc_quote_post}, /* Bq */
|
|
|
|
{mdoc_xx_pre, NULL}, /* Bsx */
|
2017-01-21 13:01:39 +00:00
|
|
|
{mdoc_xx_pre, NULL}, /* Bx */
|
2014-12-02 07:34:06 +00:00
|
|
|
{mdoc_skip_pre, NULL}, /* Db */
|
2012-10-18 09:55:16 +00:00
|
|
|
{NULL, NULL}, /* Dc */
|
|
|
|
{mdoc_quote_pre, mdoc_quote_post}, /* Do */
|
|
|
|
{mdoc_quote_pre, mdoc_quote_post}, /* Dq */
|
|
|
|
{NULL, NULL}, /* Ec */ /* FIXME: no space */
|
|
|
|
{NULL, NULL}, /* Ef */
|
2014-11-22 18:08:25 +00:00
|
|
|
{mdoc_em_pre, NULL}, /* Em */
|
2015-03-02 16:45:41 +00:00
|
|
|
{mdoc_eo_pre, mdoc_eo_post}, /* Eo */
|
2012-10-18 09:55:16 +00:00
|
|
|
{mdoc_xx_pre, NULL}, /* Fx */
|
2021-11-15 15:35:39 +00:00
|
|
|
{mdoc_no_pre, NULL}, /* Ms */
|
2014-12-02 07:34:06 +00:00
|
|
|
{mdoc_no_pre, NULL}, /* No */
|
2012-10-18 09:55:16 +00:00
|
|
|
{mdoc_ns_pre, NULL}, /* Ns */
|
|
|
|
{mdoc_xx_pre, NULL}, /* Nx */
|
|
|
|
{mdoc_xx_pre, NULL}, /* Ox */
|
|
|
|
{NULL, NULL}, /* Pc */
|
|
|
|
{mdoc_igndelim_pre, mdoc_pf_post}, /* Pf */
|
|
|
|
{mdoc_quote_pre, mdoc_quote_post}, /* Po */
|
|
|
|
{mdoc_quote_pre, mdoc_quote_post}, /* Pq */
|
|
|
|
{NULL, NULL}, /* Qc */
|
|
|
|
{mdoc_quote_pre, mdoc_quote_post}, /* Ql */
|
|
|
|
{mdoc_quote_pre, mdoc_quote_post}, /* Qo */
|
|
|
|
{mdoc_quote_pre, mdoc_quote_post}, /* Qq */
|
|
|
|
{NULL, NULL}, /* Re */
|
|
|
|
{mdoc_rs_pre, NULL}, /* Rs */
|
|
|
|
{NULL, NULL}, /* Sc */
|
|
|
|
{mdoc_quote_pre, mdoc_quote_post}, /* So */
|
|
|
|
{mdoc_quote_pre, mdoc_quote_post}, /* Sq */
|
2014-11-22 18:08:25 +00:00
|
|
|
{mdoc_sm_pre, NULL}, /* Sm */
|
2012-10-18 09:55:16 +00:00
|
|
|
{mdoc_sx_pre, NULL}, /* Sx */
|
|
|
|
{mdoc_sy_pre, NULL}, /* Sy */
|
|
|
|
{NULL, NULL}, /* Tn */
|
|
|
|
{mdoc_xx_pre, NULL}, /* Ux */
|
|
|
|
{NULL, NULL}, /* Xc */
|
|
|
|
{NULL, NULL}, /* Xo */
|
2014-11-22 18:08:25 +00:00
|
|
|
{mdoc_fo_pre, mdoc_fo_post}, /* Fo */
|
|
|
|
{NULL, NULL}, /* Fc */
|
2012-10-18 09:55:16 +00:00
|
|
|
{mdoc_quote_pre, mdoc_quote_post}, /* Oo */
|
|
|
|
{NULL, NULL}, /* Oc */
|
|
|
|
{mdoc_bk_pre, mdoc_bk_post}, /* Bk */
|
|
|
|
{NULL, NULL}, /* Ek */
|
2017-01-21 13:01:39 +00:00
|
|
|
{NULL, NULL}, /* Bt */
|
2012-10-18 09:55:16 +00:00
|
|
|
{NULL, NULL}, /* Hf */
|
2014-11-22 18:08:25 +00:00
|
|
|
{mdoc_em_pre, NULL}, /* Fr */
|
2017-01-21 13:01:39 +00:00
|
|
|
{NULL, NULL}, /* Ud */
|
2012-10-18 09:55:16 +00:00
|
|
|
{mdoc_lb_pre, NULL}, /* Lb */
|
2019-03-29 13:13:30 +00:00
|
|
|
{mdoc_abort_pre, NULL}, /* Lp */
|
2014-11-22 18:08:25 +00:00
|
|
|
{mdoc_lk_pre, NULL}, /* Lk */
|
|
|
|
{mdoc_mt_pre, NULL}, /* Mt */
|
|
|
|
{mdoc_quote_pre, mdoc_quote_post}, /* Brq */
|
|
|
|
{mdoc_quote_pre, mdoc_quote_post}, /* Bro */
|
|
|
|
{NULL, NULL}, /* Brc */
|
|
|
|
{mdoc__x_pre, mdoc__x_post}, /* %C */
|
|
|
|
{mdoc_skip_pre, NULL}, /* Es */
|
|
|
|
{mdoc_quote_pre, mdoc_quote_post}, /* En */
|
|
|
|
{mdoc_xx_pre, NULL}, /* Dx */
|
|
|
|
{mdoc__x_pre, mdoc__x_post}, /* %Q */
|
|
|
|
{mdoc__x_pre, mdoc__x_post}, /* %U */
|
|
|
|
{NULL, NULL}, /* Ta */
|
2021-11-15 15:35:39 +00:00
|
|
|
{mdoc_tg_pre, NULL}, /* Tg */
|
2012-10-18 09:55:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See the same function in mdoc_term.c for documentation.
|
|
|
|
*/
|
|
|
|
static void
|
2021-11-15 15:35:39 +00:00
|
|
|
synopsis_pre(struct html *h, struct roff_node *n)
|
2012-10-18 09:55:16 +00:00
|
|
|
{
|
2021-11-15 15:35:39 +00:00
|
|
|
struct roff_node *np;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2021-11-15 15:35:39 +00:00
|
|
|
if ((n->flags & NODE_SYNPRETTY) == 0 ||
|
|
|
|
(np = roff_node_prev(n)) == NULL)
|
2012-10-18 09:55:16 +00:00
|
|
|
return;
|
|
|
|
|
2021-11-15 15:35:39 +00:00
|
|
|
if (np->tok == n->tok &&
|
2014-11-22 18:08:25 +00:00
|
|
|
MDOC_Fo != n->tok &&
|
|
|
|
MDOC_Ft != n->tok &&
|
|
|
|
MDOC_Fn != n->tok) {
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_BR, "");
|
2012-10-18 09:55:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-11-15 15:35:39 +00:00
|
|
|
switch (np->tok) {
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_Fd:
|
|
|
|
case MDOC_Fn:
|
|
|
|
case MDOC_Fo:
|
|
|
|
case MDOC_In:
|
|
|
|
case MDOC_Vt:
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_Ft:
|
2019-03-29 13:13:30 +00:00
|
|
|
if (n->tok != MDOC_Fn && n->tok != MDOC_Fo)
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
default:
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_BR, "");
|
2019-03-29 13:13:30 +00:00
|
|
|
return;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
2019-03-29 13:13:30 +00:00
|
|
|
html_close_paragraph(h);
|
|
|
|
print_otag(h, TAG_P, "c", "Pp");
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
void
|
2019-03-29 13:13:30 +00:00
|
|
|
html_mdoc(void *arg, const struct roff_meta *mdoc)
|
2012-10-18 09:55:16 +00:00
|
|
|
{
|
2018-09-20 07:33:14 +00:00
|
|
|
struct html *h;
|
|
|
|
struct roff_node *n;
|
|
|
|
struct tag *t;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
h = (struct html *)arg;
|
2018-09-20 07:33:14 +00:00
|
|
|
n = mdoc->first->child;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
if ((h->oflags & HTML_FRAGMENT) == 0) {
|
2012-10-18 09:55:16 +00:00
|
|
|
print_gen_decls(h);
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_HTML, "");
|
2019-03-29 13:13:30 +00:00
|
|
|
if (n != NULL && n->type == ROFFT_COMMENT)
|
2018-09-20 07:33:14 +00:00
|
|
|
print_gen_comment(h, n);
|
2017-01-21 13:01:39 +00:00
|
|
|
t = print_otag(h, TAG_HEAD, "");
|
2019-03-29 13:13:30 +00:00
|
|
|
print_mdoc_head(mdoc, h);
|
2017-01-21 13:01:39 +00:00
|
|
|
print_tagq(h, t);
|
|
|
|
print_otag(h, TAG_BODY, "");
|
|
|
|
}
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2019-03-29 13:13:30 +00:00
|
|
|
mdoc_root_pre(mdoc, h);
|
2017-01-21 13:01:39 +00:00
|
|
|
t = print_otag(h, TAG_DIV, "c", "manual-text");
|
2019-03-29 13:13:30 +00:00
|
|
|
print_mdoc_nodelist(mdoc, n, h);
|
2012-10-18 09:55:16 +00:00
|
|
|
print_tagq(h, t);
|
2019-03-29 13:13:30 +00:00
|
|
|
mdoc_root_post(mdoc, h);
|
2017-01-21 13:01:39 +00:00
|
|
|
print_tagq(h, NULL);
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-09-20 07:33:14 +00:00
|
|
|
print_mdoc_head(const struct roff_meta *meta, struct html *h)
|
2012-10-18 09:55:16 +00:00
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
char *cp;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
print_gen_head(h);
|
2017-01-21 13:01:39 +00:00
|
|
|
|
|
|
|
if (meta->arch != NULL && meta->msec != NULL)
|
|
|
|
mandoc_asprintf(&cp, "%s(%s) (%s)", meta->title,
|
|
|
|
meta->msec, meta->arch);
|
|
|
|
else if (meta->msec != NULL)
|
|
|
|
mandoc_asprintf(&cp, "%s(%s)", meta->title, meta->msec);
|
|
|
|
else if (meta->arch != NULL)
|
|
|
|
mandoc_asprintf(&cp, "%s (%s)", meta->title, meta->arch);
|
|
|
|
else
|
|
|
|
cp = mandoc_strdup(meta->title);
|
|
|
|
|
|
|
|
print_otag(h, TAG_TITLE, "");
|
|
|
|
print_text(h, cp);
|
|
|
|
free(cp);
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_mdoc_nodelist(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
|
2015-03-02 16:45:41 +00:00
|
|
|
while (n != NULL) {
|
|
|
|
print_mdoc_node(meta, n, h);
|
|
|
|
n = n->next;
|
|
|
|
}
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_mdoc_node(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
struct tag *t;
|
2019-03-29 13:13:30 +00:00
|
|
|
int child;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2018-09-20 07:33:14 +00:00
|
|
|
if (n->type == ROFFT_COMMENT || n->flags & NODE_NOPRT)
|
2017-01-21 13:01:39 +00:00
|
|
|
return;
|
|
|
|
|
2021-11-15 15:35:39 +00:00
|
|
|
if ((n->flags & NODE_NOFILL) == 0)
|
|
|
|
html_fillmode(h, ROFF_fi);
|
|
|
|
else if (html_fillmode(h, ROFF_nf) == ROFF_nf &&
|
|
|
|
n->tok != ROFF_fi && n->flags & NODE_LINE)
|
|
|
|
print_endline(h);
|
2019-03-29 13:13:30 +00:00
|
|
|
|
2012-10-18 09:55:16 +00:00
|
|
|
child = 1;
|
2017-01-21 13:01:39 +00:00
|
|
|
n->flags &= ~NODE_ENDED;
|
2012-10-18 09:55:16 +00:00
|
|
|
switch (n->type) {
|
2016-01-15 23:08:59 +00:00
|
|
|
case ROFFT_TEXT:
|
2021-11-15 15:35:39 +00:00
|
|
|
if (n->flags & NODE_LINE) {
|
|
|
|
switch (*n->string) {
|
|
|
|
case '\0':
|
|
|
|
h->col = 1;
|
|
|
|
print_endline(h);
|
|
|
|
return;
|
|
|
|
case ' ':
|
|
|
|
if ((h->flags & HTML_NONEWLINE) == 0 &&
|
|
|
|
(n->flags & NODE_NOFILL) == 0)
|
|
|
|
print_otag(h, TAG_BR, "");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-03-29 13:13:30 +00:00
|
|
|
t = h->tag;
|
|
|
|
t->refcnt++;
|
2021-11-15 15:35:39 +00:00
|
|
|
if (n->flags & NODE_DELIMC)
|
2012-10-18 09:55:16 +00:00
|
|
|
h->flags |= HTML_NOSPACE;
|
2021-11-15 15:35:39 +00:00
|
|
|
if (n->flags & NODE_HREF)
|
|
|
|
print_tagged_text(h, n->string, n);
|
|
|
|
else
|
|
|
|
print_text(h, n->string);
|
|
|
|
if (n->flags & NODE_DELIMO)
|
2012-10-18 09:55:16 +00:00
|
|
|
h->flags |= HTML_NOSPACE;
|
2019-03-29 13:13:30 +00:00
|
|
|
break;
|
2016-01-15 23:08:59 +00:00
|
|
|
case ROFFT_EQN:
|
2019-03-29 13:13:30 +00:00
|
|
|
t = h->tag;
|
|
|
|
t->refcnt++;
|
2012-10-18 09:55:16 +00:00
|
|
|
print_eqn(h, n->eqn);
|
|
|
|
break;
|
2016-01-15 23:08:59 +00:00
|
|
|
case ROFFT_TBL:
|
2012-10-18 09:55:16 +00:00
|
|
|
/*
|
|
|
|
* This will take care of initialising all of the table
|
|
|
|
* state data for the first table, then tearing it down
|
|
|
|
* for the last one.
|
|
|
|
*/
|
|
|
|
print_tbl(h, n->span);
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
/*
|
|
|
|
* Close out the current table, if it's open, and unset
|
|
|
|
* the "meta" table state. This will be reopened on the
|
|
|
|
* next table element.
|
|
|
|
*/
|
2019-03-29 13:13:30 +00:00
|
|
|
if (h->tblt != NULL)
|
2012-10-18 09:55:16 +00:00
|
|
|
print_tblclose(h);
|
2014-12-02 07:34:06 +00:00
|
|
|
assert(h->tblt == NULL);
|
2019-03-29 13:13:30 +00:00
|
|
|
t = h->tag;
|
|
|
|
t->refcnt++;
|
2017-06-08 19:29:07 +00:00
|
|
|
if (n->tok < ROFF_MAX) {
|
|
|
|
roff_html_pre(h, n);
|
2019-03-29 13:13:30 +00:00
|
|
|
t->refcnt--;
|
|
|
|
print_stagq(h, t);
|
|
|
|
return;
|
2017-06-08 19:29:07 +00:00
|
|
|
}
|
|
|
|
assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX);
|
2019-03-29 13:13:30 +00:00
|
|
|
if (mdoc_html_acts[n->tok - MDOC_Dd].pre != NULL &&
|
2017-06-08 19:29:07 +00:00
|
|
|
(n->end == ENDBODY_NOT || n->child != NULL))
|
2019-03-29 13:13:30 +00:00
|
|
|
child = (*mdoc_html_acts[n->tok - MDOC_Dd].pre)(meta,
|
|
|
|
n, h);
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
if (h->flags & HTML_KEEP && n->flags & NODE_LINE) {
|
2015-03-02 16:45:41 +00:00
|
|
|
h->flags &= ~HTML_KEEP;
|
|
|
|
h->flags |= HTML_PREKEEP;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
2019-03-29 13:13:30 +00:00
|
|
|
if (child && n->child != NULL)
|
2014-01-31 19:59:03 +00:00
|
|
|
print_mdoc_nodelist(meta, n->child, h);
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2019-03-29 13:13:30 +00:00
|
|
|
t->refcnt--;
|
2012-10-18 09:55:16 +00:00
|
|
|
print_stagq(h, t);
|
|
|
|
|
|
|
|
switch (n->type) {
|
2019-03-29 13:13:30 +00:00
|
|
|
case ROFFT_TEXT:
|
2016-01-15 23:08:59 +00:00
|
|
|
case ROFFT_EQN:
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
|
|
|
default:
|
2019-03-29 13:13:30 +00:00
|
|
|
if (mdoc_html_acts[n->tok - MDOC_Dd].post == NULL ||
|
2017-06-08 19:29:07 +00:00
|
|
|
n->flags & NODE_ENDED)
|
2014-12-02 07:34:06 +00:00
|
|
|
break;
|
2019-03-29 13:13:30 +00:00
|
|
|
(*mdoc_html_acts[n->tok - MDOC_Dd].post)(meta, n, h);
|
2014-12-02 07:34:06 +00:00
|
|
|
if (n->end != ENDBODY_NOT)
|
2017-01-21 13:01:39 +00:00
|
|
|
n->body->flags |= NODE_ENDED;
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-09-20 07:33:14 +00:00
|
|
|
mdoc_root_post(const struct roff_meta *meta, struct html *h)
|
2012-10-18 09:55:16 +00:00
|
|
|
{
|
|
|
|
struct tag *t, *tt;
|
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
t = print_otag(h, TAG_TABLE, "c", "foot");
|
|
|
|
tt = print_otag(h, TAG_TR, "");
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_TD, "c", "foot-date");
|
2014-01-31 19:59:03 +00:00
|
|
|
print_text(h, meta->date);
|
2012-10-18 09:55:16 +00:00
|
|
|
print_stagq(h, tt);
|
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_TD, "c", "foot-os");
|
2014-01-31 19:59:03 +00:00
|
|
|
print_text(h, meta->os);
|
2012-10-18 09:55:16 +00:00
|
|
|
print_tagq(h, t);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2018-09-20 07:33:14 +00:00
|
|
|
mdoc_root_pre(const struct roff_meta *meta, struct html *h)
|
2012-10-18 09:55:16 +00:00
|
|
|
{
|
|
|
|
struct tag *t, *tt;
|
2014-11-22 18:08:25 +00:00
|
|
|
char *volume, *title;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2014-11-22 18:08:25 +00:00
|
|
|
if (NULL == meta->arch)
|
|
|
|
volume = mandoc_strdup(meta->vol);
|
|
|
|
else
|
|
|
|
mandoc_asprintf(&volume, "%s (%s)",
|
|
|
|
meta->vol, meta->arch);
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2014-11-22 18:08:25 +00:00
|
|
|
if (NULL == meta->msec)
|
|
|
|
title = mandoc_strdup(meta->title);
|
|
|
|
else
|
|
|
|
mandoc_asprintf(&title, "%s(%s)",
|
|
|
|
meta->title, meta->msec);
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
t = print_otag(h, TAG_TABLE, "c", "head");
|
|
|
|
tt = print_otag(h, TAG_TR, "");
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_TD, "c", "head-ltitle");
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, title);
|
|
|
|
print_stagq(h, tt);
|
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_TD, "c", "head-vol");
|
2014-11-22 18:08:25 +00:00
|
|
|
print_text(h, volume);
|
2012-10-18 09:55:16 +00:00
|
|
|
print_stagq(h, tt);
|
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_TD, "c", "head-rtitle");
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, title);
|
|
|
|
print_tagq(h, t);
|
2014-11-22 18:08:25 +00:00
|
|
|
|
|
|
|
free(title);
|
|
|
|
free(volume);
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
2021-11-15 15:35:39 +00:00
|
|
|
static int
|
|
|
|
mdoc_code_pre(MDOC_ARGS)
|
2017-01-21 13:01:39 +00:00
|
|
|
{
|
2021-11-15 15:35:39 +00:00
|
|
|
print_otag_id(h, TAG_CODE, roff_name[n->tok], n);
|
|
|
|
return 1;
|
2017-01-21 13:01:39 +00:00
|
|
|
}
|
|
|
|
|
2012-10-18 09:55:16 +00:00
|
|
|
static int
|
|
|
|
mdoc_sh_pre(MDOC_ARGS)
|
|
|
|
{
|
2019-03-29 13:13:30 +00:00
|
|
|
struct roff_node *sn, *subn;
|
|
|
|
struct tag *t, *tsec, *tsub;
|
|
|
|
char *id;
|
|
|
|
int sc;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2014-12-02 07:34:06 +00:00
|
|
|
switch (n->type) {
|
2019-03-29 13:13:30 +00:00
|
|
|
case ROFFT_BLOCK:
|
|
|
|
html_close_paragraph(h);
|
|
|
|
if ((h->oflags & HTML_TOC) == 0 ||
|
|
|
|
h->flags & HTML_TOCDONE ||
|
|
|
|
n->sec <= SEC_SYNOPSIS) {
|
|
|
|
print_otag(h, TAG_SECTION, "c", "Sh");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
h->flags |= HTML_TOCDONE;
|
|
|
|
sc = 0;
|
|
|
|
for (sn = n->next; sn != NULL; sn = sn->next)
|
|
|
|
if (sn->sec == SEC_CUSTOM)
|
|
|
|
if (++sc == 2)
|
|
|
|
break;
|
|
|
|
if (sc < 2)
|
|
|
|
break;
|
|
|
|
t = print_otag(h, TAG_H1, "c", "Sh");
|
|
|
|
print_text(h, "TABLE OF CONTENTS");
|
|
|
|
print_tagq(h, t);
|
|
|
|
t = print_otag(h, TAG_UL, "c", "Bl-compact");
|
|
|
|
for (sn = n; sn != NULL; sn = sn->next) {
|
|
|
|
tsec = print_otag(h, TAG_LI, "");
|
|
|
|
id = html_make_id(sn->head, 0);
|
|
|
|
tsub = print_otag(h, TAG_A, "hR", id);
|
|
|
|
free(id);
|
|
|
|
print_mdoc_nodelist(meta, sn->head->child, h);
|
|
|
|
print_tagq(h, tsub);
|
|
|
|
tsub = NULL;
|
|
|
|
for (subn = sn->body->child; subn != NULL;
|
|
|
|
subn = subn->next) {
|
|
|
|
if (subn->tok != MDOC_Ss)
|
|
|
|
continue;
|
|
|
|
id = html_make_id(subn->head, 0);
|
|
|
|
if (id == NULL)
|
|
|
|
continue;
|
|
|
|
if (tsub == NULL)
|
|
|
|
print_otag(h, TAG_UL,
|
|
|
|
"c", "Bl-compact");
|
|
|
|
tsub = print_otag(h, TAG_LI, "");
|
|
|
|
print_otag(h, TAG_A, "hR", id);
|
|
|
|
free(id);
|
|
|
|
print_mdoc_nodelist(meta,
|
|
|
|
subn->head->child, h);
|
|
|
|
print_tagq(h, tsub);
|
|
|
|
}
|
|
|
|
print_tagq(h, tsec);
|
|
|
|
}
|
|
|
|
print_tagq(h, t);
|
|
|
|
print_otag(h, TAG_SECTION, "c", "Sh");
|
|
|
|
break;
|
2017-02-19 17:41:20 +00:00
|
|
|
case ROFFT_HEAD:
|
2021-11-15 15:35:39 +00:00
|
|
|
print_otag_id(h, TAG_H1, "Sh", n);
|
2017-02-19 17:41:20 +00:00
|
|
|
break;
|
2016-01-15 23:08:59 +00:00
|
|
|
case ROFFT_BODY:
|
2014-12-02 07:34:06 +00:00
|
|
|
if (n->sec == SEC_AUTHORS)
|
|
|
|
h->flags &= ~(HTML_SPLIT|HTML_NOSPLIT);
|
2017-02-19 17:41:20 +00:00
|
|
|
break;
|
2014-12-02 07:34:06 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_ss_pre(MDOC_ARGS)
|
|
|
|
{
|
2019-03-29 13:13:30 +00:00
|
|
|
switch (n->type) {
|
|
|
|
case ROFFT_BLOCK:
|
|
|
|
html_close_paragraph(h);
|
|
|
|
print_otag(h, TAG_SECTION, "c", "Ss");
|
2021-11-15 15:35:39 +00:00
|
|
|
break;
|
2019-03-29 13:13:30 +00:00
|
|
|
case ROFFT_HEAD:
|
2021-11-15 15:35:39 +00:00
|
|
|
print_otag_id(h, TAG_H2, "Ss", n);
|
2019-03-29 13:13:30 +00:00
|
|
|
break;
|
|
|
|
case ROFFT_BODY:
|
2021-11-15 15:35:39 +00:00
|
|
|
break;
|
2019-03-29 13:13:30 +00:00
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_fl_pre(MDOC_ARGS)
|
|
|
|
{
|
2021-11-15 15:35:39 +00:00
|
|
|
struct roff_node *nn;
|
2017-06-08 19:29:07 +00:00
|
|
|
|
2021-11-15 15:35:39 +00:00
|
|
|
print_otag_id(h, TAG_CODE, "Fl", n);
|
2017-06-08 19:29:07 +00:00
|
|
|
print_text(h, "\\-");
|
2021-11-15 15:35:39 +00:00
|
|
|
if (n->child != NULL ||
|
|
|
|
((nn = roff_node_next(n)) != NULL &&
|
|
|
|
nn->type != ROFFT_TEXT &&
|
|
|
|
(nn->flags & NODE_LINE) == 0))
|
2012-10-18 09:55:16 +00:00
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
static int
|
|
|
|
mdoc_nd_pre(MDOC_ARGS)
|
|
|
|
{
|
2019-03-29 13:13:30 +00:00
|
|
|
switch (n->type) {
|
|
|
|
case ROFFT_BLOCK:
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2019-03-29 13:13:30 +00:00
|
|
|
case ROFFT_HEAD:
|
|
|
|
return 0;
|
|
|
|
case ROFFT_BODY:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, "\\(em");
|
2021-11-15 15:35:39 +00:00
|
|
|
print_otag(h, TAG_SPAN, "c", "Nd");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_nm_pre(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
switch (n->type) {
|
2019-03-29 13:13:30 +00:00
|
|
|
case ROFFT_BLOCK:
|
|
|
|
break;
|
2016-01-15 23:08:59 +00:00
|
|
|
case ROFFT_HEAD:
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_TD, "");
|
2016-01-15 23:08:59 +00:00
|
|
|
/* FALLTHROUGH */
|
|
|
|
case ROFFT_ELEM:
|
2019-03-29 13:13:30 +00:00
|
|
|
print_otag(h, TAG_CODE, "c", "Nm");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
|
|
|
case ROFFT_BODY:
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_TD, "");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
default:
|
2019-03-29 13:13:30 +00:00
|
|
|
abort();
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
2019-03-29 13:13:30 +00:00
|
|
|
html_close_paragraph(h);
|
2012-10-18 09:55:16 +00:00
|
|
|
synopsis_pre(h, n);
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_TABLE, "c", "Nm");
|
|
|
|
print_otag(h, TAG_TR, "");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_xr_pre(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
if (NULL == n->child)
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2019-03-29 13:13:30 +00:00
|
|
|
if (h->base_man1)
|
|
|
|
print_otag(h, TAG_A, "chM", "Xr",
|
2017-01-21 13:01:39 +00:00
|
|
|
n->child->string, n->child->next == NULL ?
|
|
|
|
NULL : n->child->next->string);
|
|
|
|
else
|
2019-03-29 13:13:30 +00:00
|
|
|
print_otag(h, TAG_A, "c", "Xr");
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
n = n->child;
|
|
|
|
print_text(h, n->string);
|
|
|
|
|
|
|
|
if (NULL == (n = n->next))
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
print_text(h, "(");
|
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
print_text(h, n->string);
|
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
print_text(h, ")");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
2021-11-15 15:35:39 +00:00
|
|
|
static int
|
|
|
|
mdoc_tg_pre(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
char *id;
|
|
|
|
|
|
|
|
if ((id = html_make_id(n, 1)) != NULL) {
|
|
|
|
print_tagq(h, print_otag(h, TAG_MARK, "i", id));
|
|
|
|
free(id);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-18 09:55:16 +00:00
|
|
|
static int
|
|
|
|
mdoc_ns_pre(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
if ( ! (NODE_LINE & n->flags))
|
2012-10-18 09:55:16 +00:00
|
|
|
h->flags |= HTML_NOSPACE;
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_ar_pre(MDOC_ARGS)
|
|
|
|
{
|
2019-03-29 13:13:30 +00:00
|
|
|
print_otag(h, TAG_VAR, "c", "Ar");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_xx_pre(MDOC_ARGS)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_SPAN, "c", "Ux");
|
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_it_pre(MDOC_ARGS)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
const struct roff_node *bl;
|
|
|
|
enum mdoc_list type;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
bl = n->parent;
|
2017-06-08 19:29:07 +00:00
|
|
|
while (bl->tok != MDOC_Bl)
|
2012-10-18 09:55:16 +00:00
|
|
|
bl = bl->parent;
|
|
|
|
type = bl->norm->Bl.type;
|
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
switch (type) {
|
|
|
|
case LIST_bullet:
|
|
|
|
case LIST_dash:
|
|
|
|
case LIST_hyphen:
|
|
|
|
case LIST_item:
|
|
|
|
case LIST_enum:
|
|
|
|
switch (n->type) {
|
|
|
|
case ROFFT_HEAD:
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2017-01-21 13:01:39 +00:00
|
|
|
case ROFFT_BODY:
|
2021-11-15 15:35:39 +00:00
|
|
|
print_otag_id(h, TAG_LI, NULL, n);
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2017-01-21 13:01:39 +00:00
|
|
|
break;
|
|
|
|
case LIST_diag:
|
|
|
|
case LIST_hang:
|
|
|
|
case LIST_inset:
|
|
|
|
case LIST_ohang:
|
|
|
|
switch (n->type) {
|
|
|
|
case ROFFT_HEAD:
|
2021-11-15 15:35:39 +00:00
|
|
|
print_otag_id(h, TAG_DT, NULL, n);
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2017-01-21 13:01:39 +00:00
|
|
|
case ROFFT_BODY:
|
2018-09-20 07:33:14 +00:00
|
|
|
print_otag(h, TAG_DD, "");
|
2017-02-19 17:41:20 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case LIST_tag:
|
|
|
|
switch (n->type) {
|
|
|
|
case ROFFT_HEAD:
|
2021-11-15 15:35:39 +00:00
|
|
|
print_otag_id(h, TAG_DT, NULL, n);
|
2017-02-19 17:41:20 +00:00
|
|
|
break;
|
|
|
|
case ROFFT_BODY:
|
|
|
|
if (n->child == NULL) {
|
2018-09-20 07:33:14 +00:00
|
|
|
print_otag(h, TAG_DD, "s", "width", "auto");
|
2017-02-19 17:41:20 +00:00
|
|
|
print_text(h, "\\ ");
|
|
|
|
} else
|
2018-09-20 07:33:14 +00:00
|
|
|
print_otag(h, TAG_DD, "");
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2017-01-21 13:01:39 +00:00
|
|
|
break;
|
|
|
|
case LIST_column:
|
|
|
|
switch (n->type) {
|
|
|
|
case ROFFT_HEAD:
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2017-01-21 13:01:39 +00:00
|
|
|
case ROFFT_BODY:
|
2018-09-20 07:33:14 +00:00
|
|
|
print_otag(h, TAG_TD, "");
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2017-01-21 13:01:39 +00:00
|
|
|
default:
|
2021-11-15 15:35:39 +00:00
|
|
|
print_otag_id(h, TAG_TR, NULL, n);
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
2017-01-21 13:01:39 +00:00
|
|
|
default:
|
|
|
|
break;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_bl_pre(MDOC_ARGS)
|
|
|
|
{
|
2019-03-29 13:13:30 +00:00
|
|
|
char cattr[32];
|
2017-02-19 17:41:20 +00:00
|
|
|
struct mdoc_bl *bl;
|
2017-01-21 13:01:39 +00:00
|
|
|
enum htmltag elemtype;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-02-19 17:41:20 +00:00
|
|
|
switch (n->type) {
|
2019-03-29 13:13:30 +00:00
|
|
|
case ROFFT_BLOCK:
|
|
|
|
html_close_paragraph(h);
|
|
|
|
break;
|
2017-02-19 17:41:20 +00:00
|
|
|
case ROFFT_HEAD:
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2019-03-29 13:13:30 +00:00
|
|
|
case ROFFT_BODY:
|
|
|
|
return 1;
|
2017-02-19 17:41:20 +00:00
|
|
|
default:
|
2019-03-29 13:13:30 +00:00
|
|
|
abort();
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
2018-09-20 07:33:14 +00:00
|
|
|
bl = &n->norm->Bl;
|
2017-02-19 17:41:20 +00:00
|
|
|
switch (bl->type) {
|
2014-11-22 18:08:25 +00:00
|
|
|
case LIST_bullet:
|
2017-01-21 13:01:39 +00:00
|
|
|
elemtype = TAG_UL;
|
2017-07-31 19:17:54 +00:00
|
|
|
(void)strlcpy(cattr, "Bl-bullet", sizeof(cattr));
|
2017-01-21 13:01:39 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case LIST_dash:
|
|
|
|
case LIST_hyphen:
|
2017-01-21 13:01:39 +00:00
|
|
|
elemtype = TAG_UL;
|
2017-07-31 19:17:54 +00:00
|
|
|
(void)strlcpy(cattr, "Bl-dash", sizeof(cattr));
|
2017-01-21 13:01:39 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case LIST_item:
|
2017-01-21 13:01:39 +00:00
|
|
|
elemtype = TAG_UL;
|
2017-07-31 19:17:54 +00:00
|
|
|
(void)strlcpy(cattr, "Bl-item", sizeof(cattr));
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case LIST_enum:
|
2017-01-21 13:01:39 +00:00
|
|
|
elemtype = TAG_OL;
|
2017-07-31 19:17:54 +00:00
|
|
|
(void)strlcpy(cattr, "Bl-enum", sizeof(cattr));
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case LIST_diag:
|
2017-01-21 13:01:39 +00:00
|
|
|
elemtype = TAG_DL;
|
2017-07-31 19:17:54 +00:00
|
|
|
(void)strlcpy(cattr, "Bl-diag", sizeof(cattr));
|
2017-01-21 13:01:39 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case LIST_hang:
|
2017-01-21 13:01:39 +00:00
|
|
|
elemtype = TAG_DL;
|
2017-07-31 19:17:54 +00:00
|
|
|
(void)strlcpy(cattr, "Bl-hang", sizeof(cattr));
|
2017-01-21 13:01:39 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case LIST_inset:
|
2017-01-21 13:01:39 +00:00
|
|
|
elemtype = TAG_DL;
|
2017-07-31 19:17:54 +00:00
|
|
|
(void)strlcpy(cattr, "Bl-inset", sizeof(cattr));
|
2017-01-21 13:01:39 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case LIST_ohang:
|
2017-01-21 13:01:39 +00:00
|
|
|
elemtype = TAG_DL;
|
2017-07-31 19:17:54 +00:00
|
|
|
(void)strlcpy(cattr, "Bl-ohang", sizeof(cattr));
|
2017-01-21 13:01:39 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case LIST_tag:
|
2017-02-19 17:41:20 +00:00
|
|
|
if (bl->offs)
|
2018-09-20 07:33:14 +00:00
|
|
|
print_otag(h, TAG_DIV, "c", "Bd-indent");
|
2021-11-15 15:35:39 +00:00
|
|
|
print_otag_id(h, TAG_DL,
|
|
|
|
bl->comp ? "Bl-tag Bl-compact" : "Bl-tag", n->body);
|
2017-02-19 17:41:20 +00:00
|
|
|
return 1;
|
2014-11-22 18:08:25 +00:00
|
|
|
case LIST_column:
|
2017-01-21 13:01:39 +00:00
|
|
|
elemtype = TAG_TABLE;
|
2017-07-31 19:17:54 +00:00
|
|
|
(void)strlcpy(cattr, "Bl-column", sizeof(cattr));
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
2018-09-20 07:33:14 +00:00
|
|
|
if (bl->offs != NULL)
|
|
|
|
(void)strlcat(cattr, " Bd-indent", sizeof(cattr));
|
2017-07-31 19:17:54 +00:00
|
|
|
if (bl->comp)
|
|
|
|
(void)strlcat(cattr, " Bl-compact", sizeof(cattr));
|
2021-11-15 15:35:39 +00:00
|
|
|
print_otag_id(h, elemtype, cattr, n->body);
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_ex_pre(MDOC_ARGS)
|
|
|
|
{
|
2021-11-15 15:35:39 +00:00
|
|
|
if (roff_node_prev(n) != NULL)
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_BR, "");
|
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
2017-02-19 17:41:20 +00:00
|
|
|
static int
|
|
|
|
mdoc_st_pre(MDOC_ARGS)
|
|
|
|
{
|
2019-03-29 13:13:30 +00:00
|
|
|
print_otag(h, TAG_SPAN, "c", "St");
|
2017-02-19 17:41:20 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-10-18 09:55:16 +00:00
|
|
|
static int
|
|
|
|
mdoc_em_pre(MDOC_ARGS)
|
|
|
|
{
|
2021-11-15 15:35:39 +00:00
|
|
|
print_otag_id(h, TAG_I, "Em", n);
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_d1_pre(MDOC_ARGS)
|
|
|
|
{
|
2019-03-29 13:13:30 +00:00
|
|
|
switch (n->type) {
|
|
|
|
case ROFFT_BLOCK:
|
|
|
|
html_close_paragraph(h);
|
2021-11-15 15:35:39 +00:00
|
|
|
return 1;
|
2019-03-29 13:13:30 +00:00
|
|
|
case ROFFT_HEAD:
|
|
|
|
return 0;
|
|
|
|
case ROFFT_BODY:
|
2021-11-15 15:35:39 +00:00
|
|
|
break;
|
2019-03-29 13:13:30 +00:00
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
2021-11-15 15:35:39 +00:00
|
|
|
print_otag_id(h, TAG_DIV, "Bd Bd-indent", n);
|
2017-01-21 13:01:39 +00:00
|
|
|
if (n->tok == MDOC_Dl)
|
|
|
|
print_otag(h, TAG_CODE, "c", "Li");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_sx_pre(MDOC_ARGS)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
char *id;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2018-09-20 07:33:14 +00:00
|
|
|
id = html_make_id(n, 0);
|
2019-03-29 13:13:30 +00:00
|
|
|
print_otag(h, TAG_A, "chR", "Sx", id);
|
2017-02-19 17:41:20 +00:00
|
|
|
free(id);
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_bd_pre(MDOC_ARGS)
|
|
|
|
{
|
2021-11-15 15:35:39 +00:00
|
|
|
char buf[20];
|
2016-01-15 23:08:59 +00:00
|
|
|
struct roff_node *nn;
|
2019-03-29 13:13:30 +00:00
|
|
|
int comp;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2019-03-29 13:13:30 +00:00
|
|
|
switch (n->type) {
|
|
|
|
case ROFFT_BLOCK:
|
|
|
|
html_close_paragraph(h);
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2019-03-29 13:13:30 +00:00
|
|
|
case ROFFT_HEAD:
|
|
|
|
return 0;
|
|
|
|
case ROFFT_BODY:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
2019-03-29 13:13:30 +00:00
|
|
|
/* Handle preceding whitespace. */
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2019-03-29 13:13:30 +00:00
|
|
|
comp = n->norm->Bd.comp;
|
|
|
|
for (nn = n; nn != NULL && comp == 0; nn = nn->parent) {
|
|
|
|
if (nn->type != ROFFT_BLOCK)
|
2012-10-18 09:55:16 +00:00
|
|
|
continue;
|
2019-03-29 13:13:30 +00:00
|
|
|
if (nn->tok == MDOC_Sh || nn->tok == MDOC_Ss)
|
|
|
|
comp = 1;
|
2021-11-15 15:35:39 +00:00
|
|
|
if (roff_node_prev(nn) != NULL)
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-03-29 13:13:30 +00:00
|
|
|
(void)strlcpy(buf, "Bd", sizeof(buf));
|
|
|
|
if (comp == 0)
|
|
|
|
(void)strlcat(buf, " Pp", sizeof(buf));
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2019-03-29 13:13:30 +00:00
|
|
|
/* Handle the -offset argument. */
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2019-03-29 13:13:30 +00:00
|
|
|
if (n->norm->Bd.offs != NULL &&
|
|
|
|
strcmp(n->norm->Bd.offs, "left") != 0)
|
|
|
|
(void)strlcat(buf, " Bd-indent", sizeof(buf));
|
|
|
|
|
2021-11-15 15:35:39 +00:00
|
|
|
if (n->norm->Bd.type == DISP_literal)
|
|
|
|
(void)strlcat(buf, " Li", sizeof(buf));
|
|
|
|
|
|
|
|
print_otag_id(h, TAG_DIV, buf, n);
|
2019-03-29 13:13:30 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_pa_pre(MDOC_ARGS)
|
|
|
|
{
|
2019-03-29 13:13:30 +00:00
|
|
|
print_otag(h, TAG_SPAN, "c", "Pa");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_ad_pre(MDOC_ARGS)
|
|
|
|
{
|
2018-09-20 07:33:14 +00:00
|
|
|
print_otag(h, TAG_SPAN, "c", "Ad");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_an_pre(MDOC_ARGS)
|
|
|
|
{
|
2014-12-02 07:34:06 +00:00
|
|
|
if (n->norm->An.auth == AUTH_split) {
|
|
|
|
h->flags &= ~HTML_NOSPLIT;
|
|
|
|
h->flags |= HTML_SPLIT;
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2014-12-02 07:34:06 +00:00
|
|
|
}
|
|
|
|
if (n->norm->An.auth == AUTH_nosplit) {
|
|
|
|
h->flags &= ~HTML_SPLIT;
|
|
|
|
h->flags |= HTML_NOSPLIT;
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2014-12-02 07:34:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (h->flags & HTML_SPLIT)
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_BR, "");
|
2014-12-02 07:34:06 +00:00
|
|
|
|
|
|
|
if (n->sec == SEC_AUTHORS && ! (h->flags & HTML_NOSPLIT))
|
|
|
|
h->flags |= HTML_SPLIT;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2019-03-29 13:13:30 +00:00
|
|
|
print_otag(h, TAG_SPAN, "c", "An");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_cd_pre(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
synopsis_pre(h, n);
|
2019-03-29 13:13:30 +00:00
|
|
|
print_otag(h, TAG_CODE, "c", "Cd");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_fa_pre(MDOC_ARGS)
|
|
|
|
{
|
2016-01-15 23:08:59 +00:00
|
|
|
const struct roff_node *nn;
|
2012-10-18 09:55:16 +00:00
|
|
|
struct tag *t;
|
|
|
|
|
|
|
|
if (n->parent->tok != MDOC_Fo) {
|
2019-03-29 13:13:30 +00:00
|
|
|
print_otag(h, TAG_VAR, "c", "Fa");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
2021-11-15 15:35:39 +00:00
|
|
|
for (nn = n->child; nn != NULL; nn = nn->next) {
|
2019-03-29 13:13:30 +00:00
|
|
|
t = print_otag(h, TAG_VAR, "c", "Fa");
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, nn->string);
|
|
|
|
print_tagq(h, t);
|
2021-11-15 15:35:39 +00:00
|
|
|
if (nn->next != NULL) {
|
2012-10-18 09:55:16 +00:00
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
print_text(h, ",");
|
|
|
|
}
|
|
|
|
}
|
2021-11-15 15:35:39 +00:00
|
|
|
if (n->child != NULL &&
|
|
|
|
(nn = roff_node_next(n)) != NULL &&
|
|
|
|
nn->tok == MDOC_Fa) {
|
2012-10-18 09:55:16 +00:00
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
print_text(h, ",");
|
|
|
|
}
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_fd_pre(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
struct tag *t;
|
2017-01-21 13:01:39 +00:00
|
|
|
char *buf, *cp;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
synopsis_pre(h, n);
|
|
|
|
|
|
|
|
if (NULL == (n = n->child))
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
assert(n->type == ROFFT_TEXT);
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
if (strcmp(n->string, "#include")) {
|
2019-03-29 13:13:30 +00:00
|
|
|
print_otag(h, TAG_CODE, "c", "Fd");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
2019-03-29 13:13:30 +00:00
|
|
|
print_otag(h, TAG_CODE, "c", "In");
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, n->string);
|
|
|
|
|
|
|
|
if (NULL != (n = n->next)) {
|
2016-01-15 23:08:59 +00:00
|
|
|
assert(n->type == ROFFT_TEXT);
|
2014-11-22 18:08:25 +00:00
|
|
|
|
2012-10-18 09:55:16 +00:00
|
|
|
if (h->base_includes) {
|
2017-01-21 13:01:39 +00:00
|
|
|
cp = n->string;
|
|
|
|
if (*cp == '<' || *cp == '"')
|
|
|
|
cp++;
|
|
|
|
buf = mandoc_strdup(cp);
|
|
|
|
cp = strchr(buf, '\0') - 1;
|
|
|
|
if (cp >= buf && (*cp == '>' || *cp == '"'))
|
|
|
|
*cp = '\0';
|
2019-03-29 13:13:30 +00:00
|
|
|
t = print_otag(h, TAG_A, "chI", "In", buf);
|
2017-01-21 13:01:39 +00:00
|
|
|
free(buf);
|
|
|
|
} else
|
2019-03-29 13:13:30 +00:00
|
|
|
t = print_otag(h, TAG_A, "c", "In");
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
print_text(h, n->string);
|
|
|
|
print_tagq(h, t);
|
|
|
|
|
|
|
|
n = n->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( ; n; n = n->next) {
|
2016-01-15 23:08:59 +00:00
|
|
|
assert(n->type == ROFFT_TEXT);
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, n->string);
|
|
|
|
}
|
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_vt_pre(MDOC_ARGS)
|
|
|
|
{
|
2016-01-15 23:08:59 +00:00
|
|
|
if (n->type == ROFFT_BLOCK) {
|
2012-10-18 09:55:16 +00:00
|
|
|
synopsis_pre(h, n);
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
|
|
|
} else if (n->type == ROFFT_ELEM) {
|
2012-10-18 09:55:16 +00:00
|
|
|
synopsis_pre(h, n);
|
2016-01-15 23:08:59 +00:00
|
|
|
} else if (n->type == ROFFT_HEAD)
|
|
|
|
return 0;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2019-03-29 13:13:30 +00:00
|
|
|
print_otag(h, TAG_VAR, "c", "Vt");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_ft_pre(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
synopsis_pre(h, n);
|
2019-03-29 13:13:30 +00:00
|
|
|
print_otag(h, TAG_VAR, "c", "Ft");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_fn_pre(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
struct tag *t;
|
|
|
|
char nbuf[BUFSIZ];
|
|
|
|
const char *sp, *ep;
|
2017-01-21 13:01:39 +00:00
|
|
|
int sz, pretty;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
pretty = NODE_SYNPRETTY & n->flags;
|
2012-10-18 09:55:16 +00:00
|
|
|
synopsis_pre(h, n);
|
|
|
|
|
|
|
|
/* Split apart into type and name. */
|
|
|
|
assert(n->child->string);
|
|
|
|
sp = n->child->string;
|
|
|
|
|
|
|
|
ep = strchr(sp, ' ');
|
|
|
|
if (NULL != ep) {
|
2019-03-29 13:13:30 +00:00
|
|
|
t = print_otag(h, TAG_VAR, "c", "Ft");
|
2014-11-22 18:08:25 +00:00
|
|
|
|
2012-10-18 09:55:16 +00:00
|
|
|
while (ep) {
|
|
|
|
sz = MIN((int)(ep - sp), BUFSIZ - 1);
|
|
|
|
(void)memcpy(nbuf, sp, (size_t)sz);
|
|
|
|
nbuf[sz] = '\0';
|
|
|
|
print_text(h, nbuf);
|
|
|
|
sp = ++ep;
|
|
|
|
ep = strchr(sp, ' ');
|
|
|
|
}
|
|
|
|
print_tagq(h, t);
|
|
|
|
}
|
|
|
|
|
2021-11-15 15:35:39 +00:00
|
|
|
t = print_otag_id(h, TAG_CODE, "Fn", n);
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2014-11-22 18:08:25 +00:00
|
|
|
if (sp)
|
|
|
|
print_text(h, sp);
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
print_tagq(h, t);
|
|
|
|
|
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
print_text(h, "(");
|
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
|
|
|
|
for (n = n->child->next; n; n = n->next) {
|
2017-01-21 13:01:39 +00:00
|
|
|
if (NODE_SYNPRETTY & n->flags)
|
2019-03-29 13:13:30 +00:00
|
|
|
t = print_otag(h, TAG_VAR, "cs", "Fa",
|
2017-01-21 13:01:39 +00:00
|
|
|
"white-space", "nowrap");
|
|
|
|
else
|
2019-03-29 13:13:30 +00:00
|
|
|
t = print_otag(h, TAG_VAR, "c", "Fa");
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, n->string);
|
|
|
|
print_tagq(h, t);
|
|
|
|
if (n->next) {
|
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
print_text(h, ",");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
print_text(h, ")");
|
|
|
|
|
|
|
|
if (pretty) {
|
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
print_text(h, ";");
|
|
|
|
}
|
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_sm_pre(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
|
2014-11-22 18:08:25 +00:00
|
|
|
if (NULL == n->child)
|
|
|
|
h->flags ^= HTML_NONOSPACE;
|
|
|
|
else if (0 == strcmp("on", n->child->string))
|
2012-10-18 09:55:16 +00:00
|
|
|
h->flags &= ~HTML_NONOSPACE;
|
2014-11-22 18:08:25 +00:00
|
|
|
else
|
2012-10-18 09:55:16 +00:00
|
|
|
h->flags |= HTML_NONOSPACE;
|
|
|
|
|
2014-11-22 18:08:25 +00:00
|
|
|
if ( ! (HTML_NONOSPACE & h->flags))
|
|
|
|
h->flags &= ~HTML_NOSPACE;
|
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2014-11-22 18:08:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_skip_pre(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_pp_pre(MDOC_ARGS)
|
|
|
|
{
|
2021-11-15 15:35:39 +00:00
|
|
|
char *id;
|
|
|
|
|
|
|
|
if (n->flags & NODE_NOFILL) {
|
|
|
|
print_endline(h);
|
|
|
|
if (n->flags & NODE_ID)
|
|
|
|
mdoc_tg_pre(meta, n, h);
|
|
|
|
else {
|
|
|
|
h->col = 1;
|
|
|
|
print_endline(h);
|
|
|
|
}
|
|
|
|
} else {
|
2019-03-29 13:13:30 +00:00
|
|
|
html_close_paragraph(h);
|
2021-11-15 15:35:39 +00:00
|
|
|
id = n->flags & NODE_ID ? html_make_id(n, 1) : NULL;
|
|
|
|
print_otag(h, TAG_P, "ci", "Pp", id);
|
|
|
|
free(id);
|
2019-03-29 13:13:30 +00:00
|
|
|
}
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_lk_pre(MDOC_ARGS)
|
|
|
|
{
|
2017-06-08 19:29:07 +00:00
|
|
|
const struct roff_node *link, *descr, *punct;
|
|
|
|
struct tag *t;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-06-08 19:29:07 +00:00
|
|
|
if ((link = n->child) == NULL)
|
|
|
|
return 0;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-06-08 19:29:07 +00:00
|
|
|
/* Find beginning of trailing punctuation. */
|
|
|
|
punct = n->last;
|
|
|
|
while (punct != link && punct->flags & NODE_DELIMC)
|
|
|
|
punct = punct->prev;
|
|
|
|
punct = punct->next;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-06-08 19:29:07 +00:00
|
|
|
/* Link target and link text. */
|
2017-07-31 19:17:54 +00:00
|
|
|
descr = link->next;
|
|
|
|
if (descr == punct)
|
|
|
|
descr = link; /* no text */
|
2019-03-29 13:13:30 +00:00
|
|
|
t = print_otag(h, TAG_A, "ch", "Lk", link->string);
|
2017-07-31 19:17:54 +00:00
|
|
|
do {
|
2017-06-08 19:29:07 +00:00
|
|
|
if (descr->flags & (NODE_DELIMC | NODE_DELIMO))
|
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
print_text(h, descr->string);
|
2017-07-31 19:17:54 +00:00
|
|
|
descr = descr->next;
|
|
|
|
} while (descr != punct);
|
2017-06-08 19:29:07 +00:00
|
|
|
print_tagq(h, t);
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-06-08 19:29:07 +00:00
|
|
|
/* Trailing punctuation. */
|
|
|
|
while (punct != NULL) {
|
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
print_text(h, punct->string);
|
|
|
|
punct = punct->next;
|
|
|
|
}
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_mt_pre(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
struct tag *t;
|
2017-01-21 13:01:39 +00:00
|
|
|
char *cp;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
for (n = n->child; n; n = n->next) {
|
2016-01-15 23:08:59 +00:00
|
|
|
assert(n->type == ROFFT_TEXT);
|
2017-01-21 13:01:39 +00:00
|
|
|
mandoc_asprintf(&cp, "mailto:%s", n->string);
|
2019-03-29 13:13:30 +00:00
|
|
|
t = print_otag(h, TAG_A, "ch", "Mt", cp);
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, n->string);
|
|
|
|
print_tagq(h, t);
|
2017-01-21 13:01:39 +00:00
|
|
|
free(cp);
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_fo_pre(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
struct tag *t;
|
|
|
|
|
2021-11-15 15:35:39 +00:00
|
|
|
switch (n->type) {
|
|
|
|
case ROFFT_BLOCK:
|
|
|
|
synopsis_pre(h, n);
|
|
|
|
return 1;
|
|
|
|
case ROFFT_HEAD:
|
|
|
|
if (n->child != NULL) {
|
|
|
|
t = print_otag_id(h, TAG_CODE, "Fn", n);
|
|
|
|
print_text(h, n->child->string);
|
|
|
|
print_tagq(h, t);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case ROFFT_BODY:
|
2012-10-18 09:55:16 +00:00
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
print_text(h, "(");
|
|
|
|
h->flags |= HTML_NOSPACE;
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2021-11-15 15:35:39 +00:00
|
|
|
default:
|
|
|
|
abort();
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mdoc_fo_post(MDOC_ARGS)
|
|
|
|
{
|
2016-01-15 23:08:59 +00:00
|
|
|
if (n->type != ROFFT_BODY)
|
2012-10-18 09:55:16 +00:00
|
|
|
return;
|
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
print_text(h, ")");
|
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
print_text(h, ";");
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_in_pre(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
struct tag *t;
|
|
|
|
|
|
|
|
synopsis_pre(h, n);
|
2019-03-29 13:13:30 +00:00
|
|
|
print_otag(h, TAG_CODE, "c", "In");
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The first argument of the `In' gets special treatment as
|
|
|
|
* being a linked value. Subsequent values are printed
|
|
|
|
* afterward. groff does similarly. This also handles the case
|
|
|
|
* of no children.
|
|
|
|
*/
|
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
if (NODE_SYNPRETTY & n->flags && NODE_LINE & n->flags)
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, "#include");
|
|
|
|
|
|
|
|
print_text(h, "<");
|
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
|
|
|
|
if (NULL != (n = n->child)) {
|
2016-01-15 23:08:59 +00:00
|
|
|
assert(n->type == ROFFT_TEXT);
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
if (h->base_includes)
|
2019-03-29 13:13:30 +00:00
|
|
|
t = print_otag(h, TAG_A, "chI", "In", n->string);
|
2017-01-21 13:01:39 +00:00
|
|
|
else
|
2019-03-29 13:13:30 +00:00
|
|
|
t = print_otag(h, TAG_A, "c", "In");
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, n->string);
|
|
|
|
print_tagq(h, t);
|
|
|
|
|
|
|
|
n = n->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
print_text(h, ">");
|
|
|
|
|
|
|
|
for ( ; n; n = n->next) {
|
2016-01-15 23:08:59 +00:00
|
|
|
assert(n->type == ROFFT_TEXT);
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, n->string);
|
|
|
|
}
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_va_pre(MDOC_ARGS)
|
|
|
|
{
|
2019-03-29 13:13:30 +00:00
|
|
|
print_otag(h, TAG_VAR, "c", "Va");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_ap_pre(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
print_text(h, "\\(aq");
|
|
|
|
h->flags |= HTML_NOSPACE;
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_bf_pre(MDOC_ARGS)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
const char *cattr;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2019-03-29 13:13:30 +00:00
|
|
|
switch (n->type) {
|
|
|
|
case ROFFT_BLOCK:
|
|
|
|
html_close_paragraph(h);
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2019-03-29 13:13:30 +00:00
|
|
|
case ROFFT_HEAD:
|
|
|
|
return 0;
|
|
|
|
case ROFFT_BODY:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2014-11-22 18:08:25 +00:00
|
|
|
if (FONT_Em == n->norm->Bf.font)
|
2018-09-20 07:33:14 +00:00
|
|
|
cattr = "Bf Em";
|
2014-11-22 18:08:25 +00:00
|
|
|
else if (FONT_Sy == n->norm->Bf.font)
|
2018-09-20 07:33:14 +00:00
|
|
|
cattr = "Bf Sy";
|
2014-11-22 18:08:25 +00:00
|
|
|
else if (FONT_Li == n->norm->Bf.font)
|
2018-09-20 07:33:14 +00:00
|
|
|
cattr = "Bf Li";
|
2012-10-18 09:55:16 +00:00
|
|
|
else
|
2018-09-20 07:33:14 +00:00
|
|
|
cattr = "Bf No";
|
2017-01-21 13:01:39 +00:00
|
|
|
|
2018-09-20 07:33:14 +00:00
|
|
|
/* Cannot use TAG_SPAN because it may contain blocks. */
|
|
|
|
print_otag(h, TAG_DIV, "c", cattr);
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_igndelim_pre(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
h->flags |= HTML_IGNDELIM;
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mdoc_pf_post(MDOC_ARGS)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
if ( ! (n->next == NULL || n->next->flags & NODE_LINE))
|
2014-12-25 21:33:25 +00:00
|
|
|
h->flags |= HTML_NOSPACE;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_rs_pre(MDOC_ARGS)
|
|
|
|
{
|
2019-03-29 13:13:30 +00:00
|
|
|
switch (n->type) {
|
|
|
|
case ROFFT_BLOCK:
|
|
|
|
if (n->sec == SEC_SEE_ALSO)
|
|
|
|
html_close_paragraph(h);
|
|
|
|
break;
|
|
|
|
case ROFFT_HEAD:
|
|
|
|
return 0;
|
|
|
|
case ROFFT_BODY:
|
|
|
|
if (n->sec == SEC_SEE_ALSO)
|
|
|
|
print_otag(h, TAG_P, "c", "Pp");
|
|
|
|
print_otag(h, TAG_CITE, "c", "Rs");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
2014-12-02 07:34:06 +00:00
|
|
|
static int
|
|
|
|
mdoc_no_pre(MDOC_ARGS)
|
|
|
|
{
|
2021-11-15 15:35:39 +00:00
|
|
|
print_otag_id(h, TAG_SPAN, roff_name[n->tok], n);
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_sy_pre(MDOC_ARGS)
|
|
|
|
{
|
2021-11-15 15:35:39 +00:00
|
|
|
print_otag_id(h, TAG_B, "Sy", n);
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_lb_pre(MDOC_ARGS)
|
|
|
|
{
|
2021-11-15 15:35:39 +00:00
|
|
|
if (n->sec == SEC_LIBRARY &&
|
|
|
|
n->flags & NODE_LINE &&
|
|
|
|
roff_node_prev(n) != NULL)
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_BR, "");
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2019-03-29 13:13:30 +00:00
|
|
|
print_otag(h, TAG_SPAN, "c", "Lb");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc__x_pre(MDOC_ARGS)
|
|
|
|
{
|
2021-11-15 15:35:39 +00:00
|
|
|
struct roff_node *nn;
|
|
|
|
const char *cattr;
|
|
|
|
enum htmltag t;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
t = TAG_SPAN;
|
|
|
|
|
|
|
|
switch (n->tok) {
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC__A:
|
2017-01-21 13:01:39 +00:00
|
|
|
cattr = "RsA";
|
2021-11-15 15:35:39 +00:00
|
|
|
if ((nn = roff_node_prev(n)) != NULL && nn->tok == MDOC__A &&
|
|
|
|
((nn = roff_node_next(n)) == NULL || nn->tok != MDOC__A))
|
|
|
|
print_text(h, "and");
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC__B:
|
2012-10-18 09:55:16 +00:00
|
|
|
t = TAG_I;
|
2017-01-21 13:01:39 +00:00
|
|
|
cattr = "RsB";
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC__C:
|
2017-01-21 13:01:39 +00:00
|
|
|
cattr = "RsC";
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC__D:
|
2017-01-21 13:01:39 +00:00
|
|
|
cattr = "RsD";
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC__I:
|
2012-10-18 09:55:16 +00:00
|
|
|
t = TAG_I;
|
2017-01-21 13:01:39 +00:00
|
|
|
cattr = "RsI";
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC__J:
|
2012-10-18 09:55:16 +00:00
|
|
|
t = TAG_I;
|
2017-01-21 13:01:39 +00:00
|
|
|
cattr = "RsJ";
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC__N:
|
2017-01-21 13:01:39 +00:00
|
|
|
cattr = "RsN";
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC__O:
|
2017-01-21 13:01:39 +00:00
|
|
|
cattr = "RsO";
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC__P:
|
2017-01-21 13:01:39 +00:00
|
|
|
cattr = "RsP";
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC__Q:
|
2017-01-21 13:01:39 +00:00
|
|
|
cattr = "RsQ";
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC__R:
|
2017-01-21 13:01:39 +00:00
|
|
|
cattr = "RsR";
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC__T:
|
2017-01-21 13:01:39 +00:00
|
|
|
cattr = "RsT";
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC__U:
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_A, "ch", "RsU", n->child->string);
|
|
|
|
return 1;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC__V:
|
2017-01-21 13:01:39 +00:00
|
|
|
cattr = "RsV";
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, t, "c", cattr);
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mdoc__x_post(MDOC_ARGS)
|
|
|
|
{
|
2021-11-15 15:35:39 +00:00
|
|
|
struct roff_node *nn;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2021-11-15 15:35:39 +00:00
|
|
|
if (n->tok == MDOC__A &&
|
|
|
|
(nn = roff_node_next(n)) != NULL && nn->tok == MDOC__A &&
|
|
|
|
((nn = roff_node_next(nn)) == NULL || nn->tok != MDOC__A) &&
|
|
|
|
((nn = roff_node_prev(n)) == NULL || nn->tok != MDOC__A))
|
|
|
|
return;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
/* TODO: %U */
|
|
|
|
|
2021-11-15 15:35:39 +00:00
|
|
|
if (n->parent == NULL || n->parent->tok != MDOC_Rs)
|
2012-10-18 09:55:16 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
h->flags |= HTML_NOSPACE;
|
2021-11-15 15:35:39 +00:00
|
|
|
print_text(h, roff_node_next(n) ? "," : ".");
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_bk_pre(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (n->type) {
|
2016-01-15 23:08:59 +00:00
|
|
|
case ROFFT_BLOCK:
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2016-01-15 23:08:59 +00:00
|
|
|
case ROFFT_HEAD:
|
|
|
|
return 0;
|
|
|
|
case ROFFT_BODY:
|
|
|
|
if (n->parent->args != NULL || n->prev->child == NULL)
|
2012-10-18 09:55:16 +00:00
|
|
|
h->flags |= HTML_PREKEEP;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mdoc_bk_post(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
if (n->type == ROFFT_BODY)
|
2012-10-18 09:55:16 +00:00
|
|
|
h->flags &= ~(HTML_KEEP | HTML_PREKEEP);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_quote_pre(MDOC_ARGS)
|
|
|
|
{
|
2016-01-15 23:08:59 +00:00
|
|
|
if (n->type != ROFFT_BODY)
|
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
switch (n->tok) {
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_Ao:
|
|
|
|
case MDOC_Aq:
|
2016-01-15 23:08:59 +00:00
|
|
|
print_text(h, n->child != NULL && n->child->next == NULL &&
|
2015-03-02 16:45:41 +00:00
|
|
|
n->child->tok == MDOC_Mt ? "<" : "\\(la");
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_Bro:
|
|
|
|
case MDOC_Brq:
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, "\\(lC");
|
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_Bo:
|
|
|
|
case MDOC_Bq:
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, "\\(lB");
|
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_Oo:
|
|
|
|
case MDOC_Op:
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, "\\(lB");
|
2019-03-29 13:13:30 +00:00
|
|
|
/*
|
|
|
|
* Give up on semantic markup for now.
|
|
|
|
* We cannot use TAG_SPAN because .Oo may contain blocks.
|
2021-11-15 15:35:39 +00:00
|
|
|
* We cannot use TAG_DIV because we might be in a
|
2019-03-29 13:13:30 +00:00
|
|
|
* phrasing context (like .Dl or .Pp); we cannot
|
|
|
|
* close out a .Pp at this point either because
|
|
|
|
* that would break the line.
|
|
|
|
*/
|
|
|
|
/* XXX print_otag(h, TAG_???, "c", "Op"); */
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_En:
|
|
|
|
if (NULL == n->norm->Es ||
|
|
|
|
NULL == n->norm->Es->child)
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2014-11-22 18:08:25 +00:00
|
|
|
print_text(h, n->norm->Es->child->string);
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_Do:
|
|
|
|
case MDOC_Dq:
|
2021-11-15 15:35:39 +00:00
|
|
|
print_text(h, "\\(lq");
|
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_Qo:
|
|
|
|
case MDOC_Qq:
|
2021-11-15 15:35:39 +00:00
|
|
|
print_text(h, "\"");
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_Po:
|
|
|
|
case MDOC_Pq:
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, "(");
|
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_Ql:
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, "\\(oq");
|
|
|
|
h->flags |= HTML_NOSPACE;
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_CODE, "c", "Li");
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_So:
|
|
|
|
case MDOC_Sq:
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, "\\(oq");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
h->flags |= HTML_NOSPACE;
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mdoc_quote_post(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
if (n->type != ROFFT_BODY && n->type != ROFFT_ELEM)
|
2012-10-18 09:55:16 +00:00
|
|
|
return;
|
|
|
|
|
2015-03-02 16:45:41 +00:00
|
|
|
h->flags |= HTML_NOSPACE;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
switch (n->tok) {
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_Ao:
|
|
|
|
case MDOC_Aq:
|
2016-01-15 23:08:59 +00:00
|
|
|
print_text(h, n->child != NULL && n->child->next == NULL &&
|
2015-03-02 16:45:41 +00:00
|
|
|
n->child->tok == MDOC_Mt ? ">" : "\\(ra");
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_Bro:
|
|
|
|
case MDOC_Brq:
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, "\\(rC");
|
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_Oo:
|
|
|
|
case MDOC_Op:
|
|
|
|
case MDOC_Bo:
|
|
|
|
case MDOC_Bq:
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, "\\(rB");
|
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_En:
|
2015-03-02 16:45:41 +00:00
|
|
|
if (n->norm->Es == NULL ||
|
|
|
|
n->norm->Es->child == NULL ||
|
|
|
|
n->norm->Es->child->next == NULL)
|
|
|
|
h->flags &= ~HTML_NOSPACE;
|
|
|
|
else
|
2014-11-22 18:08:25 +00:00
|
|
|
print_text(h, n->norm->Es->child->next->string);
|
|
|
|
break;
|
|
|
|
case MDOC_Do:
|
|
|
|
case MDOC_Dq:
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, "\\(rq");
|
|
|
|
break;
|
2021-11-15 15:35:39 +00:00
|
|
|
case MDOC_Qo:
|
|
|
|
case MDOC_Qq:
|
|
|
|
print_text(h, "\"");
|
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_Po:
|
|
|
|
case MDOC_Pq:
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, ")");
|
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_Ql:
|
|
|
|
case MDOC_So:
|
|
|
|
case MDOC_Sq:
|
2014-01-31 19:59:03 +00:00
|
|
|
print_text(h, "\\(cq");
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
2015-03-02 16:45:41 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_eo_pre(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
if (n->type != ROFFT_BODY)
|
|
|
|
return 1;
|
2015-03-02 16:45:41 +00:00
|
|
|
|
|
|
|
if (n->end == ENDBODY_NOT &&
|
|
|
|
n->parent->head->child == NULL &&
|
|
|
|
n->child != NULL &&
|
|
|
|
n->child->end != ENDBODY_NOT)
|
|
|
|
print_text(h, "\\&");
|
|
|
|
else if (n->end != ENDBODY_NOT ? n->child != NULL :
|
|
|
|
n->parent->head->child != NULL && (n->child != NULL ||
|
|
|
|
(n->parent->tail != NULL && n->parent->tail->child != NULL)))
|
|
|
|
h->flags |= HTML_NOSPACE;
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2015-03-02 16:45:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mdoc_eo_post(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
int body, tail;
|
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
if (n->type != ROFFT_BODY)
|
2015-03-02 16:45:41 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (n->end != ENDBODY_NOT) {
|
|
|
|
h->flags &= ~HTML_NOSPACE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
body = n->child != NULL || n->parent->head->child != NULL;
|
|
|
|
tail = n->parent->tail != NULL && n->parent->tail->child != NULL;
|
|
|
|
|
|
|
|
if (body && tail)
|
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
else if ( ! tail)
|
|
|
|
h->flags &= ~HTML_NOSPACE;
|
|
|
|
}
|
2019-03-29 13:13:30 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_abort_pre(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
abort();
|
|
|
|
}
|