From: megacz Date: Fri, 30 Jan 2004 06:49:59 +0000 (+0000) Subject: 2002/08/10 23:36:31 X-Git-Tag: RC3~1569 X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=commitdiff_plain;h=8d228af01157d87c7f62e010330ca360e0d7889b 2002/08/10 23:36:31 darcs-hash:20040130064959-2ba56-c56554d8d9871f8bfe57c31c61536363cc13f4f8.gz --- diff --git a/CHANGES b/CHANGES index e93b512..9321416 100644 --- a/CHANGES +++ b/CHANGES @@ -358,4 +358,6 @@ 09-Aug megacz Win32.java, Win32.cc: hack to avoid strange race condition in Win32 GDI +10-Aug megacz HTML.java, html.xwt: fixed HTML widget to handle unclosed
  • tags + diff --git a/src/org/xwt/HTML.java b/src/org/xwt/HTML.java index b04b9d1..8d36a10 100644 --- a/src/org/xwt/HTML.java +++ b/src/org/xwt/HTML.java @@ -20,8 +20,6 @@ import java.io.*; http://www.htmlhelp.com/reference/html40/entities/special.html http://www.htmlhelp.com/reference/html40/entities/symbols.html http://www.htmlhelp.com/reference/html40/entities/latin1.html - - FIXME FIXME FIXME:
  • tags close enclosing
  • tags */ /** @@ -47,10 +45,14 @@ public class HTML { /** we keep a StringBuffer around for use by removeRedundantWhitespace() */ private static StringBuffer sbuf = null; + /** true iff we have encountered an LI more recently than the last OL/UL */ + private static boolean withinLI = false; + public static synchronized JSObject parseReader(Reader r) throws IOException { CharStream cs = new CharStream(r); JSObject h = new JSObject(); + withinLI = false; h.put("$name", "html"); try { @@ -84,6 +86,19 @@ public class HTML { while(Character.isSpace(cs.peek())) cs.get(); String elementName = parseElementName(cs); + // FIXME: this might not deal correctly with EOFExceptions + boolean saveWithinLI = withinLI; + if (elementName.equals("li")) { + if (withinLI) { + cs.unread(new char[] { '<', 'l', 'i', ' ' }); + return "li"; + } else { + withinLI = true; + } + } else if (elementName.equals("ol") || elementName.equals("ul")) { + withinLI = false; + } + h.put("$name", elementName); if (elementName.equals("!--")) { h.put("0", parseComment(cs)); @@ -108,7 +123,9 @@ public class HTML { return null; // scan body - return parseBody(cs, h, elementName); + String ret = parseBody(cs, h, elementName); + withinLI = saveWithinLI; + return ret; } /** @@ -304,7 +321,7 @@ public class HTML { // CharStream ///////////////////////////////////////////////////////////////////// private static class CharStream extends PushbackReader { - public CharStream(Reader r) { super(r); } + public CharStream(Reader r) { super(r, 1024); } public char peek() throws IOException { char c = get();