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/11/07 16:12:02 UTC

svn commit: r712151 - /maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java

Author: vsiveton
Date: Fri Nov  7 07:11:48 2008
New Revision: 712151

URL: http://svn.apache.org/viewvc?rev=712151&view=rev
Log:
o be sure that XHTML will be valid regarding the img tag

Modified:
    maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java

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=712151&r1=712150&r2=712151&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 Nov  7 07:11:48 2008
@@ -57,6 +57,9 @@
     /** An indication on if we're inside a head. */
     private boolean headFlag;
 
+    /** An indication on if we're inside an image caption flag. */
+    private boolean figureCaptionFlag;
+
     /** An indication on if we're in verbatim mode. */
     private boolean verbatimFlag;
 
@@ -758,6 +761,11 @@
     {
         if ( legacyFigure )
         {
+            if ( !figureCaptionFlag )
+            {
+                // Attribute "alt" is required and must be specified for element type "img".
+                write( String.valueOf( SPACE ) + Attribute.ALT + EQUAL + QUOTE + QUOTE );
+            }
             write( String.valueOf( SPACE ) + SLASH + GREATER_THAN );
             legacyFigure = false;
         }
@@ -766,6 +774,8 @@
             writeEndTag( Tag.DIV );
             inFigure = false;
         }
+
+        figureCaptionFlag = false;
     }
 
     /** {@inheritDoc}
@@ -796,6 +806,10 @@
         atts.addAttribute( Attribute.SRC, src );
         atts.addAttributes( SinkUtils.filterAttributes(
                 attributes, SinkUtils.SINK_IMG_ATTRIBUTES ) );
+        if ( atts.getAttribute( Attribute.ALT ) == null )
+        {
+            atts.addAttribute( Attribute.ALT, "" );
+        }
 
         writeStartTag( Tag.IMG, atts, true );
 
@@ -812,6 +826,7 @@
      */
     public void figureCaption()
     {
+        figureCaptionFlag = true;
         write( String.valueOf( SPACE ) + Attribute.ALT + EQUAL + QUOTE );
         legacyFigureCaption = true;
     }
@@ -823,6 +838,7 @@
         {
             write( String.valueOf( SPACE ) + Attribute.ALT + EQUAL + QUOTE );
             legacyFigureCaption = false;
+            figureCaptionFlag = true;
         }
         else
         {