Re: View Source

Henri Sivonen wrote:
> I think a toggle between real source and reserialized source on the View 
> Source window, as Jonas suggested, would make sense.

There are problems that make simply reserialising the source less 
valuable to developers than you might think.  Consider this fragment:

<p>A paragraph with <a href="#">a link</p>
<p>Another paragraph</p>

When that's parsed, the <a> element is cloned so the second paragraph, 
and all subsequent markup until a </a> is found.  Simply reserialising 
would result in:

<p>A paragraph with <a href="#">a link</a></p><a href="#">
<p>Another paragraph</p></a>

(I used the HTML5lib parse tree viewer [1] to get that.  I didn't check 
the spec to make sure that's totally correct)

However, a more useful solution to cleaning up the source would be to 
simply close the <a> element at the end of the first paragraph and not 
clone it for subsequent content.

[1] http://james.html5.org/parsetree.html

-- 
Lachlan Hunt - Opera Software
http://lachy.id.au/
http://www.opera.com/

Received on Tuesday, 17 March 2009 11:45:26 UTC