=================================================================== RCS file: /cvs/mandoc/html.c,v retrieving revision 1.229 retrieving revision 1.237 diff -u -p -r1.229 -r1.237 --- mandoc/html.c 2018/05/25 20:23:51 1.229 +++ mandoc/html.c 2018/06/25 14:13:54 1.237 @@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.229 2018/05/25 20:23:51 schwarze Exp $ */ +/* $Id: html.c,v 1.237 2018/06/25 14:13:54 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons * Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze @@ -69,8 +69,6 @@ static const struct htmldata htmltags[TAG_MAX] = { {"br", HTML_NOSTACK | HTML_AUTOCLOSE | HTML_NLALL}, {"a", 0}, {"table", HTML_NLALL | HTML_INDENT}, - {"colgroup", HTML_NLALL | HTML_INDENT}, - {"col", HTML_NOSTACK | HTML_AUTOCLOSE | HTML_NLALL}, {"tr", HTML_NLALL | HTML_INDENT}, {"td", HTML_NLAROUND}, {"li", HTML_NLAROUND | HTML_INDENT}, @@ -122,7 +120,6 @@ static const char *const roffscales[SCALE_MAX] = { /* Avoid duplicate HTML id= attributes. */ static struct ohash id_unique; -static void a2width(const char *, struct roffsu *); static void print_byte(struct html *, char); static void print_endword(struct html *); static void print_indent(struct html *); @@ -287,10 +284,16 @@ html_make_id(const struct roff_node *n, int unique) if (buf == NULL) return NULL; - /* http://www.w3.org/TR/html5/dom.html#the-id-attribute */ + /* + * In ID attributes, only use ASCII characters that are + * permitted in URL-fragment strings according to the + * explicit list at: + * https://url.spec.whatwg.org/#url-fragment-string + */ for (cp = buf; *cp != '\0'; cp++) - if (*cp == ' ') + if (isalnum((unsigned char)*cp) == 0 && + strchr("!$&'()*+,-./:;=?@_~", *cp) == NULL) *cp = '_'; if (unique == 0) @@ -550,13 +553,13 @@ struct tag * print_otag(struct html *h, enum htmltag tag, const char *fmt, ...) { va_list ap; - struct roffsu mysu, *su; + struct roffsu *su; char numbuf[16]; struct tag *t; const char *attr; char *arg1, *arg2; double v; - int i, have_style, tflags; + int have_style, tflags; tflags = htmltags[tag].flags; @@ -672,43 +675,12 @@ print_otag(struct html *h, enum htmltag tag, const cha /* First letter: input argument type. */ switch (*fmt++) { - case 'h': - i = va_arg(ap, int); - su = &mysu; - SCALE_HS_INIT(su, i); - break; case 's': arg1 = va_arg(ap, char *); break; case 'u': su = va_arg(ap, struct roffsu *); break; - case 'w': - 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++; - } - if (*fmt == '+') { - if (su != NULL) { - /* Make even bold text fit. */ - su->scale *= 1.2; - /* Add padding. */ - su->scale += 3.0; - } - fmt++; - } - if (*fmt == '-') { - if (su != NULL) - su->scale *= -1.0; - fmt++; - } - break; default: abort(); } @@ -719,18 +691,6 @@ print_otag(struct html *h, enum htmltag tag, const cha case 'h': attr = "height"; break; - case 'i': - attr = "text-indent"; - break; - case 'l': - attr = "margin-left"; - break; - case 'w': - attr = "width"; - break; - case 'W': - attr = "min-width"; - break; case '?': attr = arg1; arg1 = va_arg(ap, char *); @@ -1044,22 +1004,4 @@ print_word(struct html *h, const char *cp) { while (*cp != '\0') print_byte(h, *cp++); -} - -/* - * Calculate the scaling unit passed in a `-width' argument. This uses - * either a native scaling unit (e.g., 1i, 2m) or the string length of - * the value. - */ -static void -a2width(const char *p, struct roffsu *su) -{ - const char *end; - - end = a2roffsu(p, su, SCALE_MAX); - if (end == NULL || *end != '\0') { - su->unit = SCALE_EN; - su->scale = html_strlen(p); - } else if (su->scale < 0.0) - su->scale = 0.0; }