diff options
author | corvid <corvid@lavabit.com> | 2010-04-07 22:07:07 +0000 |
---|---|---|
committer | corvid <corvid@lavabit.com> | 2010-04-07 22:07:07 +0000 |
commit | 7a6266b40e3b340883d1f7fb22c0099a8253cc88 (patch) | |
tree | c770fe8c0e8d4fb95bf270409cf855c5ee373fef /src | |
parent | 865148221562ff526c12a0805c0ab5ea5c859b29 (diff) |
white-space: pre-line
Diffstat (limited to 'src')
-rw-r--r-- | src/html.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/html.cc b/src/html.cc index 9e72c5f2..361f127a 100644 --- a/src/html.cc +++ b/src/html.cc @@ -1033,6 +1033,29 @@ char *a_Html_parse_entities(DilloHtml *html, const char *token, int toksize) } /* + * For white-space: pre-line, we must break the line if encountering a newline. + * Otherwise, collapse whitespace as usual. + */ +static void Html_process_space_pre_line(DilloHtml *html, const char *space, + int spacesize) +{ + int i, breakCnt = 0; + + for (i = 0; i < spacesize; i++) { + /* Support for "\r", "\n" and "\r\n" line breaks */ + if (space[i] == '\r' || (space[i] == '\n' && !html->PrevWasCR)) { + breakCnt++; + html->PrevWasCR = (space[i] == '\r'); + + HT2TB(html)->addLinebreak (html->styleEngine->wordStyle ()); + } + } + if (breakCnt == 0) { + HT2TB(html)->addSpace(html->styleEngine->wordStyle ()); + } +} + +/* * Parse spaces */ static void Html_process_space(DilloHtml *html, const char *space, @@ -1099,6 +1122,9 @@ static void Html_process_space(DilloHtml *html, const char *space, } else { if (SGML_SPCDEL) { /* SGML_SPCDEL ignores white space immediately after an open tag */ + } else if (html->styleEngine->wordStyle ()->whiteSpace == + WHITE_SPACE_PRE_LINE) { + Html_process_space_pre_line(html, space, spacesize); } else { HT2TB(html)->addSpace(html->styleEngine->wordStyle ()); } |