=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/html.c,v retrieving revision 1.83 retrieving revision 1.84 diff -c -r1.83 -r1.84 *** src/usr.bin/mandoc/html.c 2017/06/08 12:54:40 1.83 --- src/usr.bin/mandoc/html.c 2017/06/14 01:31:19 1.84 *************** *** 1,4 **** ! /* $OpenBSD: html.c,v 1.83 2017/06/08 12:54:40 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons * Copyright (c) 2011-2015, 2017 Ingo Schwarze --- 1,4 ---- ! /* $OpenBSD: html.c,v 1.84 2017/06/14 01:31:19 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons * Copyright (c) 2011-2015, 2017 Ingo Schwarze *************** *** 343,358 **** print_encode(struct html *h, const char *p, const char *pend, int norecurse) { char numbuf[16]; ! size_t sz; ! int c, len, nospace; const char *seq; enum mandoc_esc esc; ! static const char rejs[9] = { '\\', '<', '>', '&', '"', ASCII_NBRSP, ASCII_HYPH, ASCII_BREAK, '\0' }; if (pend == NULL) pend = strchr(p, '\0'); nospace = 0; while (p < pend) { --- 343,360 ---- print_encode(struct html *h, const char *p, const char *pend, int norecurse) { char numbuf[16]; ! struct tag *t; const char *seq; + size_t sz; + int c, len, breakline, nospace; enum mandoc_esc esc; ! static const char rejs[10] = { ' ', '\\', '<', '>', '&', '"', ASCII_NBRSP, ASCII_HYPH, ASCII_BREAK, '\0' }; if (pend == NULL) pend = strchr(p, '\0'); + breakline = 0; nospace = 0; while (p < pend) { *************** *** 363,376 **** } for (sz = strcspn(p, rejs); sz-- && p < pend; p++) ! if (*p == ' ') ! print_endword(h); ! else ! print_byte(h, *p); if (p >= pend) break; if (print_escape(h, *p++)) continue; --- 365,392 ---- } for (sz = strcspn(p, rejs); sz-- && p < pend; p++) ! 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) break; + if (*p == ' ') { + print_endword(h); + p++; + continue; + } + if (print_escape(h, *p++)) continue; *************** *** 415,420 **** --- 431,439 ---- if (c <= 0) continue; break; + case ESCAPE_BREAK: + breakline = 1; + continue; case ESCAPE_NOSPACE: if ('\0' == *p) nospace = 1;