]> git.saurik.com Git - wxWidgets.git/blobdiff - src/html/m_pre.cpp
refactor wxDocChildFrame and wxDocMDIChildFrame to use wxDocChildFrameAny intead...
[wxWidgets.git] / src / html / m_pre.cpp
index c4a33f8c82892f84fcde411bc1d5995ca31a537d..1a0ef36813be6f8df7a8f25c64c5aa332cc04cb9 100644 (file)
@@ -47,9 +47,22 @@ static wxString LINKAGEMODE HtmlizeLinebreaks(const wxString& str)
                 if ( i == end )
                     return out;
                 break;
                 if ( i == end )
                     return out;
                 break;
+
+            // We need to translate any line break into exactly one <br>.
+            // Quoting HTML spec: "A line break is defined to be a carriage
+            // return (&#x000D;), a line feed (&#x000A;), or a carriage
+            // return/line feed pair."
+            case '\r':
+                {
+                    wxString::const_iterator j(i + 1);
+                    if ( j != end && *j == '\n' )
+                        i = j;
+                }
+                // fall through
             case '\n':
                 out << "<br>";
                 break;
             case '\n':
                 out << "<br>";
                 break;
+
             default:
                 out << *i;
                 break;
             default:
                 out << *i;
                 break;