From 35d4aaed89e7337b61f0213b253b9bee370ad2c3 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Tue, 8 May 2018 21:42:34 +0000 Subject: Eliminate the class=It-* attributes. Cleaner HTML, more idiomatic CSS, and minus 30 lines of C code. Suggested by John Gardner . --- TODO | 8 +------- html.c | 6 +++++- man_html.c | 6 +++--- mandoc.css | 44 +++++++++++++++++++++++----------------- mdoc_html.c | 67 ++++++++++++------------------------------------------------- 5 files changed, 48 insertions(+), 83 deletions(-) diff --git a/TODO b/TODO index 13e951f0..24981679 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ ************************************************************************ * Official mandoc TODO. -* $Id: TODO,v 1.252 2018/04/24 13:30:59 schwarze Exp $ +* $Id: TODO,v 1.253 2018/05/08 21:42:34 schwarze Exp $ ************************************************************************ Many issues are annotated for difficulty as follows: @@ -379,12 +379,6 @@ are mere guesses, and some may be wrong. --- HTML issues -------------------------------------------------------- -- replace "li.It-dash:before" with "ul.Bl-dash > li:before" - and get rid of the class="It-dash" in the
  • , - and similarly for other blocks - John Gardner 23 Apr 2018 13:17:16 +1000 - loc ** exist ** algo * size ** imp ** - - duplicate names generate duplicate href="#..." anchor attributes possibly use "#..._" suffixes? Jakub Klinkovsky 3 Oct 2017 21:23:36 +0200 diff --git a/html.c b/html.c index 00631cd9..e57322b4 100644 --- a/html.c +++ b/html.c @@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.223 2018/05/08 17:52:55 schwarze Exp $ */ +/* $Id: html.c,v 1.224 2018/05/08 21:42:34 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons * Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze @@ -187,6 +187,10 @@ print_gen_head(struct html *h) print_endline(h); print_text(h, "div.Pp { margin: 1ex 0ex; }"); print_endline(h); + print_text(h, "dl.Bl-diag "); + print_byte(h, '>'); + print_text(h, " dt { font-weight: bold; }"); + print_endline(h); print_text(h, "code.Nm, code.Fl, code.Cm, code.Ic, " "code.In, code.Fd, code.Fn,"); print_endline(h); diff --git a/man_html.c b/man_html.c index 6aee4ffe..e8b4138c 100644 --- a/man_html.c +++ b/man_html.c @@ -1,4 +1,4 @@ -/* $Id: man_html.c,v 1.148 2018/04/24 00:36:53 schwarze Exp $ */ +/* $Id: man_html.c,v 1.149 2018/05/08 21:42:34 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze @@ -525,7 +525,7 @@ man_IP_pre(MAN_ARGS) const struct roff_node *nn; if (n->type == ROFFT_BODY) { - print_otag(h, TAG_DD, "c", "It-tag"); + print_otag(h, TAG_DD, ""); return 1; } else if (n->type != ROFFT_HEAD) { print_otag(h, TAG_DL, "c", "Bl-tag"); @@ -534,7 +534,7 @@ man_IP_pre(MAN_ARGS) /* FIXME: width specification. */ - print_otag(h, TAG_DT, "c", "It-tag"); + print_otag(h, TAG_DT, ""); /* For IP, only print the first header element. */ diff --git a/mandoc.css b/mandoc.css index 2955498b..57278ca3 100644 --- a/mandoc.css +++ b/mandoc.css @@ -1,4 +1,4 @@ -/* $Id: mandoc.css,v 1.24 2018/05/08 17:52:55 schwarze Exp $ */ +/* $Id: mandoc.css,v 1.25 2018/05/08 21:42:34 schwarze Exp $ */ /* * Standard style sheet for mandoc(1) -Thtml and man.cgi(8). */ @@ -72,42 +72,49 @@ div.D1 { margin-left: 5ex; } ul.Bl-bullet { list-style-type: disc; padding-left: 1em; } -li.It-bullet { } +ul.Bl-bullet > li { } ul.Bl-dash { list-style-type: none; padding-left: 0em; } -li.It-dash:before { +ul.Bl-dash > li:before { content: "\2014 "; } ul.Bl-item { list-style-type: none; padding-left: 0em; } -li.It-item { } +ul.Bl-item > li { } ul.Bl-compact > li { margin-top: 0ex; } ol.Bl-enum { padding-left: 2em; } -li.It-enum { } +ol.Bl-enum > li { } ol.Bl-compact > li { margin-top: 0ex; } dl.Bl-diag { } -dt.It-diag { } -dd.It-diag { margin-left: 0ex; } -b.It-diag { font-style: normal; } +dl.Bl-diag > dt { + font-style: normal; + font-weight: bold; } +dl.Bl-diag > dd { + margin-left: 0ex; } dl.Bl-hang { } -dt.It-hang { } -dd.It-hang { margin-left: 10.2ex; } +dl.Bl-hang > dt { } +dl.Bl-hang > dd { + margin-left: 10.2ex; } dl.Bl-inset { } -dt.It-inset { } -dd.It-inset { margin-left: 0ex; } +dl.Bl-inset > dt { } +dl.Bl-inset > dd { + margin-left: 0ex; } dl.Bl-ohang { } -dt.It-ohang { } -dd.It-ohang { margin-left: 0ex; } +dl.Bl-ohang > dt { } +dl.Bl-ohang > dd { + margin-left: 0ex; } dl.Bl-tag { margin-left: 10.2ex; } -dt.It-tag { float: left; +dl.Bl-tag > dt { + float: left; margin-top: 0ex; margin-left: -10.2ex; padding-right: 2ex; vertical-align: top; } -dd.It-tag { clear: right; +dl.Bl-tag > dd { + clear: right; width: 100%; margin-top: 0ex; margin-left: 0ex; @@ -117,8 +124,9 @@ dl.Bl-compact > dt { margin-top: 0ex; } table.Bl-column { } -tr.It-column { } -td.It-column { margin-top: 1em; } +table.Bl-column > tbody > tr { } +table.Bl-column > tbody > tr > td { + margin-top: 1em; } table.Bl-compact > tbody > tr > td { margin-top: 0ex; } diff --git a/mdoc_html.c b/mdoc_html.c index 9c7c0ec2..9930cb55 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -1,7 +1,7 @@ -/* $Id: mdoc_html.c,v 1.298 2018/05/08 17:52:55 schwarze Exp $ */ +/* $Id: mdoc_html.c,v 1.299 2018/05/08 21:42:34 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons - * Copyright (c) 2014, 2015, 2016, 2017 Ingo Schwarze + * Copyright (c) 2014,2015,2016,2017,2018 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -668,7 +668,6 @@ mdoc_it_pre(MDOC_ARGS) { const struct roff_node *bl; struct tag *t; - const char *cattr; enum mdoc_list type; bl = n->parent; @@ -676,42 +675,6 @@ mdoc_it_pre(MDOC_ARGS) bl = bl->parent; type = bl->norm->Bl.type; - 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; - } - switch (type) { case LIST_bullet: case LIST_dash: @@ -722,7 +685,7 @@ mdoc_it_pre(MDOC_ARGS) case ROFFT_HEAD: return 0; case ROFFT_BODY: - print_otag(h, TAG_LI, "c", cattr); + print_otag(h, TAG_LI, ""); break; default: break; @@ -734,13 +697,10 @@ mdoc_it_pre(MDOC_ARGS) case LIST_ohang: switch (n->type) { case ROFFT_HEAD: - print_otag(h, TAG_DT, "c", cattr); - if (type == LIST_diag) - print_otag(h, TAG_B, "c", cattr); + print_otag(h, TAG_DT, ""); break; case ROFFT_BODY: - print_otag(h, TAG_DD, "csw*+l", cattr, - bl->norm->Bl.width); + print_otag(h, TAG_DD, "sw*+l", bl->norm->Bl.width); break; default: break; @@ -753,24 +713,23 @@ mdoc_it_pre(MDOC_ARGS) (n->parent->prev == NULL || n->parent->prev->body == NULL || n->parent->prev->body->child != NULL)) { - t = print_otag(h, TAG_DT, "csw*+-l", - cattr, bl->norm->Bl.width); + t = print_otag(h, TAG_DT, "sw*+-l", + bl->norm->Bl.width); print_text(h, "\\ "); print_tagq(h, t); - t = print_otag(h, TAG_DD, "c", cattr); + t = print_otag(h, TAG_DD, ""); print_text(h, "\\ "); print_tagq(h, t); } - print_otag(h, TAG_DT, "csw*+-l", cattr, - bl->norm->Bl.width); + print_otag(h, TAG_DT, "sw*+-l", bl->norm->Bl.width); break; case ROFFT_BODY: if (n->child == NULL) { - print_otag(h, TAG_DD, "css?", cattr, + print_otag(h, TAG_DD, "ss?", "width", "auto"); print_text(h, "\\ "); } else - print_otag(h, TAG_DD, "c", cattr); + print_otag(h, TAG_DD, ""); break; default: break; @@ -781,10 +740,10 @@ mdoc_it_pre(MDOC_ARGS) case ROFFT_HEAD: break; case ROFFT_BODY: - print_otag(h, TAG_TD, "c", cattr); + print_otag(h, TAG_TD, ""); break; default: - print_otag(h, TAG_TR, "c", cattr); + print_otag(h, TAG_TR, ""); } default: break; -- cgit v1.2.3-56-ge451