maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ltheu...@apache.org
Subject svn commit: r635929 - in /maven/doxia: doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/ doxia-sitetools/trunk/doxia-site-renderer/src/test/site/xdoc/ doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxi...
Date Tue, 11 Mar 2008 14:00:31 GMT
Author: ltheussl
Date: Tue Mar 11 07:00:28 2008
New Revision: 635929

URL: http://svn.apache.org/viewvc?rev=635929&view=rev
Log:
[DOXIA-163, DOXIA-164] Add support for underscore, strike-through, sub- and super-script.

Modified:
    maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
    maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/site/xdoc/attributes.xml
    maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
    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-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java
    maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/SinkEventAttributes.java

Modified: maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java?rev=635929&r1=635928&r2=635929&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
(original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
Tue Mar 11 07:00:28 2008
@@ -42,6 +42,7 @@
 import com.gargoylesoftware.htmlunit.html.HtmlTableRow;
 import com.gargoylesoftware.htmlunit.html.HtmlUnorderedList;
 
+import com.gargoylesoftware.htmlunit.html.UnknownHtmlElement;
 import org.apache.maven.doxia.site.decoration.DecorationModel;
 import org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader;
 
@@ -71,6 +72,7 @@
     private Renderer renderer;
 
     /**
+     * @throws java.lang.Exception
      * @see org.codehaus.plexus.PlexusTestCase#setUp()
      */
     protected void setUp()
@@ -85,6 +87,7 @@
     }
 
     /**
+     * @throws java.lang.Exception
      * @see org.codehaus.plexus.PlexusTestCase#tearDown()
      */
     protected void tearDown()
@@ -106,17 +109,17 @@
         DecorationModel decoration = new DecorationXpp3Reader()
             .read( new FileReader( getTestFile( "src/test/site/site.xml" ) ) );
 
-        SiteRenderingContext context = new SiteRenderingContext();
-        context.setTemplateName( "default-site.vm" );
-        context.setTemplateClassLoader( getClassLoader() );
-        context.setUsingDefaultTemplate( true );
+        SiteRenderingContext ctxt = new SiteRenderingContext();
+        ctxt.setTemplateName( "default-site.vm" );
+        ctxt.setTemplateClassLoader( getClassLoader() );
+        ctxt.setUsingDefaultTemplate( true );
         Map templateProp = new HashMap();
         templateProp.put( "outputEncoding", "UTF-8" );
-        context.setTemplateProperties( templateProp );
-        context.setDecoration( decoration );
-        context.addSiteDirectory( getTestFile( "src/test/site" ) );
+        ctxt.setTemplateProperties( templateProp );
+        ctxt.setDecoration( decoration );
+        ctxt.addSiteDirectory( getTestFile( "src/test/site" ) );
 
-        renderer.render( renderer.locateDocumentFiles( context ).values(), context, getTestFile(
OUTPUT ) );
+        renderer.render( renderer.locateDocumentFiles( ctxt ).values(), ctxt, getTestFile(
OUTPUT ) );
 
         // ----------------------------------------------------------------------
         // Verify specific pages
@@ -154,7 +157,7 @@
 
         // HtmlUnit
         WebClient webClient = new WebClient();
-        HtmlPage page = (HtmlPage) webClient.getPage( nestedItems.toURL() );
+        HtmlPage page = (HtmlPage) webClient.getPage( nestedItems.toURI().toURL() );
         assertNotNull( page );
 
         HtmlElement element = page.getHtmlElementById( "contentBox" );
@@ -197,59 +200,55 @@
 
         HtmlUnorderedList ul = (HtmlUnorderedList) elementIterator.next();
         assertNotNull( ul );
-        // TODO: how can this be?
-        //assertEquals( ul.getFirstChild().asText().trim(), "" );
 
         HtmlListItem li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 1." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 1." );
 
         ul = (HtmlUnorderedList) elementIterator.next();
         assertNotNull( ul );
-        //assertEquals( ul.getFirstChild().asText().trim(), "" );
 
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
         p = (HtmlParagraph) elementIterator.next();
         assertNotNull( p );
-        assertEquals( p.getFirstChild().asText().trim(), "Item 11." );
+        assertEquals( p.getFirstDomChild().asText().trim(), "Item 11." );
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
         p = (HtmlParagraph) elementIterator.next();
         assertNotNull( p );
