* mdocml: Make SYNOPSIS `Nm' use a TABLE in -T[x]html mode.
@ 2010-12-17 1:02 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2010-12-17 1:02 UTC (permalink / raw)
To: source
Log Message:
-----------
Make SYNOPSIS `Nm' use a TABLE in -T[x]html mode. Also fix `Nd' using
desc-body instead of desc as its CSS key.
Modified Files:
--------------
mdocml:
example.style.css
mdoc_html.c
Revision Data
-------------
Index: mdoc_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_html.c,v
retrieving revision 1.123
retrieving revision 1.124
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.123 -r1.124
--- mdoc_html.c
+++ mdoc_html.c
@@ -644,7 +644,7 @@ mdoc_nd_pre(MDOC_ARGS)
/* XXX: this tag in theory can contain block elements. */
print_text(h, "\\(em");
- PAIR_CLASS_INIT(&tag, "desc-body");
+ PAIR_CLASS_INIT(&tag, "desc");
print_otag(h, TAG_SPAN, 1, &tag);
return(1);
}
@@ -655,68 +655,46 @@ mdoc_nm_pre(MDOC_ARGS)
{
struct htmlpair tag;
struct roffsu su;
- const char *cp;
+ size_t len;
- /*
- * Accomodate for `Nm' being both an element (which may have
- * NULL children AND no m->name) and a block.
- */
-
- cp = NULL;
-
- if (MDOC_ELEM == n->type) {
- if (NULL == n->child && NULL == m->name)
- return(1);
+ switch (n->type) {
+ case (MDOC_ELEM):
synopsis_pre(h, n);
PAIR_CLASS_INIT(&tag, "name");
print_otag(h, TAG_SPAN, 1, &tag);
- if (NULL == n->child)
+ if (NULL == n->child && m->name)
print_text(h, m->name);
- } else if (MDOC_BLOCK == n->type) {
- synopsis_pre(h, n);
-
- bufcat_style(h, "clear", "both");
- if (n->head->child || m->name) {
- if (n->head->child && MDOC_TEXT ==
- n->head->child->type)
- cp = n->head->child->string;
- if (NULL == cp || '\0' == *cp)
- cp = m->name;
-
- SCALE_HS_INIT(&su, (double)strlen(cp));
- bufcat_su(h, "padding-left", &su);
- }
-
- PAIR_STYLE_INIT(&tag, h);
- print_otag(h, TAG_DIV, 1, &tag);
- } else if (MDOC_HEAD == n->type) {
- if (NULL == n->child && NULL == m->name)
- return(1);
-
- if (n->child && MDOC_TEXT == n->child->type)
- cp = n->child->string;
- if (NULL == cp || '\0' == *cp)
- cp = m->name;
-
- SCALE_HS_INIT(&su, (double)strlen(cp));
-
- bufcat_style(h, "float", "left");
- bufcat_su(h, "min-width", &su);
- SCALE_INVERT(&su);
- bufcat_su(h, "margin-left", &su);
-
- PAIR_STYLE_INIT(&tag, h);
- print_otag(h, TAG_DIV, 1, &tag);
-
- if (NULL == n->child)
+ return(1);
+ case (MDOC_HEAD):
+ print_otag(h, TAG_TD, 0, NULL);
+ if (NULL == n->child && m->name)
print_text(h, m->name);
- } else if (MDOC_BODY == n->type) {
- SCALE_HS_INIT(&su, 2);
- bufcat_su(h, "margin-left", &su);
- PAIR_STYLE_INIT(&tag, h);
- print_otag(h, TAG_DIV, 1, &tag);
+ return(1);
+ case (MDOC_BODY):
+ print_otag(h, TAG_TD, 0, NULL);
+ return(1);
+ default:
+ break;
}
+ synopsis_pre(h, n);
+ PAIR_CLASS_INIT(&tag, "synopsis");
+ print_otag(h, TAG_TABLE, 1, &tag);
+
+ for (len = 0, n = n->child; n; n = n->next)
+ if (MDOC_TEXT == n->type)
+ len += strlen(n->string);
+
+ if (0 == len && m->name)
+ len = strlen(m->name);
+
+ SCALE_HS_INIT(&su, (double)len);
+ bufcat_su(h, "width", &su);
+ PAIR_STYLE_INIT(&tag, h);
+ print_otag(h, TAG_COL, 1, &tag);
+ print_otag(h, TAG_COL, 0, NULL);
+ print_otag(h, TAG_TBODY, 0, NULL);
+ print_otag(h, TAG_TR, 0, NULL);
return(1);
}
Index: example.style.css
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/example.style.css,v
retrieving revision 1.28
retrieving revision 1.29
diff -Lexample.style.css -Lexample.style.css -u -p -r1.28 -r1.29
--- example.style.css
+++ example.style.css
@@ -3,12 +3,19 @@
html { min-width: 580px; width: 580px; }
body { font-family: monospace; }
+/* Preamble structure. */
+
+table.footer { } /* Document footer. */
+table.header { } /* Document header. */
+
/* Sections. */
h1 { font-size: medium; margin-left: -4ex; } /* Section header (Sh, SH). */
h2 { font-size: medium; margin-left: -2ex; } /* Sub-section header (Ss, SS). */
div.section { margin-bottom: 3ex; margin-left: 4ex; } /* Sections (Sh, SH). */
div.subsection { } /* Sub-sections (Ss, SS). */
+table.synopsis { } /* SYNOPSIS section table. */
+table.synopsis td { vertical-align: top; } /* SYNOPSIS section table. */
/* Vertical spacing. */
@@ -71,9 +78,6 @@ a.link-mail { } /* Mailto links (Mt). */
a.link-man { } /* Manual links (Xr). */
a.link-ref { } /* Reference section links (%Q). */
a.link-sec { } /* Section links (Sx). */
-
-table.footer { } /* Document footer. */
-table.header { } /* Document header. */
/* Formatting for lists. */
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-12-17 1:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-17 1:02 mdocml: Make SYNOPSIS `Nm' use a TABLE in -T[x]html mode kristaps
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).