scinfu/SwiftSoup

Parse Line Breaks in .text()

winsmith opened this issue · 1 comments

Is there a way to get line breaks out of parsed text? Suppose I have an element like so:

<p class="mycooltext">
  Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br><br>
  Vestibulum feugiat ex eu turpis efficitur bibendum.
</p>

If I use the text function on this element, I get

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum feugiat ex eu turpis efficitur bibendum.

But I'd rather have

Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n\n Vestibulum feugiat ex eu turpis efficitur bibendum.

with the <br> tags converted to newlines. Is that possible somehow?

Apologies, this got created twice.