From 0c1b7bd0c0c67e2ee5fee8952d8aa5f5ef33ee28 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sat, 15 Jul 2017 17:57:51 +0000 Subject: In .Bl -tag and -hang, do not print a margin-left style attribute for each individual item if the -width argument matches the default of 6n. Suggested by Steffen Nurpmeso on in April 2017. --- html.c | 32 ++++++++++++++++++-------------- mandoc_html.3 | 13 ++++++++----- mdoc_html.c | 10 +++++----- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/html.c b/html.c index 28f8cf98..fc55e881 100644 --- a/html.c +++ b/html.c @@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.218 2017/07/14 16:28:38 schwarze Exp $ */ +/* $Id: html.c,v 1.219 2017/07/15 17:57:51 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons * Copyright (c) 2011-2015, 2017 Ingo Schwarze @@ -624,24 +624,28 @@ print_otag(struct html *h, enum htmltag tag, const char *fmt, ...) su = va_arg(ap, struct roffsu *); break; case 'w': - if ((arg2 = va_arg(ap, char *)) == NULL) { - if (*fmt == '+') - fmt++; - if (*fmt == '-') - fmt++; - break; + if ((arg2 = va_arg(ap, char *)) != NULL) { + su = &mysu; + a2width(arg2, su); + } + if (*fmt == '*') { + if (su != NULL && su->unit == SCALE_EN && + su->scale > 5.9 && su->scale < 6.1) + su = NULL; + fmt++; } - su = &mysu; - a2width(arg2, su); if (*fmt == '+') { - /* Increase to make even bold text fit. */ - su->scale *= 1.2; - /* Add padding. */ - su->scale += 3.0; + if (su != NULL) { + /* Make even bold text fit. */ + su->scale *= 1.2; + /* Add padding. */ + su->scale += 3.0; + } fmt++; } if (*fmt == '-') { - su->scale *= -1.0; + if (su != NULL) + su->scale *= -1.0; fmt++; } break; diff --git a/mandoc_html.3 b/mandoc_html.3 index 4c652e7a..ba25e0ad 100644 --- a/mandoc_html.3 +++ b/mandoc_html.3 @@ -1,4 +1,4 @@ -.\" $Id: mandoc_html.3,v 1.9 2017/07/14 16:06:44 schwarze Exp $ +.\" $Id: mandoc_html.3,v 1.10 2017/07/15 17:57:51 schwarze Exp $ .\" .\" Copyright (c) 2014, 2017 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: July 14 2017 $ +.Dd $Mdocdate: July 15 2017 $ .Dt MANDOC_HTML 3 .Os .Sh NAME @@ -231,12 +231,15 @@ nothing is printed for this pair. .Pp The .Cm w -argument type letter can optionally be followed by one or two +argument type letter can optionally be followed by one, two, or three modifier letters. The modifier +.Cm * +suppresses printing of the pair if the argument matches 6n. +The modifier .Cm + -increases the width by 10% to make even bold text fit -and adds two units for padding between columns. +increases the width by 20% to make even bold text fit +and adds three units for padding between columns. The modifier .Cm \- makes the width negative by multiplying it with \-1. diff --git a/mdoc_html.c b/mdoc_html.c index 2b734584..0b4b9adf 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.293 2017/07/15 17:29:31 schwarze Exp $ */ +/* $Id: mdoc_html.c,v 1.294 2017/07/15 17:57:51 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons * Copyright (c) 2014, 2015, 2016, 2017 Ingo Schwarze @@ -732,7 +732,7 @@ mdoc_it_pre(MDOC_ARGS) print_otag(h, TAG_B, "c", cattr); break; case ROFFT_BODY: - print_otag(h, TAG_DD, "csw+l", cattr, + print_otag(h, TAG_DD, "csw*+l", cattr, bl->norm->Bl.width); break; default: @@ -746,7 +746,7 @@ 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", + t = print_otag(h, TAG_DT, "csw*+-l", cattr, bl->norm->Bl.width); print_text(h, "\\ "); print_tagq(h, t); @@ -754,7 +754,7 @@ mdoc_it_pre(MDOC_ARGS) print_text(h, "\\ "); print_tagq(h, t); } - print_otag(h, TAG_DT, "csw+-l", cattr, + print_otag(h, TAG_DT, "csw*+-l", cattr, bl->norm->Bl.width); break; case ROFFT_BODY: @@ -860,7 +860,7 @@ mdoc_bl_pre(MDOC_ARGS) case LIST_tag: if (bl->offs) print_otag(h, TAG_DIV, "cswl", "Bl-tag", bl->offs); - print_otag(h, TAG_DL, "csw+l", bl->comp ? + print_otag(h, TAG_DL, "csw*+l", bl->comp ? "Bl-tag Bl-compact" : "Bl-tag", bl->width); return 1; case LIST_column: -- cgit v1.2.3-56-ge451