-        assertEquals( p.getFirstChild().asText().trim(), "Item 12." );
+        assertEquals( p.getFirstDomChild().asText().trim(), "Item 12." );
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 13." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 13." );
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 14." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 14." );
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 2." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 2." );
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 3." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 3." );
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 4." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 4." );
 
         ul = (HtmlUnorderedList) elementIterator.next();
         assertNotNull( ul );
-        //assertEquals( ul.getFirstChild().asText().trim(), "" );
 
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 41." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 41." );
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 42." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 42." );
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 43." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 43." );
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 44." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 44." );
 
         p = (HtmlParagraph) elementIterator.next();
         assertNotNull( p );
@@ -287,54 +286,51 @@
 
         HtmlOrderedList ol = (HtmlOrderedList) elementIterator.next();
         assertNotNull( ol );
-        //assertEquals( ol.getFirstChild().asText().trim(), "" );
 
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 1." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 1." );
 
         ol = (HtmlOrderedList) elementIterator.next();
         assertNotNull( ol );
-        //assertEquals( ol.getFirstChild().asText().trim(), "" );
 
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 11." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 11." );
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 12." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 12." );
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 13." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 13." );
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 14." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 14." );
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 2." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 2." );
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 3." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 3." );
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 4." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 4." );
 
         ol = (HtmlOrderedList) elementIterator.next();
         assertNotNull( ol );
-        //assertEquals( ol.getFirstChild().asText().trim(), "" );
 
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 41." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 41." );
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 42." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 42." );
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 43." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 43." );
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "Item 44." );
+        assertEquals( li.getFirstDomChild().asText().trim(), "Item 44." );
 
         p = (HtmlParagraph) elementIterator.next();
         assertNotNull( p );
@@ -372,31 +368,29 @@
 
         HtmlDefinitionList dl = (HtmlDefinitionList) elementIterator.next();
         assertNotNull( dl );
-        //assertEquals( dl.getFirstChild().asText().trim(), "" );
 
         HtmlDefinitionTerm dt = (HtmlDefinitionTerm) elementIterator.next();
         assertNotNull( dt );
-        assertEquals( dt.getFirstChild().asText().trim(), "Term 1." );
+        assertEquals( dt.getFirstDomChild().asText().trim(), "Term 1." );
         HtmlDefinitionDescription dd = (HtmlDefinitionDescription) elementIterator.next();
         assertNotNull( dd );
-        assertEquals( dd.getFirstChild().asText().trim(), "Description 1." );
+        assertEquals( dd.getFirstDomChild().asText().trim(), "Description 1." );
 
         dt = (HtmlDefinitionTerm) elementIterator.next();
         assertNotNull( dt );
-        assertEquals( dt.getFirstChild().asText().trim(), "Term 2." );
+        assertEquals( dt.getFirstDomChild().asText().trim(), "Term 2." );
         dd = (HtmlDefinitionDescription) elementIterator.next();
         assertNotNull( dd );
-        assertEquals( dd.getFirstChild().asText().trim(), "Description 2." );
+        assertEquals( dd.getFirstDomChild().asText().trim(), "Description 2." );
 
         dl = (HtmlDefinitionList) elementIterator.next();
         assertNotNull( dl );
-        //assertEquals( dl.getFirstChild().asText().trim(), "" );
         dt = (HtmlDefinitionTerm) elementIterator.next();
         assertNotNull( dt );
-        assertEquals( dt.getFirstChild().asText().trim(), "Term 21." );
+        assertEquals( dt.getFirstDomChild().asText().trim(), "Term 21." );
         dd = (HtmlDefinitionDescription) elementIterator.next();
         assertNotNull( dd );
-        assertEquals( dd.getFirstChild().asText().trim(), "Description 21." );
+        assertEquals( dd.getFirstDomChild().asText().trim(), "Description 21." );
 
         p = (HtmlParagraph) elementIterator.next();
         assertNotNull( p );
@@ -432,7 +426,7 @@
 
         // HtmlUnit
         WebClient webClient = new WebClient();
-        HtmlPage page = (HtmlPage) webClient.getPage( multipleblock.toURL() );
+        HtmlPage page = (HtmlPage) webClient.getPage( multipleblock.toURI().toURL() );
         assertNotNull( page );
 
         HtmlElement element = page.getHtmlElementById( "contentBox" );
@@ -472,11 +466,10 @@
 
         HtmlUnorderedList ul = (HtmlUnorderedList) elementIterator.next();
         assertNotNull( ul );
-        //assertEquals( ul.getFirstChild().asText().trim(), "" );
 
         HtmlListItem li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "list1" );
