Author: ltheussl
Date: Sun Dec 16 11:56:27 2007
New Revision: 604681
URL: http://svn.apache.org/viewvc?rev=604681&view=rev
Log:
[DOXIA-190] text like (=something=) is parsed incorrectly
Submitted by: Juan F. Codagnone, Christian Nardi
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/parser/FormatedTextParser.java
maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/FormatedTextTest.java
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/parser/FormatedTextParser.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/parser/FormatedTextParser.java?rev=604681&r1=604680&r2=604681&view=diff
==============================================================================
---
maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/parser/FormatedTextParser.java
(original)
+++
maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/parser/FormatedTextParser.java
Sun Dec 16 11:56:27 2007
@@ -174,7 +174,8 @@
while ( t != -1 && ( t = line.indexOf( SPECIAL_CHAR[i], t ) ) !=
-1 )
{
// and check if it at the begining of a word.
- if ( t == 0 || isSpace( line.charAt( t - 1 ) ) )
+ if ( t == 0 || isSpace( line.charAt( t - 1 ) )
+ || isParenthesis( line.charAt( t - 1 ) ) )
{
// if it is, and if, check to avoid going beyond the
string
if ( t + specialLen < line.length() )
@@ -267,6 +268,14 @@
// profit
return ret;
+ }
+
+ /**
+ * @param c character to test
+ * @return <code>true</code> if c is a parenthesis
+ */
+ private boolean isParenthesis( final char c ) {
+ return c == '(' || c == ')';
}
/**
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/FormatedTextTest.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/FormatedTextTest.java?rev=604681&r1=604680&r2=604681&view=diff
==============================================================================
---
maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/FormatedTextTest.java
(original)
+++
maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/FormatedTextTest.java
Sun Dec 16 11:56:27 2007
@@ -111,14 +111,16 @@
String text;
Block []blocks;
- text = "mary =has= a =little= lamb";
+ text = "mary =has= a =little= lamb He followed her (=to school one
day=)";
blocks = formatTextParser.parse( text );
assertTrue( Arrays.equals( new Block[]{
new TextBlock( "mary " ),
new MonospaceBlock( new Block[]{new TextBlock( "has" )} ),
new TextBlock( " a " ),
new MonospaceBlock( new Block[]{new TextBlock( "little" )} ),
- new TextBlock( " lamb" ),
+ new TextBlock( " lamb He followed her (" ),
+ new MonospaceBlock( new Block[]{new TextBlock( "to school one day"
)} ),
+ new TextBlock( ")" ),
}, blocks ) );
}