Line breaks in comments.

Dan Tsimbala <[email protected]>
Newsgroups gmane.comp.mozilla.devel.dom
Message-ID <[email protected]>
Hi!

It's probably nothing you can help me with, but I'm just curious about
reasons. I'm writing my own HTML DOM serializer, and I'm facing the
following problem - all the line breaks inside comment nodes are changed
when HTML was parsed. I'm using MAC OS X 10.5 which uses Unix line breaks
LF, so my source contains only them. When I'm trying to serialize the source
(and even innerHTML itself has the same issue) with my serializer the line
breaks in the text nodes will be correct (LF), but the line break in the
comment nodes will be replaced by CR+LF. I see that IE does the same with
comments, but it also messes up text nodes with whitespaces comepletely, so
I guess it's no wonder about them. I didn't get to Opera still, but Webkit
preserves everything nicely. Are there any reasons about this? Is there a
way to retrieve initial chars or are they lost during parsing?

Just don't want to write my own HTML DOM parser, although I'm becoming more
and more convinced this is the only solution for all the problems at once.

Thanx in advance!
Dan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.