+        assertEquals( li.getFirstDomChild().asText().trim(), "list1" );
 
         // ----------------------------------------------------------------------
         // Paragraph
@@ -492,11 +485,10 @@
 
         ul = (HtmlUnorderedList) elementIterator.next();
         assertNotNull( ul );
-        //assertEquals( ul.getFirstChild().asText().trim(), "" );
 
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "list1" );
+        assertEquals( li.getFirstDomChild().asText().trim(), "list1" );
 
         // ----------------------------------------------------------------------
         // Paragraph
@@ -512,14 +504,13 @@
 
         ul = (HtmlUnorderedList) elementIterator.next();
         assertNotNull( ul );
-        //assertEquals( ul.getFirstChild().asText().trim(), "" );
 
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
 
         p = (HtmlParagraph) elementIterator.next();
         assertNotNull( p );
-        assertEquals( p.getFirstChild().asText().trim(), "list1" );
+        assertEquals( p.getFirstDomChild().asText().trim(), "list1" );
 
         assertFalse( elementIterator.hasNext() );
     }
@@ -550,7 +541,7 @@
 
         // HtmlUnit
         WebClient webClient = new WebClient();
-        HtmlPage page = (HtmlPage) webClient.getPage( entityTest.toURL() );
+        HtmlPage page = (HtmlPage) webClient.getPage( entityTest.toURI().toURL() );
         assertNotNull( page );
 
         HtmlElement element = page.getHtmlElementById( "contentBox" );
@@ -632,7 +623,7 @@
         final List collectedAlerts = new ArrayList();
         webClient.setAlertHandler( new CollectingAlertHandler( collectedAlerts ) );
 
-        HtmlPage page = (HtmlPage) webClient.getPage( jsTest.toURL() );
+        HtmlPage page = (HtmlPage) webClient.getPage( jsTest.toURI().toURL() );
         assertNotNull( page );
 
         HtmlElement element = page.getHtmlElementById( "contentBox" );
@@ -682,7 +673,7 @@
 
         // HtmlUnit
         WebClient webClient = new WebClient();
-        HtmlPage page = (HtmlPage) webClient.getPage( faqTest.toURL() );
+        HtmlPage page = (HtmlPage) webClient.getPage( faqTest.toURI().toURL() );
         assertNotNull( page );
 
         HtmlElement element = page.getHtmlElementById( "contentBox" );
@@ -711,10 +702,10 @@
         assertEquals( element.asText().trim(), "Contributing" );
 
         HtmlOrderedList ol = (HtmlOrderedList) elementIterator.next();
