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: <li> tags close enclosing <li> tags
*/
/**
/** 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 {
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));
return null;
// scan body
- return parseBody(cs, h, elementName);
+ String ret = parseBody(cs, h, elementName);
+ withinLI = saveWithinLI;
+ return ret;
}
/**
// 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();