[prev in list] [next in list] [prev in thread] [next in thread]
List: mandoc-source
Subject: mdocml: Improve HTML formatting of .Bl -tag.
From: schwarze () mdocml ! bsd ! lv
Date: 2017-01-25 2:15:13
Message-ID: 11763686238154285192.enqueue () fantadrom ! bsd ! lv
[Download RAW message or body]
Log Message:
-----------
Improve HTML formatting of .Bl -tag.
In particular, when using the style sheet, put the body on the same
line as the head for short heads, or on the next line for long
heads, in a way that preserves both correct indentation and correct
vertical spacing with and without -compact, and with one or more
heads per body (hi, Zaphod) - eight use cases so far - and with and
without -tag, and with and without -offset, 32 use cases grand total.
Using many ideas from zhuk@, from <David dot Dahlberg at fkie dot
fraunhofer dot de>, and from Benny Lofgren <bl dash lists at lofgren
dot biz>, and a few of my own.
This is an excellent demonstration that CSS is an extremely hostile
language, much more trapful and much harder to use than, say, C.
When matthew@ reported this in July 2014 (!), it was already a known
issue, and i no longer remember for how long. My first serious
attempt at fixing it (in November 2015) failed miserably. I'd love
to see simplifications of both the generated HTML code and of the
style sheet, but without breaking any of the 32 use cases, please.
Modified Files:
--------------
mdocml:
TODO
cgi.c
html.c
mandoc.css
mandoc_html.3
mdoc_html.c
Revision Data
-------------
Index: cgi.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/cgi.c,v
retrieving revision 1.144
retrieving revision 1.145
diff -Lcgi.c -Lcgi.c -u -p -r1.144 -r1.145
--- cgi.c
+++ cgi.c
@@ -799,6 +799,7 @@ resp_format(const struct req *req, const
memset(&conf, 0, sizeof(conf));
conf.fragment = 1;
+ conf.style = mandoc_strdup(CSS_DIR "/mandoc.css");
usepath = strcmp(req->q.manpath, req->p[0]);
mandoc_asprintf(&conf.man, "/%s%s%%N.%%S",
usepath ? req->q.manpath : "", usepath ? "/" : "");
@@ -826,6 +827,7 @@ resp_format(const struct req *req, const
mparse_free(mp);
mchars_free();
free(conf.man);
+ free(conf.style);
}
static void
Index: TODO
===================================================================
RCS file: /home/cvs/mdocml/mdocml/TODO,v
retrieving revision 1.223
retrieving revision 1.224
diff -LTODO -LTODO -u -p -r1.223 -r1.224
--- TODO
+++ TODO
@@ -408,12 +408,6 @@ are mere guesses, and some may be wrong.
--- HTML issues --------------------------------------------------------
-- <dl><dt><dd> formatting is ugly
- hints are easy to find on the web, e.g.
- http://stackoverflow.com/questions/1713048/
- see also matthew@ Fri, 18 Jul 2014 19:25:12 -0700
- loc * exist * algo ** size * imp ***
-
- In -man -Thtml, .nf does not preserve indentation.
It should either convert blanks to
or use <pre> rather than <div> (like .Bd -literal does).
Index: mandoc_html.3
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc_html.3,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lmandoc_html.3 -Lmandoc_html.3 -u -p -r1.3 -r1.4
--- mandoc_html.3
+++ mandoc_html.3
@@ -212,6 +212,10 @@ Requires one
argument, interpreted as an
.Xr mdoc 7 Ns -style
width specifier.
+.It Cm W
+Similar to
+.Cm w ,
+but makes the width negative by multiplying it with \(mi1.
.El
.Pp
Style name letters decide what to do with the preceding argument:
Index: html.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/html.c,v
retrieving revision 1.200
retrieving revision 1.201
diff -Lhtml.c -Lhtml.c -u -p -r1.200 -r1.201
--- html.c
+++ html.c
@@ -566,8 +566,11 @@ print_otag(struct html *h, enum htmltag
SCALE_VS_INIT(su, i);
break;
case 'w':
+ case 'W':
s = va_arg(ap, char *);
a2width(s, su);
+ if (fmt[-1] == 'W')
+ su->scale *= -1.0;
break;
default:
abort();
Index: mandoc.css
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc.css,v
retrieving revision 1.13
retrieving revision 1.14
diff -Lmandoc.css -Lmandoc.css -u -p -r1.13 -r1.14
--- mandoc.css
+++ mandoc.css
@@ -91,9 +91,18 @@ dd.It-inset { }
dl.Bl-ohang { }
dt.It-ohang { }
dd.It-ohang { margin-left: 0ex; }
-dl.Bl-tag { }
-dt.It-tag { }
-dd.It-tag { }
+dl.Bl-tag { margin-left: 8ex; }
+dt.It-tag { float: left;
+ clear: both;
+ margin-top: 0ex;
+ margin-left: -8ex;
+ padding-right: 2ex;
+ vertical-align: top; }
+dd.It-tag { width: 100%;
+ margin-top: 0ex;
+ margin-left: 0ex;
+ vertical-align: top;
+ overflow: auto; }
table.Bl-column { }
tr.It-column { }
Index: mdoc_html.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_html.c,v
retrieving revision 1.260
retrieving revision 1.261
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.260 -r1.261
--- mdoc_html.c
+++ mdoc_html.c
@@ -671,6 +671,7 @@ static int
mdoc_it_pre(MDOC_ARGS)
{
const struct roff_node *bl;
+ struct tag *t;
const char *cattr;
enum mdoc_list type;
@@ -738,7 +739,6 @@ mdoc_it_pre(MDOC_ARGS)
case LIST_hang:
case LIST_inset:
case LIST_ohang:
- case LIST_tag:
switch (n->type) {
case ROFFT_HEAD:
if (bl->norm->Bl.comp)
@@ -759,6 +759,41 @@ mdoc_it_pre(MDOC_ARGS)
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)) {
+ if (bl->norm->Bl.width == NULL)
+ t = print_otag(h, TAG_DT, "c", cattr);
+ else
+ 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);
+ }
+ if (bl->norm->Bl.width == NULL)
+ print_otag(h, TAG_DT, "c", cattr);
+ else
+ 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
+ print_otag(h, TAG_DD, "c", cattr);
+ break;
+ default:
+ break;
+ }
+ break;
case LIST_column:
switch (n->type) {
case ROFFT_HEAD:
@@ -845,9 +880,16 @@ mdoc_bl_pre(MDOC_ARGS)
cattr = "Bl-ohang";
break;
case LIST_tag:
- elemtype = TAG_DL;
cattr = "Bl-tag";
- break;
+ if (n->norm->Bl.offs)
+ print_otag(h, TAG_DIV, "cswl", cattr,
+ n->norm->Bl.offs);
+ if (n->norm->Bl.width == NULL)
+ print_otag(h, TAG_DL, "c", cattr);
+ else
+ print_otag(h, TAG_DL, "cswl", cattr,
+ n->norm->Bl.width);
+ return 1;
case LIST_column:
elemtype = TAG_TABLE;
cattr = "Bl-column";
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic