version 1.229, 2018/05/25 20:23:51 |
version 1.236, 2018/06/25 14:00:28 |
Line 69 static const struct htmldata htmltags[TAG_MAX] = { |
|
Line 69 static const struct htmldata htmltags[TAG_MAX] = { |
|
{"br", HTML_NOSTACK | HTML_AUTOCLOSE | HTML_NLALL}, |
{"br", HTML_NOSTACK | HTML_AUTOCLOSE | HTML_NLALL}, |
{"a", 0}, |
{"a", 0}, |
{"table", HTML_NLALL | HTML_INDENT}, |
{"table", HTML_NLALL | HTML_INDENT}, |
{"colgroup", HTML_NLALL | HTML_INDENT}, |
|
{"col", HTML_NOSTACK | HTML_AUTOCLOSE | HTML_NLALL}, |
|
{"tr", HTML_NLALL | HTML_INDENT}, |
{"tr", HTML_NLALL | HTML_INDENT}, |
{"td", HTML_NLAROUND}, |
{"td", HTML_NLAROUND}, |
{"li", HTML_NLAROUND | HTML_INDENT}, |
{"li", HTML_NLAROUND | HTML_INDENT}, |
Line 122 static const char *const roffscales[SCALE_MAX] = { |
|
Line 120 static const char *const roffscales[SCALE_MAX] = { |
|
/* Avoid duplicate HTML id= attributes. */ |
/* Avoid duplicate HTML id= attributes. */ |
static struct ohash id_unique; |
static struct ohash id_unique; |
|
|
static void a2width(const char *, struct roffsu *); |
|
static void print_byte(struct html *, char); |
static void print_byte(struct html *, char); |
static void print_endword(struct html *); |
static void print_endword(struct html *); |
static void print_indent(struct html *); |
static void print_indent(struct html *); |
Line 287 html_make_id(const struct roff_node *n, int unique) |
|
Line 284 html_make_id(const struct roff_node *n, int unique) |
|
if (buf == NULL) |
if (buf == NULL) |
return 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++) |
for (cp = buf; *cp != '\0'; cp++) |
if (*cp == ' ') |
if (isalnum((unsigned char)*cp) == 0 && |
|
strchr("!$&'()*+,-./:;=?@_~", *cp) == NULL) |
*cp = '_'; |
*cp = '_'; |
|
|
if (unique == 0) |
if (unique == 0) |
Line 683 print_otag(struct html *h, enum htmltag tag, const cha |
|
Line 686 print_otag(struct html *h, enum htmltag tag, const cha |
|
case 'u': |
case 'u': |
su = va_arg(ap, struct roffsu *); |
su = va_arg(ap, struct roffsu *); |
break; |
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: |
default: |
abort(); |
abort(); |
} |
} |
Line 719 print_otag(struct html *h, enum htmltag tag, const cha |
|
Line 696 print_otag(struct html *h, enum htmltag tag, const cha |
|
case 'h': |
case 'h': |
attr = "height"; |
attr = "height"; |
break; |
break; |
case 'i': |
|
attr = "text-indent"; |
|
break; |
|
case 'l': |
case 'l': |
attr = "margin-left"; |
attr = "margin-left"; |
break; |
break; |
case 'w': |
|
attr = "width"; |
|
break; |
|
case 'W': |
|
attr = "min-width"; |
|
break; |
|
case '?': |
case '?': |
attr = arg1; |
attr = arg1; |
arg1 = va_arg(ap, char *); |
arg1 = va_arg(ap, char *); |
Line 1044 print_word(struct html *h, const char *cp) |
|
Line 1012 print_word(struct html *h, const char *cp) |
|
{ |
{ |
while (*cp != '\0') |
while (*cp != '\0') |
print_byte(h, *cp++); |
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; |
|
} |
} |