From: <ad...@us...> - 2010-11-13 21:24:59
|
Revision: 1187 http://jtidy.svn.sourceforge.net/jtidy/?rev=1187&view=rev Author: aditsu Date: 2010-11-13 21:24:53 +0000 (Sat, 13 Nov 2010) Log Message: ----------- fixed test 1638062 - added additional conditions for coercing a node to endtag, also moved textNodeEndWithSpace to Lexer and fixed the NESTED_EMPHASIS warning Modified Paths: -------------- branches/CodeUpdateAndJava5/src/main/java/org/w3c/tidy/Lexer.java branches/CodeUpdateAndJava5/src/main/java/org/w3c/tidy/PPrint.java branches/CodeUpdateAndJava5/src/main/java/org/w3c/tidy/ParserImpl.java branches/CodeUpdateAndJava5/src/main/java/org/w3c/tidy/Report.java Modified: branches/CodeUpdateAndJava5/src/main/java/org/w3c/tidy/Lexer.java =================================================================== --- branches/CodeUpdateAndJava5/src/main/java/org/w3c/tidy/Lexer.java 2010-11-13 20:44:58 UTC (rev 1186) +++ branches/CodeUpdateAndJava5/src/main/java/org/w3c/tidy/Lexer.java 2010-11-13 21:24:53 UTC (rev 1187) @@ -3814,11 +3814,25 @@ return null; } - public Node findXmlDecl() { + protected Node findXmlDecl() { Node node = root.content; while (node != null && node.type != NodeType.XmlDecl) { node = node.next; } return node; } + + protected boolean textNodeEndWithSpace(final Node node) { + if (node.isText() && node.end > node.start) { + int i, c = '\0'; /* initialised to avoid warnings */ + for (i = node.start; i < node.end; ++i) { + c = lexbuf[i] & 0xFF; // Convert to unsigned. + } + + if (c == ' ' || c == '\n') { + return true; + } + } + return false; + } } Modified: branches/CodeUpdateAndJava5/src/main/java/org/w3c/tidy/PPrint.java =================================================================== --- branches/CodeUpdateAndJava5/src/main/java/org/w3c/tidy/PPrint.java 2010-11-13 20:44:58 UTC (rev 1186) +++ branches/CodeUpdateAndJava5/src/main/java/org/w3c/tidy/PPrint.java 2010-11-13 21:24:53 UTC (rev 1187) @@ -1263,20 +1263,6 @@ } } - private static boolean textNodeEndWithSpace(final Lexer lexer, final Node node) { - if (node.isText() && node.end > node.start) { - int i, c = '\0'; /* initialised to avoid warnings */ - for (i = node.start; i < node.end; ++i) { - c = lexer.lexbuf[i] & 0xFF; // Convert to unsigned. - } - - if (c == ' ' || c == '\n') { - return true; - } - } - return false; - } - /* Line can be wrapped immediately after inline start tag provided if follows a text node ending in a space, or it follows a <br>, @@ -1298,7 +1284,7 @@ Node prev = node.prev; if (prev != null) { if (prev.isText()) { - return textNodeEndWithSpace(lexer, prev); + return lexer.textNodeEndWithSpace(prev); } else if (prev.is(TagId.BR)) { return true; } Modified: branches/CodeUpdateAndJava5/src/main/java/org/w3c/tidy/ParserImpl.java =================================================================== --- branches/CodeUpdateAndJava5/src/main/java/org/w3c/tidy/ParserImpl.java 2010-11-13 20:44:58 UTC (rev 1186) +++ branches/CodeUpdateAndJava5/src/main/java/org/w3c/tidy/ParserImpl.java 2010-11-13 21:24:53 UTC (rev 1187) @@ -1185,8 +1185,8 @@ && !node.is(TagId.SMALL) && !node.is(TagId.Q)) { - if (element.content != null && node.attributes == null) - { + if (element.content != null && node.attributes == null + && element.last.isText() && !lexer.textNodeEndWithSpace(element.last)) { lexer.report.warning(lexer, element, node, ErrorCode.COERCE_TO_ENDTAG); node.type = NodeType.EndTag; lexer.ungetToken(); Modified: branches/CodeUpdateAndJava5/src/main/java/org/w3c/tidy/Report.java =================================================================== --- branches/CodeUpdateAndJava5/src/main/java/org/w3c/tidy/Report.java 2010-11-13 20:44:58 UTC (rev 1186) +++ branches/CodeUpdateAndJava5/src/main/java/org/w3c/tidy/Report.java 2010-11-13 21:24:53 UTC (rev 1187) @@ -701,7 +701,7 @@ break; case NESTED_EMPHASIS : - messageLexer(lexer, Level.INFO, code, getTagName(node)); + messageNode(lexer, Level.WARNING, rpt, code, nodedesc); break; case MISSING_STARTTAG : This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |