You are viewing a plain text version of this content. The canonical link for it is here.
Posted to doxia-commits@maven.apache.org by vs...@apache.org on 2008/10/17 00:53:37 UTC

svn commit: r705390 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki: TWikiMarkup.java TWikiSink.java TWikiSinkFactory.java

Author: vsiveton
Date: Thu Oct 16 15:53:36 2008
New Revision: 705390

URL: http://svn.apache.org/viewvc?rev=705390&view=rev
Log:
DOXIA-262: Add a Twiki sink

o added it

Added:
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiMarkup.java   (with props)
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiSink.java   (with props)
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiSinkFactory.java   (with props)

Added: maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiMarkup.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/TWikiMarkup.java?rev=705390&view=auto
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiMarkup.java (added)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiMarkup.java Thu Oct 16 15:53:36 2008
@@ -0,0 +1,155 @@
+package org.apache.maven.doxia.module.twiki;
+
+/*
+ * 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 javax.swing.text.html.HTML.Tag;
+
+import org.apache.maven.doxia.markup.TextMarkup;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * This interface defines all markups and syntaxes used by the <b>TWiki</b> format.
+ *
+ * @see <a href="http://twiki.org/cgi-bin/view/TWiki/TextFormattingRules">http://twiki.org/cgi-bin/view/TWiki/TextFormattingRules</a>
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ * @since 1.0
+ */
+public interface TWikiMarkup
+    extends TextMarkup
+{
+    // ----------------------------------------------------------------------
+    // Twiki markups
+    // ----------------------------------------------------------------------
+
+    /** Syntax for the anchor : '#' */
+    char ANCHOR_MARKUP = '#';
+
+    /** Syntax for the start line separator: "   " */
+    String THREE_SPACES_MARKUP = "   ";
+
+    /** Syntax for the bold markup: "*" */
+    String BOLD_END_MARKUP = "*";
+
+    /** Syntax for the bold markup: "*" */
+    String BOLD_START_MARKUP = "*";
+
+    /** Syntax for the bold italic markup: "__" */
+    String BOLD_ITALIC_END_MARKUP = "__";
+
+    /** Syntax for the bold italic markup: "__" */
+    String BOLD_ITALIC_START_MARKUP = "__";
+
+    /** Syntax for the bold monospaced markup: "==" */
+    String BOLD_MONOSPACED_END_MARKUP = "==";
+
+    /** Syntax for the bold monospaced markup: "==" */
+    String BOLD_MONOSPACED_START_MARKUP = "==";
+
+    /** Syntax for the definition list item: "   " */
+    String DEFINITION_LIST_ITEM_MARKUP = THREE_SPACES_MARKUP + "$";
+
+    /** Syntax for the definition list definition: "   " */
+    String DEFINITION_LIST_DEFINITION_MARKUP = ": ";
+
+    /** Syntax for the horizontal rule markup: "---" */
+    String HORIZONTAL_RULE_MARKUP = "---";
+
+    /** Syntax for the italic markup: "_" */
+    String ITALIC_END_MARKUP = "_";
+
+    /** Syntax for the italic markup: "_" */
+    String ITALIC_START_MARKUP = "_";
+
+    /** Syntax for the link end markup: "]]" */
+    String LINK_END_MARKUP = "]]";
+
+    /** Syntax for the link middle markup: "[[" */
+    String LINK_MIDDLE_MARKUP = "][";
+
+    /** Syntax for the link start markup: "]]" */
+    String LINK_START_MARKUP = "[[";
+
+    /** Syntax for the list item markup: "* */
+    String LIST_ITEM_MARKUP = "* ";
+
+    /** Syntax for the mono-spaced style end: "=" */
+    String MONOSPACED_END_MARKUP = "=";
+
+    /** Syntax for the mono-spaced style start: "=" */
+    String MONOSPACED_START_MARKUP = "=";
+
+    /** Syntax for the numbering decimal markup char: "1." */
+    String NUMBERING_MARKUP = "1.";
+
+    /** Syntax for the numbering lower alpha markup char: "a." */
+    String NUMBERING_LOWER_ALPHA_MARKUP = "a.";
+
+    /** Syntax for the numbering lower roman markup char: "i." */
+    String NUMBERING_LOWER_ROMAN_MARKUP = "i.";
+
+    /** Syntax for the numbering upper alpha markup char: "A." */
+    String NUMBERING_UPPER_ALPHA_MARKUP = "A.";
+
+    /** Syntax for the numbering upper roman markup char: "I." */
+    String NUMBERING_UPPER_ROMAN_MARKUP = "I.";
+
+    /** Syntax for the section title 1 markup: "---+" */
+    String SECTION_TITLE1_MARKUP = StringUtils.repeat( "-", 3 ) + "+";
+
+    /** Syntax for the section title 2 markup: "---++" */
+    String SECTION_TITLE2_MARKUP = StringUtils.repeat( "-", 3 ) + StringUtils.repeat( "+", 2 );
+
+    /** Syntax for the section title 3 markup: "---+++" */
+    String SECTION_TITLE3_MARKUP = StringUtils.repeat( "-", 3 ) + StringUtils.repeat( "+", 3 );
+
+    /** Syntax for the section title 4 markup: "---++++" */
+    String SECTION_TITLE4_MARKUP = StringUtils.repeat( "-", 3 ) + StringUtils.repeat( "+", 4 );
+
+    /** Syntax for the section title 5 markup: "---+++++" */
+    String SECTION_TITLE5_MARKUP = StringUtils.repeat( "-", 3 ) + StringUtils.repeat( "+", 5 );
+
+    /** Syntax for the table cell header end markup: "* |" */
+    String TABLE_CELL_HEADER_END_MARKUP = "* |";
+
+    /** Syntax for the table cell header start markup: " *" */
+    String TABLE_CELL_HEADER_START_MARKUP = " *";
+
+    /** Syntax for the table cell markup: "| " */
+    String TABLE_CELL_MARKUP = " |";
+
+    /** Syntax for the table row markup: "|" */
+    String TABLE_ROW_MARKUP = "|";
+
+    // ----------------------------------------------------------------------
+    // Specific Twiki tags
+    // ----------------------------------------------------------------------
+
+    /** TWiki tag for <code>verbatim</code> */
+    Tag VERBATIM_TAG = new Tag()
+    {
+        /** {@inheritDoc} */
+        public String toString()
+        {
+            return "verbatim";
+        }
+    };
+}

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

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

