jsoup icon indicating copy to clipboard operation
jsoup copied to clipboard

Should wholeText() introduce newlines between block elements?

Open h920526 opened this issue 1 year ago • 5 comments

Hi team,

Jsoup v1.16.1

<div><p>Hello</p><p>World</p></div>

after calling wholeText()

expected: Hello World

but actual: HelloWorld

does not wrap with new line thanks

h920526 avatar Dec 14 '23 03:12 h920526

This is "as designed" currently - wholeText gets only the non-normalized text values from the elements.

I have considered changing it to emit a newline when encountering a new block tag as that seems more useful.

text() will give you normalized text with a (space, not newline) between the nodes. That's designed for e.g. indexing / searching / extracting.

Would be good to hear opinions from folks on this. It seems safe and information preserving.

jhy avatar Dec 14 '23 06:12 jhy

use br Tag

akashsahu25 avatar Jan 21 '24 12:01 akashsahu25