Reputation: 1174
My problem is that jsoup destroys my html code. I am downloading website from url, change it a little and displaying it in WebView.
Jsoup adding formating to code and it causing problems:
Before html: http://jsfiddle.net/zr3xtus9/
<div class="ctr-element"><div class="ctr-content" style="z-index: 100; margin: 0px; left: 0px; top: 0px; visibility: visible; position: relative;"><div class="ctr-textWrapper" style="text-align: center; line-height: 1; font-size: 124px;" spellcheck="false"><span style="font-size: 124px; color: rgb(245, 230, 93); font-family: capture_it_2;" id="object13textContainer0"> P</span><span style="font-size: 124px; color: rgb(245, 230, 93); font-family: capture_it_2;" id="object13textContainer1">arty</span></div></div></div>
After html: http://jsfiddle.net/5kv47sny/
<div class="ctr-element">
<div class="ctr-content" style="z-index: 100; margin: 0px; left: 0px; top: 0px; visibility: visible; position: relative;">
<div class="ctr-textWrapper" style="text-align: center; line-height: 1; font-size: 124px;" spellcheck="false">
<span style="font-size: 124px; color: rgb(245, 230, 93); font-family: capture_it_2;" id="object13textContainer0" onclick="javscript:changeText('object13textContainer0')"> P</span>
<span style="font-size: 124px; color: rgb(245, 230, 93); font-family: capture_it_2;" id="object13textContainer1" onclick="javscript:changeText('object13textContainer1')">arty</span>
</div>
</div>
</div>
As you can see jsoup adds extra whitespaces as text indent. How to avoid this?
Upvotes: 2
Views: 169
Reputation: 1174
Solution is very easy. To disable text indent I used this code before printing html:
doc.outputSettings().prettyPrint(false);
Here is documentation: http://jsoup.org/apidocs/org/jsoup/nodes/Document.OutputSettings.html#prettyPrint(boolean)
Upvotes: 5