I'm using Jsoup for sanitizing user input from a form. The form in question contains a
<textarea> that expects plain text. When the form is submitted, I clean the input with
Jsoup.clean(textareaContents); however, since html ignores extra whitespace,
Jsoup.clean() will remove valuable whitespace characters from the input.
For example, if someone entered some lines of text in the
Jsoup.clean(), you will have:
How can you make
Jsoup.clean() preserve whitespace? I know it's designed for parsing html and this isn't html, so is there a better alternative?