summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mdoc_html.c355
1 files changed, 142 insertions, 213 deletions
diff --git a/mdoc_html.c b/mdoc_html.c
index ad5b0872..dc5ced4b 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -67,8 +67,6 @@ 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 void mdoc_aq_post(MDOC_ARGS);
-static int mdoc_aq_pre(MDOC_ARGS);
static int mdoc_ar_pre(MDOC_ARGS);
static int mdoc_bd_pre(MDOC_ARGS);
static int mdoc_bf_pre(MDOC_ARGS);
@@ -76,16 +74,10 @@ static void mdoc_bk_post(MDOC_ARGS);
static int mdoc_bk_pre(MDOC_ARGS);
static void mdoc_bl_post(MDOC_ARGS);
static int mdoc_bl_pre(MDOC_ARGS);
-static void mdoc_bq_post(MDOC_ARGS);
-static int mdoc_bq_pre(MDOC_ARGS);
-static void mdoc_brq_post(MDOC_ARGS);
-static int mdoc_brq_pre(MDOC_ARGS);
static int mdoc_bt_pre(MDOC_ARGS);
static int mdoc_bx_pre(MDOC_ARGS);
static int mdoc_cd_pre(MDOC_ARGS);
static int mdoc_d1_pre(MDOC_ARGS);
-static void mdoc_dq_post(MDOC_ARGS);
-static int mdoc_dq_pre(MDOC_ARGS);
static int mdoc_dv_pre(MDOC_ARGS);
static int mdoc_fa_pre(MDOC_ARGS);
static int mdoc_fd_pre(MDOC_ARGS);
@@ -115,20 +107,16 @@ static int mdoc_ms_pre(MDOC_ARGS);
static int mdoc_nd_pre(MDOC_ARGS);
static int mdoc_nm_pre(MDOC_ARGS);
static int mdoc_ns_pre(MDOC_ARGS);
-static void mdoc_op_post(MDOC_ARGS);
-static int mdoc_op_pre(MDOC_ARGS);
static int mdoc_pa_pre(MDOC_ARGS);
static void mdoc_pf_post(MDOC_ARGS);
static int mdoc_pf_pre(MDOC_ARGS);
-static void mdoc_pq_post(MDOC_ARGS);
-static int mdoc_pq_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_rv_pre(MDOC_ARGS);
static int mdoc_sh_pre(MDOC_ARGS);
static int mdoc_sm_pre(MDOC_ARGS);
static int mdoc_sp_pre(MDOC_ARGS);
-static void mdoc_sq_post(MDOC_ARGS);
-static int mdoc_sq_pre(MDOC_ARGS);
static int mdoc_ss_pre(MDOC_ARGS);
static int mdoc_sx_pre(MDOC_ARGS);
static int mdoc_sy_pre(MDOC_ARGS);
@@ -172,7 +160,7 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = {
{mdoc_li_pre, NULL}, /* Li */
{mdoc_nd_pre, NULL}, /* Nd */
{mdoc_nm_pre, NULL}, /* Nm */
- {mdoc_op_pre, mdoc_op_post}, /* Op */
+ {mdoc_quote_pre, mdoc_quote_post}, /* Op */
{NULL, NULL}, /* Ot */
{mdoc_pa_pre, NULL}, /* Pa */
{mdoc_rv_pre, NULL}, /* Rv */
@@ -192,19 +180,19 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = {
{mdoc__x_pre, mdoc__x_post}, /* %T */
{mdoc__x_pre, mdoc__x_post}, /* %V */
{NULL, NULL}, /* Ac */
- {mdoc_aq_pre, mdoc_aq_post}, /* Ao */
- {mdoc_aq_pre, mdoc_aq_post}, /* Aq */
+ {mdoc_quote_pre, mdoc_quote_post}, /* Ao */
+ {mdoc_quote_pre, mdoc_quote_post}, /* Aq */
{NULL, NULL}, /* At */
{NULL, NULL}, /* Bc */
{mdoc_bf_pre, NULL}, /* Bf */
- {mdoc_bq_pre, mdoc_bq_post}, /* Bo */
- {mdoc_bq_pre, mdoc_bq_post}, /* Bq */
+ {mdoc_quote_pre, mdoc_quote_post}, /* Bo */
+ {mdoc_quote_pre, mdoc_quote_post}, /* Bq */
{mdoc_xx_pre, NULL}, /* Bsx */
{mdoc_bx_pre, NULL}, /* Bx */
{NULL, NULL}, /* Db */
{NULL, NULL}, /* Dc */
- {mdoc_dq_pre, mdoc_dq_post}, /* Do */
- {mdoc_dq_pre, mdoc_dq_post}, /* Dq */
+ {mdoc_quote_pre, mdoc_quote_post}, /* Do */
+ {mdoc_quote_pre, mdoc_quote_post}, /* Dq */
{NULL, NULL}, /* Ec */ /* FIXME: no space */
{NULL, NULL}, /* Ef */
{mdoc_em_pre, NULL}, /* Em */
@@ -217,17 +205,17 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = {
{mdoc_xx_pre, NULL}, /* Ox */
{NULL, NULL}, /* Pc */
{mdoc_pf_pre, mdoc_pf_post}, /* Pf */
- {mdoc_pq_pre, mdoc_pq_post}, /* Po */
- {mdoc_pq_pre, mdoc_pq_post}, /* Pq */
+ {mdoc_quote_pre, mdoc_quote_post}, /* Po */
+ {mdoc_quote_pre, mdoc_quote_post}, /* Pq */
{NULL, NULL}, /* Qc */
- {mdoc_sq_pre, mdoc_sq_post}, /* Ql */
- {mdoc_dq_pre, mdoc_dq_post}, /* Qo */
- {mdoc_dq_pre, mdoc_dq_post}, /* Qq */
+ {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_sq_pre, mdoc_sq_post}, /* So */
- {mdoc_sq_pre, mdoc_sq_post}, /* Sq */
+ {mdoc_quote_pre, mdoc_quote_post}, /* So */
+ {mdoc_quote_pre, mdoc_quote_post}, /* Sq */
{mdoc_sm_pre, NULL}, /* Sm */
{mdoc_sx_pre, NULL}, /* Sx */
{mdoc_sy_pre, NULL}, /* Sy */
@@ -237,7 +225,7 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = {
{NULL, NULL}, /* Xo */
{mdoc_fo_pre, mdoc_fo_post}, /* Fo */
{NULL, NULL}, /* Fc */
- {mdoc_op_pre, mdoc_op_post}, /* Oo */
+ {mdoc_quote_pre, mdoc_quote_post}, /* Oo */
{NULL, NULL}, /* Oc */
{mdoc_bk_pre, mdoc_bk_post}, /* Bk */
{NULL, NULL}, /* Ek */
@@ -249,8 +237,8 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = {
{mdoc_sp_pre, NULL}, /* Lp */
{mdoc_lk_pre, NULL}, /* Lk */
{mdoc_mt_pre, NULL}, /* Mt */
- {mdoc_brq_pre, mdoc_brq_post}, /* Brq */
- {mdoc_brq_pre, mdoc_brq_post}, /* Bro */
+ {mdoc_quote_pre, mdoc_quote_post}, /* Brq */
+ {mdoc_quote_pre, mdoc_quote_post}, /* Bro */
{NULL, NULL}, /* Brc */
{mdoc__x_pre, mdoc__x_post}, /* %C */
{NULL, NULL}, /* Es */ /* TODO */
@@ -716,37 +704,6 @@ mdoc_nd_pre(MDOC_ARGS)
}
-/* ARGSUSED */
-static int
-mdoc_op_pre(MDOC_ARGS)
-{
- struct htmlpair tag;
-
- if (MDOC_BODY != n->type)
- return(1);
-
- /* XXX: this tag in theory can contain block elements. */
-
- print_text(h, "\\(lB");
- h->flags |= HTML_NOSPACE;
- PAIR_CLASS_INIT(&tag, "opt");
- print_otag(h, TAG_SPAN, 1, &tag);
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-mdoc_op_post(MDOC_ARGS)
-{
-
- if (MDOC_BODY != n->type)
- return;
- h->flags |= HTML_NOSPACE;
- print_text(h, "\\(rB");
-}
-
-
static int
mdoc_nm_pre(MDOC_ARGS)
{
@@ -1249,80 +1206,6 @@ mdoc_ex_pre(MDOC_ARGS)
/* ARGSUSED */
static int
-mdoc_dq_pre(MDOC_ARGS)
-{
-
- if (MDOC_BODY != n->type)
- return(1);
- print_text(h, "\\(lq");
- h->flags |= HTML_NOSPACE;
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-mdoc_dq_post(MDOC_ARGS)
-{
-
- if (MDOC_BODY != n->type)
- return;
- h->flags |= HTML_NOSPACE;
- print_text(h, "\\(rq");
-}
-
-
-/* ARGSUSED */
-static int
-mdoc_pq_pre(MDOC_ARGS)
-{
-
- if (MDOC_BODY != n->type)
- return(1);
- print_text(h, "\\&(");
- h->flags |= HTML_NOSPACE;
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-mdoc_pq_post(MDOC_ARGS)
-{
-
- if (MDOC_BODY != n->type)
- return;
- print_text(h, ")");
-}
-
-
-/* ARGSUSED */
-static int
-mdoc_sq_pre(MDOC_ARGS)
-{
-
- if (MDOC_BODY != n->type)
- return(1);
- print_text(h, "\\(oq");
- h->flags |= HTML_NOSPACE;
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-mdoc_sq_post(MDOC_ARGS)
-{
-
- if (MDOC_BODY != n->type)
- return;
- h->flags |= HTML_NOSPACE;
- print_text(h, "\\(aq");
-}
-
-
-/* ARGSUSED */
-static int
mdoc_em_pre(MDOC_ARGS)
{
struct htmlpair tag;
@@ -1379,31 +1262,6 @@ mdoc_sx_pre(MDOC_ARGS)
/* ARGSUSED */
static int
-mdoc_aq_pre(MDOC_ARGS)
-{
-
- if (MDOC_BODY != n->type)
- return(1);
- print_text(h, "\\(la");
- h->flags |= HTML_NOSPACE;
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-mdoc_aq_post(MDOC_ARGS)
-{
-
- if (MDOC_BODY != n->type)
- return;
- h->flags |= HTML_NOSPACE;
- print_text(h, "\\(ra");
-}
-
-
-/* ARGSUSED */
-static int
mdoc_bd_pre(MDOC_ARGS)
{
struct htmlpair tag[2];
@@ -1775,31 +1633,6 @@ mdoc_sp_pre(MDOC_ARGS)
/* ARGSUSED */
static int
-mdoc_brq_pre(MDOC_ARGS)
-{
-
- if (MDOC_BODY != n->type)
- return(1);
- print_text(h, "\\(lC");
- h->flags |= HTML_NOSPACE;
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-mdoc_brq_post(MDOC_ARGS)
-{
-
- if (MDOC_BODY != n->type)
- return;
- h->flags |= HTML_NOSPACE;
- print_text(h, "\\(rC");
-}
-
-
-/* ARGSUSED */
-static int
mdoc_lk_pre(MDOC_ARGS)
{
const struct mdoc_node *nn;
@@ -1882,9 +1715,7 @@ mdoc_fo_post(MDOC_ARGS)
if (MDOC_BODY != n->type)
return;
- h->flags |= HTML_NOSPACE;
print_text(h, ")");
- h->flags |= HTML_NOSPACE;
print_text(h, ";");
}
@@ -1999,31 +1830,6 @@ mdoc_va_pre(MDOC_ARGS)
/* ARGSUSED */
static int
-mdoc_bq_pre(MDOC_ARGS)
-{
-
- if (MDOC_BODY != n->type)
- return(1);
- print_text(h, "\\(lB");
- h->flags |= HTML_NOSPACE;
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-mdoc_bq_post(MDOC_ARGS)
-{
-
- if (MDOC_BODY != n->type)
- return;
- h->flags |= HTML_NOSPACE;
- print_text(h, "\\(rB");
-}
-
-
-/* ARGSUSED */
-static int
mdoc_ap_pre(MDOC_ARGS)
{
@@ -2300,3 +2106,126 @@ mdoc_bk_post(MDOC_ARGS)
if (MDOC_BODY == n->type)
h->flags &= ~(HTML_KEEP | HTML_PREKEEP);
}
+
+
+/* ARGSUSED */
+static int
+mdoc_quote_pre(MDOC_ARGS)
+{
+ struct htmlpair tag;
+
+ if (MDOC_BODY != n->type)
+ return(1);
+
+ switch (n->tok) {
+ case (MDOC_Ao):
+ /* FALLTHROUGH */
+ case (MDOC_Aq):
+ print_text(h, "\\(la");
+ break;
+ case (MDOC_Bro):
+ /* FALLTHROUGH */
+ case (MDOC_Brq):
+ print_text(h, "\\(lC");
+ break;
+ case (MDOC_Bo):
+ /* FALLTHROUGH */
+ case (MDOC_Bq):
+ print_text(h, "\\(lB");
+ break;
+ case (MDOC_Oo):
+ /* FALLTHROUGH */
+ case (MDOC_Op):
+ print_text(h, "\\(lB");
+ PAIR_CLASS_INIT(&tag, "opt");
+ print_otag(h, TAG_SPAN, 1, &tag);
+ break;
+ case (MDOC_Do):
+ /* FALLTHROUGH */
+ case (MDOC_Dq):
+ /* FALLTHROUGH */
+ case (MDOC_Qo):
+ /* FALLTHROUGH */
+ case (MDOC_Qq):
+ print_text(h, "\\(lq");
+ break;
+ case (MDOC_Po):
+ /* FALLTHROUGH */
+ case (MDOC_Pq):
+ print_text(h, "(");
+ break;
+ case (MDOC_Ql):
+ /* FALLTHROUGH */
+ case (MDOC_So):
+ /* FALLTHROUGH */
+ case (MDOC_Sq):
+ print_text(h, "\\(oq");
+ break;
+ default:
+ abort();
+ /* NOTREACHED */
+ }
+
+ h->flags |= HTML_NOSPACE;
+ return(1);
+}
+
+
+/* ARGSUSED */
+static void
+mdoc_quote_post(MDOC_ARGS)
+{
+
+ if (MDOC_BODY != n->type)
+ return;
+
+ h->flags |= HTML_NOSPACE;
+
+ switch (n->tok) {
+ case (MDOC_Ao):
+ /* FALLTHROUGH */
+ case (MDOC_Aq):
+ print_text(h, "\\(ra");
+ break;
+ case (MDOC_Bro):
+ /* FALLTHROUGH */
+ case (MDOC_Brq):
+ print_text(h, "\\(rC");
+ break;
+ case (MDOC_Oo):
+ /* FALLTHROUGH */
+ case (MDOC_Op):
+ /* FALLTHROUGH */
+ case (MDOC_Bo):
+ /* FALLTHROUGH */
+ case (MDOC_Bq):
+ print_text(h, "\\(rB");
+ break;
+ case (MDOC_Qo):
+ /* FALLTHROUGH */
+ case (MDOC_Qq):
+ /* FALLTHROUGH */
+ case (MDOC_Do):
+ /* FALLTHROUGH */
+ case (MDOC_Dq):
+ print_text(h, "\\(rq");
+ break;
+ case (MDOC_Po):
+ /* FALLTHROUGH */
+ case (MDOC_Pq):
+ print_text(h, ")");
+ break;
+ case (MDOC_Ql):
+ /* FALLTHROUGH */
+ case (MDOC_So):
+ /* FALLTHROUGH */
+ case (MDOC_Sq):
+ print_text(h, "\\(aq");
+ break;
+ default:
+ abort();
+ /* NOTREACHED */
+ }
+}
+
+