Author: vsiveton
Date: Fri Nov 7 07:13:26 2008
New Revision: 712152
URL: http://svn.apache.org/viewvc?rev=712152&view=rev
Log:
o be sure that XHTML will be valid regarding the title tag inside the head tag
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.java
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java
Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.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/XhtmlSink.java?rev=712152&r1=712151&r2=712152&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.java
Fri Nov 7 07:13:26 2008
@@ -61,6 +61,8 @@
// TODO: this doesn't belong here
private RenderingContext renderingContext;
+ /** An indication on if we're inside a head title. */
+ private boolean headTitleFlag;
// ----------------------------------------------------------------------
// Constructors
@@ -115,7 +117,19 @@
/** {@inheritDoc} */
public void head_()
{
+ if ( !isHeadTitleFlag() )
+ {
+ // The content of element type "head" must match
+ // "((script|style|meta|link|object|isindex)*,
+ // ((title,(script|style|meta|link|object|isindex)*,
+ // (base,(script|style|meta|link|object|isindex)*)?)|(base,(script|style|meta|link|object|isindex)*,
+ // (title,(script|style|meta|link|object|isindex)*))))"
+ writeStartTag( Tag.TITLE );
+ writeEndTag( Tag.TITLE );
+ }
+
setHeadFlag( false );
+ setHeadTitleFlag( false );
// always UTF-8
write( "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>"
);
@@ -129,6 +143,8 @@
*/
public void title()
{
+ setHeadTitleFlag( true );
+
writeStartTag( Tag.TITLE );
}
@@ -143,6 +159,7 @@
writeEndTag( Tag.TITLE );
resetBuffer();
+
}
/**
@@ -238,4 +255,20 @@
{
return renderingContext;
}
+
+ /**
+ * @param headTitleFlag an header title flag.
+ */
+ protected void setHeadTitleFlag( boolean headTitleFlag )
+ {
+ this.headTitleFlag = headTitleFlag;
+ }
+
+ /**
+ * @return the current headTitleFlag.
+ */
+ protected boolean isHeadTitleFlag()
+ {
+ return this.headTitleFlag ;
+ }
}
Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java?rev=712152&r1=712151&r2=712152&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java
Fri Nov 7 07:13:26 2008
@@ -126,8 +126,9 @@
String text = sb.toString();
StringWriter w = new StringWriter();
Sink sink = new XhtmlSink( w );
- // Should fail when fixing DOXIA-263 I guess.
- ( (XhtmlParser) createParser() ).parse( text.toString(), sink );
+ XhtmlParser parser = (XhtmlParser) createParser();
+ parser.setValidate( false );
+ parser.parse( text.toString(), sink );
String result = w.toString();
assertTrue( result.indexOf( "ř" ) != -1 );
Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java?rev=712152&r1=712151&r2=712152&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java
Fri Nov 7 07:13:26 2008
@@ -88,7 +88,7 @@
protected String getHeadBlock()
{
return "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
+
- "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta
http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/></head>";
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title></title><meta
http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/></head>";
}
/** {@inheritDoc} */
|