Menu

#279 toHtml(verbatim) doesn't work correctly

v2.0
open
nobody
None
5
2010-04-27
2010-04-27
hoymkot
No

If verbatim == true, then toHtml(verbatim) should return as close to the original page text as possible. Setting verbatim == true should make toHtml(verbatim) ignore all virtual end tags created by the parser. However, the toHtml(verbatim) method only ignores virtual end tags for top level composite tag.

If you use html parser to parse the html file I provided and use toHTML(true) to reproduce this file, you will notice that toHTML(true) will print the virtual end tags.

Discussion

  • hoymkot

    hoymkot - 2010-04-27
     
  • hoymkot

    hoymkot - 2010-11-09

    Here is my proposed fix.

    In CompositeTag.java

    protected void putChildrenInto (StringBuffer sb, boolean verbatim)
    {
    Node node;
    for (SimpleNodeIterator e = children (); e.hasMoreNodes ();)
    {
    node = e.nextNode ();
    // eliminate virtual tags
    // Hou Kot Edited 04-26-2009
    // original
    /*
    if (!verbatim || !(node.getStartPosition () == node.getEndPosition ()))
    sb.append (node.toHtml ());
    */
    if (!verbatim || !(node.getStartPosition () == node.getEndPosition ()))
    sb.append (node.toHtml (verbatim));
    // Hou Kot Edited 04-26-2009
    }
    }

     

Log in to post a comment.