[xml] htmlHandleOmittedElem bug

Date view Thread view Subject view Author view

From: Jonas Borgström (jonas@codefactory.se)
Date: Tue Jan 09 2001 - 13:30:54 EST


Hi,

While debugging some weird layout of a page in gtkhtml2 I found a bug in
gnome-xml. The page contained the following code:

<html>
  <body>
    <span>foo</span> bar
  </body>
</html>

It should be layouted like this "foo bar", the text should be on the same
line because the <span> element has the css-property "display: inline" as
default.
But when gnome-xml parses this page, it noticed that the <body> element
contains both other elements (<span>) and text (" bar"). It tries to fix
this by adding a paragraph to the text like this:

<html>
  <body>
    <span>foo</span>
    <p>
    bar
    </p>
  </body>
</html>

But this is not correct (it would be if <span> was <p> or <div>). It will be
layouted like:

foo
bar

because the <p> starts a new paragraph. This is not correct.
The correct way for gnome-xml to fix the broken html is like this:

<html>
  <body>
    <p>
    <span>foo</span>
    bar
    </p>
  </body>
</html>

when htmlCheckParagraph() noticed that we want to put contents in the <html>
element then it pushes a <p> element and then the text goes into it. But
this breaks the line and starts a new paragraph and this might not always be
correct.

I think the correct way of doing it when the htmlCheckParagraph detects
this is to put a <p> element between the <body> and its first child. because
gnome-xml can't know if the elements are inline or not (can be changed
through css).

What do you think?

/ Jonas

PS.
Yes one other question: should the htmtHandleOmittedElem(x) flag be global,
isn't it better that it is per parser context.
DS.

-- 
Jonas Borgström                  jonas@codefactory.se
CodeFactory AB                   http://www.codefactory.se/
Office: +46 (0)90 71 86 10       Cell: +46 (0)70 248 89 58
----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Tue Jan 09 2001 - 13:43:45 EST