Added: maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiSink.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/TWikiSink.java?rev=705390&view=auto
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiSink.java (added)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiSink.java Thu Oct 16 15:53:36 2008
@@ -0,0 +1,1224 @@
+package org.apache.maven.doxia.module.twiki;
+
+/*
+ * 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 java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.Stack;
+
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.html.HTML.Attribute;
+import javax.swing.text.html.HTML.Tag;
+
+import org.apache.maven.doxia.sink.AbstractTextSink;
+import org.apache.maven.doxia.sink.AbstractXmlSink;
+import org.apache.maven.doxia.sink.SinkEventAttributeSet;
+import org.apache.maven.doxia.sink.SinkEventAttributes;
+import org.apache.maven.doxia.sink.SinkUtils;
+import org.apache.maven.doxia.util.HtmlTools;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * TWiki Sink implementation.
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ * @since 1.0
+ */
+public class TWikiSink
+    extends AbstractTextSink
+    implements TWikiMarkup
+{
+    /**  The writer to use. */
+    private PrintWriter out;
+
+    /**  The writer to use. */
+    private StringWriter writer;
+
+    /** An indication on if we're in bold mode. */
+    private boolean boldFlag;
+
+    /** An indication on if we're in bold italic or monospaced mode. */
+    private boolean boldItalicOrMonodpacedFlag;
+
+    /** An indication on if we're in head mode. */
+    private boolean headFlag;
+
+    private int levelList = 0;
+
+    /**  listStyles. */
+    private Stack listStyles;
+
+    /**
+     * @param writer writer not null
+     */
+    public TWikiSink( Writer writer )
+    {
+        this.out = new PrintWriter( writer );
+        this.writer = new StringWriter();
+        this.listStyles = new Stack();
+    }
+
+    /** {@inheritDoc} */
+    public void anchor( String name )
+    {
+        write( EOL );
+        write( ANCHOR_MARKUP + name );
+    }
+
+    /** {@inheritDoc} */
+    public void anchor( String name, SinkEventAttributes attributes )
+    {
+        anchor( name );
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void anchor_()
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void author()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void author( SinkEventAttributes attributes )
+    {
+        author();
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void author_()
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void body()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void body( SinkEventAttributes attributes )
+    {
+        body();
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void body_()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void bold()
+    {
+        boldFlag = true;
+        write( BOLD_START_MARKUP );
+    }
+
+    /** {@inheritDoc} */
+    public void bold_()
+    {
+        boldFlag = false;
+        if ( !boldItalicOrMonodpacedFlag )
+        {
+            write( BOLD_END_MARKUP );
+        }
+        boldItalicOrMonodpacedFlag = false;
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void comment( String comment )
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void close()
+    {
+        out.write( writer.toString() );
+        out.close();
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void date()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void date( SinkEventAttributes attributes )
+    {
+        date();
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void date_()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void definedTerm()
+    {
+        write( " " );
+    }
+
+    /** {@inheritDoc} */
+    public void definedTerm( SinkEventAttributes attributes )
+    {
+        definedTerm();
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void definedTerm_()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void definition()
+    {
+        write( DEFINITION_LIST_DEFINITION_MARKUP );
+    }
+
+    /** {@inheritDoc} */
+    public void definition( SinkEventAttributes attributes )
+    {
+        definition();
+    }
+
+    /** {@inheritDoc} */
+    public void definition_()
+    {
+        writeEOL( true );
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void definitionList()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void definitionList( SinkEventAttributes attributes )
+    {
+        definitionList();
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void definitionList_()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void definitionListItem()
+    {
+        writeEOL( true );
+        writeEOL();
+        write( DEFINITION_LIST_ITEM_MARKUP );
+    }
+
+    /** {@inheritDoc} */
+    public void definitionListItem( SinkEventAttributes attributes )
+    {
+        definitionListItem();
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void definitionListItem_()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void figure()
+    {
+        write( String.valueOf( LESS_THAN ) + Tag.IMG.toString() + SPACE );
+    }
+
+    /** {@inheritDoc} */
+    public void figure( SinkEventAttributes attributes )
+    {
+        figure();
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void figure_()
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void figureCaption()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void figureCaption( SinkEventAttributes attributes )
+    {
+        figureCaption();
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void figureCaption_()
+    {
+        // nop;
+    }
+
+    /** {@inheritDoc} */
+    public void figureGraphics( String name )
+    {
+        write( String.valueOf( SPACE ) + Attribute.SRC + EQUAL + QUOTE + name + QUOTE );
+    }
+
+    /** {@inheritDoc} */
+    public void figureGraphics( String src, SinkEventAttributes attributes )
+    {
+        figureGraphics( src );
+    }
+
+    /** {@inheritDoc} */
+    public void flush()
+    {
+        close();
+        writer.flush();
+    }
+
+    /** {@inheritDoc} */
+    public void head()
+    {
+        headFlag = true;
+    }
+
+    /** {@inheritDoc} */
+    public void head( SinkEventAttributes attributes )
+    {
+        head();
+    }
+
+    /** {@inheritDoc} */
+    public void head_()
+    {
+        headFlag = false;
+    }
+
+    /** {@inheritDoc} */
+    public void horizontalRule()
+    {
+        writeEOL( true );
+        write( HORIZONTAL_RULE_MARKUP );
+        writeEOL( true );
+    }
+
+    /** {@inheritDoc} */
+    public void horizontalRule( SinkEventAttributes attributes )
+    {
+        horizontalRule();
+    }
+
+    /** {@inheritDoc} */
+    public void italic()
+    {
+        if ( boldFlag )
+        {
+            boldItalicOrMonodpacedFlag = true;
+
+            String tmp = writer.toString();
+            writer = new StringWriter();
+            writer.write( tmp.substring( 0, tmp.length() - 1 ) );
+            write( BOLD_ITALIC_START_MARKUP );
+        }
+        else
+        {
+            write( ITALIC_START_MARKUP );
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void italic_()
+    {
+        if ( boldFlag )
+        {
+            write( BOLD_ITALIC_END_MARKUP );
+        }
+        else
+        {
+            write( ITALIC_END_MARKUP );
+        }
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void lineBreak()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void lineBreak( SinkEventAttributes attributes )
+    {
+        lineBreak();
+    }
+
+    /** {@inheritDoc} */
+    public void link( String name )
+    {
+        write( LINK_START_MARKUP + name + LINK_MIDDLE_MARKUP );
+    }
+
+    /** {@inheritDoc} */
+    public void link( String name, SinkEventAttributes attributes )
+    {
+        link( name );
+    }
+
+    /** {@inheritDoc} */
+    public void link_()
+    {
+        write( LINK_END_MARKUP );
+    }
+
+    /** {@inheritDoc} */
+    public void list()
+    {
+        if ( !writer.toString().endsWith( EOL + EOL ) )
+        {
+            writeEOL( true );
+        }
+
+        levelList++;
+    }
+
+    /** {@inheritDoc} */
+    public void list( SinkEventAttributes attributes )
+    {
+        list();
+    }
+
+    /** {@inheritDoc} */
+    public void list_()
+    {
+        levelList--;
+    }
+
+    /** {@inheritDoc} */
+    public void listItem()
+    {
+        String indent = StringUtils.repeat( THREE_SPACES_MARKUP, levelList );
+        write( indent + LIST_ITEM_MARKUP );
+    }
+
+    /** {@inheritDoc} */
+    public void listItem( SinkEventAttributes attributes )
+    {
+        listItem();
+    }
+
+    /** {@inheritDoc} */
+    public void listItem_()
+    {
+        writeEOL( true );
+    }
+
+    /** {@inheritDoc} */
+    public void monospaced()
+    {
+        if ( boldFlag )
+        {
+            boldItalicOrMonodpacedFlag = true;
+
+            String tmp = writer.toString();
+            writer = new StringWriter();
+            writer.write( tmp.substring( 0, tmp.length() - 1 ) );
+            write( BOLD_MONOSPACED_START_MARKUP );
+        }
+        else
+        {
+            write( MONOSPACED_START_MARKUP );
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void monospaced_()
+    {
+        if ( boldFlag )
+        {
+            write( BOLD_MONOSPACED_END_MARKUP );
+        }
+        else
+        {
+            write( MONOSPACED_END_MARKUP );
+        }
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void nonBreakingSpace()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void numberedList( int numbering )
+    {
+        levelList++;
+    }
+
+    /** {@inheritDoc} */
+    public void numberedList( int numbering, SinkEventAttributes attributes )
+    {
+        numberedList( numbering );
+
+        String style;
+        switch ( numbering )
+        {
+            case NUMBERING_UPPER_ALPHA:
+                style = NUMBERING_UPPER_ALPHA_MARKUP;
+                break;
+            case NUMBERING_LOWER_ALPHA:
+                style = NUMBERING_LOWER_ALPHA_MARKUP;
+                break;
+            case NUMBERING_UPPER_ROMAN:
+                style = NUMBERING_UPPER_ROMAN_MARKUP;
+                break;
+            case NUMBERING_LOWER_ROMAN:
+                style = NUMBERING_LOWER_ROMAN_MARKUP;
+                break;
+            case NUMBERING_DECIMAL:
+            default:
+                style = NUMBERING_MARKUP;
+        }
+
+        listStyles.push( style );
+    }
+
+    /** {@inheritDoc} */
+    public void numberedList_()
+    {
+        levelList--;
+        listStyles.pop();
+    }
+
+    /** {@inheritDoc} */
+    public void numberedListItem()
+    {
+        writeEOL( true );
+        String style = (String) listStyles.peek();
+        String indent = StringUtils.repeat( THREE_SPACES_MARKUP, levelList );
+        write( indent + style + SPACE );
+    }
+
+    /** {@inheritDoc} */
+    public void numberedListItem( SinkEventAttributes attributes )
+    {
+        numberedListItem();
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void numberedListItem_()
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void pageBreak()
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void paragraph()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void paragraph( SinkEventAttributes attributes )
+    {
+        paragraph();
+    }
+
+    /** {@inheritDoc} */
+    public void paragraph_()
+    {
+        writeEOL( true );
+        writeEOL();
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void rawText( String text )
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void section( int level, SinkEventAttributes attributes )
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void section1()
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void section1_()
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void section2()
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void section2_()
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void section3()
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void section3_()
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void section4()
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void section4_()
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void section5()
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void section5_()
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void section_( int level )
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void sectionTitle()
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void sectionTitle( int level, SinkEventAttributes attributes )
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle1()
+    {
+        write( SECTION_TITLE1_MARKUP );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle1_()
+    {
+        writeEOL( true );
+        writeEOL();
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle2()
+    {
+        write( SECTION_TITLE2_MARKUP );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle2_()
+    {
+        writeEOL( true );
+        writeEOL();
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle3()
+    {
+        write( SECTION_TITLE3_MARKUP );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle3_()
+    {
+        writeEOL( true );
+        writeEOL();
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle4()
+    {
+        write( SECTION_TITLE4_MARKUP );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle4_()
+    {
+        writeEOL( true );
+        writeEOL();
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle5()
+    {
+        write( SECTION_TITLE5_MARKUP );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle5_()
+    {
+        writeEOL( true );
+        writeEOL();
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void sectionTitle_()
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void sectionTitle_( int level )
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void table()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void table( SinkEventAttributes attributes )
+    {
+        table();
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void table_()
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void tableCaption()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void tableCaption( SinkEventAttributes attributes )
+    {
+        tableCaption();
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void tableCaption_()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void tableCell()
+    {
+        write( " " );
+    }
+
+    /** {@inheritDoc} */
+    public void tableCell( SinkEventAttributes attributes )
+    {
+        tableCell();
+    }
+
+    /** {@inheritDoc} */
+    public void tableCell( String width )
+    {
+        tableCell();
+    }
+
+    /** {@inheritDoc} */
+    public void tableCell_()
+    {
+        write( TABLE_CELL_MARKUP );
+    }
+
+    /** {@inheritDoc} */
+    public void tableHeaderCell()
+    {
+        write( TABLE_CELL_HEADER_START_MARKUP );
+    }
+
+    /** {@inheritDoc} */
+    public void tableHeaderCell( SinkEventAttributes attributes )
+    {
+        tableHeaderCell();
+    }
+
+    /** {@inheritDoc} */
+    public void tableHeaderCell( String width )
+    {
+        tableHeaderCell();
+    }
+
+    /** {@inheritDoc} */
+    public void tableHeaderCell_()
+    {
+        write( TABLE_CELL_HEADER_END_MARKUP );
+    }
+
+    /** {@inheritDoc} */
+    public void tableRow()
+    {
+        write( TABLE_ROW_MARKUP );
+    }
+
+    /** {@inheritDoc} */
+    public void tableRow( SinkEventAttributes attributes )
+    {
+        tableRow();
+    }
+
+    /** {@inheritDoc} */
+    public void tableRow_()
+    {
+        writeEOL( true );
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void tableRows( int[] justification, boolean grid )
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void tableRows_()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void text( String text )
+    {
+        if ( headFlag )
+        {
+            return;
+        }
+
+        if ( headFlag )
+        {
+            return;
+        }
+        content( text );
+    }
+
+    /** {@inheritDoc} */
+    public void text( String text, SinkEventAttributes attributes )
+    {
+        if ( attributes == null )
+        {
+            text( text );
+        }
+        else
+        {
+            if ( attributes.containsAttribute( SinkEventAttributes.DECORATION, "underline" ) )
+            {
+                writeStartTag( Tag.U );
+            }
+            if ( attributes.containsAttribute( SinkEventAttributes.DECORATION, "line-through" ) )
+            {
+                writeStartTag( Tag.S );
+            }
+            if ( attributes.containsAttribute( SinkEventAttributes.VALIGN, "sub" ) )
+            {
+                writeStartTag( Tag.SUB );
+            }
+            if ( attributes.containsAttribute( SinkEventAttributes.VALIGN, "sup" ) )
+            {
+                writeStartTag( Tag.SUP );
+            }
+
+            text( text );
+
+            if ( attributes.containsAttribute( SinkEventAttributes.VALIGN, "sup" ) )
+            {
+                writeEndTag( Tag.SUP );
+            }
+            if ( attributes.containsAttribute( SinkEventAttributes.VALIGN, "sub" ) )
+            {
+                writeEndTag( Tag.SUB );
+            }
+            if ( attributes.containsAttribute( SinkEventAttributes.DECORATION, "line-through" ) )
+            {
+                writeEndTag( Tag.S );
+            }
+            if ( attributes.containsAttribute( SinkEventAttributes.DECORATION, "underline" ) )
+            {
+                writeEndTag( Tag.U );
+            }
+        }
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void title()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void title( SinkEventAttributes attributes )
+    {
+        title();
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void title_()
+    {
+        // nop
+    }
+
+    /** Not used.
+     * {@inheritDoc} */
+    public void unknown( String name, Object[] requiredParams, SinkEventAttributes attributes )
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void verbatim( boolean boxed )
+    {
+        SinkEventAttributeSet att = new SinkEventAttributeSet();
+
+        if ( boxed )
+        {
+            att.addAttribute( SinkEventAttributes.DECORATION, "boxed" );
+        }
+
+        verbatim( att );
+    }
+
+    /** {@inheritDoc} */
+    public void verbatim( SinkEventAttributes attributes )
+    {
+        MutableAttributeSet atts = SinkUtils.filterAttributes( attributes, SinkUtils.SINK_VERBATIM_ATTRIBUTES );
+
+        if ( atts == null )
+        {
+            atts = new SinkEventAttributeSet();
+        }
+
+        boolean boxed = false;
+
+        if ( atts.isDefined( SinkEventAttributes.DECORATION ) )
+        {
+            boxed = "boxed".equals( (String) atts.getAttribute( SinkEventAttributes.DECORATION ) );
+        }
+
+        if ( boxed )
+        {
+            atts.addAttribute( Attribute.CLASS, "source" );
+        }
+
+        atts.removeAttribute( SinkEventAttributes.DECORATION );
+
+        String width = (String) atts.getAttribute( Attribute.WIDTH.toString() );
+        atts.removeAttribute( Attribute.WIDTH.toString() );
+
+        writeStartTag( Tag.DIV, atts );
+        writeEOL( true );
+
+        if ( width != null )
+        {
+            atts.addAttribute( Attribute.WIDTH.toString(), width );
+        }
+
+        atts.removeAttribute( Attribute.ALIGN.toString() );
+        atts.removeAttribute( Attribute.CLASS.toString() );
+
+        writeStartTag( VERBATIM_TAG, atts );
+    }
+
+    /** {@inheritDoc} */
+    public void verbatim_()
+    {
+        writeEndTag( VERBATIM_TAG );
+        writeEOL( true );
+        writeEndTag( Tag.DIV );
+        writeEOL( true );
+    }
+
+    // ----------------------------------------------------------------------
+    // Private methods
+    // ----------------------------------------------------------------------
+
+    private void write( String text )
+    {
+        writer.write( unifyEOLs( text ) );
+    }
+
+    /**
+     * Starts a Tag. For instance:
+     * <pre>
+     * &lt;tag&gt;
+     * </pre>
+     * <br/>
+     * <b>Note</b>: Copy from {@link AbstractXmlSink#writeStartTag(javax.swing.text.html.HTML.Tag)}
+     *
+     * @param t a non null tag
+     * @see #writeStartTag(javax.swing.text.html.HTML.Tag)
+     */
+    private void writeStartTag( Tag t )
+    {
+        writeStartTag( t, null );
+    }
+
+    /**
+     * Starts a Tag with attributes. For instance:
+     * <pre>
+     * &lt;tag attName="attValue"&gt;
+     * </pre>
+     * <br/>
+     * <b>Note</b>: Copy from {@link AbstractXmlSink#writeStartTag(javax.swing.text.html.HTML.Tag, javax.swing.text.MutableAttributeSet)}
+     *
+     * @param t a non null tag
+     * @param att a set of attributes
+     * @see #writeStartTag(javax.swing.text.html.HTML.Tag, javax.swing.text.MutableAttributeSet, boolean)
+     */
+    private void writeStartTag( Tag t, MutableAttributeSet att )
+    {
+        writeStartTag( t, att, false );
+    }
+
+    /**
+     * Starts a Tag with attributes. For instance:
+     * <pre>
+     * &lt;tag attName="attValue"&gt;
+     * </pre>
+     * <br/>
+     * <b>Note</b>: Copy from {@link AbstractXmlSink#writeStartTag(javax.swing.text.html.HTML.Tag, javax.swing.text.MutableAttributeSet, boolean)}
+     *
+     * @param t a non null tag
+     * @param att a set of attributes
+     * @param isSimpleTag boolean to write as a simple tag
+     */
+    private void writeStartTag( Tag t, MutableAttributeSet att, boolean isSimpleTag )
+    {
+        if ( t == null )
+        {
+            throw new IllegalArgumentException( "A tag is required" );
+        }
+
+        StringBuffer sb = new StringBuffer();
+        sb.append( LESS_THAN );
+
+        sb.append( t.toString() );
+
+        sb.append( SinkUtils.getAttributeString( att ) );
+
+        if ( isSimpleTag )
+        {
+            sb.append( SPACE ).append( SLASH );
+        }
+
+        sb.append( GREATER_THAN );
+
+        write( sb.toString() );
+    }
+
+    /**
+     * Writes a system EOL.
+     */
+    private void writeEOL()
+    {
+        write( EOL );
+    }
+
+    /**
+     * Writes a system EOL, with or without trim.
+     */
+    private void writeEOL( boolean trim )
+    {
+        if ( !trim )
+        {
+            writeEOL();
+            return;
+        }
+
+        String tmp = writer.toString().trim();
+        writer = new StringWriter();
+        writer.write( tmp );
+        write( EOL );
+    }
+
+    /**
+     * Ends a Tag without writing an EOL. For instance: <pre>&lt;/tag&gt;</pre>.
+     * <br/>
+     * <b>Note</b>: Copy from {@link AbstractXmlSink#writeEndTag(javax.swing.text.html.HTML.Tag)}
+     *
+     * @param t a tag.
+     */
+    private void writeEndTag( Tag t )
+    {
+        StringBuffer sb = new StringBuffer();
+        sb.append( LESS_THAN );
+        sb.append( SLASH );
+
+        sb.append( t.toString() );
+        sb.append( GREATER_THAN );
+
+        write( sb.toString() );
+    }
+
+    /**
+     * Starts a simple Tag. For instance:
+     * <pre>
+     * &lt;tag /&gt;
+     * </pre>
+     * <br/>
+     * <b>Note</b>: Copy from {@link AbstractXmlSink#writeSimpleTag(javax.swing.text.html.HTML.Tag)}
+     *
+     * @param t a non null tag
+     * @see #writeSimpleTag(javax.swing.text.html.HTML.Tag, javax.swing.text.MutableAttributeSet)
+     */
+    private void writeSimpleTag( Tag t )
+    {
+        writeSimpleTag( t, null );
+    }
+
+    /**
+     * Starts a simple Tag with attributes. For instance:
+     * <pre>
+     * &lt;tag attName="attValue" /&gt;
+     * </pre>
+     * <br/>
+     * <b>Note</b>: Copy from {@link AbstractXmlSink#writeSimpleTag(javax.swing.text.html.HTML.Tag, javax.swing.text.MutableAttributeSet)}
+     *
+     * @param t a non null tag
+     * @param att a set of attributes
+     * @see #writeStartTag(javax.swing.text.html.HTML.Tag, javax.swing.text.MutableAttributeSet, boolean)
+     */
+    private void writeSimpleTag( Tag t, MutableAttributeSet att )
+    {
+        writeStartTag( t, att, true );
+    }
+
+    /**
+     * Write HTML escaped text to output.
+     *
+     * @param text The text to write.
+     */
+    protected void content( String text )
+    {
+        write( escapeHTML( text ) );
+    }
+
+    /**
+     * Forward to HtmlTools.escapeHTML( text ).
+     *
+     * @param text the String to escape, may be null
+     * @return the text escaped, "" if null String input
+     * @see org.apache.maven.doxia.util.HtmlTools#escapeHTML(String)
+     */
+    protected static String escapeHTML( String text )
+    {
+        return HtmlTools.escapeHTML( text );
+    }
+}

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

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

Added: maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiSinkFactory.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/TWikiSinkFactory.java?rev=705390&view=auto
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiSinkFactory.java (added)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiSinkFactory.java Thu Oct 16 15:53:36 2008
@@ -0,0 +1,67 @@
+package org.apache.maven.doxia.module.twiki;
+
+/*
+ * 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 java.io.File;
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.SinkFactory;
+import org.codehaus.plexus.util.WriterFactory;
+
+/**
+ * TWiki implementation of the Sink factory.
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ * @since 1.0
+ * @plexus.component role="org.apache.maven.doxia.sink.SinkFactory" role-hint="twiki"
+ */
+public class TWikiSinkFactory
+    implements SinkFactory
+{
+    /** {@inheritDoc} */
+    public Sink createSink( File outputDir, String outputName )
+        throws IOException
+    {
+        return createSink( outputDir, outputName, WriterFactory.UTF_8 );
+    }
+
+    /** {@inheritDoc} */
+    public Sink createSink( File outputDir, String outputName, String encoding )
+        throws IOException
+    {
+        if ( !outputDir.isDirectory() )
+        {
+            throw new IllegalArgumentException( "The dir '" + outputDir + "' is not a directory or not exist" );
+        }
+
+        Writer writer = WriterFactory.newWriter( new File( outputDir, outputName ), encoding );
+
+        return new TWikiSink( writer );
+    }
+
+    /** {@inheritDoc} */
+    public Sink createSink( Writer writer )
+    {
+        return new TWikiSink( writer );
+    }
+}

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

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