I am importing a HTML-formatted string with

ImportString[string, "HTML"]

to properly parse all HTML-escaped characters like > and  . However, Mathematica seems to trim all repeated spaces in the process:

ImportString["a   b", "HTML"]
ImportString["a   b", "HTML"]
ImportString["a    b", "HTML"]
a b
a b
a b

Can I disable this unwanted trimming of spaces while parsing a HTML-formatted string?

  • 1
    $\begingroup$ I was under the impression that repeated whitespace characters are trimmed by definition in HTML. My knowledge is 10 yrs out of date, so I may be misremembering it. $\endgroup$ – rcollyer Oct 2 '15 at 12:15
  • $\begingroup$ But how could ASCII art survive if this would be true? $\endgroup$ – shrx Oct 2 '15 at 12:18
  • $\begingroup$ pre and code elements preserve formatting, and likely so do a few others. But, it seems I was correct, at least as far as chrome is concerned about p eating white space. $\endgroup$ – rcollyer Oct 2 '15 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.