1. Thomas Waldmann
  2. moin-2.0
  3. Issues
Issue #157 resolved

html content type with div is not rendered

Bruno Martin
created an issue

when saving some item with html content that contais a <div> tag, like:



<p> Some text Some text Some text </p> <div></div>


nothing is rendered.

Here the related code (MoinMoin/converter/html_in.py:106):



html_tree = HTML(html_str)

We should have a root element, which will be converted as <page>

for the DOM Tree. It can be <html> or <div>.

NB : If <html> used, it will be converted back to <div> after

one roundtrip

if html_tree.tag.name != 'html' and html_tree.tag.name != 'div': html_str = ''.join(['<div>', html_str, '</div>']) html_tree = HTML(html_str)


when we check if html_tree.tag.name is div, we get true, and we lost the tags that comes before it.

Comments (7)

  1. Thomas Waldmann repo owner
    # how it should be:
    >>> t=HTML('<html><h1>foo</h1><div>foo</div></html>')
    >>> t
    <Element QName(u'html', u'http://www.w3.org/1999/xhtml') at 14d4250>
    >>> for e in t: print e
    <Element QName(u'h1', u'http://www.w3.org/1999/xhtml') at 14d4290>
    <Element QName(u'div', u'http://www.w3.org/1999/xhtml') at 14d42d0>
    # what happens if we get strange input (no toplevel html tag in that case):
    >>> t=HTML('<h1>foo</h1><div>foo</div>')
    >>> t
    <Element QName(u'div', u'http://www.w3.org/1999/xhtml') at 14d4210>
    >>> for e in t: print e
  2. RogerHaase
    • changed status to open

    Tried to reproduce this on a old repo that has not been updated in a year.

    I created a new html item, typed "some text<enter>", clicked the div tool, then clicked OK.

    "some text" was displayed OK. Partial html source output:

    <div xmlns="http://www.w3.org/1999/xhtml"> <p> some text</p> <div> <p> </p> </div> <p> </p> </div>

    On the current tip, the results were the same:

    <div xmlns="http://www.w3.org/1999/xhtml"> <p> some text</p> <div> <p> </p></div> <p> </p> </div>

    As the div was invisible, I added a blue border:

    <div xmlns="http://www.w3.org/1999/xhtml"> <p> some text</p> <div style="border: 1px solid blue;"> <p> </p></div> <p> </p> </div>

    Tried several variations, but could not reproduce the problem with Firefox, Chrome, or IE9 on W/7.

  3. Thomas Waldmann repo owner

    roger: see first comment. also, you can just copy and paste the problematic html into ckeditor "sourcecode" view and then save to create such an item, which will show as empty.

  4. RogerHaase

    The bug was introduced in June 2010 in changeset c20b7349dfd7. Per the comment, the goal was to reduce div multiplication. But the result was that any source prior to a root div tag was thrown away.

    The div multiplication issue is a minor problem and is visible some of the test cases (caused by unusual input), but not in the rendering of an HTML item. The fix is to revert the change and fix 8 newly broken tests by adding in a div. Two new tests were added to verify elements prior to a trailing div are present.


  5. Log in to comment