maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject svn commit: r530611 - /maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java
Date Fri, 20 Apr 2007 02:08:53 GMT
Author: jdcasey
Date: Thu Apr 19 19:08:52 2007
New Revision: 530611

URL: http://svn.apache.org/viewvc?view=rev&rev=530611
Log:
Adding escape sequence for pipe and equals sign using backslash character, so we can embed
more advanced macro parameter values, like scripting lines.

Modified:
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.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?view=diff&rev=530611&r1=530610&r2=530611
==============================================================================
--- 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
Thu Apr 19 19:08:52 2007
@@ -2192,6 +2192,8 @@
             String s = text;
 
             s = s.substring( 2, s.length() - 1 );
+            
+            s = escapeForMacro( s );
 
             String[] params = StringUtils.split( s, "|" );
 
@@ -2203,7 +2205,10 @@
             {
                 String[] param = StringUtils.split( params[i], "=" );
 
-                parameters.put( param[0], param[1] );
+                String key = unescapeForMacro( param[0] );
+                String value = unescapeForMacro( param[1] );
+                
+                parameters.put( key, value );
             }
 
             parameters.put( "sourceContent", sourceContent );
@@ -2225,6 +2230,38 @@
             {
                 throw new AptParseException( "Unable to find macro used in the APT document",
e );
             }
+        }
+
+        private String escapeForMacro( String s )
+        {
+            if ( s == null || s.length() < 1 )
+            {
+                return s;
+            }
+            
+            String result = s;
+            
+            // use some outrageously out-of-place chars for text 
+            // (these are device control one/two in unicode)
+            result = StringUtils.replace( result, "\\=", "\u0011" );
+            result = StringUtils.replace( result, "\\|", "\u0012" );
+            
+            return result;
+        }
+        
+        private String unescapeForMacro( String s )
+        {
+            if ( s == null || s.length() < 1 )
+            {
+                return s;
+            }
+            
+            String result = s;
+            
+            result = StringUtils.replace( result, "\u0011", "=" );
+            result = StringUtils.replace( result, "\u0012", "|" );
+            
+            return result;
         }
     }
 



Mime
View raw message