aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/html.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-06-14 01:31:26 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-06-14 01:31:26 +0000
commit078c4f79913f5f296b88db4a9fed67f1ea124c86 (patch)
treedeafb282df1e0b025b4322b763df47080a885828 /html.c
parent3352a8e9bd0f6a0666c5dcb84ccdb5536471d280 (diff)
downloadmandoc-078c4f79913f5f296b88db4a9fed67f1ea124c86.tar.gz
mandoc-078c4f79913f5f296b88db4a9fed67f1ea124c86.tar.zst
mandoc-078c4f79913f5f296b88db4a9fed67f1ea124c86.zip
implement the roff(7) \p (break output line) escape sequence
Diffstat (limited to 'html.c')
-rw-r--r--html.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/html.c b/html.c
index 4bb3ca56..d92ec16a 100644
--- a/html.c
+++ b/html.c
@@ -1,4 +1,4 @@
-/* $Id: html.c,v 1.213 2017/06/08 12:54:58 schwarze Exp $ */
+/* $Id: html.c,v 1.214 2017/06/14 01:31:26 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -345,16 +345,18 @@ static int
print_encode(struct html *h, const char *p, const char *pend, int norecurse)
{
char numbuf[16];
- size_t sz;
- int c, len, nospace;
+ struct tag *t;
const char *seq;
+ size_t sz;
+ int c, len, breakline, nospace;
enum mandoc_esc esc;
- static const char rejs[9] = { '\\', '<', '>', '&', '"',
+ 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) {
@@ -365,14 +367,28 @@ print_encode(struct html *h, const char *p, const char *pend, int norecurse)
}
for (sz = strcspn(p, rejs); sz-- && p < pend; p++)
- if (*p == ' ')
- print_endword(h);
- else
- print_byte(h, *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;
@@ -417,6 +433,9 @@ print_encode(struct html *h, const char *p, const char *pend, int norecurse)
if (c <= 0)
continue;
break;
+ case ESCAPE_BREAK:
+ breakline = 1;
+ continue;
case ESCAPE_NOSPACE:
if ('\0' == *p)
nospace = 1;