public Page parse(char[] data) throws IOException {
CharArray head = new CharArray(64);
CharArray body = new CharArray(4096);
GrailsTokenizedHTMLPage page = new GrailsTokenizedHTMLPage(data, body, head);
HTMLProcessor processor = new HTMLProcessor(data, body);
State html = processor.defaultState();
// Core rules for SiteMesh to be functional.
html.addRule(new HeadExtractingRule(head)); // contents of <head>
html.addRule(new BodyTagRule(page, body)); // contents of <body>
html.addRule(new TitleExtractingRule(page)); // the <title>
html.addRule(new FramesetRule(page)); // if the page is a frameset
// Additional rules - designed to be tweaked.
addUserDefinedRules(html, page);
processor.process();