scinfu / SwiftSoup

SwiftSoup: Pure Swift HTML Parser, with best of DOM, CSS, and jquery (Supports Linux, iOS, Mac, tvOS, watchOS)
https://scinfu.github.io/SwiftSoup/
MIT License
4.53k stars 345 forks source link

Weird behaviour on printing element text when containing <del> & <ins> tag #106

Closed skipness closed 5 years ago

skipness commented 5 years ago

Here is the fragment html code:

<del>
  <span style="color: red;">
    <ins>AB</ins>
   </span>
   <span style="color: green;">
     CD EFG
   </span>
</del>

I use the following code and print the text:

do {
    let doc: Document =  try SwiftSoup.parseBodyFragment(htmlText)
    debugPrint(try doc.body()?.text())
} catch { debugPrint(error) }

The output is ABCD EFG, which is as expected, but if I slightly modify the html code to:

<del>
  <span style="color: red;">
    A<ins>B</ins><!--Changed here-->
   </span>
   <span style="color: green;">
     CD EFG
   </span>
</del>

The output become A BCD EFG I am not sure why there is a space between 'A' and 'B'