version 1.212, 2017/05/14 12:27:28 |
version 1.216, 2017/07/14 15:56:37 |
Line 87 static const struct htmldata htmltags[TAG_MAX] = { |
|
Line 87 static const struct htmldata htmltags[TAG_MAX] = { |
|
{"math", HTML_NLALL | HTML_INDENT}, |
{"math", HTML_NLALL | HTML_INDENT}, |
{"mrow", 0}, |
{"mrow", 0}, |
{"mi", 0}, |
{"mi", 0}, |
|
{"mn", 0}, |
{"mo", 0}, |
{"mo", 0}, |
{"msup", 0}, |
{"msup", 0}, |
{"msub", 0}, |
{"msub", 0}, |
|
|
print_encode(struct html *h, const char *p, const char *pend, int norecurse) |
print_encode(struct html *h, const char *p, const char *pend, int norecurse) |
{ |
{ |
char numbuf[16]; |
char numbuf[16]; |
size_t sz; |
struct tag *t; |
int c, len, nospace; |
|
const char *seq; |
const char *seq; |
|
size_t sz; |
|
int c, len, breakline, nospace; |
enum mandoc_esc esc; |
enum mandoc_esc esc; |
static const char rejs[9] = { '\\', '<', '>', '&', '"', |
static const char rejs[10] = { ' ', '\\', '<', '>', '&', '"', |
ASCII_NBRSP, ASCII_HYPH, ASCII_BREAK, '\0' }; |
ASCII_NBRSP, ASCII_HYPH, ASCII_BREAK, '\0' }; |
|
|
if (pend == NULL) |
if (pend == NULL) |
pend = strchr(p, '\0'); |
pend = strchr(p, '\0'); |
|
|
|
breakline = 0; |
nospace = 0; |
nospace = 0; |
|
|
while (p < pend) { |
while (p < pend) { |
Line 365 print_encode(struct html *h, const char *p, const char |
|
Line 368 print_encode(struct html *h, const char *p, const char |
|
} |
} |
|
|
for (sz = strcspn(p, rejs); sz-- && p < pend; p++) |
for (sz = strcspn(p, rejs); sz-- && p < pend; p++) |
if (*p == ' ') |
print_byte(h, *p); |
print_endword(h); |
|
else |
|
print_byte(h, *p); |
|
|
|
|
if (breakline && |
|
(p >= pend || *p == ' ' || *p == ASCII_NBRSP)) { |
|
t = print_otag(h, TAG_DIV, ""); |
|
print_text(h, "\\~"); |
|
print_tagq(h, t); |
|
breakline = 0; |
|
while (p < pend && (*p == ' ' || *p == ASCII_NBRSP)) |
|
p++; |
|
continue; |
|
} |
|
|
if (p >= pend) |
if (p >= pend) |
break; |
break; |
|
|
|
if (*p == ' ') { |
|
print_endword(h); |
|
p++; |
|
continue; |
|
} |
|
|
if (print_escape(h, *p++)) |
if (print_escape(h, *p++)) |
continue; |
continue; |
|
|
Line 417 print_encode(struct html *h, const char *p, const char |
|
Line 434 print_encode(struct html *h, const char *p, const char |
|
if (c <= 0) |
if (c <= 0) |
continue; |
continue; |
break; |
break; |
|
case ESCAPE_BREAK: |
|
breakline = 1; |
|
continue; |
case ESCAPE_NOSPACE: |
case ESCAPE_NOSPACE: |
if ('\0' == *p) |
if ('\0' == *p) |
nospace = 1; |
nospace = 1; |
Line 433 print_encode(struct html *h, const char *p, const char |
|
Line 453 print_encode(struct html *h, const char *p, const char |
|
(c > 0x7E && c < 0xA0)) |
(c > 0x7E && c < 0xA0)) |
c = 0xFFFD; |
c = 0xFFFD; |
if (c > 0x7E) { |
if (c > 0x7E) { |
(void)snprintf(numbuf, sizeof(numbuf), "&#%d;", c); |
(void)snprintf(numbuf, sizeof(numbuf), "&#x%.4X;", c); |
print_word(h, numbuf); |
print_word(h, numbuf); |
} else if (print_escape(h, c) == 0) |
} else if (print_escape(h, c) == 0) |
print_byte(h, c); |
print_byte(h, c); |
Line 496 print_otag(struct html *h, enum htmltag tag, const cha |
|
Line 516 print_otag(struct html *h, enum htmltag tag, const cha |
|
print_indent(h); |
print_indent(h); |
else if ((h->flags & HTML_NOSPACE) == 0) { |
else if ((h->flags & HTML_NOSPACE) == 0) { |
if (h->flags & HTML_KEEP) |
if (h->flags & HTML_KEEP) |
print_word(h, " "); |
print_word(h, " "); |
else { |
else { |
if (h->flags & HTML_PREKEEP) |
if (h->flags & HTML_PREKEEP) |
h->flags |= HTML_KEEP; |
h->flags |= HTML_KEEP; |
Line 759 print_text(struct html *h, const char *word) |
|
Line 779 print_text(struct html *h, const char *word) |
|
h->flags |= HTML_KEEP; |
h->flags |= HTML_KEEP; |
print_endword(h); |
print_endword(h); |
} else |
} else |
print_word(h, " "); |
print_word(h, " "); |
} |
} |
|
|
assert(NULL == h->metaf); |
assert(NULL == h->metaf); |
Line 950 print_word(struct html *h, const char *cp) |
|
Line 970 print_word(struct html *h, const char *cp) |
|
static void |
static void |
a2width(const char *p, struct roffsu *su) |
a2width(const char *p, struct roffsu *su) |
{ |
{ |
if (a2roffsu(p, su, SCALE_MAX) < 2) { |
const char *end; |
|
|
|
end = a2roffsu(p, su, SCALE_MAX); |
|
if (end == NULL || *end != '\0') { |
su->unit = SCALE_EN; |
su->unit = SCALE_EN; |
su->scale = html_strlen(p); |
su->scale = html_strlen(p); |
} else if (su->scale < 0.0) |
} else if (su->scale < 0.0) |