Author: hboutemy
Date: Sun Nov 9 09:57:22 2008
New Revision: 712525
URL: http://svn.apache.org/viewvc?rev=712525&view=rev
Log:
DOXIA-185: output encoding in generated XHTML content consistently with SinkFactory
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/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkFactory.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=712525&r1=712524&r2=712525&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
Sun Nov 9 09:57:22 2008
@@ -33,8 +33,6 @@
/**
* Xhtml sink implementation.
- * <br/>
- * <b>Note</b>: The encoding used is UTF-8.
*
* @author Jason van Zyl
* @author ltheussl
@@ -61,6 +59,8 @@
// TODO: this doesn't belong here
private RenderingContext renderingContext;
+ private String encoding;
+
/** An indication on if we're inside a head title. */
private boolean headTitleFlag;
@@ -71,12 +71,25 @@
/**
* Constructor, initialize the Writer.
*
- * @param writer not null writer to write the result. <b>Should</b> be an
UTF-8 Writer.
- * You could use <code>newXmlWriter</code> methods from {@link org.codehaus.plexus.util.WriterFactory}.
+ * @param writer not null writer to write the result.
*/
protected XhtmlSink( Writer writer )
{
- this( writer, null );
+ this( writer, (RenderingContext) null );
+ }
+
+ /**
+ * Constructor, initialize the Writer and tells which encoding is used.
+ *
+ * @param writer not null writer to write the result.
+ * @param encoding the encoding used, that should be written to the generated HTML content
+ * if not <code>null</code>.
+ */
+ protected XhtmlSink( Writer writer, String encoding )
+ {
+ this( writer, (RenderingContext) null );
+
+ this.encoding = encoding;
}
/**
@@ -131,8 +144,10 @@
setHeadFlag( false );
setHeadTitleFlag( false );
- // always UTF-8
- write( "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>"
);
+ if ( encoding != null )
+ {
+ write( "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" +
encoding + "\"/>" );
+ }
writeEndTag( Tag.HEAD );
}
Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkFactory.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/XhtmlSinkFactory.java?rev=712525&r1=712524&r2=712525&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkFactory.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkFactory.java
Sun Nov 9 09:57:22 2008
@@ -38,7 +38,6 @@
/** {@inheritDoc} */
public Sink createSink( Writer writer, String encoding )
{
- // TODO: don't ignore encoding parameter
- return new XhtmlSink( writer );
+ return new XhtmlSink( writer, encoding );
}
}
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=712525&r1=712524&r2=712525&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
Sun Nov 9 09:57:22 2008
@@ -41,7 +41,7 @@
/** {@inheritDoc} */
protected Sink createSink( Writer writer )
{
- return new XhtmlSink( writer );
+ return new XhtmlSink( writer, "UTF-8" );
}
/** {@inheritDoc} */
|