-        assertEquals( ol.getFirstChild().asText().trim(), "One stupid question & a silly
answer?" );
+        assertEquals( ol.getFirstDomChild().asText().trim(), "One stupid question & a
silly answer?" );
 
         HtmlListItem li = (HtmlListItem) elementIterator.next();
-        assertEquals( li.getFirstChild().asText().trim(), "One stupid question & a silly
answer?" );
+        assertEquals( li.getFirstDomChild().asText().trim(), "One stupid question & a
silly answer?" );
 
         a = (HtmlAnchor) elementIterator.next();
         assertEquals( a.getAttributeValue( "href" ), "#stupid-question" );
@@ -729,11 +720,11 @@
         assertEquals( element.asText().trim(), "Using Maven" );
 
         ol = (HtmlOrderedList) elementIterator.next();
-        assertEquals( ol.getFirstChild().asText().trim(), "How do I disable a report on my
site?" );
+        assertEquals( ol.getFirstDomChild().asText().trim(), "How do I disable a report on
my site?" );
 
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
-        assertEquals( li.getFirstChild().asText().trim(), "How do I disable a report on my
site?" );
+        assertEquals( li.getFirstDomChild().asText().trim(), "How do I disable a report on
my site?" );
 
         a = (HtmlAnchor) elementIterator.next();
         assertEquals( a.getAttributeValue( "href" ), "#disable-reports" );
@@ -750,7 +741,7 @@
         HtmlDefinitionList dl = (HtmlDefinitionList) elementIterator.next();
 
         HtmlDefinitionTerm dt = (HtmlDefinitionTerm) elementIterator.next();
-        assertEquals( dt.getFirstChild().asText().trim(), "One stupid question & a silly
answer?" );
+        assertEquals( dt.getFirstDomChild().asText().trim(), "One stupid question & a
silly answer?" );
 
         a = (HtmlAnchor) elementIterator.next();
         assertEquals( a.getAttributeValue( "name" ), "stupid-question" );
@@ -807,7 +798,7 @@
         dl = (HtmlDefinitionList) elementIterator.next();
 
         dt = (HtmlDefinitionTerm) elementIterator.next();
-        assertEquals( dt.getFirstChild().asText().trim(), "How do I disable a report on my
site?" );
+        assertEquals( dt.getFirstDomChild().asText().trim(), "How do I disable a report on
my site?" );
 
         a = (HtmlAnchor) elementIterator.next();
         assertEquals( a.getAttributeValue( "name" ), "disable-reports" );
@@ -856,7 +847,7 @@
 
         // HtmlUnit
         WebClient webClient = new WebClient();
-        HtmlPage page = (HtmlPage) webClient.getPage( attributes.toURL() );
+        HtmlPage page = (HtmlPage) webClient.getPage( attributes.toURI().toURL() );
         assertNotNull( page );
 
         HtmlElement element = page.getHtmlElementById( "contentBox" );
@@ -924,5 +915,23 @@
         assertEquals( "left", th.getAttributeValue( "align" ) );
         assertEquals( "2", th.getAttributeValue( "rowspan" ) );
         assertEquals( "middle", th.getAttributeValue( "valign" ) );
+
+        HtmlTableDataCell td = (HtmlTableDataCell) elementIterator.next();
+        td = (HtmlTableDataCell) elementIterator.next();
+        tr = (HtmlTableRow) elementIterator.next();
+        td = (HtmlTableDataCell) elementIterator.next();
+        td = (HtmlTableDataCell) elementIterator.next();
+
+        p = (HtmlParagraph) elementIterator.next();
+        assertNotNull( p );
+        
+        UnknownHtmlElement unk = (UnknownHtmlElement) elementIterator.next();
+        assertEquals( "u", unk.getTagName());
+        unk = (UnknownHtmlElement) elementIterator.next();
+        assertEquals( "s", unk.getTagName());
+        unk = (UnknownHtmlElement) elementIterator.next();
+        assertEquals( "sub", unk.getTagName());
+        unk = (UnknownHtmlElement) elementIterator.next();
+        assertEquals( "sup", unk.getTagName());
     }
 }

Modified: maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/site/xdoc/attributes.xml
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/site/xdoc/attributes.xml?rev=635929&r1=635928&r2=635929&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/site/xdoc/attributes.xml
(original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/site/xdoc/attributes.xml
Tue Mar 11 07:00:28 2008
@@ -23,6 +23,10 @@
           <td valign="bottom">555 77 855</td>
         </tr>
       </table>
+      <p>
+        <!-- DOXIA-163, DOXIA 164 -->
+        <u>underline</u> <s>strike-through</s> <sub>subscript</sub>
<sup>superscript</sup>
+      </p>
     </section>
   </body>
 </document>

Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java?rev=635929&r1=635928&r2=635929&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
(original)
+++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
Tue Mar 11 07:00:28 2008
@@ -90,7 +90,7 @@
      * Converts the attributes of the current start tag of the given parser to a SinkEventAttributeSet.
      *
      * @param parser A parser.
-     * @param return a SinkEventAttributeSet or null if the current parser event is not a
start tag.
+     * @return a SinkEventAttributeSet or null if the current parser event is not a start
tag.
      */
     protected SinkEventAttributeSet getAttributesFromParser( XmlPullParser parser )
     {

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=635929&r1=635928&r2=635929&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
Tue Mar 11 07:00:28 2008
@@ -62,6 +62,9 @@
     /** Used to recognize the case of img inside figure. */
     private boolean inFigure;
 
+    /** Decoration properties, eg for texts. */
+    private String decoration;
+
     /**
      * <p>
      *   Goes through a common list of possible html start tags. These include only tags
that can go into
@@ -129,6 +132,24 @@
 
             sink.sectionTitle( Sink.SECTION_LEVEL_5, attribs );
         }
+        else if ( parser.getName().equals( Tag.U.toString() ) )
+        {
+            this.decoration = "underline";
+        }
+        else if ( parser.getName().equals( Tag.S.toString() )
+                || parser.getName().equals( Tag.STRIKE.toString() )
+                || parser.getName().equals( "del" ) )
+        {
+            this.decoration = "line-through";
+        }
+        else if ( parser.getName().equals( Tag.SUB.toString() ) )
+        {
+            this.decoration = "sub";
+        }
+        else if ( parser.getName().equals( Tag.SUP.toString() ) )
+        {
+            this.decoration = "sup";
+        }
         else if ( parser.getName().equals( Tag.P.toString() ) )
         {
             if ( !inFigure )
@@ -395,6 +416,15 @@
                 sink.paragraph_();
             }
         }
+        else if ( parser.getName().equals( Tag.U.toString() )
+                || parser.getName().equals( Tag.S.toString() )
+                || parser.getName().equals( Tag.STRIKE.toString() )
+                || parser.getName().equals( "del" )
+                || parser.getName().equals( Tag.SUB.toString() )
+                || parser.getName().equals( Tag.SUP.toString() ) )
+        {
+            this.decoration = null;
+        }
         else if ( parser.getName().equals( Tag.DIV.toString() ) )
         {
             if ( inFigure )
@@ -589,6 +619,20 @@
          */
         if ( StringUtils.isNotEmpty( text ) )
         {
+            SinkEventAttributeSet atts = new SinkEventAttributeSet();
+
+            if ( StringUtils.isNotEmpty( decoration ) )
+            {
+                if ( "underline".equals( decoration ) || "line-through".equals( decoration
) )
+                {
+                    atts.addAttribute( SinkEventAttributeSet.DECORATION, decoration);
+                }
+                else if ( "sub".equals( decoration ) || "sup".equals( decoration ) )
+                {
+                    atts.addAttribute( SinkEventAttributeSet.VALIGN, decoration);
+                }
+            }
+
             // 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.
@@ -597,12 +641,12 @@
 
             for ( int i = 0; i < lines.length - 1; i++ )
             {
-                sink.text( lines[i] + EOL );
+                sink.text( lines[i] + EOL, atts );
             }
 
             if ( lines[lines.length - 1].length() > 0 )
             {
-                sink.text( lines[lines.length - 1] );
+                sink.text( lines[lines.length - 1], 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=635929&r1=635928&r2=635929&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
Tue Mar 11 07:00:28 2008
@@ -173,7 +173,7 @@
     }
 
     /**
-     * @param verb an evenTableRow flag.
+     * @param even an evenTableRow flag.
      */
     protected void setEvenTableRow( boolean even )
     {
@@ -1366,6 +1366,9 @@
     /**
      * {@link StructureSinkUtils#isExternalLink(String)} also treats links to other documents
as
      * external links, those should not have a class="externalLink" attribute.
+     * @param href the link.
+     * @return true if the link starts with "http:/", "https:/", "ftp:/",
+     * "mailto:" or "file:/".
      */
     protected boolean isExternalLink( String href )
     {
@@ -1380,6 +1383,8 @@
      * Legacy: treat links to other html documents as external links.
      * Note that links to other file formats (images, pdf) will still be broken,
      * links to other documents should always start with "./" or "../".
+     * @param href the link.
+     * @return true if the link points to another source document.
      */
     protected boolean isExternalHtml( String href )
     {
@@ -1586,6 +1591,52 @@
         else
         {
             content( text );
+        }
+    }
+
+    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 );
+            }
         }
     }
 

Modified: maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java?rev=635929&r1=635928&r2=635929&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java
(original)
+++ maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java
Tue Mar 11 07:00:28 2008
@@ -872,7 +872,9 @@
     
     /**
      * Adds a text. 
-     * Supported attributes are the {@link SinkEventAttributes base attributes}.
+     * Supported attributes are the {@link SinkEventAttributes base attributes}
+     * plus VALIGN (values "sub", "sup") and DECORATION (values "underline",
+     * "overline", "line-through").
      *
      * @param text The text to write.
      * @param attributes A set of {@link SinkEventAttributes}.

Modified: maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/SinkEventAttributes.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/SinkEventAttributes.java?rev=635929&r1=635928&r2=635929&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/SinkEventAttributes.java
(original)
+++ maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/SinkEventAttributes.java
Tue Mar 11 07:00:28 2008
@@ -279,7 +279,8 @@
     String SCOPE = "scope";
 
     /**
-     * Specifies the vertical alignment of an element.
+     * Specifies the vertical alignment of an element. Generally accepted values
+     * are "top", "baseline", "middle", "bottom", "sup", "sub".
      */
     String VALIGN = "valign";
 
@@ -289,4 +290,11 @@
      * Whether to draw a border, or box around an element.
      */
     String BOXED = "boxed";
+
+    // text
+    /**
+     * Specifies a decoration for an element. Generally accepted values
+     * are "underline", "overline", "line-through".
+     */
+    String DECORATION = "decoration";
 }



Mime
View raw message