maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ltheu...@apache.org
Subject svn commit: r661590 - in /maven/doxia/doxia/trunk: doxia-core/src/main/java/org/apache/maven/doxia/parser/ doxia-core/src/main/java/org/apache/maven/doxia/sink/ doxia-core/src/test/java/org/apache/maven/doxia/sink/ doxia-modules/doxia-module-fml/src/ma...
Date Fri, 30 May 2008 08:28:03 GMT
Author: ltheussl
Date: Fri May 30 01:28:03 2008
New Revision: 661590

URL: http://svn.apache.org/viewvc?rev=661590&view=rev
Log:
Fix verbatim content, in particular arbitrary tags and newlines within verbatim blocks

Modified:
    maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java
    maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java
    maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkTestDocument.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlContentParser.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java

Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java?rev=661590&r1=661589&r2=661590&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java
(original)
+++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java
Fri May 30 01:28:03 2008
@@ -94,7 +94,16 @@
 
         SinkEventAttributeSet attribs = getAttributesFromParser( parser );
 
-        if ( parser.getName().equals( Tag.H2.toString() ) )
+        if ( isVerbatim() )
+        {
+            if ( parser.getName().equals( Tag.PRE.toString() ) )
+            {
+                verbatim();
+            }
+
+            sink.text( parser.getText() );
+        }
+        else if ( parser.getName().equals( Tag.H2.toString() ) )
         {
             closeOpenSections( Sink.SECTION_LEVEL_1, sink );
 
@@ -411,7 +420,27 @@
     {
         boolean visited = true;
 
-        if ( parser.getName().equals( Tag.P.toString() ) )
+        if ( isVerbatim() )
+        {
+            if ( parser.getName().equals( Tag.PRE.toString() ) )
+            {
+                verbatim_();
+
+                if ( isVerbatim() )
+                {
+                    sink.text( parser.getText() );
+                }
+                else
+                {
+                    sink.verbatim_();
+                }
+            }
+            else
+            {
+                sink.text( parser.getText() );
+            }
+        }
+        else if ( parser.getName().equals( Tag.P.toString() ) )
         {
             if ( !inFigure )
             {
@@ -635,21 +664,7 @@
                 }
             }
 
-            // Emit separate text events for different lines, e.g. the input
-            // "\nLine1\n\nLine2\n\n" should deliver the event sequence "\n", "Line1\n",
"\n", "Line2\n", "\n".
-            // In other words, the concatenation of the text events must deliver the input
sequence.
-            // (according to section 2.11 of the XML spec, parsers must normalize line breaks
to "\n")
-            String[] lines = text.split( "\n", -1 );
-
-            for ( int i = 0; i < lines.length - 1; i++ )
-            {
-                sink.text( lines[i] + EOL, atts );
-            }
-
-            if ( lines[lines.length - 1].length() > 0 )
-            {
-                sink.text( lines[lines.length - 1], atts );
-            }
+            sink.text( text, atts );
         }
     }
 

Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java?rev=661590&r1=661589&r2=661590&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java
(original)
+++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java
Fri May 30 01:28:03 2008
@@ -1466,7 +1466,7 @@
      */
     public void lineBreak()
     {
-        if ( headFlag )
+        if ( headFlag || isVerbatimFlag() )
         {
             getBuffer().append( EOL );
         }

Modified: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkTestDocument.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkTestDocument.java?rev=661590&r1=661589&r2=661590&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkTestDocument.java
(original)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkTestDocument.java
Fri May 30 01:28:03 2008
@@ -268,9 +268,7 @@
         sink.definition();
         sink.text( "of definition list." );
         sink.verbatim( true );
-        sink.text( "Verbatim text" );
-        sink.lineBreak();
-        sink.text( "                        in a box        " );
+        sink.text( "Verbatim text" + EOL + "                        in a box        " );
         sink.verbatim_();
         sink.definition_();
         sink.definitionListItem_();

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlContentParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlContentParser.java?rev=661590&r1=661589&r2=661590&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlContentParser.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlContentParser.java
Fri May 30 01:28:03 2008
@@ -46,7 +46,16 @@
     {
         isEmptyElement = parser.isEmptyElementTag();
 
-        if ( parser.getName().equals( QUESTION_TAG.toString() )
+        if ( isVerbatim() )
+        {
+            if ( parser.getName().equals( SOURCE_TAG.toString() ) )
+            {
+                verbatim();
+            }
+
+            sink.text( parser.getText() );
+        }
+        else if ( parser.getName().equals( QUESTION_TAG.toString() )
             || parser.getName().equals( ANSWER_TAG.toString() ) )
         {
             // ignore
@@ -84,7 +93,27 @@
     protected void handleEndTag( XmlPullParser parser, Sink sink )
         throws XmlPullParserException, MacroExecutionException
     {
-        if ( parser.getName().equals( QUESTION_TAG.toString() )
+        if ( isVerbatim() )
+        {
+            if ( parser.getName().equals( SOURCE_TAG.toString() ) )
+            {
+                verbatim_();
+
+                if ( isVerbatim() )
+                {
+                    sink.text( parser.getText() );
+                }
+                else
+                {
+                    sink.verbatim_();
+                }
+            }
+            else
+            {
+                sink.text( parser.getText() );
+            }
+        }
+        else if ( parser.getName().equals( QUESTION_TAG.toString() )
             || parser.getName().equals( ANSWER_TAG.toString() ) )
         {
             // ignore

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java?rev=661590&r1=661589&r2=661590&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
Fri May 30 01:28:03 2008
@@ -102,7 +102,17 @@
 
         SinkEventAttributeSet attribs = getAttributesFromParser( parser );
 
-        if ( parser.getName().equals( DOCUMENT_TAG.toString() ) )
+        if ( isVerbatim() )
+        {
+            if ( parser.getName().equals( SOURCE_TAG.toString() )
+                || parser.getName().equals( Tag.PRE.toString() ) )
+            {
+                verbatim();
+            }
+
+            sink.text( parser.getText() );
+        }
+        else if ( parser.getName().equals( DOCUMENT_TAG.toString() ) )
         {
             //Do nothing
             return;
@@ -242,7 +252,28 @@
     protected void handleEndTag( XmlPullParser parser, Sink sink )
         throws XmlPullParserException, MacroExecutionException
     {
-        if ( parser.getName().equals( DOCUMENT_TAG.toString() ) )
+        if ( isVerbatim() )
+        {
+            if ( parser.getName().equals( SOURCE_TAG.toString() )
+                || parser.getName().equals( Tag.PRE.toString() ) )
+            {
+                verbatim_();
+
+                if ( isVerbatim() )
+                {
+                    sink.text( parser.getText() );
+                }
+                else
+                {
+                    sink.verbatim_();
+                }
+            }
+            else
+            {
+                sink.text( parser.getText() );
+            }
+        }
+        else if ( parser.getName().equals( DOCUMENT_TAG.toString() ) )
         {
             //Do nothing
             return;

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java?rev=661590&r1=661589&r2=661590&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java
Fri May 30 01:28:03 2008
@@ -56,7 +56,16 @@
 
         SinkEventAttributeSet attribs = getAttributesFromParser( parser );
 
-        if ( parser.getName().equals( Tag.HTML.toString() ) )
+        if ( isVerbatim() )
+        {
+            if ( parser.getName().equals( Tag.PRE.toString() ) )
+            {
+                verbatim();
+            }
+
+            sink.text( parser.getText() );
+        }
+        else if ( parser.getName().equals( Tag.HTML.toString() ) )
         {
             //Do nothing
             return;
@@ -136,6 +145,8 @@
                 attribs.addAttribute( SinkEventAttributeSet.DECORATION, "boxed" );
             }
 
+            verbatim();
+
             sink.verbatim( attribs );
         }
         else if ( !baseStartTag( parser, sink ) )
@@ -164,7 +175,27 @@
     protected void handleEndTag( XmlPullParser parser, Sink sink )
         throws XmlPullParserException, MacroExecutionException
     {
-        if ( parser.getName().equals( Tag.HTML.toString() ) )
+        if ( isVerbatim() )
+        {
+            if ( parser.getName().equals( Tag.PRE.toString() ) )
+            {
+                verbatim_();
+
+                if ( isVerbatim() )
+                {
+                    sink.text( parser.getText() );
+                }
+                else
+                {
+                    sink.verbatim_();
+                }
+            }
+            else
+            {
+                sink.text( parser.getText() );
+            }
+        }
+        else if ( parser.getName().equals( Tag.HTML.toString() ) )
         {
             //Do nothing
             return;



Mime
View raw message