maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsive...@apache.org
Subject svn commit: r560360 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src: main/java/org/apache/maven/doxia/module/apt/ test/java/org/apache/maven/doxia/module/apt/
Date Fri, 27 Jul 2007 19:34:14 GMT
Author: vsiveton
Date: Fri Jul 27 12:34:13 2007
New Revision: 560360

URL: http://svn.apache.org/viewvc?view=rev&rev=560360
Log:
o Put all hardcoded markups in an interface
o updated references
o added also some javadocs

Added:
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptMarkup.java   (with props)
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/main/java/org/apache/maven/doxia/module/apt/AptSink.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptSinkTest.java

Added: maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptMarkup.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/AptMarkup.java?view=auto&rev=560360
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptMarkup.java (added)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptMarkup.java Fri Jul 27 12:34:13 2007
@@ -0,0 +1,199 @@
+package org.apache.maven.doxia.module.apt;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * This interface defines all markups and syntaxes used by the <b>APT</b> format.
+ *
+ * @see <a href="http://maven.apache.org/doxia/references/apt-format.html">http://maven.apache.org/doxia/references/apt-format.html</a>
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ * @since 1.0
+ */
+public interface AptMarkup
+{
+    /** The vm line separator */
+    /** TODO should be in a super interface */
+    String EOL = System.getProperty( "line.separator" );
+
+    // ----------------------------------------------------------------------
+    // Markup separators
+    // ----------------------------------------------------------------------
+
+    /** APT comment markup char: '~' */
+    char COMMENT_MARKUP = '~';
+
+    /** APT space markup char: ' ' */
+    char SPACE_MARKUP = ' ';
+
+    /** APT tab markup char: '\t' */
+    char TAB_MARKUP = '\t';
+
+    /** APT backslash markup char: '\\' */
+    char BACKSLASH_MARKUP = '\\';
+
+    /** APT star markup char: '*' */
+    char STAR_MARKUP = '*';
+
+    /** APT plus markup char: '+' */
+    char PLUS_MARKUP = '+';
+
+    /** APT minus markup char: '-' */
+    char MINUS_MARKUP = '-';
+
+    /** APT equal markup char: '=' */
+    char EQUAL_MARKUP = '=';
+
+    /** APT pipe markup char: '|' */
+    char PIPE_MARKUP = '|';
+
+    /** APT left curly bracket markup char: '{' */
+    char LEFT_CURLY_BRACKET_MARKUP = '{';
+
+    /** APT right curly bracket markup char: '}' */
+    char RIGHT_CURLY_BRACKET_MARKUP = '}';
+
+    /** APT left square bracket markup char: '[' */
+    char LEFT_SQUARE_BRACKET_MARKUP = '[';
+
+    /** APT right square bracket markup char: ']' */
+    char RIGHT_SQUARE_BRACKET_MARKUP = ']';
+
+    /** APT less than markup char: '<' */
+    char LESS_THAN_MARKUP = '<';
+
+    /** APT greater than markup char: '>' */
+    char GREATER_THAN_MARKUP = '>';
+
+    /** APT numbering lower alpha markup char: 'a' */
+    char NUMBERING_LOWER_ALPHA_MARKUP = 'a';
+
+    /** APT numbering upper alpha markup char: 'A' */
+    char NUMBERING_UPPER_ALPHA_MARKUP = 'A';
+
+    /** APT numbering lower roman markup char: 'i' */
+    char NUMBERING_LOWER_ROMAN_MARKUP = 'i';
+
+    /** APT numbering upper roman markup char: 'I' */
+    char NUMBERING_UPPER_ROMAN_MARKUP = 'I';
+
+    /** APT numbering decimal markup char: '1' */
+    char NUMBERING_MARKUP = '1';
+
+    /** APT page break markup char: '\f' */
+    char PAGE_BREAK_MARKUP = '\f';
+
+    /** APT percent markup char: '%' */
+    char PERCENT_MARKUP = '%';
+
+    /** APT colon markup char: ':' */
+    char COLON_MARKUP = ':';
+
+    // ----------------------------------------------------------------------
+    // Markup syntax
+    // ----------------------------------------------------------------------
+
+    /** Syntax for the header start: " -----" */
+    String HEADER_START = SPACE_MARKUP + StringUtils.repeat( String.valueOf( MINUS_MARKUP ), 5 );
+
+    /** Syntax for the section title start: "*" */
+    String SECTION_TITLE_START = String.valueOf( STAR_MARKUP );
+
+    /** Syntax for the list start: "*" */
+    String LIST_START = String.valueOf( STAR_MARKUP );
+
+    /** Syntax for the list end: "[]" */
+    String LIST_END = String.valueOf( LEFT_SQUARE_BRACKET_MARKUP ) + String.valueOf( RIGHT_SQUARE_BRACKET_MARKUP );
+
+    /** Syntax for the page break: "\f" */
+    String PAGE_BREAK = String.valueOf( PAGE_BREAK_MARKUP );
+
+    /** Syntax for the boxed verbatim start: "+------+" */
+    String BOXED_VERBATIM_START = String.valueOf( PLUS_MARKUP )
+        + StringUtils.repeat( String.valueOf( MINUS_MARKUP ), 6 ) + String.valueOf( PLUS_MARKUP );
+
+    /** Syntax for the boxed verbatim end: "+------+" */
+    String BOXED_VERBATIM_END = BOXED_VERBATIM_START;
+
+    /** Syntax for the non boxed verbatim start: "------" */
+    String NON_BOXED_VERBATIM_START = StringUtils.repeat( String.valueOf( MINUS_MARKUP ), 6 );
+
+    /** Syntax for the non boxed verbatim end: "------" */
+    String NON_BOXED_VERBATIM_END = NON_BOXED_VERBATIM_START;
+
+    /** Syntax for the horizontal rule: "========" */
+    String HORIZONTAL_RULE = StringUtils.repeat( String.valueOf( EQUAL_MARKUP ), 8 );
+
+    /** Syntax for the table row start: "*--" */
+    String TABLE_ROW_START = STAR_MARKUP + StringUtils.repeat( String.valueOf( MINUS_MARKUP ), 2 );
+
+    /** Syntax for the table row end: "|" */
+    String TABLE_ROW_SEPARATOR = String.valueOf( PIPE_MARKUP );
+
+    /** Syntax for the table column, left style: "-+" */
+    String TABLE_COL_LEFT_ALIGNED = StringUtils.repeat( String.valueOf( MINUS_MARKUP ), 2 )
+        + String.valueOf( PLUS_MARKUP );
+
+    /** Syntax for the table column, centered style: "-*" */
+    String TABLE_COL_CENTERED_ALIGNED = StringUtils.repeat( String.valueOf( MINUS_MARKUP ), 2 )
+        + String.valueOf( STAR_MARKUP );
+
+    /** Syntax for the table column, right style: "-:" */
+    String TABLE_COL_RIGHT_ALIGNED = StringUtils.repeat( String.valueOf( MINUS_MARKUP ), 2 )
+        + String.valueOf( COLON_MARKUP );
+
+    /** Syntax for the table cell start: "|" */
+    String TABLE_CELL_SEPARATOR = String.valueOf( PIPE_MARKUP );
+
+    /** Syntax for the anchor start: "{" */
+    String ANCHOR_START = String.valueOf( LEFT_CURLY_BRACKET_MARKUP );
+
+    /** Syntax for the anchor end: "}" */
+    String ANCHOR_END = String.valueOf( RIGHT_CURLY_BRACKET_MARKUP );
+
+    /** Syntax for the link start: "{{{" */
+    String LINK_START_1 = StringUtils.repeat( String.valueOf( LEFT_CURLY_BRACKET_MARKUP ), 3 );
+
+    /** Syntax for the link start: "}" */
+    String LINK_START_2 = String.valueOf( RIGHT_CURLY_BRACKET_MARKUP );
+
+    /** Syntax for the link end: "}}" */
+    String LINK_END = StringUtils.repeat( String.valueOf( RIGHT_CURLY_BRACKET_MARKUP ), 2 );
+
+    /** Syntax for the italic style start: "<" */
+    String ITALIC_START = String.valueOf( LESS_THAN_MARKUP );
+
+    /** Syntax for the italic style end: ">" */
+    String ITALIC_END = String.valueOf( GREATER_THAN_MARKUP );
+
+    /** Syntax for the bold style start: "<<" */
+    String BOLD_START = StringUtils.repeat( String.valueOf( LESS_THAN_MARKUP ), 2 );
+
+    /** Syntax for the bold style end: ">>" */
+    String BOLD_END = StringUtils.repeat( String.valueOf( GREATER_THAN_MARKUP ), 2 );
+
+    /** Syntax for the mono-spaced style start: "<<<" */
+    String MONOSPACED_START = StringUtils.repeat( String.valueOf( LESS_THAN_MARKUP ), 3 );
+
+    /** Syntax for the mono-spaced style end: ">>>" */
+    String MONOSPACED_END = StringUtils.repeat( String.valueOf( GREATER_THAN_MARKUP ), 3 );
+
+    /** Syntax for the non breaking space: "\ " */
+    String NON_BREAKING_SPACE = String.valueOf( BACKSLASH_MARKUP ) + String.valueOf( SPACE_MARKUP );
+}

