diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/html.cc | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/html.cc b/src/html.cc index c59a9ddd..356d08f8 100644 --- a/src/html.cc +++ b/src/html.cc @@ -1164,10 +1164,15 @@ static void Html_process_word(DilloHtml *html, const char *word, int size) } else { /* Collapse white-space entities inside the word (except ) */ Pword = a_Html_parse_entities(html, word, size); - for (i = 0; Pword[i]; ++i) - if (strchr("\t\f\n\r", Pword[i])) - for (j = i; (Pword[j] = Pword[j+1]); ++j) ; - + /* Collapse adjacent "\t\f\n\r" characters into a single space */ + for (i = j = 0; (Pword[i] = Pword[j]); ++i, ++j) { + if (strchr("\t\f\n\r", Pword[i])) { + if (i == 0 || (i > 0 && Pword[i-1] != ' ')) + Pword[i] = ' '; + else + for (--i; strchr("\t\f\n\r", Pword[j+1]); ++j) ; + } + } DW2TB(html->dw)->addText(Pword, html->styleEngine->wordStyle ()); dFree(Pword); } |