This adds a little more whitespace magic to the html parser. This time
we need to consume any initial whitespace and whitespace that follows
after a SGML/DTD insertion. This has confused the HTML parser for
instance on Planet Classpath which has effectively lead to it stopping
in the middle of the page (interestingly mostly after Mark's
posts ;-) ).
2006-12-04 Roman Kennke <[EMAIL PROTECTED]>
* gnu/javax/swing/text/html/parser/support/Parser.java
(Sgml): Consume any whitespace that immediately follows
and sgml insertion.
(parseDocument): Consume any initial whitespace.
/Roman
Index: gnu/javax/swing/text/html/parser/support/Parser.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/javax/swing/text/html/parser/support/Parser.java,v
retrieving revision 1.15
diff -u -1 -5 -r1.15 Parser.java
--- gnu/javax/swing/text/html/parser/support/Parser.java 1 Dec 2006 14:43:43 -0000 1.15
+++ gnu/javax/swing/text/html/parser/support/Parser.java 3 Dec 2006 23:15:51 -0000
@@ -571,30 +571,32 @@
else
append(t);
}
try
{
parseMarkupDeclarations(buffer);
}
catch (IOException ex)
{
error("Unable to parse SGML insertion: '" + buffer + "'",
new Token(start, t)
);
}
}
+ // Consume any whitespace that follows the Sgml insertion.
+ optional(WS);
}
/**
* Read a style definition. The text, returned without any changes,
* is terminated only by the closing tag STYLE.
*/
protected void Style()
throws ParseException
{
Token name;
Token start = hTag = mustBe(BEGIN);
optional(WS);
name = mustBe(STYLE);
@@ -884,30 +886,32 @@
* Consume the optional token, if present.
* @param kind The kind of token to consume.
*/
protected Token optional(int kind)
{
if (getTokenAhead().kind == kind)
return getNextToken();
else
return null;
}
/** Parse the html document. */
protected void parseDocument()
throws ParseException
{
+ // Read up any initial whitespace.
+ optional(WS);
while (getTokenAhead().kind != EOF)
{
advanced = false;
if (TAG.matches(this))
Tag();
else if (COMMENT_OPEN.matches(this))
Comment();
else if (STYLE_OPEN.matches(this))
Style();
else if (SCRIPT_OPEN.matches(this))
Script();
else if (SGML.matches(this))
Sgml();
else
CDATA(true);