2017-02-19 17:41:20 +00:00
|
|
|
/* $Id: mdoc_html.c,v 1.271 2017/02/16 03:00:23 schwarze Exp $ */
|
2012-10-18 09:55:16 +00:00
|
|
|
/*
|
2014-12-02 07:34:06 +00:00
|
|
|
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
|
2017-01-21 13:01:39 +00:00
|
|
|
* Copyright (c) 2014, 2015, 2016, 2017 Ingo Schwarze <schwarze@openbsd.org>
|
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.
|
|
|
|
*/
|
|
|
|
#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"
|
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"
|
|
|
|
|
|
|
|
#define INDENT 5
|
|
|
|
|
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
|
|
|
|
|
|
|
|
struct htmlmdoc {
|
|
|
|
int (*pre)(MDOC_ARGS);
|
|
|
|
void (*post)(MDOC_ARGS);
|
|
|
|
};
|
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
static char *make_id(const struct roff_node *);
|
2012-10-18 09:55:16 +00:00
|
|
|
static void print_mdoc_head(MDOC_ARGS);
|
|
|
|
static void print_mdoc_node(MDOC_ARGS);
|
|
|
|
static void print_mdoc_nodelist(MDOC_ARGS);
|
2014-11-22 18:08:25 +00:00
|
|
|
static void synopsis_pre(struct html *,
|
2016-01-15 23:08:59 +00:00
|
|
|
const struct roff_node *);
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
static void mdoc_root_post(MDOC_ARGS);
|
|
|
|
static int mdoc_root_pre(MDOC_ARGS);
|
|
|
|
|
|
|
|
static void mdoc__x_post(MDOC_ARGS);
|
|
|
|
static int mdoc__x_pre(MDOC_ARGS);
|
|
|
|
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);
|
2017-01-21 13:01:39 +00:00
|
|
|
static int mdoc_cm_pre(MDOC_ARGS);
|
2012-10-18 09:55:16 +00:00
|
|
|
static int mdoc_d1_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_dv_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_er_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_ev_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_ex_pre(MDOC_ARGS);
|
|
|
|
static void mdoc_fo_post(MDOC_ARGS);
|
|
|
|
static int mdoc_fo_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_ic_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_li_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_lk_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_mt_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_ms_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_nd_pre(MDOC_ARGS);
|
|
|
|
static int mdoc_nm_pre(MDOC_ARGS);
|
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_sp_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);
|
|
|
|
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);
|
|
|
|
|
|
|
|
static const struct htmlmdoc mdocs[MDOC_MAX] = {
|
|
|
|
{mdoc_ap_pre, NULL}, /* Ap */
|
|
|
|
{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 */
|
|
|
|
{mdoc_ar_pre, NULL}, /* Ar */
|
|
|
|
{mdoc_cd_pre, NULL}, /* Cd */
|
2017-01-21 13:01:39 +00:00
|
|
|
{mdoc_cm_pre, NULL}, /* Cm */
|
2014-11-22 18:08:25 +00:00
|
|
|
{mdoc_dv_pre, NULL}, /* Dv */
|
|
|
|
{mdoc_er_pre, NULL}, /* Er */
|
|
|
|
{mdoc_ev_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 */
|
|
|
|
{mdoc_ic_pre, NULL}, /* Ic */
|
|
|
|
{mdoc_in_pre, NULL}, /* In */
|
2012-10-18 09:55:16 +00:00
|
|
|
{mdoc_li_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 */
|
2014-11-22 18:08:25 +00:00
|
|
|
{mdoc_ft_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 */
|
|
|
|
{mdoc_ms_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 */
|
2014-11-22 18:08:25 +00:00
|
|
|
{mdoc_pp_pre, NULL}, /* Lp */
|
|
|
|
{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 */
|
2012-10-18 09:55:16 +00:00
|
|
|
{mdoc_sp_pre, NULL}, /* br */
|
2014-11-22 18:08:25 +00:00
|
|
|
{mdoc_sp_pre, NULL}, /* sp */
|
|
|
|
{mdoc__x_pre, mdoc__x_post}, /* %U */
|
|
|
|
{NULL, NULL}, /* Ta */
|
|
|
|
{mdoc_skip_pre, NULL}, /* ll */
|
2012-10-18 09:55:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See the same function in mdoc_term.c for documentation.
|
|
|
|
*/
|
|
|
|
static void
|
2016-01-15 23:08:59 +00:00
|
|
|
synopsis_pre(struct html *h, const struct roff_node *n)
|
2012-10-18 09:55:16 +00:00
|
|
|
{
|
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
if (NULL == n->prev || ! (NODE_SYNPRETTY & n->flags))
|
2012-10-18 09:55:16 +00:00
|
|
|
return;
|
|
|
|
|
2014-11-22 18:08:25 +00:00
|
|
|
if (n->prev->tok == n->tok &&
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (n->prev->tok) {
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_Fd:
|
|
|
|
case MDOC_Fn:
|
|
|
|
case MDOC_Fo:
|
|
|
|
case MDOC_In:
|
|
|
|
case MDOC_Vt:
|
2014-12-02 07:34:06 +00:00
|
|
|
print_paragraph(h);
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_Ft:
|
2012-10-18 09:55:16 +00:00
|
|
|
if (MDOC_Fn != n->tok && MDOC_Fo != n->tok) {
|
2014-12-02 07:34:06 +00:00
|
|
|
print_paragraph(h);
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
default:
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_BR, "");
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
void
|
|
|
|
html_mdoc(void *arg, const struct roff_man *mdoc)
|
2012-10-18 09:55:16 +00:00
|
|
|
{
|
2016-01-15 23:08:59 +00:00
|
|
|
struct html *h;
|
2017-01-21 13:01:39 +00:00
|
|
|
struct tag *t;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
h = (struct html *)arg;
|
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, "");
|
|
|
|
t = print_otag(h, TAG_HEAD, "");
|
2016-01-15 23:08:59 +00:00
|
|
|
print_mdoc_head(&mdoc->meta, mdoc->first->child, 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
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
mdoc_root_pre(&mdoc->meta, mdoc->first->child, h);
|
2017-01-21 13:01:39 +00:00
|
|
|
t = print_otag(h, TAG_DIV, "c", "manual-text");
|
2016-01-15 23:08:59 +00:00
|
|
|
print_mdoc_nodelist(&mdoc->meta, mdoc->first->child, h);
|
2012-10-18 09:55:16 +00:00
|
|
|
print_tagq(h, t);
|
2017-01-21 13:01:39 +00:00
|
|
|
mdoc_root_post(&mdoc->meta, mdoc->first->child, h);
|
|
|
|
print_tagq(h, NULL);
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_mdoc_head(MDOC_ARGS)
|
|
|
|
{
|
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)
|
|
|
|
{
|
|
|
|
int child;
|
|
|
|
struct tag *t;
|
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
if (n->flags & NODE_NOPRT)
|
|
|
|
return;
|
|
|
|
|
2012-10-18 09:55:16 +00:00
|
|
|
child = 1;
|
2017-02-19 17:41:20 +00:00
|
|
|
t = h->tag;
|
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:
|
2012-10-18 09:55:16 +00:00
|
|
|
/* No tables in this mode... */
|
|
|
|
assert(NULL == h->tblt);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure that if we're in a literal mode already
|
|
|
|
* (i.e., within a <PRE>) don't print the newline.
|
|
|
|
*/
|
2017-01-21 13:01:39 +00:00
|
|
|
if (' ' == *n->string && NODE_LINE & n->flags)
|
2012-10-18 09:55:16 +00:00
|
|
|
if ( ! (HTML_LITERAL & h->flags))
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_BR, "");
|
|
|
|
if (NODE_DELIMC & n->flags)
|
2012-10-18 09:55:16 +00:00
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
print_text(h, n->string);
|
2017-01-21 13:01:39 +00:00
|
|
|
if (NODE_DELIMO & n->flags)
|
2012-10-18 09:55:16 +00:00
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
return;
|
2016-01-15 23:08:59 +00:00
|
|
|
case ROFFT_EQN:
|
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.
|
|
|
|
*/
|
2014-12-02 07:34:06 +00:00
|
|
|
if (h->tblt != NULL) {
|
2012-10-18 09:55:16 +00:00
|
|
|
print_tblclose(h);
|
2017-02-19 17:41:20 +00:00
|
|
|
t = h->tag;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
2014-12-02 07:34:06 +00:00
|
|
|
assert(h->tblt == NULL);
|
|
|
|
if (mdocs[n->tok].pre && (n->end == ENDBODY_NOT || n->child))
|
2014-01-31 19:59:03 +00:00
|
|
|
child = (*mdocs[n->tok].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
|
|
|
}
|
|
|
|
|
|
|
|
if (child && n->child)
|
2014-01-31 19:59:03 +00:00
|
|
|
print_mdoc_nodelist(meta, n->child, h);
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
print_stagq(h, t);
|
|
|
|
|
|
|
|
switch (n->type) {
|
2016-01-15 23:08:59 +00:00
|
|
|
case ROFFT_EQN:
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
|
|
|
default:
|
2017-01-21 13:01:39 +00:00
|
|
|
if ( ! mdocs[n->tok].post || n->flags & NODE_ENDED)
|
2014-12-02 07:34:06 +00:00
|
|
|
break;
|
|
|
|
(*mdocs[n->tok].post)(meta, n, h);
|
|
|
|
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
|
|
|
|
mdoc_root_post(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
mdoc_root_pre(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
static char *
|
|
|
|
make_id(const struct roff_node *n)
|
|
|
|
{
|
|
|
|
const struct roff_node *nch;
|
|
|
|
char *buf, *cp;
|
|
|
|
|
|
|
|
for (nch = n->child; nch != NULL; nch = nch->next)
|
|
|
|
if (nch->type != ROFFT_TEXT)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
buf = NULL;
|
|
|
|
deroff(&buf, n);
|
|
|
|
|
|
|
|
/* http://www.w3.org/TR/html5/dom.html#the-id-attribute */
|
|
|
|
|
|
|
|
for (cp = buf; *cp != '\0'; cp++)
|
|
|
|
if (*cp == ' ')
|
|
|
|
*cp = '_';
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2012-10-18 09:55:16 +00:00
|
|
|
static int
|
|
|
|
mdoc_sh_pre(MDOC_ARGS)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
char *id;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2014-12-02 07:34:06 +00:00
|
|
|
switch (n->type) {
|
2017-02-19 17:41:20 +00:00
|
|
|
case ROFFT_HEAD:
|
|
|
|
id = make_id(n);
|
|
|
|
print_otag(h, TAG_H1, "ci", "Sh", id);
|
|
|
|
free(id);
|
|
|
|
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)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
char *id;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
if (n->type != ROFFT_HEAD)
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-02-19 17:41:20 +00:00
|
|
|
id = make_id(n);
|
|
|
|
print_otag(h, TAG_H2, "ci", "Ss", id);
|
|
|
|
free(id);
|
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)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_B, "c", "Fl");
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, "\\-");
|
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
if (!(n->child == NULL &&
|
2014-12-02 07:34:06 +00:00
|
|
|
(n->next == NULL ||
|
2016-01-15 23:08:59 +00:00
|
|
|
n->next->type == ROFFT_TEXT ||
|
2017-01-21 13:01:39 +00:00
|
|
|
n->next->flags & NODE_LINE)))
|
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
|
2017-01-21 13:01:39 +00:00
|
|
|
mdoc_cm_pre(MDOC_ARGS)
|
2012-10-18 09:55:16 +00:00
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_B, "c", "Cm");
|
|
|
|
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)
|
|
|
|
{
|
2016-01-15 23:08:59 +00:00
|
|
|
if (n->type != ROFFT_BODY)
|
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
/* XXX: this tag in theory can contain block elements. */
|
|
|
|
|
|
|
|
print_text(h, "\\(em");
|
2017-01-21 13:01: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)
|
|
|
|
{
|
2017-02-19 17:41:20 +00:00
|
|
|
struct tag *t;
|
2012-10-18 09:55:16 +00:00
|
|
|
int len;
|
|
|
|
|
|
|
|
switch (n->type) {
|
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:
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_B, "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:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
synopsis_pre(h, n);
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_TABLE, "c", "Nm");
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
for (len = 0, n = n->head->child; n; n = n->next)
|
|
|
|
if (n->type == ROFFT_TEXT)
|
2012-10-18 09:55:16 +00:00
|
|
|
len += html_strlen(n->string);
|
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
if (len == 0 && meta->name != NULL)
|
2014-01-31 19:59:03 +00:00
|
|
|
len = html_strlen(meta->name);
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-02-19 17:41:20 +00:00
|
|
|
t = print_otag(h, TAG_COLGROUP, "");
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_COL, "shw", len);
|
|
|
|
print_otag(h, TAG_COL, "");
|
2017-02-19 17:41:20 +00:00
|
|
|
print_tagq(h, t);
|
2017-01-21 13:01:39 +00:00
|
|
|
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
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
if (h->base_man)
|
|
|
|
print_otag(h, TAG_A, "chM", "Xr",
|
|
|
|
n->child->string, n->child->next == NULL ?
|
|
|
|
NULL : n->child->next->string);
|
|
|
|
else
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2017-02-19 17:41:20 +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;
|
2017-02-19 17:41:20 +00:00
|
|
|
struct tag *t;
|
2017-01-21 13:01:39 +00:00
|
|
|
const char *cattr;
|
|
|
|
enum mdoc_list type;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
bl = n->parent;
|
2017-01-21 13:01:39 +00:00
|
|
|
while (bl != NULL && 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:
|
|
|
|
cattr = "It-bullet";
|
|
|
|
break;
|
|
|
|
case LIST_dash:
|
|
|
|
case LIST_hyphen:
|
|
|
|
cattr = "It-dash";
|
|
|
|
break;
|
|
|
|
case LIST_item:
|
|
|
|
cattr = "It-item";
|
|
|
|
break;
|
|
|
|
case LIST_enum:
|
|
|
|
cattr = "It-enum";
|
|
|
|
break;
|
|
|
|
case LIST_diag:
|
|
|
|
cattr = "It-diag";
|
|
|
|
break;
|
|
|
|
case LIST_hang:
|
|
|
|
cattr = "It-hang";
|
|
|
|
break;
|
|
|
|
case LIST_inset:
|
|
|
|
cattr = "It-inset";
|
|
|
|
break;
|
|
|
|
case LIST_ohang:
|
|
|
|
cattr = "It-ohang";
|
|
|
|
break;
|
|
|
|
case LIST_tag:
|
|
|
|
cattr = "It-tag";
|
|
|
|
break;
|
|
|
|
case LIST_column:
|
|
|
|
cattr = "It-column";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2012-10-18 09:55:16 +00:00
|
|
|
|
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:
|
|
|
|
if (bl->norm->Bl.comp)
|
|
|
|
print_otag(h, TAG_LI, "csvt", cattr, 0);
|
|
|
|
else
|
|
|
|
print_otag(h, TAG_LI, "c", cattr);
|
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:
|
|
|
|
if (bl->norm->Bl.comp)
|
|
|
|
print_otag(h, TAG_DT, "csvt", cattr, 0);
|
|
|
|
else
|
|
|
|
print_otag(h, TAG_DT, "c", cattr);
|
|
|
|
if (type == LIST_diag)
|
|
|
|
print_otag(h, TAG_B, "c", cattr);
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2017-01-21 13:01:39 +00:00
|
|
|
case ROFFT_BODY:
|
2017-02-19 17:41:20 +00:00
|
|
|
print_otag(h, TAG_DD, "cswl", cattr,
|
|
|
|
bl->norm->Bl.width);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case LIST_tag:
|
|
|
|
switch (n->type) {
|
|
|
|
case ROFFT_HEAD:
|
|
|
|
if (h->style != NULL && !bl->norm->Bl.comp &&
|
|
|
|
(n->parent->prev == NULL ||
|
|
|
|
n->parent->prev->body->child != NULL)) {
|
|
|
|
t = print_otag(h, TAG_DT, "csWl",
|
|
|
|
cattr, bl->norm->Bl.width);
|
|
|
|
print_text(h, "\\ ");
|
|
|
|
print_tagq(h, t);
|
|
|
|
t = print_otag(h, TAG_DD, "c", cattr);
|
|
|
|
print_text(h, "\\ ");
|
|
|
|
print_tagq(h, t);
|
|
|
|
}
|
|
|
|
print_otag(h, TAG_DT, "csWl", cattr,
|
|
|
|
bl->norm->Bl.width);
|
|
|
|
break;
|
|
|
|
case ROFFT_BODY:
|
|
|
|
if (n->child == NULL) {
|
|
|
|
print_otag(h, TAG_DD, "css?", cattr,
|
|
|
|
"width", "auto");
|
|
|
|
print_text(h, "\\ ");
|
|
|
|
} else
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_DD, "c", cattr);
|
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:
|
|
|
|
if (bl->norm->Bl.comp)
|
|
|
|
print_otag(h, TAG_TD, "csvt", cattr, 0);
|
|
|
|
else
|
|
|
|
print_otag(h, TAG_TD, "c", cattr);
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
2017-01-21 13:01:39 +00:00
|
|
|
default:
|
|
|
|
print_otag(h, TAG_TR, "c", cattr);
|
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)
|
|
|
|
{
|
2017-02-19 17:41:20 +00:00
|
|
|
struct tag *t;
|
|
|
|
struct mdoc_bl *bl;
|
2017-01-21 13:01:39 +00:00
|
|
|
const char *cattr;
|
2017-02-19 17:41:20 +00:00
|
|
|
size_t i;
|
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
|
|
|
bl = &n->norm->Bl;
|
|
|
|
|
|
|
|
switch (n->type) {
|
|
|
|
case ROFFT_BODY:
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-02-19 17:41:20 +00:00
|
|
|
case ROFFT_HEAD:
|
|
|
|
if (bl->type != LIST_column || bl->ncols == 0)
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For each column, print out the <COL> tag with our
|
|
|
|
* suggested width. The last column gets min-width, as
|
|
|
|
* in terminal mode it auto-sizes to the width of the
|
|
|
|
* screen and we want to preserve that behaviour.
|
|
|
|
*/
|
|
|
|
|
2017-02-19 17:41:20 +00:00
|
|
|
t = print_otag(h, TAG_COLGROUP, "");
|
|
|
|
for (i = 0; i < bl->ncols - 1; i++)
|
|
|
|
print_otag(h, TAG_COL, "sww", bl->cols[i]);
|
|
|
|
print_otag(h, TAG_COL, "swW", bl->cols[i]);
|
|
|
|
print_tagq(h, t);
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2017-02-19 17:41:20 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
cattr = "Bl-bullet";
|
|
|
|
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;
|
|
|
|
cattr = "Bl-dash";
|
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case LIST_item:
|
2017-01-21 13:01:39 +00:00
|
|
|
elemtype = TAG_UL;
|
|
|
|
cattr = "Bl-item";
|
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;
|
|
|
|
cattr = "Bl-enum";
|
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;
|
|
|
|
cattr = "Bl-diag";
|
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case LIST_hang:
|
2017-01-21 13:01:39 +00:00
|
|
|
elemtype = TAG_DL;
|
|
|
|
cattr = "Bl-hang";
|
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case LIST_inset:
|
2017-01-21 13:01:39 +00:00
|
|
|
elemtype = TAG_DL;
|
|
|
|
cattr = "Bl-inset";
|
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case LIST_ohang:
|
2017-01-21 13:01:39 +00:00
|
|
|
elemtype = TAG_DL;
|
|
|
|
cattr = "Bl-ohang";
|
|
|
|
break;
|
2014-11-22 18:08:25 +00:00
|
|
|
case LIST_tag:
|
2017-01-21 13:01:39 +00:00
|
|
|
cattr = "Bl-tag";
|
2017-02-19 17:41:20 +00:00
|
|
|
if (bl->offs)
|
|
|
|
print_otag(h, TAG_DIV, "cswl", cattr, bl->offs);
|
|
|
|
print_otag(h, TAG_DL, "cswl", cattr, bl->width);
|
|
|
|
return 1;
|
2014-11-22 18:08:25 +00:00
|
|
|
case LIST_column:
|
2017-01-21 13:01:39 +00:00
|
|
|
elemtype = TAG_TABLE;
|
|
|
|
cattr = "Bl-column";
|
2012-10-18 09:55:16 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
2017-02-19 17:41:20 +00:00
|
|
|
print_otag(h, elemtype, "cswl", cattr, bl->offs);
|
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)
|
|
|
|
{
|
|
|
|
if (n->prev)
|
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)
|
|
|
|
{
|
|
|
|
print_otag(h, TAG_SPAN, "c", "St");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-10-18 09:55:16 +00:00
|
|
|
static int
|
|
|
|
mdoc_em_pre(MDOC_ARGS)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_I, "c", "Em");
|
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)
|
|
|
|
{
|
2016-01-15 23:08:59 +00:00
|
|
|
if (n->type != ROFFT_BLOCK)
|
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_DIV, "c", "D1");
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
if (n->tok == MDOC_Dl)
|
|
|
|
print_otag(h, TAG_CODE, "c", "Li");
|
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_sx_pre(MDOC_ARGS)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
char *id;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-02-19 17:41:20 +00:00
|
|
|
id = make_id(n);
|
|
|
|
print_otag(h, TAG_A, "chR", "Sx", id);
|
|
|
|
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)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
int comp, offs, sv;
|
2016-01-15 23:08:59 +00:00
|
|
|
struct roff_node *nn;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
if (n->type == ROFFT_HEAD)
|
|
|
|
return 0;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
if (n->type == ROFFT_BLOCK) {
|
2012-10-18 09:55:16 +00:00
|
|
|
comp = n->norm->Bd.comp;
|
|
|
|
for (nn = n; nn && ! comp; nn = nn->parent) {
|
2016-01-15 23:08:59 +00:00
|
|
|
if (nn->type != ROFFT_BLOCK)
|
2012-10-18 09:55:16 +00:00
|
|
|
continue;
|
|
|
|
if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok)
|
|
|
|
comp = 1;
|
|
|
|
if (nn->prev)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ( ! comp)
|
2014-12-02 07:34:06 +00:00
|
|
|
print_paragraph(h);
|
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
|
|
|
/* Handle the -offset argument. */
|
|
|
|
|
|
|
|
if (n->norm->Bd.offs == NULL ||
|
|
|
|
! strcmp(n->norm->Bd.offs, "left"))
|
2017-01-21 13:01:39 +00:00
|
|
|
offs = 0;
|
2014-12-02 07:34:06 +00:00
|
|
|
else if ( ! strcmp(n->norm->Bd.offs, "indent"))
|
2017-01-21 13:01:39 +00:00
|
|
|
offs = INDENT;
|
2014-12-02 07:34:06 +00:00
|
|
|
else if ( ! strcmp(n->norm->Bd.offs, "indent-two"))
|
2017-01-21 13:01:39 +00:00
|
|
|
offs = INDENT * 2;
|
2014-12-02 07:34:06 +00:00
|
|
|
else
|
2017-01-21 13:01:39 +00:00
|
|
|
offs = -1;
|
2014-11-22 18:08:25 +00:00
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
if (offs == -1)
|
|
|
|
print_otag(h, TAG_DIV, "cswl", "Bd", n->norm->Bd.offs);
|
|
|
|
else
|
|
|
|
print_otag(h, TAG_DIV, "cshl", "Bd", offs);
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
if (n->norm->Bd.type != DISP_unfilled &&
|
|
|
|
n->norm->Bd.type != DISP_literal)
|
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
|
|
|
print_otag(h, TAG_PRE, "c", "Li");
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
/* This can be recursive: save & set our literal state. */
|
|
|
|
|
|
|
|
sv = h->flags & HTML_LITERAL;
|
|
|
|
h->flags |= HTML_LITERAL;
|
|
|
|
|
|
|
|
for (nn = n->child; nn; nn = nn->next) {
|
2014-01-31 19:59:03 +00:00
|
|
|
print_mdoc_node(meta, nn, h);
|
2012-10-18 09:55:16 +00:00
|
|
|
/*
|
|
|
|
* If the printed node flushes its own line, then we
|
|
|
|
* needn't do it here as well. This is hacky, but the
|
|
|
|
* notion of selective eoln whitespace is pretty dumb
|
|
|
|
* anyway, so don't sweat it.
|
|
|
|
*/
|
|
|
|
switch (nn->tok) {
|
2014-11-22 18:08:25 +00:00
|
|
|
case MDOC_Sm:
|
|
|
|
case MDOC_br:
|
|
|
|
case MDOC_sp:
|
|
|
|
case MDOC_Bl:
|
|
|
|
case MDOC_D1:
|
|
|
|
case MDOC_Dl:
|
|
|
|
case MDOC_Lp:
|
|
|
|
case MDOC_Pp:
|
2012-10-18 09:55:16 +00:00
|
|
|
continue;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-12-25 21:33:25 +00:00
|
|
|
if (h->flags & HTML_NONEWLINE ||
|
2017-01-21 13:01:39 +00:00
|
|
|
(nn->next && ! (nn->next->flags & NODE_LINE)))
|
2012-10-18 09:55:16 +00:00
|
|
|
continue;
|
|
|
|
else if (nn->next)
|
|
|
|
print_text(h, "\n");
|
|
|
|
|
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == sv)
|
|
|
|
h->flags &= ~HTML_LITERAL;
|
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_pa_pre(MDOC_ARGS)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_I, "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)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_I, "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
|
|
|
|
2017-01-21 13:01:39 +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);
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_B, "c", "Cd");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_dv_pre(MDOC_ARGS)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_CODE, "c", "Dv");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_ev_pre(MDOC_ARGS)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_CODE, "c", "Ev");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_er_pre(MDOC_ARGS)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_CODE, "c", "Er");
|
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) {
|
2017-02-19 17:41:20 +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
|
|
|
}
|
|
|
|
|
|
|
|
for (nn = n->child; nn; nn = nn->next) {
|
2017-02-19 17:41:20 +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);
|
|
|
|
if (nn->next) {
|
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
print_text(h, ",");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n->child && n->next && n->next->tok == MDOC_Fa) {
|
|
|
|
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")) {
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_B, "c", "Fd");
|
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
|
|
|
print_otag(h, TAG_B, "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';
|
|
|
|
t = print_otag(h, TAG_A, "chI", "In", buf);
|
|
|
|
free(buf);
|
|
|
|
} else
|
|
|
|
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
|
|
|
|
2017-02-19 17:41:20 +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);
|
2017-02-19 17:41:20 +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) {
|
2017-02-19 17:41:20 +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);
|
|
|
|
}
|
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
t = print_otag(h, TAG_B, "c", "Fn");
|
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)
|
2017-02-19 17:41:20 +00:00
|
|
|
t = print_otag(h, TAG_VAR, "css?", "Fa",
|
2017-01-21 13:01:39 +00:00
|
|
|
"white-space", "nowrap");
|
|
|
|
else
|
2017-02-19 17:41:20 +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)
|
|
|
|
{
|
|
|
|
|
2014-12-02 07:34:06 +00:00
|
|
|
print_paragraph(h);
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_sp_pre(MDOC_ARGS)
|
|
|
|
{
|
|
|
|
struct roffsu su;
|
|
|
|
|
|
|
|
SCALE_VS_INIT(&su, 1);
|
|
|
|
|
|
|
|
if (MDOC_sp == n->tok) {
|
2015-03-02 16:45:41 +00:00
|
|
|
if (NULL != (n = n->child)) {
|
2012-10-18 09:55:16 +00:00
|
|
|
if ( ! a2roffsu(n->string, &su, SCALE_VS))
|
2015-03-02 16:45:41 +00:00
|
|
|
su.scale = 1.0;
|
|
|
|
else if (su.scale < 0.0)
|
|
|
|
su.scale = 0.0;
|
|
|
|
}
|
2012-10-18 09:55:16 +00:00
|
|
|
} else
|
2014-11-22 18:08:25 +00:00
|
|
|
su.scale = 0.0;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_DIV, "suh", &su);
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
/* So the div isn't empty: */
|
|
|
|
print_text(h, "\\~");
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_A, "ch", "Lk", n->string);
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
if (NULL == n->next)
|
|
|
|
print_text(h, n->string);
|
|
|
|
|
|
|
|
for (n = n->next; n; n = n->next)
|
|
|
|
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_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);
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-01-21 13:01:39 +00:00
|
|
|
mandoc_asprintf(&cp, "mailto:%s", n->string);
|
|
|
|
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
|
|
|
}
|
2014-11-22 18:08:25 +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;
|
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
if (n->type == 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;
|
|
|
|
} else 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;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
if (n->child == NULL)
|
|
|
|
return 0;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
assert(n->child->string);
|
2017-01-21 13:01:39 +00:00
|
|
|
t = print_otag(h, TAG_B, "c", "Fn");
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, n->child->string);
|
|
|
|
print_tagq(h, t);
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
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);
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_B, "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)
|
|
|
|
t = print_otag(h, TAG_A, "chI", "In", n->string);
|
|
|
|
else
|
|
|
|
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_ic_pre(MDOC_ARGS)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_B, "c", "Ic");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_va_pre(MDOC_ARGS)
|
|
|
|
{
|
2017-02-19 17:41:20 +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)
|
|
|
|
{
|
2014-11-22 18:08:25 +00:00
|
|
|
|
2012-10-18 09:55:16 +00:00
|
|
|
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
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
if (n->type == ROFFT_HEAD)
|
|
|
|
return 0;
|
|
|
|
else if (n->type != ROFFT_BODY)
|
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2014-11-22 18:08:25 +00:00
|
|
|
if (FONT_Em == n->norm->Bf.font)
|
2017-01-21 13:01:39 +00:00
|
|
|
cattr = "Em";
|
2014-11-22 18:08:25 +00:00
|
|
|
else if (FONT_Sy == n->norm->Bf.font)
|
2017-01-21 13:01:39 +00:00
|
|
|
cattr = "Sy";
|
2014-11-22 18:08:25 +00:00
|
|
|
else if (FONT_Li == n->norm->Bf.font)
|
2017-01-21 13:01:39 +00:00
|
|
|
cattr = "Li";
|
2012-10-18 09:55:16 +00:00
|
|
|
else
|
2017-02-19 17:41:20 +00:00
|
|
|
cattr = "No";
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2014-11-22 18:08:25 +00:00
|
|
|
/*
|
2012-10-18 09:55:16 +00:00
|
|
|
* We want this to be inline-formatted, but needs to be div to
|
2014-11-22 18:08:25 +00:00
|
|
|
* accept block children.
|
2012-10-18 09:55:16 +00:00
|
|
|
*/
|
2017-01-21 13:01:39 +00:00
|
|
|
|
|
|
|
print_otag(h, TAG_DIV, "css?hl", cattr, "display", "inline", 1);
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdoc_ms_pre(MDOC_ARGS)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_B, "c", "Ms");
|
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)
|
|
|
|
{
|
2016-01-15 23:08:59 +00:00
|
|
|
if (n->type != ROFFT_BLOCK)
|
|
|
|
return 1;
|
2012-10-18 09:55:16 +00:00
|
|
|
|
|
|
|
if (n->prev && SEC_SEE_ALSO == n->sec)
|
2014-12-02 07:34:06 +00:00
|
|
|
print_paragraph(h);
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-02-19 17:41:20 +00:00
|
|
|
print_otag(h, TAG_CITE, "c", "Rs");
|
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)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_SPAN, "c", "No");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2014-12-02 07:34:06 +00:00
|
|
|
}
|
|
|
|
|
2012-10-18 09:55:16 +00:00
|
|
|
static int
|
|
|
|
mdoc_li_pre(MDOC_ARGS)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
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_sy_pre(MDOC_ARGS)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_B, "c", "Sy");
|
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)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
if (SEC_LIBRARY == n->sec && NODE_LINE & n->flags && n->prev)
|
|
|
|
print_otag(h, TAG_BR, "");
|
2012-10-18 09:55:16 +00:00
|
|
|
|
2017-01-21 13:01:39 +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)
|
|
|
|
{
|
2017-01-21 13:01:39 +00:00
|
|
|
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";
|
2012-10-18 09:55:16 +00:00
|
|
|
if (n->prev && MDOC__A == n->prev->tok)
|
|
|
|
if (NULL == n->next || MDOC__A != n->next->tok)
|
|
|
|
print_text(h, "and");
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (MDOC__A == n->tok && n->next && MDOC__A == n->next->tok)
|
|
|
|
if (NULL == n->next->next || MDOC__A != n->next->next->tok)
|
|
|
|
if (NULL == n->prev || MDOC__A != n->prev->tok)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* TODO: %U */
|
|
|
|
|
|
|
|
if (NULL == n->parent || MDOC_Rs != n->parent->tok)
|
|
|
|
return;
|
|
|
|
|
|
|
|
h->flags |= HTML_NOSPACE;
|
|
|
|
print_text(h, n->next ? "," : ".");
|
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
|
|
|
h->flags |= HTML_NOSPACE;
|
2017-01-21 13:01:39 +00:00
|
|
|
print_otag(h, TAG_SPAN, "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:
|
|
|
|
case MDOC_Qo:
|
|
|
|
case MDOC_Qq:
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, "\\(lq");
|
|
|
|
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_Qo:
|
|
|
|
case MDOC_Qq:
|
|
|
|
case MDOC_Do:
|
|
|
|
case MDOC_Dq:
|
2012-10-18 09:55:16 +00:00
|
|
|
print_text(h, "\\(rq");
|
|
|
|
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;
|
|
|
|
}
|