Propchange: maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptMarkup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptMarkup.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

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=560360&r1=560359&r2=560360
==============================================================================
--- 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 Fri Jul 27 12:34:13 2007
@@ -36,44 +36,67 @@
 import java.util.Map;
 import java.util.StringTokenizer;
 
-/** @plexus.component role="org.apache.maven.doxia.parser.Parser" role-hint="apt" */
+/**
+ * The APT parser.
+ * <br/>
+ * Based on the <a href="http://www.xmlmind.com/aptconvert.html">APTconvert</a> project.
+ *
+ * @since 1.0
+ * @plexus.component role="org.apache.maven.doxia.parser.Parser" role-hint="apt"
+ */
 public class AptParser
     extends AbstractParser
+    implements AptMarkup
 {
-    private static final String EOL = System.getProperty( "line.separator" );
-
+    /** Title event id */
     private static final int TITLE = 0;
 
+    /** Section 1 event id */
     private static final int SECTION1 = 1;
 
+    /** Section 2 event id */
     private static final int SECTION2 = 2;
 
+    /** Section 3 event id */
     private static final int SECTION3 = 3;
 
+    /** Section 4 event id */
     private static final int SECTION4 = 4;
 
+    /** Section 5 event id */
     private static final int SECTION5 = 5;
 
+    /** Paragraph event id */
     private static final int PARAGRAPH = 6;
 
+    /** Verbatim event id */
     private static final int VERBATIM = 7;
 
+    /** Figure event id */
     private static final int FIGURE = 8;
 
+    /** Table event id */
     private static final int TABLE = 9;
 
+    /** List event id */
     private static final int LIST_ITEM = 10;
 
+    /** Numbered list event id */
     private static final int NUMBERED_LIST_ITEM = 11;
 
+    /** Definition list event id */
     private static final int DEFINITION_LIST_ITEM = 12;
 
+    /** Horizontal rule event id */
     private static final int HORIZONTAL_RULE = 13;
 
+    /** Page break event id */
     private static final int PAGE_BREAK = 14;
 
+    /** List break event id */
     private static final int LIST_BREAK = 15;
 
+    /** Macro event id */
     private static final int MACRO = 16;
 
     private static final String typeNames[] = {"TITLE", "SECTION1", "SECTION2", "SECTION3", "SECTION4", "SECTION5",
@@ -88,7 +111,9 @@
 
     public static final int TAB_WIDTH = 8;
 
-    // -----------------------------------------------------------------------
+    // ----------------------------------------------------------------------
+    // Instance fields
+    // ----------------------------------------------------------------------
 
     private String sourceContent;
 
@@ -104,7 +129,9 @@
 
     private int blockLineNumber;
 
-    // -----------------------------------------------------------------------
+    // ----------------------------------------------------------------------
+    // Public methods
+    // ----------------------------------------------------------------------
 
     public void parse( Reader source,
                        Sink sink )
@@ -163,6 +190,10 @@
         return blockLineNumber;
     }
 
+    // ----------------------------------------------------------------------
+    // Private methods
+    // ----------------------------------------------------------------------
+
     private void traverseHead()
         throws AptParseException
     {
@@ -617,14 +648,14 @@
             {
                 switch ( line.charAt( i ) )
                 {
-                    case' ':
+                    case SPACE_MARKUP:
                         ++indent;
                         break;
-                    case'\t':
+                    case TAB_MARKUP:
                         indent += 8;
                         break;
-                    case'~':
-                        if ( charAt( line, length, i + 1 ) == '~' )
+                    case COMMENT_MARKUP:
+                        if ( charAt( line, length, i + 1 ) == COMMENT_MARKUP )
                         {
                             // Comment.
                             i = length;
@@ -650,18 +681,18 @@
         block = null;
         switch ( line.charAt( i ) )
         {
-            case'*':
+            case STAR_MARKUP:
                 if ( indent == 0 )
                 {
-                    if ( charAt( line, length, i + 1 ) == '-' && charAt( line, length, i + 2 ) == '-' )
+                    if ( charAt( line, length, i + 1 ) == MINUS_MARKUP && charAt( line, length, i + 2 ) == MINUS_MARKUP )
                     {
                         block = new Table( indent, line );
                     }
-                    else if ( charAt( line, length, i + 1 ) == '*' )
+                    else if ( charAt( line, length, i + 1 ) == STAR_MARKUP )
                     {
-                        if ( charAt( line, length, i + 2 ) == '*' )
+                        if ( charAt( line, length, i + 2 ) == STAR_MARKUP )
                         {
-                            if ( charAt( line, length, i + 3 ) == '*' )
+                            if ( charAt( line, length, i + 3 ) == STAR_MARKUP )
                             {
                                 block = new Section5( indent, line );
                             }
@@ -685,8 +716,8 @@
                     block = new ListItem( indent, line );
                 }
                 break;
-            case'[':
-                if ( charAt( line, length, i + 1 ) == ']' )
+            case LEFT_SQUARE_BRACKET_MARKUP:
+                if ( charAt( line, length, i + 1 ) == RIGHT_SQUARE_BRACKET_MARKUP )
                 {
                     block = new ListBreak( indent, line );
                 }
@@ -698,25 +729,25 @@
                     }
                     else
                     {
-                        if ( charAt( line, length, i + 1 ) == '[' )
+                        if ( charAt( line, length, i + 1 ) == LEFT_SQUARE_BRACKET_MARKUP )
                         {
                             int numbering;
 
                             switch ( charAt( line, length, i + 2 ) )
                             {
-                                case'a':
+                                case NUMBERING_LOWER_ALPHA_MARKUP:
                                     numbering = Sink.NUMBERING_LOWER_ALPHA;
                                     break;
-                                case'A':
+                                case NUMBERING_UPPER_ALPHA_MARKUP:
                                     numbering = Sink.NUMBERING_UPPER_ALPHA;
                                     break;
-                                case'i':
+                                case NUMBERING_LOWER_ROMAN_MARKUP:
                                     numbering = Sink.NUMBERING_LOWER_ROMAN;
                                     break;
-                                case'I':
+                                case NUMBERING_UPPER_ROMAN_MARKUP:
                                     numbering = Sink.NUMBERING_UPPER_ROMAN;
                                     break;
-                                case'1':
+                                case NUMBERING_MARKUP:
                                 default:
                                     // The first item establishes the numbering
                                     // scheme for the whole list.
@@ -732,8 +763,8 @@
                     }
                 }
                 break;
-            case'-':
-                if ( charAt( line, length, i + 1 ) == '-' && charAt( line, length, i + 2 ) == '-' )
+            case MINUS_MARKUP:
+                if ( charAt( line, length, i + 1 ) == MINUS_MARKUP && charAt( line, length, i + 2 ) == MINUS_MARKUP )
                 {
                     if ( indent == 0 )
                     {
@@ -748,26 +779,26 @@
                     }
                 }
                 break;
-            case'+':
-                if ( indent == 0 && charAt( line, length, i + 1 ) == '-' && charAt( line, length, i + 2 ) == '-' )
+            case PLUS_MARKUP:
+                if ( indent == 0 && charAt( line, length, i + 1 ) == MINUS_MARKUP && charAt( line, length, i + 2 ) == MINUS_MARKUP )
                 {
                     block = new Verbatim( indent, line );
                 }
                 break;
-            case'=':
-                if ( indent == 0 && charAt( line, length, i + 1 ) == '=' && charAt( line, length, i + 2 ) == '=' )
+            case EQUAL_MARKUP:
+                if ( indent == 0 && charAt( line, length, i + 1 ) == EQUAL_MARKUP && charAt( line, length, i + 2 ) == EQUAL_MARKUP )
                 {
                     block = new HorizontalRule( indent, line );
                 }
                 break;
-            case'\f':
+            case PAGE_BREAK_MARKUP:
                 if ( indent == 0 )
                 {
                     block = new PageBreak( indent, line );
                 }
                 break;
-            case'%':
-                if ( indent == 0 && charAt( line, length, i + 1 ) == '{' )
+            case PERCENT_MARKUP:
+                if ( indent == 0 && charAt( line, length, i + 1 ) == LEFT_CURLY_BRACKET_MARKUP )
                 {
                     block = new MacroBlock( indent, line );
                 }
@@ -826,8 +857,8 @@
         {
             switch ( string.charAt( i ) )
             {
-                case' ':
-                case'\t':
+                case SPACE_MARKUP:
+                case TAB_MARKUP:
                     break;
                 default:
                     break loop;
@@ -854,19 +885,19 @@
             char c = text.charAt( i );
             switch ( c )
             {
-                case'\\':
+                case BACKSLASH_MARKUP:
                     if ( i + 1 < end )
                     {
                         char escaped = text.charAt( i + 1 );
                         switch ( escaped )
                         {
-                            case' ':
+                            case SPACE_MARKUP:
                                 ++i;
                                 flushTraversed( buffer, sink );
                                 sink.nonBreakingSpace();
                                 break;
-                            case'\r':
-                            case'\n':
+                            case '\r':
+                            case '\n':
                                 ++i;
                                 // Skip white space which may follow a line break.
                                 while ( i + 1 < end && Character.isWhitespace( text.charAt( i + 1 ) ) )
@@ -876,23 +907,23 @@
                                 flushTraversed( buffer, sink );
                                 sink.lineBreak();
                                 break;
-                            case'\\':
-                            case'|':
-                            case'~':
-                            case'=':
-                            case'-':
-                            case'+':
-                            case'*':
-                            case'[':
-                            case']':
-                            case'<':
-                            case'>':
-                            case'{':
-                            case'}':
+                            case BACKSLASH_MARKUP:
+                            case PIPE_MARKUP:
+                            case COMMENT_MARKUP:
+                            case EQUAL_MARKUP:
+                            case MINUS_MARKUP:
+                            case PLUS_MARKUP:
+                            case STAR_MARKUP:
+                            case LEFT_SQUARE_BRACKET_MARKUP:
+                            case RIGHT_SQUARE_BRACKET_MARKUP:
+                            case LESS_THAN_MARKUP:
+                            case GREATER_THAN_MARKUP:
+                            case LEFT_CURLY_BRACKET_MARKUP:
+                            case RIGHT_CURLY_BRACKET_MARKUP:
                                 ++i;
                                 buffer.append( escaped );
                                 break;
-                            case'x':
+                            case 'x':
                                 if ( i + 3 < end && isHexChar( text.charAt( i + 2 ) ) &&
                                     isHexChar( text.charAt( i + 3 ) ) )
                                 {
@@ -911,10 +942,10 @@
                                 }
                                 else
                                 {
-                                    buffer.append( '\\' );
+                                    buffer.append( BACKSLASH_MARKUP );
                                 }
                                 break;
-                            case'u':
+                            case 'u':
                                 if ( i + 5 < end && isHexChar( text.charAt( i + 2 ) ) &&
                                     isHexChar( text.charAt( i + 3 ) ) && isHexChar( text.charAt( i + 4 ) ) &&
                                     isHexChar( text.charAt( i + 5 ) ) )
@@ -934,7 +965,7 @@
                                 }
                                 else
                                 {
-                                    buffer.append( '\\' );
+                                    buffer.append( BACKSLASH_MARKUP );
                                 }
                                 break;
                             default:
@@ -964,20 +995,20 @@
                                 }
                                 else
                                 {
-                                    buffer.append( '\\' );
+                                    buffer.append( BACKSLASH_MARKUP );
                                 }
                         }
                     }
                     else
                     {
-                        buffer.append( '\\' );
+                        buffer.append( BACKSLASH_MARKUP );
                     }
                     break;
 
-                case'{': /*}*/
+                case LEFT_CURLY_BRACKET_MARKUP: /*}*/
                     if ( !anchor && !link )
                     {
-                        if ( i + 1 < end && text.charAt( i + 1 ) == '{' /*}*/ )
+                        if ( i + 1 < end && text.charAt( i + 1 ) == LEFT_CURLY_BRACKET_MARKUP /*}*/ )
                         {
                             ++i;
                             link = true;
@@ -985,7 +1016,7 @@
 
                             String linkAnchor = null;
 
-                            if ( i + 1 < end && text.charAt( i + 1 ) == '{' /*}*/ )
+                            if ( i + 1 < end && text.charAt( i + 1 ) == LEFT_CURLY_BRACKET_MARKUP /*}*/ )
                             {
                                 ++i;
                                 StringBuffer buf = new StringBuffer();
@@ -1013,8 +1044,8 @@
                     }
                     break;
 
-                case /*{*/ '}':
-                    if ( link && i + 1 < end && text.charAt( i + 1 ) == /*{*/ '}' )
+                case /*{*/ RIGHT_CURLY_BRACKET_MARKUP:
+                    if ( link && i + 1 < end && text.charAt( i + 1 ) == /*{*/ RIGHT_CURLY_BRACKET_MARKUP )
                     {
                         ++i;
                         link = false;
@@ -1033,12 +1064,12 @@
                     }
                     break;
 
-                case'<':
+                case LESS_THAN_MARKUP:
                     if ( !italic && !bold && !monospaced )
                     {
-                        if ( i + 1 < end && text.charAt( i + 1 ) == '<' )
+                        if ( i + 1 < end && text.charAt( i + 1 ) == LESS_THAN_MARKUP )
                         {
-                            if ( i + 2 < end && text.charAt( i + 2 ) == '<' )
+                            if ( i + 2 < end && text.charAt( i + 2 ) == LESS_THAN_MARKUP )
                             {
                                 i += 2;
                                 monospaced = true;
@@ -1066,15 +1097,15 @@
                     }
                     break;
 
-                case'>':
-                    if ( monospaced && i + 2 < end && text.charAt( i + 1 ) == '>' && text.charAt( i + 2 ) == '>' )
+                case GREATER_THAN_MARKUP:
+                    if ( monospaced && i + 2 < end && text.charAt( i + 1 ) == GREATER_THAN_MARKUP && text.charAt( i + 2 ) == GREATER_THAN_MARKUP )
                     {
                         i += 2;
                         monospaced = false;
                         flushTraversed( buffer, sink );
                         sink.monospaced_();
                     }
-                    else if ( bold && i + 1 < end && text.charAt( i + 1 ) == '>' )
+                    else if ( bold && i + 1 < end && text.charAt( i + 1 ) == GREATER_THAN_MARKUP )
                     {
                         ++i;
                         bold = false;
@@ -1096,7 +1127,7 @@
                 default:
                     if ( Character.isWhitespace( c ) )
                     {
-                        buffer.append( ' ' );
+                        buffer.append( SPACE_MARKUP );
 
                         // Skip to the last char of a sequence of white spaces.
                         while ( i + 1 < end && Character.isWhitespace( text.charAt( i + 1 ) ) )
@@ -1113,23 +1144,23 @@
 
         if ( monospaced )
         {
-            throw new AptParseException( "missing '>>>'" );
+            throw new AptParseException( "missing '" + GREATER_THAN_MARKUP + GREATER_THAN_MARKUP + GREATER_THAN_MARKUP + "'" );
         }
         if ( bold )
         {
-            throw new AptParseException( "missing '>>'" );
+            throw new AptParseException( "missing '" + GREATER_THAN_MARKUP + GREATER_THAN_MARKUP + "'" );
         }
         if ( italic )
         {
-            throw new AptParseException( "missing '>'" );
+            throw new AptParseException( "missing '" + GREATER_THAN_MARKUP + "'" );
         }
         if ( link )
         {
-            throw new AptParseException( "missing '}}'" );
+            throw new AptParseException( "missing '" + RIGHT_CURLY_BRACKET_MARKUP + RIGHT_CURLY_BRACKET_MARKUP + "'" );
         }
         if ( anchor )
         {
-            throw new AptParseException( "missing '}'" );
+            throw new AptParseException( "missing '" + RIGHT_CURLY_BRACKET_MARKUP + "'" );
         }
 
         flushTraversed( buffer, sink );
@@ -1158,9 +1189,9 @@
             char c = text.charAt( i );
             switch ( c )
             {
-                case'}':
+                case RIGHT_CURLY_BRACKET_MARKUP:
                     break loop;
-                case'\\':
+                case BACKSLASH_MARKUP:
                     if ( i + 1 < end )
                     {
                         ++i;
@@ -1168,7 +1199,7 @@
                     }
                     else
                     {
-                        linkAnchor.append( '\\' );
+                        linkAnchor.append( BACKSLASH_MARKUP );
                     }
                     break;
                 default:
@@ -1177,7 +1208,7 @@
         }
         if ( i == end )
         {
-            throw new AptParseException( "missing '}'" );
+            throw new AptParseException( "missing '" + RIGHT_CURLY_BRACKET_MARKUP + "'" );
         }
 
         return i;
@@ -1188,14 +1219,14 @@
                                             int end )
         throws AptParseException
     {
-        char previous2 = '{';
-        char previous = '{';
+        char previous2 = LEFT_CURLY_BRACKET_MARKUP;
+        char previous = LEFT_CURLY_BRACKET_MARKUP;
         int i;
 
         for ( i = begin; i < end; ++i )
         {
             char c = text.charAt( i );
-            if ( c == '}' && previous == '}' && previous2 != '\\' )
+            if ( c == RIGHT_CURLY_BRACKET_MARKUP && previous == RIGHT_CURLY_BRACKET_MARKUP && previous2 != BACKSLASH_MARKUP )
             {
                 break;
             }
@@ -1205,7 +1236,7 @@
         }
         if ( i == end )
         {
-            throw new AptParseException( "missing '}}'" );
+            throw new AptParseException( "missing '" + LEFT_CURLY_BRACKET_MARKUP + LEFT_CURLY_BRACKET_MARKUP + "'" );
         }
 
         return doGetTraversedLink( text, begin, i - 1 );
@@ -1216,13 +1247,13 @@
                                               int end )
         throws AptParseException
     {
-        char previous = '{';
+        char previous = LEFT_CURLY_BRACKET_MARKUP;
         int i;
 
         for ( i = begin; i < end; ++i )
         {
             char c = text.charAt( i );
-            if ( c == '}' && previous != '\\' )
+            if ( c == RIGHT_CURLY_BRACKET_MARKUP && previous != BACKSLASH_MARKUP )
             {
                 break;
             }
@@ -1231,7 +1262,7 @@
         }
         if ( i == end )
         {
-            throw new AptParseException( "missing '}'" );
+            throw new AptParseException( "missing '" + RIGHT_CURLY_BRACKET_MARKUP + "'" );
         }
 
         return doGetTraversedLink( text, begin, i );
@@ -1248,12 +1279,12 @@
         {
             public void lineBreak()
             {
-                buffer.append( ' ' );
+                buffer.append( SPACE_MARKUP );
             }
 
             public void nonBreakingSpace()
             {
-                buffer.append( ' ' );
+                buffer.append( SPACE_MARKUP );
             }
 
             public void text( String text )
@@ -1314,7 +1345,7 @@
 
                     i = skipSpace( l, length, i );
                     if ( i == length ||
-                        ( AptParser.charAt( l, length, i ) == '~' && AptParser.charAt( l, length, i + 1 ) == '~' ) )
+                        ( AptParser.charAt( l, length, i ) == COMMENT_MARKUP && AptParser.charAt( l, length, i + 1 ) == COMMENT_MARKUP ) )
                     {
                         // Stop after open or comment line and skip it.
                         // (A comment line is considered to be an open line.)
@@ -1364,7 +1395,7 @@
             int i = skipSpaceFrom( 0 );
             for ( ; i < textLength; ++i )
             {
-                if ( text.charAt( i ) != '*' )
+                if ( text.charAt( i ) != STAR_MARKUP )
                 {
                     break;
                 }
@@ -1375,11 +1406,11 @@
         protected int skipFromLeftToRightBracket( int i )
             throws AptParseException
         {
-            char previous = '[';
+            char previous = LEFT_SQUARE_BRACKET_MARKUP;
             for ( ++i; i < textLength; ++i )
             {
                 char c = text.charAt( i );
-                if ( c == ']' && previous != '\\' )
+                if ( c == RIGHT_SQUARE_BRACKET_MARKUP && previous != BACKSLASH_MARKUP )
                 {
                     break;
                 }
@@ -1387,7 +1418,7 @@
             }
             if ( i == textLength )
             {
-                throw new AptParseException( "missing ']'" );
+                throw new AptParseException( "missing '" + RIGHT_SQUARE_BRACKET_MARKUP + "'" );
             }
 
             return i;
@@ -1442,8 +1473,8 @@
                 String line = lines.nextToken().trim();
                 int lineLength = line.length();
 
-                if ( AptParser.charAt( line, lineLength, 0 ) == '-' && AptParser.charAt( line, lineLength, 1 ) == '-' &&
-                    AptParser.charAt( line, lineLength, 2 ) == '-' )
+                if ( AptParser.charAt( line, lineLength, 0 ) == MINUS_MARKUP && AptParser.charAt( line, lineLength, 1 ) == MINUS_MARKUP &&
+                    AptParser.charAt( line, lineLength, 2 ) == MINUS_MARKUP )
                 {
                     switch ( separator )
                     {
@@ -1700,15 +1731,15 @@
 
             StringBuffer buffer = new StringBuffer();
             char firstChar = firstLine.charAt( 0 );
-            boxed = ( firstChar == '+' );
+            boxed = ( firstChar == PLUS_MARKUP );
 
             while ( AptParser.this.line != null )
             {
                 String l = AptParser.this.line;
                 int length = l.length();
 
-                if ( AptParser.charAt( l, length, 0 ) == firstChar && AptParser.charAt( l, length, 1 ) == '-' &&
-                    AptParser.charAt( l, length, 2 ) == '-' )
+                if ( AptParser.charAt( l, length, 0 ) == firstChar && AptParser.charAt( l, length, 1 ) == MINUS_MARKUP &&
+                    AptParser.charAt( l, length, 2 ) == MINUS_MARKUP )
                 {
                     AptParser.this.nextLine();
 
@@ -1725,7 +1756,7 @@
                 {
                     char c = l.charAt( i );
 
-                    if ( c == '\t' )
+                    if ( c == TAB_MARKUP )
                     {
                         prevColumn = column;
 
@@ -1873,7 +1904,7 @@
                     if ( init == 1 )
                     {
                         init = 0;
-                        grid = ( AptParser.charAt( line, lineLength, 0 ) == '|' );
+                        grid = ( AptParser.charAt( line, lineLength, 0 ) == PIPE_MARKUP );
                         AptParser.this.sink.tableRows( justification, grid );
                     }
 
@@ -1949,9 +1980,9 @@
             {
                 switch ( line.charAt( i ) )
                 {
-                    case'*':
-                    case'+':
-                    case':':
+                    case STAR_MARKUP:
+                    case PLUS_MARKUP:
+                    case COLON_MARKUP:
                         ++columns;
                         break;
                 }
@@ -1968,13 +1999,13 @@
             {
                 switch ( line.charAt( i ) )
                 {
-                    case'*':
+                    case STAR_MARKUP:
                         justification[columns++] = JUSTIFY_CENTER;
                         break;
-                    case'+':
+                    case PLUS_MARKUP:
                         justification[columns++] = JUSTIFY_LEFT;
                         break;
-                    case':':
+                    case COLON_MARKUP:
                         justification[columns++] = JUSTIFY_RIGHT;
                         break;
                 }
@@ -2084,11 +2115,11 @@
         {
             int i = skipSpaceFrom( 0 );
 
-            char prevChar = ' ';
+            char prevChar = SPACE_MARKUP;
             for ( ; i < textLength; ++i )
             {
                 char c = text.charAt( i );
-                if ( c == ']' && prevChar == ']' )
+                if ( c == RIGHT_SQUARE_BRACKET_MARKUP && prevChar == RIGHT_SQUARE_BRACKET_MARKUP )
                 {
                     break;
                 }
@@ -2097,7 +2128,7 @@
 
             if ( i == textLength )
             {
-                throw new AptParseException( "missing ']]'" );
+                throw new AptParseException( "missing '" + RIGHT_SQUARE_BRACKET_MARKUP + RIGHT_SQUARE_BRACKET_MARKUP + "'" );
             }
 
             return skipSpaceFrom( i + 1 );
@@ -2194,7 +2225,7 @@
             String s = text;
 
             s = s.substring( 2, s.length() - 1 );
-            
+
             s = escapeForMacro( s );
 
             String[] params = StringUtils.split( s, "|" );
@@ -2209,7 +2240,7 @@
 
                 String key = unescapeForMacro( param[0] );
                 String value = unescapeForMacro( param[1] );
-                
+
                 parameters.put( key, value );
             }
 
@@ -2240,29 +2271,29 @@
             {
                 return s;
             }
-            
+
             String result = s;
-            
-            // use some outrageously out-of-place chars for text 
+
+            // 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;
         }
     }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSink.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/AptSink.java?view=diff&rev=560360&r1=560359&r2=560360
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSink.java Fri Jul 27 12:34:13 2007
@@ -29,12 +29,19 @@
 
 /**
  * APT Sink implementation.
+ *
+ * @since 1.0
  * @author eredmond
  * @plexus.component
  */
-public class AptSink extends SinkAdapter
+public class AptSink
+    extends SinkAdapter
+    implements AptMarkup
 {
-    private static final String EOL = System.getProperty( "line.separator" );
+    // ----------------------------------------------------------------------
+    // Instance fields
+    // ----------------------------------------------------------------------
+
     private StringBuffer buffer;
     private StringBuffer tableCaptionBuffer;
     private String author;
@@ -54,6 +61,10 @@
     private String listNestingIndent;
     private Stack listStyles;
 
+    // ----------------------------------------------------------------------
+    // Public protected methods
+    // ----------------------------------------------------------------------
+
     /**
      * Constructor, initialize the variables.
      *
@@ -128,13 +139,13 @@
     {
         headerFlag = false;
 
-        write( " -----" + EOL );
+        write( HEADER_START + EOL );
         write( " " + title + EOL  );
-        write( " -----" + EOL );
+        write( HEADER_START + EOL );
         write( " " + author + EOL  );
-        write( " -----" + EOL );
+        write( HEADER_START + EOL );
         write( " " + date + EOL  );
-        write( " -----" + EOL );
+        write( HEADER_START + EOL );
     }
 
     /** {@inheritDoc} */
@@ -212,7 +223,7 @@
     /** {@inheritDoc} */
     public void sectionTitle2()
     {
-        write( EOL + "*" );
+        write( EOL + SECTION_TITLE_START );
     }
 
     /** {@inheritDoc} */
@@ -224,7 +235,7 @@
     /** {@inheritDoc} */
     public void sectionTitle3()
     {
-        write( EOL + "**" );
+        write( EOL + StringUtils.repeat( SECTION_TITLE_START, 2 ) );
     }
 
     /** {@inheritDoc} */
@@ -236,7 +247,7 @@
     /** {@inheritDoc} */
     public void sectionTitle4()
     {
-        write( EOL + "***" );
+        write( EOL + StringUtils.repeat( SECTION_TITLE_START, 3 ) );
     }
 
     /** {@inheritDoc} */
@@ -248,7 +259,7 @@
     /** {@inheritDoc} */
     public void sectionTitle5()
     {
-        write( EOL + "****" );
+        write( EOL + StringUtils.repeat( SECTION_TITLE_START, 4 ) );
     }
 
     /** {@inheritDoc} */
@@ -261,7 +272,7 @@
     public void list()
     {
         listNestingIndent += " ";
-        listStyles.push( "*" );
+        listStyles.push( LIST_START );
         write( EOL );
     }
 
@@ -270,7 +281,7 @@
     {
         if ( listNestingIndent.length() <= 1 )
         {
-            write( EOL + listNestingIndent + "[]" + EOL );
+            write( EOL + listNestingIndent + LIST_END + EOL );
         }
         else
         {
@@ -331,7 +342,7 @@
     {
         if ( listNestingIndent.length() <= 1 )
         {
-            write( EOL + listNestingIndent + "[]" + EOL );
+            write( EOL + listNestingIndent + LIST_END + EOL );
         }
         else
         {
@@ -346,13 +357,15 @@
     public void numberedListItem()
     {
         String style = (String) listStyles.peek();
-        if ( style == "*" )
+        if ( style.equals( String.valueOf( AptParser.STAR_MARKUP ) ) )
         {
-            write( EOL + listNestingIndent + "* " );
+            write( EOL + listNestingIndent + AptParser.STAR_MARKUP + "" + AptParser.SPACE_MARKUP );
         }
         else
         {
-            write( EOL + listNestingIndent + "[[" + style + "]] " );
+            write( EOL + listNestingIndent + AptParser.LEFT_SQUARE_BRACKET_MARKUP + ""
+                + AptParser.LEFT_SQUARE_BRACKET_MARKUP + style + AptParser.RIGHT_SQUARE_BRACKET_MARKUP + ""
+                + AptParser.RIGHT_SQUARE_BRACKET_MARKUP + "" + AptParser.SPACE_MARKUP );
         }
         itemFlag = true;
     }
@@ -403,7 +416,7 @@
     /** {@inheritDoc} */
     public void pageBreak()
     {
-        write( EOL + "\f" + EOL );
+        write( EOL + PAGE_BREAK + EOL );
     }
 
     /** {@inheritDoc} */
@@ -435,11 +448,11 @@
         this.boxed = boxed;
         if ( boxed )
         {
-            write( "\n+------+\n" );
+            write( "\n" + BOXED_VERBATIM_START + "\n" );
         }
         else
         {
-            write( "\n------\n" );
+            write( "\n" + NON_BOXED_VERBATIM_START + "\n" );
         }
     }
 
@@ -448,11 +461,11 @@
     {
         if ( boxed )
         {
-            write( "\n+------+\n" );
+            write( "\n" + BOXED_VERBATIM_END + "\n" );
         }
         else
         {
-            write( "\n------\n" );
+            write( "\n" + NON_BOXED_VERBATIM_END + "\n" );
         }
         boxed = false;
         verbatimFlag = false;
@@ -461,7 +474,7 @@
     /** {@inheritDoc} */
     public void horizontalRule()
     {
-        write( EOL + "========" + EOL );
+        write( EOL + HORIZONTAL_RULE + EOL );
     }
 
     /** {@inheritDoc} */
@@ -521,7 +534,7 @@
         // TODO: This will need to be more clever, for multi-line cells
         if ( gridFlag )
         {
-            write( "|" );
+            write( TABLE_ROW_SEPARATOR );
         }
 
         write( buffer.toString() );
@@ -538,7 +551,7 @@
     private void buildRowLine()
     {
         StringBuffer rowLine = new StringBuffer();
-        rowLine.append( "*--" );
+        rowLine.append( TABLE_ROW_START );
 
         for ( int i = 0; i < cellCount; i++ )
         {
@@ -546,20 +559,19 @@
             {
                 switch ( cellJustif[i] )
                 {
-                // TODO: use Parser constants
                 case 1:
-                    rowLine.append( "--+" );
+                    rowLine.append( TABLE_COL_LEFT_ALIGNED );
                     break;
                 case 2:
-                    rowLine.append( "--:" );
+                    rowLine.append( TABLE_COL_RIGHT_ALIGNED );
                     break;
                 default:
-                    rowLine.append( "--*" );
+                    rowLine.append( TABLE_COL_CENTERED_ALIGNED );
                 }
             }
             else
             {
-                rowLine.append( "--*" );
+                rowLine.append( TABLE_COL_CENTERED_ALIGNED );
             }
         }
         rowLine.append( EOL );
@@ -588,7 +600,7 @@
     {
         if ( headerRow )
         {
-            buffer.append( "|" );
+            buffer.append( TABLE_CELL_SEPARATOR );
         }
     }
 
@@ -607,7 +619,7 @@
     /** {@inheritDoc} */
     public void tableCell_( boolean headerRow )
     {
-        buffer.append( "|" );
+        buffer.append( TABLE_CELL_SEPARATOR );
         cellCount++;
     }
 
@@ -639,13 +651,13 @@
     public void anchor( String name )
     {
 //        String id = HtmlTools.encodeId(name);
-        write( "{" );
+        write( ANCHOR_START );
     }
 
     /** {@inheritDoc} */
     public void anchor_()
     {
-        write( "}" );
+        write( ANCHOR_END );
     }
 
     /** {@inheritDoc} */
@@ -653,9 +665,9 @@
     {
         if ( !headerFlag )
         {
-            write( "{{{" );
+            write( LINK_START_1 );
             text( name );
-            write( "}" );
+            write( LINK_START_2 );
         }
     }
 
@@ -664,7 +676,7 @@
     {
         if ( !headerFlag )
         {
-            write( "}}" );
+            write( LINK_END );
         }
     }
 
@@ -673,9 +685,9 @@
     {
         if ( !headerFlag )
         {
-            write( "{{{" );
+            write( LINK_START_1 );
             text( target );
-            write( "}" );
+            write( LINK_START_2 );
             text( name );
         }
     }
@@ -685,7 +697,7 @@
     {
         if ( !headerFlag )
         {
-            write( "<" );
+            write( ITALIC_START );
         }
     }
 
@@ -694,7 +706,7 @@
     {
         if ( !headerFlag )
         {
-            write( ">" );
+            write( ITALIC_END );
         }
     }
 
@@ -703,7 +715,7 @@
     {
         if ( !headerFlag )
         {
-            write( "<<" );
+            write( BOLD_START );
         }
     }
 
@@ -712,7 +724,7 @@
     {
         if ( !headerFlag )
         {
-            write( ">>" );
+            write( BOLD_END );
         }
     }
 
@@ -721,7 +733,7 @@
     {
         if ( !headerFlag )
         {
-            write( "<<<" );
+            write( MONOSPACED_START );
         }
     }
 
@@ -730,7 +742,7 @@
     {
         if ( !headerFlag )
         {
-            write( ">>>" );
+            write( MONOSPACED_END );
         }
     }
 
@@ -752,11 +764,11 @@
     {
         if ( headerFlag || bufferFlag )
         {
-            buffer.append( "\\ " );
+            buffer.append( NON_BREAKING_SPACE );
         }
         else
         {
-            write( "\\ " );
+            write( NON_BREAKING_SPACE );
         }
     }
 
@@ -852,6 +864,10 @@
     {
         writer.close();
     }
+
+    // ----------------------------------------------------------------------
+    // Private methods
+    // ----------------------------------------------------------------------
 
     /**
      * Escape special characters in a text in APT:

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptSinkTest.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/AptSinkTest.java?view=diff&rev=560360&r1=560359&r2=560360
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptSinkTest.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptSinkTest.java Fri Jul 27 12:34:13 2007
@@ -23,7 +23,13 @@
 
 import org.apache.maven.doxia.sink.AbstractSinkTest;
 import org.apache.maven.doxia.sink.Sink;
+import org.codehaus.plexus.util.StringUtils;
 
+/**
+ * Test the <code>AptSink</code> class
+ *
+ * @see AptSink
+ */
 public class AptSinkTest extends AbstractSinkTest
 {
     /** {@inheritDoc} */
@@ -59,7 +65,8 @@
     /** {@inheritDoc} */
     protected String getHeadBlock()
     {
-        return " ----- null ----- null ----- null -----";
+        return AptMarkup.HEADER_START + " null" + AptMarkup.HEADER_START + " null" + AptMarkup.HEADER_START + " null"
+            + AptMarkup.HEADER_START;
     }
 
     /** {@inheritDoc} */
@@ -83,128 +90,149 @@
     /** {@inheritDoc} */
     protected String getSection2Block( String title )
     {
-        return "*" + title;
+        return AptMarkup.SECTION_TITLE_START + title;
     }
 
     /** {@inheritDoc} */
     protected String getSection3Block( String title )
     {
-        return "**" + title;
+        return StringUtils.repeat( String.valueOf( AptMarkup.SECTION_TITLE_START ), 2 ) + title;
     }
 
     /** {@inheritDoc} */
     protected String getSection4Block( String title )
     {
-        return "***" + title;
+        return StringUtils.repeat( String.valueOf( AptMarkup.SECTION_TITLE_START ), 3 ) + title;
     }
 
     /** {@inheritDoc} */
     protected String getSection5Block( String title )
     {
-        return "****" + title;
+        return StringUtils.repeat( String.valueOf( AptMarkup.SECTION_TITLE_START ), 4 ) + title;
     }
 
     /** {@inheritDoc} */
     protected String getListBlock( String item )
     {
-        return " * " + item + " []";
+        return AptMarkup.SPACE_MARKUP + "" + AptMarkup.LIST_START + "" + AptMarkup.SPACE_MARKUP + item
+            + AptMarkup.SPACE_MARKUP + "" + AptMarkup.LIST_END;
     }
 
     /** {@inheritDoc} */
     protected String getNumberedListBlock( String item )
     {
-        return " [[i]] " + item + " []";
+        return AptMarkup.SPACE_MARKUP + "" + AptMarkup.LEFT_SQUARE_BRACKET_MARKUP + ""
+            + AptMarkup.LEFT_SQUARE_BRACKET_MARKUP + AptMarkup.NUMBERING_LOWER_ROMAN_MARKUP + ""
+            + AptMarkup.RIGHT_SQUARE_BRACKET_MARKUP + "" + AptMarkup.RIGHT_SQUARE_BRACKET_MARKUP
+            + AptMarkup.SPACE_MARKUP + item + AptMarkup.SPACE_MARKUP + "" + AptMarkup.LIST_END;
     }
 
     /** {@inheritDoc} */
     protected String getDefinitionListBlock( String definum, String definition )
     {
-        return " [" + definum + "]" + definition;
+        return AptMarkup.SPACE_MARKUP + "" + AptMarkup.LEFT_SQUARE_BRACKET_MARKUP + definum
+            + AptMarkup.RIGHT_SQUARE_BRACKET_MARKUP + "" + definition;
     }
 
     /** {@inheritDoc} */
     protected String getFigureBlock( String source, String caption )
     {
-        return "[" + source + "] " + caption;
+        return AptMarkup.LEFT_SQUARE_BRACKET_MARKUP + source + AptMarkup.RIGHT_SQUARE_BRACKET_MARKUP
+            + AptMarkup.SPACE_MARKUP + caption;
     }
 
     /** {@inheritDoc} */
     protected String getTableBlock( String cell, String caption )
     {
-        return "*----*" + cell + "|*----*" + caption;
+        return AptMarkup.TABLE_ROW_START + AptMarkup.TABLE_COL_CENTERED_ALIGNED + cell
+        + AptMarkup.TABLE_ROW_SEPARATOR + AptMarkup.TABLE_ROW_START + AptMarkup.TABLE_COL_CENTERED_ALIGNED  + caption;
     }
 
     /** {@inheritDoc} */
     protected String getParagraphBlock( String text )
     {
-        return " " + text;
+        return AptMarkup.SPACE_MARKUP + text;
     }
 
     /** {@inheritDoc} */
     protected String getVerbatimBlock( String text )
     {
-        return "\n+------+\n" + text + "\n+------+\n";
+        return "\n" + AptMarkup.BOXED_VERBATIM_START + "\n" + text + "\n" + AptMarkup.BOXED_VERBATIM_START + "\n";
     }
 
     /** {@inheritDoc} */
     protected String getHorizontalRuleBlock()
     {
-        return "========";
+        return AptMarkup.HORIZONTAL_RULE;
     }
 
     /** {@inheritDoc} */
     protected String getPageBreakBlock()
     {
-        return "\f";
+        return AptMarkup.PAGE_BREAK;
     }
 
     /** {@inheritDoc} */
     protected String getAnchorBlock( String anchor )
     {
-        return "{" + anchor + "}";
+        return AptMarkup.ANCHOR_START + anchor + AptMarkup.ANCHOR_END;
     }
 
     /** {@inheritDoc} */
     protected String getLinkBlock( String link, String text )
     {
-        return "{{{" + link + "}" + text + "}}";
+        return AptMarkup.LINK_START_1 + link + AptMarkup.LINK_START_2 + text + AptMarkup.LINK_END;
     }
 
     /** {@inheritDoc} */
     protected String getItalicBlock( String text )
     {
-        return "<" + text + ">";
+        return AptMarkup.ITALIC_START + text + AptMarkup.ITALIC_END;
     }
 
     /** {@inheritDoc} */
     protected String getBoldBlock( String text )
     {
-        return "<<" + text + ">>";
+        return AptMarkup.BOLD_START + text + AptMarkup.BOLD_END;
     }
 
     /** {@inheritDoc} */
     protected String getMonospacedBlock( String text )
     {
-        return "<<<" + text + ">>>";
+        return AptMarkup.MONOSPACED_START + text + AptMarkup.MONOSPACED_END;
     }
 
     /** {@inheritDoc} */
     protected String getLineBreakBlock()
     {
-        return "\\";
+        return AptMarkup.BACKSLASH_MARKUP + "";
     }
 
     /** {@inheritDoc} */
     protected String getNonBreakingSpaceBlock()
     {
-        return "\\ ";
+        return AptMarkup.NON_BREAKING_SPACE;
     }
 
     /** {@inheritDoc} */
     protected String getTextBlock( String text )
     {
-        // TODO: need to be able to retreive those from outside the sink
-        return "\\~, \\=, \\-, \\+, \\*, \\[, \\], \\<, \\>, \\{, \\}, \\\\";
+        // "\\~, \\=, \\-, \\+, \\*, \\[, \\], \\<, \\>, \\{, \\}, \\\\"
+        StringBuffer sb = new StringBuffer();
+        sb.append( getSpecialCharacters( AptMarkup.COMMENT_MARKUP ) ).append( ", " );
+        sb.append( getSpecialCharacters( AptMarkup.EQUAL_MARKUP ) ).append( ", " );
+        sb.append( getSpecialCharacters( AptMarkup.MINUS_MARKUP ) ).append( ", " );
+        sb.append( getSpecialCharacters( AptMarkup.PLUS_MARKUP ) ).append( ", " );
+        sb.append( getSpecialCharacters( AptMarkup.STAR_MARKUP ) ).append( ", " );
+        sb.append( getSpecialCharacters( AptMarkup.LEFT_SQUARE_BRACKET_MARKUP ) ).append( ", " );
+        sb.append( getSpecialCharacters( AptMarkup.RIGHT_SQUARE_BRACKET_MARKUP ) ).append( ", " );
+        sb.append( getSpecialCharacters( AptMarkup.LESS_THAN_MARKUP ) ).append( ", " );
+        sb.append( getSpecialCharacters( AptMarkup.GREATER_THAN_MARKUP ) ).append( ", " );
+        sb.append( getSpecialCharacters( AptMarkup.LEFT_CURLY_BRACKET_MARKUP ) ).append( ", " );
+        sb.append( getSpecialCharacters( AptMarkup.RIGHT_CURLY_BRACKET_MARKUP ) ).append( ", " );
+        sb.append( getSpecialCharacters( AptMarkup.BACKSLASH_MARKUP ) );
+
+        return sb.toString();
     }
 
     /** {@inheritDoc} */
@@ -213,5 +241,14 @@
         return text;
     }
 
-
+    /**
+     * Add a backslash for a special markup character
+     *
+     * @param c
+     * @return the character with a backslash before
+     */
+    private static String getSpecialCharacters( char c )
+    {
+        return AptMarkup.BACKSLASH_MARKUP + "" + c;
+    }
 }



Mime
View raw message