Author: vsiveton Date: Wed May 27 10:20:47 2009 New Revision: 779083 URL: http://svn.apache.org/viewvc?rev=779083&view=rev Log: DOXIA-323: Apt parser garbles some special characters inside tables
o take care of special characters in cell o using unicode char o update test case Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java?rev=779083&r1=779082&r2=779083&view=diff ============================================================================== --- maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java (original) +++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java Wed May 27 10:20:47 2009 @@ -2359,7 +2359,7 @@ AptParser.this.sink.tableRows( justification, grid ); } - line = replaceAll( line, "\\|", "\\174" ); + line = replaceAll( line, "\\|", "\\u007C" ); StringTokenizer cellLines = new StringTokenizer( line, "|", true ); @@ -2382,14 +2382,27 @@ continue; } processedGrid = false; - cellLine = replaceAll( cellLine, "\\", "\\240" ); + cellLine = replaceAll( cellLine, "\\", "\\u00A0" ); // linebreak + // Escaped special characters: \~, \=, \-, \+, \*, \[, \], \<, \>, \{, \}, \\. + cellLine = replaceAll( cellLine, "\\u00A0~", "\\~" ); + cellLine = replaceAll( cellLine, "\\u00A0=", "\\=" ); + cellLine = replaceAll( cellLine, "\\u00A0-", "\\-" ); + cellLine = replaceAll( cellLine, "\\u00A0+", "\\+" ); + cellLine = replaceAll( cellLine, "\\u00A0*", "\\*" ); + cellLine = replaceAll( cellLine, "\\u00A0[", "\\[" ); + cellLine = replaceAll( cellLine, "\\u00A0]", "\\]" ); + cellLine = replaceAll( cellLine, "\\u00A0<", "\\<" ); + cellLine = replaceAll( cellLine, "\\u00A0>", "\\>" ); + cellLine = replaceAll( cellLine, "\\u00A0{", "\\{" ); + cellLine = replaceAll( cellLine, "\\u00A0}", "\\}" ); + cellLine = replaceAll( cellLine, "\\u00A0\\u00A0", "\\\\" ); cellLine = cellLine.trim(); StringBuffer cell = cells[i]; if ( cellLine.length() > 0 ) { // line break in table cells - if ( cell.toString().trim().endsWith( "\\240" ) ) + if ( cell.toString().trim().endsWith( "\\u00A0" ) ) { cell.append( "\\\n" ); } Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java?rev=779083&r1=779082&r2=779083&view=diff ============================================================================== --- maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java (original) +++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java Wed May 27 10:20:47 2009 @@ -583,15 +583,11 @@ event = (SinkEventElement) it.next(); assertEquals( "text", event.getName() ); - - // FIXME! - /* assertEquals( "~ = - + * [ ] < > { } \\", event.getArgs()[0] ); assertEquals( "tableCell_", ( (SinkEventElement) it.next() ).getName() ); assertEquals( "tableCell", ( (SinkEventElement) it.next() ).getName() ); assertEquals( "text", ( (SinkEventElement) it.next() ).getName() ); assertEquals( "tableCell_", ( (SinkEventElement) it.next() ).getName() ); - */ } /** {...@inheritdoc} */