summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--example.style.css6
-rw-r--r--html.c5
-rw-r--r--html.h3
-rw-r--r--mdoc_html.c176
-rw-r--r--mdoc_term.c6
5 files changed, 153 insertions, 43 deletions
diff --git a/example.style.css b/example.style.css
index ff7833df..9a4da78d 100644
--- a/example.style.css
+++ b/example.style.css
@@ -26,9 +26,11 @@ span.fname { text-decoration: underline; } /* Function name (Fa, Fn, Rv). */
span.file { font-style: italic; } /* File (Pa). */
span.flag { font-weight: bold; } /* Flag (Fl, Cm). */
span.includes { font-weight: bold; } /* Header includes (In). */
+span.lit { font-family: monospace; } /* Literals (Bf -literal). */
span.macro { } /* Macro-ish thing (Fd). */
span.name { font-weight: bold; } /* Name of utility (Nm). */
span.opt { } /* Options (Op, Oo/Oc). */
+span.symb { font-weight: bold; } /* Symbols. */
span.type { font-style: italic; } /* Variable types (Vt, Ft, Fn). */
span.unix { } /* Unices (Ux, Ox, Nx, Fx, Bx, Bsx, Dx). */
span.utility { font-weight: bold; } /* Name of utility (Ex). */
@@ -39,7 +41,9 @@ a.link-sec { } /* Section links (Sx). */
a.link-mail { } /* Mailto links (Mt). */
a.link-ext { } /* Off-site link (Lk). */
-div.lit-block { font-family: monospace; } /* Literal block (D1, Bd -literal, Dl). */
+div.lit { font-family: monospace; } /* Literal (D1, Bd -literal, Dl, Bd -literal). */
+div.emph { font-style: italic; } /* Emphasis (Bl -emphasis). */
+div.symb { font-weight: bold; } /* Symbols (Bl -symbolic). */
table.header { } /* Document header. */
table.footer { } /* Document footer. */
diff --git a/html.c b/html.c
index 9070e825..426624a4 100644
--- a/html.c
+++ b/html.c
@@ -1,4 +1,4 @@
-/* $Id: html.c,v 1.51 2009/09/21 14:56:56 kristaps Exp $ */
+/* $Id: html.c,v 1.52 2009/09/24 09:50:31 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -424,7 +424,8 @@ print_text(struct html *h, const char *p)
case(']'):
/* FALLTHROUGH */
case('}'):
- h->flags |= HTML_NOSPACE;
+ if ( ! (HTML_IGNDELIM & h->flags))
+ h->flags |= HTML_NOSPACE;
break;
default:
break;
diff --git a/html.h b/html.h
index 92dc5524..a776f466 100644
--- a/html.h
+++ b/html.h
@@ -1,4 +1,4 @@
-/* $Id: html.h,v 1.6 2009/09/21 14:56:56 kristaps Exp $ */
+/* $Id: html.h,v 1.7 2009/09/24 09:50:31 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -82,6 +82,7 @@ struct html {
int flags;
#define HTML_NOSPACE (1 << 0)
#define HTML_NEWLINE (1 << 1)
+#define HTML_IGNDELIM (1 << 2)
struct tagq tags;
struct ordq ords;
void *symtab;
diff --git a/mdoc_html.c b/mdoc_html.c
index 79bb7873..20d589e0 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.4 2009/09/24 09:20:02 kristaps Exp $ */
+/* $Id: mdoc_html.c,v 1.5 2009/09/24 09:50:31 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -61,10 +61,12 @@ static int mdoc_tbl_head_pre(MDOC_ARGS, int, int);
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);
static void mdoc_bl_post(MDOC_ARGS);
static int mdoc_bl_pre(MDOC_ARGS);
static void mdoc_bq_post(MDOC_ARGS);
@@ -93,16 +95,18 @@ static int mdoc_in_pre(MDOC_ARGS);
static int mdoc_it_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);
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_qq_post(MDOC_ARGS);
-static int mdoc_qq_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_sp_pre(MDOC_ARGS);
@@ -121,7 +125,7 @@ extern size_t strlcat(char *, const char *, size_t);
#endif
static const struct htmlmdoc mdocs[MDOC_MAX] = {
- {NULL, NULL}, /* Ap */
+ {mdoc_ap_pre, NULL}, /* Ap */
{NULL, NULL}, /* Dd */
{NULL, NULL}, /* Dt */
{NULL, NULL}, /* Os */
@@ -178,7 +182,7 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = {
{mdoc_aq_pre, mdoc_aq_post}, /* Aq */
{NULL, NULL}, /* At */
{NULL, NULL}, /* Bc */
- {NULL, NULL}, /* Bf */
+ {mdoc_bf_pre, NULL}, /* Bf */
{mdoc_bq_pre, mdoc_bq_post}, /* Bo */
{mdoc_bq_pre, mdoc_bq_post}, /* Bq */
{mdoc_xx_pre, NULL}, /* Bsx */
@@ -192,21 +196,21 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = {
{mdoc_em_pre, NULL}, /* Em */
{NULL, NULL}, /* Eo */
{mdoc_xx_pre, NULL}, /* Fx */
- {NULL, NULL}, /* Ms */
+ {mdoc_ms_pre, NULL}, /* Ms */ /* FIXME: convert to symbol? */
{NULL, NULL}, /* No */
{mdoc_ns_pre, NULL}, /* Ns */
{mdoc_xx_pre, NULL}, /* Nx */
{mdoc_xx_pre, NULL}, /* Ox */
{NULL, NULL}, /* Pc */
- {NULL, NULL}, /* Pf */
+ {mdoc_pf_pre, mdoc_pf_post}, /* Pf */
{mdoc_pq_pre, mdoc_pq_post}, /* Po */
{mdoc_pq_pre, mdoc_pq_post}, /* Pq */
{NULL, NULL}, /* Qc */
{mdoc_sq_pre, mdoc_sq_post}, /* Ql */
- {mdoc_qq_pre, mdoc_qq_post}, /* Qo */
- {mdoc_qq_pre, mdoc_qq_post}, /* Qq */
+ {mdoc_dq_pre, mdoc_dq_post}, /* Qo */
+ {mdoc_dq_pre, mdoc_dq_post}, /* Qq */
{NULL, NULL}, /* Re */
- {NULL, NULL}, /* Rs */
+ {mdoc_rs_pre, NULL}, /* Rs */
{NULL, NULL}, /* Sc */
{mdoc_sq_pre, mdoc_sq_post}, /* So */
{mdoc_sq_pre, mdoc_sq_post}, /* Sq */
@@ -1234,7 +1238,7 @@ mdoc_d1_pre(MDOC_ARGS)
buffmt("margin-left: %dem;", INDENT);
tag[0].key = ATTR_CLASS;
- tag[0].val = "lit-block";
+ tag[0].val = "lit";
tag[1].key = ATTR_STYLE;
tag[1].val = buf;
@@ -1353,7 +1357,7 @@ mdoc_bd_pre(MDOC_ARGS)
tag[0].key = ATTR_STYLE;
tag[0].val = buf;
tag[1].key = ATTR_CLASS;
- tag[1].val = "lit-block";
+ tag[1].val = "lit";
print_otag(h, TAG_DIV, 2, tag);
@@ -1384,31 +1388,6 @@ mdoc_pa_pre(MDOC_ARGS)
/* ARGSUSED */
static int
-mdoc_qq_pre(MDOC_ARGS)
-{
-
- if (MDOC_BODY != n->type)
- return(1);
- print_text(h, "\\*q");
- h->flags |= HTML_NOSPACE;
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-mdoc_qq_post(MDOC_ARGS)
-{
-
- if (MDOC_BODY != n->type)
- return;
- h->flags |= HTML_NOSPACE;
- print_text(h, "\\*q");
-}
-
-
-/* ARGSUSED */
-static int
mdoc_ad_pre(MDOC_ARGS)
{
struct htmlpair tag;
@@ -1906,3 +1885,126 @@ mdoc_bq_post(MDOC_ARGS)
h->flags |= HTML_NOSPACE;
print_text(h, "\\(rB");
}
+
+
+/* ARGSUSED */
+static int
+mdoc_ap_pre(MDOC_ARGS)
+{
+
+ h->flags |= HTML_NOSPACE;
+ print_text(h, "\\(aq");
+ h->flags |= HTML_NOSPACE;
+ return(1);
+}
+
+
+/* ARGSUSED */
+static int
+mdoc_bf_pre(MDOC_ARGS)
+{
+ int i;
+ struct htmlpair tag[2];
+
+ if (MDOC_HEAD == n->type)
+ return(0);
+ else if (MDOC_BLOCK != n->type)
+ return(1);
+
+ tag[0].key = ATTR_CLASS;
+ tag[0].val = NULL;
+
+ if (n->head->child) {
+ if ( ! strcmp("Em", n->head->child->string))
+ tag[0].val = "emph";
+ else if ( ! strcmp("Sy", n->head->child->string))
+ tag[0].val = "symb";
+ else if ( ! strcmp("Li", n->head->child->string))
+ tag[0].val = "lit";
+ } else {
+ assert(n->args);
+ for (i = 0; i < (int)n->args->argc; i++)
+ switch (n->args->argv[i].arg) {
+ case (MDOC_Symbolic):
+ tag[0].val = "symb";
+ break;
+ case (MDOC_Literal):
+ tag[0].val = "lit";
+ break;
+ case (MDOC_Emphasis):
+ tag[0].val = "emph";
+ break;
+ default:
+ break;
+ }
+ }
+
+ /* FIXME: div's have spaces stripped--we want them. */
+
+ assert(tag[0].val);
+ tag[1].key = ATTR_STYLE;
+ tag[1].val = "display: inline; margin-right: 1em;";
+ print_otag(h, TAG_DIV, 2, tag);
+ return(1);
+}
+
+
+/* ARGSUSED */
+static int
+mdoc_ms_pre(MDOC_ARGS)
+{
+ struct htmlpair tag;
+
+ tag.key = ATTR_CLASS;
+ tag.val = "symb";
+ print_otag(h, TAG_SPAN, 1, &tag);
+ return(1);
+}
+
+
+/* ARGSUSED */
+static int
+mdoc_pf_pre(MDOC_ARGS)
+{
+
+ h->flags |= HTML_IGNDELIM;
+ return(1);
+}
+
+
+/* ARGSUSED */
+static void
+mdoc_pf_post(MDOC_ARGS)
+{
+
+ h->flags &= ~HTML_IGNDELIM;
+ h->flags |= HTML_NOSPACE;
+}
+
+
+/* ARGSUSED */
+static int
+mdoc_rs_pre(MDOC_ARGS)
+{
+ struct htmlpair tag[2];
+ int i;
+
+ if (MDOC_BLOCK != n->type)
+ return(1);
+
+ tag[i = 0].key = ATTR_CLASS;
+ tag[i++].val = "ref";
+
+ if (n->prev && SEC_SYNOPSIS == n->sec) {
+ tag[i].key = ATTR_STYLE;
+ tag[i++].val = "margin-top: 1em;";
+ } else if (SEC_SYNOPSIS != n->sec) {
+ tag[i].key = ATTR_STYLE;
+ tag[i++].val = "display: inline; margin-right: 1em";
+ }
+
+ /* FIXME: div's have spaces stripped--we want them. */
+
+ print_otag(h, TAG_DIV, i, tag);
+ return(1);
+}
diff --git a/mdoc_term.c b/mdoc_term.c
index 998607c1..8bc65123 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.79 2009/09/24 09:20:02 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.80 2009/09/24 09:50:31 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -218,7 +218,7 @@ static const struct termact termacts[MDOC_MAX] = {
{ termp_under_pre, NULL }, /* Em */
{ NULL, NULL }, /* Eo */
{ termp_xx_pre, NULL }, /* Fx */
- { termp_bold_pre, NULL }, /* Ms */
+ { termp_bold_pre, NULL }, /* Ms */ /* FIXME: convert to symbol? */
{ NULL, NULL }, /* No */
{ termp_ns_pre, NULL }, /* Ns */
{ termp_xx_pre, NULL }, /* Nx */
@@ -1164,6 +1164,8 @@ static int
termp_rs_pre(DECL_ARGS)
{
+ if (SEC_SEE_ALSO != node->sec)
+ return(1);
if (MDOC_BLOCK == node->type && node->prev)
term_vspace(p);
return(1);