diff --git a/docs/changes.txt b/docs/changes.txt index 3f3f8ad100..bfda87fa83 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -102,6 +102,7 @@ All (GUI): Polish Pro input. - Fixed wxHtmlWindow::SelectionToText() to correctly insert newlines after single-cell paragraphs. +- Fixed wxHTML's line breaks handling in
blocks broken in 2.8.8 (#10120) All (Unix): diff --git a/src/html/m_pre.cpp b/src/html/m_pre.cpp index 354e585384..0c20222a7c 100644 --- a/src/html/m_pre.cpp +++ b/src/html/m_pre.cpp @@ -46,9 +46,22 @@ static wxString LINKAGEMODE HtmlizeLinebreaks(const wxString& str) } out << wxT('>'); break; + + // We need to translate any line break into exactly one
. + // Quoting HTML spec: "A line break is defined to be a carriage + // return ( ), a line feed ( ), or a carriage + // return/line feed pair." + case wxT('\r'): + { + size_t j = i + 1; + if ( j < len && str[j] == wxT('\n') ) + i = j; + } + // fall through case wxT('\n'): out << wxT("
"); break; + default: out << str[i]; break;