pyquery icon indicating copy to clipboard operation
pyquery copied to clipboard

.html() get wrong

Open pasicopan opened this issue 11 years ago • 2 comments

I have some html code like: < body> < table>< /table> < div>< /div> < /body> when I use $("body").html(),it return < table >< /table >< div >< /div > # miss the '\n'

pasicopan avatar Jan 06 '14 04:01 pasicopan

Apart from flattering HTML it also makes some magic stuff with entities - I get

&#13; &lt; &gt; &amp;

in source code given by .html() - any clues why?

Should I remove entities myself?

lechup avatar May 06 '14 13:05 lechup

I think it is right to return < table >< /table >< div >< /div >, because the code written in multi-lines is the same effect with the single line code. But when I tested It works well.

>>> from pyquery import PyQuery as pq
>>> para = '''
... <html>
... <body>
... <div>xx \n yy \n zz</div>
... </body>
... </html>
... '''
>>> pq
<class 'pyquery.pyquery.PyQuery'>
>>> pq(para)
[<html>]
>>> pq(para).html()
u'\n<body>\n<div>xx \n yy \n zz</div>\n</body>\n'
>>> 

twz915 avatar Oct 17 '15 11:10 twz915