Skip to content

Commit 0b2d595

Browse files
committed
Fix collapse of white spaces when parsing HTML text.
1 parent 52e48a8 commit 0b2d595

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Aztec/Classes/Libxml2/Converters/In/HTMLParser.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,16 @@ open class HTMLParser {
4545
//
4646
htmlHandleOmittedElem(0)
4747

48+
var parserOptions = HTML_PARSE_RECOVER.rawValue | HTML_PARSE_NODEFDTD.rawValue | HTML_PARSE_NOERROR.rawValue | HTML_PARSE_NOWARNING.rawValue | HTML_PARSE_NOIMPLIED.rawValue
49+
if shouldCollapseSpaces {
50+
parserOptions = parserOptions | HTML_PARSE_NOBLANKS.rawValue
51+
}
4852
let document = htmlCtxtReadMemory(parserContext,
4953
htmlPtr,
5054
Int32(wrappedHTML.lengthOfBytes(using: String.Encoding.utf8)),
5155
"",
5256
"UTF-8",
53-
Int32(HTML_PARSE_RECOVER.rawValue | HTML_PARSE_NODEFDTD.rawValue | HTML_PARSE_NOERROR.rawValue | HTML_PARSE_NOWARNING.rawValue | HTML_PARSE_NOIMPLIED.rawValue | HTML_PARSE_NOBLANKS.rawValue))
57+
Int32(parserOptions))
5458

5559
defer {
5660
xmlFreeDoc(document)

0 commit comments

Comments
 (0)