File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
Aztec/Classes/Libxml2/Converters/In Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff 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)
Original file line number Diff line number Diff line change @@ -566,7 +566,7 @@ class TextStorageTests: XCTestCase {
566566 /// Verifies that spaces are not collapsed
567567 ///
568568 func testConverterCollapsesSpacesText( ) {
569- let initialHTML = " <p> Hello World </p> "
569+ let initialHTML = " <p> Hello <br> <strong> World</strong> </p> "
570570
571571 // Setup
572572 let defaultAttributes : [ NSAttributedString . Key : Any ] = [ . font: UIFont . systemFont ( ofSize: 14 ) ,
@@ -575,7 +575,7 @@ class TextStorageTests: XCTestCase {
575575 storage. htmlConverter. shouldCollapseSpaces = false
576576 storage. setHTML ( initialHTML, defaultAttributes: defaultAttributes)
577577
578- let expectedResult = " <p> Hello World </p> "
578+ let expectedResult = " <p> Hello <br> <strong> World</strong> </p> "
579579 let result = storage. getHTML ( )
580580 XCTAssertEqual ( expectedResult, result)
581581 }
You can’t perform that action at this time.
0 commit comments