Author: ltheussl
Date: Sun Oct 28 13:14:50 2007
New Revision: 589412
URL: http://svn.apache.org/viewvc?rev=589412&view=rev
Log:
Further unify the xdoc and xhtml sinks. The idea is to factor out some common
AbstactXhtmlParser/Sink, that can be extended by all xhtml-based modules, in
particular fml.
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.java
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.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/XdocSink.java?rev=589412&r1=589411&r2=589412&view=diff
==============================================================================
---
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java
(original)
+++
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java
Sun Oct 28 13:14:50 2007
@@ -19,6 +19,7 @@
* under the License.
*/
+import java.io.PrintWriter;
import java.io.Writer;
import javax.swing.text.MutableAttributeSet;
@@ -30,7 +31,6 @@
import org.apache.maven.doxia.sink.AbstractXmlSink;
import org.apache.maven.doxia.sink.StructureSink;
import org.apache.maven.doxia.util.HtmlTools;
-import org.apache.maven.doxia.util.LineBreaker;
/**
* A doxia Sink which produces an xdoc model.
@@ -48,21 +48,14 @@
// Instance fields
// ----------------------------------------------------------------------
- /** The LineBreaker to write the result. */
- protected LineBreaker out;
+ /** The PrintWriter to write the result. */
+ private PrintWriter writer;
/** Used to collect text events. */
- protected StringBuffer buffer = new StringBuffer();
+ private StringBuffer buffer = new StringBuffer();
/** An indication on if we're inside a head. */
- protected boolean headFlag;
-
- /**
- * An indication on if we're inside a title.
- *
- * This will prevent the styling of titles.
- */
- protected boolean titleFlag;
+ private boolean headFlag;
/** An indication on if we're inside a box (verbatim). */
private boolean boxedFlag;
@@ -81,13 +74,13 @@
// ----------------------------------------------------------------------
/**
- * Constructor, initialize the LineBreaker.
+ * Constructor, initialize the PrintWriter.
*
* @param writer The writer to write the result.
*/
public XdocSink( Writer writer )
{
- this.out = new LineBreaker( writer );
+ this.writer = new PrintWriter( writer );
}
// ----------------------------------------------------------------------
@@ -134,7 +127,7 @@
headFlag = true;
- markup( "<?xml version=\"1.0\" ?>" + EOL );
+ write( "<?xml version=\"1.0\" ?>" + EOL );
writeStartTag( DOCUMENT_TAG );
@@ -157,15 +150,22 @@
* [EMAIL PROTECTED]
* @see javax.swing.text.html.HTML.Tag#TITLE
*/
+ public void title()
+ {
+ writeStartTag( Tag.TITLE );
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see javax.swing.text.html.HTML.Tag#TITLE
+ */
public void title_()
{
- if ( buffer.length() > 0 )
- {
- writeStartTag( Tag.TITLE );
- content( buffer.toString() );
- writeEndTag( Tag.TITLE );
- resetBuffer();
- }
+ content( buffer.toString() );
+
+ writeEndTag( Tag.TITLE );
+
+ resetBuffer();
}
/**
@@ -218,25 +218,25 @@
writeEndTag( DOCUMENT_TAG );
- out.flush();
+ flush();
resetState();
}
- // -----------------------------------------------------------------------
+ // ----------------------------------------------------------------------
// Sections
- // -----------------------------------------------------------------------
+ // ----------------------------------------------------------------------
/** [EMAIL PROTECTED] */
public void section1()
{
- onSection( 1 );
+ onSection( SECTION_LEVEL_1 );
}
/** [EMAIL PROTECTED] */
public void sectionTitle1()
{
- onSectionTitle( 1 );
+ onSectionTitle( SECTION_LEVEL_1 );
}
/** [EMAIL PROTECTED] */
@@ -358,17 +358,32 @@
{
if ( depth == SECTION_LEVEL_1 )
{
- markup( String.valueOf( LESS_THAN ) + SECTION_TAG.toString() +
String.valueOf( SPACE ) + Attribute.NAME
+ write( String.valueOf( LESS_THAN ) + SECTION_TAG.toString() +
String.valueOf( SPACE ) + Attribute.NAME
+ String.valueOf( EQUAL ) + String.valueOf( QUOTE ) );
-
- titleFlag = true;
}
else if ( depth == SECTION_LEVEL_2 )
{
- markup( String.valueOf( LESS_THAN ) + SUBSECTION_TAG.toString() +
String.valueOf( SPACE ) + Attribute.NAME
+ write( String.valueOf( LESS_THAN ) + SUBSECTION_TAG.toString() +
String.valueOf( SPACE ) + Attribute.NAME
+ String.valueOf( EQUAL ) + String.valueOf( QUOTE ) );
+ }
+ }
- titleFlag = true;
+ /**
+ * Ends a section.
+ *
+ * @param depth The level of the section.
+ * @see XdocMarkup#SECTION_TAG
+ * @see XdocMarkup#SUBSECTION_TAG
+ */
+ private void onSection_( int depth )
+ {
+ if ( depth == SECTION_LEVEL_1 )
+ {
+ writeEndTag( SECTION_TAG );
+ }
+ else if ( depth == SECTION_LEVEL_2 )
+ {
+ writeEndTag( SUBSECTION_TAG );
}
}
@@ -394,8 +409,6 @@
{
writeStartTag( Tag.H6 );
}
-
- titleFlag = true;
}
/**
@@ -410,7 +423,7 @@
{
if ( depth == SECTION_LEVEL_1 || depth == SECTION_LEVEL_2 )
{
- markup( String.valueOf( QUOTE ) + String.valueOf( GREATER_THAN ) );
+ write( String.valueOf( QUOTE ) + String.valueOf( GREATER_THAN ) );
}
else if ( depth == SECTION_LEVEL_3 )
{
@@ -424,27 +437,6 @@
{
writeEndTag( Tag.H6 );
}
-
- titleFlag = false;
- }
-
- /**
- * Ends a section.
- *
- * @param depth The level of the section.
- * @see XdocMarkup#SECTION_TAG
- * @see XdocMarkup#SUBSECTION_TAG
- */
- private void onSection_( int depth )
- {
- if ( depth == SECTION_LEVEL_1 )
- {
- writeEndTag( SECTION_TAG );
- }
- else if ( depth == SECTION_LEVEL_2 )
- {
- writeEndTag( SUBSECTION_TAG );
- }
}
// -----------------------------------------------------------------------
@@ -608,32 +600,32 @@
*/
public void figure()
{
- markup( String.valueOf( LESS_THAN ) + Tag.IMG );
+ write( String.valueOf( LESS_THAN ) + Tag.IMG );
}
/** [EMAIL PROTECTED] */
public void figure_()
{
- markup( String.valueOf( SPACE ) + String.valueOf( SLASH ) +
String.valueOf( GREATER_THAN ) );
+ write( String.valueOf( SPACE ) + String.valueOf( SLASH ) +
String.valueOf( GREATER_THAN ) );
}
/** [EMAIL PROTECTED] */
- public void figureGraphics( String s )
+ public void figureGraphics( String name )
{
- markup( String.valueOf( SPACE ) + Attribute.SRC + String.valueOf(
EQUAL ) + String.valueOf( QUOTE ) + s
+ write( String.valueOf( SPACE ) + Attribute.SRC + String.valueOf( EQUAL
) + String.valueOf( QUOTE ) + name
+ String.valueOf( QUOTE ) );
}
/** [EMAIL PROTECTED] */
public void figureCaption()
{
- markup( String.valueOf( SPACE ) + Attribute.ALT + String.valueOf(
EQUAL ) + String.valueOf( QUOTE ) );
+ write( String.valueOf( SPACE ) + Attribute.ALT + String.valueOf( EQUAL
) + String.valueOf( QUOTE ) );
}
/** [EMAIL PROTECTED] */
public void figureCaption_()
{
- markup( String.valueOf( QUOTE ) );
+ write( String.valueOf( QUOTE ) );
}
/**
@@ -662,7 +654,9 @@
public void verbatim( boolean boxed )
{
verbatimFlag = true;
+
boxedFlag = boxed;
+
if ( boxed )
{
writeStartTag( SOURCE_TAG );
@@ -796,6 +790,29 @@
*/
public void tableCell( boolean headerRow )
{
+ tableCell( headerRow, null );
+ }
+
+ /** [EMAIL PROTECTED] */
+ public void tableCell( String width )
+ {
+ tableCell( false, width );
+ }
+
+ /** [EMAIL PROTECTED] */
+ public void tableHeaderCell( String width )
+ {
+ tableCell( true, width );
+ }
+
+ /**
+ * @param headerRow true if it is an header row
+ * @param width the cell size
+ * @see javax.swing.text.html.HTML.Tag#TH
+ * @see javax.swing.text.html.HTML.Tag#TD
+ */
+ public void tableCell( boolean headerRow, String width )
+ {
String justif = null;
if ( cellJustif != null )
@@ -815,13 +832,18 @@
}
}
+
Tag t = ( headerRow ? Tag.TH : Tag.TD );
- MutableAttributeSet att = null;
+ MutableAttributeSet att = new SimpleAttributeSet();
+
+ if ( width != null )
+ {
+ att.addAttribute( Attribute.WIDTH, width );
+ }
if ( justif != null )
{
- att = new SimpleAttributeSet();
att.addAttribute( Attribute.ALIGN, justif );
}
@@ -881,7 +903,7 @@
*/
public void anchor( String name )
{
- if ( !headFlag && !titleFlag )
+ if ( !headFlag )
{
String id = HtmlTools.encodeId( name );
@@ -902,7 +924,7 @@
*/
public void anchor_()
{
- if ( !headFlag && !titleFlag )
+ if ( !headFlag )
{
writeEndTag( Tag.A );
}
@@ -914,7 +936,7 @@
*/
public void link( String name )
{
- if ( headFlag || titleFlag )
+ if ( headFlag )
{
return;
}
@@ -952,7 +974,7 @@
*/
public void link_()
{
- if ( !headFlag && !titleFlag )
+ if ( !headFlag )
{
writeEndTag( Tag.A );
}
@@ -964,7 +986,7 @@
*/
public void italic()
{
- if ( !headFlag && !titleFlag )
+ if ( !headFlag )
{
writeStartTag( Tag.I );
}
@@ -976,7 +998,7 @@
*/
public void italic_()
{
- if ( !headFlag && !titleFlag )
+ if ( !headFlag )
{
writeEndTag( Tag.I );
}
@@ -988,7 +1010,7 @@
*/
public void bold()
{
- if ( !headFlag && !titleFlag )
+ if ( !headFlag )
{
writeStartTag( Tag.B );
}
@@ -1000,7 +1022,7 @@
*/
public void bold_()
{
- if ( !headFlag && !titleFlag )
+ if ( !headFlag )
{
writeEndTag( Tag.B );
}
@@ -1012,7 +1034,7 @@
*/
public void monospaced()
{
- if ( !headFlag && !titleFlag )
+ if ( !headFlag )
{
writeStartTag( Tag.TT );
}
@@ -1024,7 +1046,7 @@
*/
public void monospaced_()
{
- if ( !headFlag && !titleFlag )
+ if ( !headFlag )
{
writeEndTag( Tag.TT );
}
@@ -1036,7 +1058,7 @@
*/
public void lineBreak()
{
- if ( headFlag || titleFlag )
+ if ( headFlag )
{
buffer.append( EOL );
}
@@ -1055,13 +1077,13 @@
/** [EMAIL PROTECTED] */
public void nonBreakingSpace()
{
- if ( headFlag || titleFlag )
+ if ( headFlag )
{
buffer.append( ' ' );
}
else
{
- markup( " " );
+ write( " " );
}
}
@@ -1083,6 +1105,12 @@
}
/** [EMAIL PROTECTED] */
+ public void rawText( String text )
+ {
+ write( text );
+ }
+
+ /** [EMAIL PROTECTED] */
public void comment( String comment )
{
StringBuffer buffer = new StringBuffer( comment.length() + 9 );
@@ -1093,9 +1121,20 @@
buffer.append( SPACE ).append( MINUS ).append( MINUS ).append(
GREATER_THAN );
- markup( buffer.toString() );
+ rawText( buffer.toString() );
+ }
+
+ /** [EMAIL PROTECTED] */
+ public void flush()
+ {
+ writer.flush();
}
+ /** [EMAIL PROTECTED] */
+ public void close()
+ {
+ writer.close();
+ }
// ----------------------------------------------------------------------
//
@@ -1105,30 +1144,31 @@
* Write text to output, preserving white space.
*
* @param text The text to write.
+ * @deprecated use write(String)
*/
protected void markup( String text )
{
- out.write( text, true );
+ write( text );
}
/**
- * Write HTML escaped text to output, preserving white space.
+ * Write HTML escaped text to output.
*
* @param text The text to write.
*/
protected void content( String text )
{
- out.write( escapeHTML( text ), true );
+ write( escapeHTML( text ) );
}
/**
- * Write HTML escaped text to output, preserving white space.
+ * Write HTML escaped text to output.
*
* @param text The text to write.
*/
protected void verbatimContent( String text )
{
- out.write( escapeHTML( text ), true );
+ write( escapeHTML( text ) );
}
/**
@@ -1156,20 +1196,8 @@
}
/** [EMAIL PROTECTED] */
- public void flush()
- {
- out.flush();
- }
-
- /** [EMAIL PROTECTED] */
- public void close()
- {
- out.close();
- }
-
- /** [EMAIL PROTECTED] */
protected void write( String text )
{
- markup( text );
+ writer.write( text );
}
}
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java?rev=589412&r1=589411&r2=589412&view=diff
==============================================================================
---
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java
(original)
+++
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java
Sun Oct 28 13:14:50 2007
@@ -48,7 +48,7 @@
/** [EMAIL PROTECTED] */
protected String getTitleBlock( String title )
{
- return title;
+ return "<title>" + title + "</title>";
}
/** [EMAIL PROTECTED] */
@@ -235,8 +235,7 @@
/** [EMAIL PROTECTED] */
protected String getRawTextBlock( String text )
{
- // TODO
- return "";
+ return "~, =, -, +, *, [, ], <, >, {, }, \\";
}
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=589412&r1=589411&r2=589412&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 Oct 28 13:14:50 2007
@@ -31,7 +31,6 @@
import org.apache.maven.doxia.module.xhtml.decoration.render.RenderingContext;
import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.sink.AbstractXmlSink;
-import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.StructureSink;
import org.apache.maven.doxia.util.HtmlTools;
import org.codehaus.plexus.util.StringUtils;
@@ -52,20 +51,30 @@
// Instance fields
// ----------------------------------------------------------------------
+ /** The PrintWriter to write the result. */
+ private PrintWriter writer;
+
+ /** Used to collect text events. */
private StringBuffer buffer = new StringBuffer();
+ /** An indication on if we're inside a head. */
private boolean headFlag;
+ /** An indication on if we're in verbatim mode. */
private boolean verbatimFlag;
- private int cellCount;
-
- private PrintWriter writer;
-
+ // TODO: this doesn't belong here
private RenderingContext renderingContext;
+ /** Justification of table cells. */
private int[] cellJustif;
+ /** Number of cells in a table row. */
+ private int cellCount;
+
+ /** Used to style successive table rows differently. */
+ private boolean evenTableRow = true;
+
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
@@ -97,9 +106,7 @@
*/
public XhtmlSink( Writer writer, RenderingContext renderingContext, Map
directives )
{
- this.writer = new PrintWriter( writer );
-
- this.renderingContext = renderingContext;
+ this( writer, renderingContext );
}
// ----------------------------------------------------------------------
@@ -130,6 +137,7 @@
headFlag = false;
resetBuffer();
verbatimFlag = false;
+ cellJustif = null;
cellCount = 0;
}
@@ -177,7 +185,7 @@
*/
public void title_()
{
- write( buffer.toString() );
+ content( buffer.toString() );
writeEndTag( Tag.TITLE );
@@ -237,220 +245,240 @@
public void body_()
{
writeEndTag( Tag.BODY );
+
writeEndTag( Tag.HTML );
+
+ flush();
+
+ resetState();
}
// ----------------------------------------------------------------------
// Sections
// ----------------------------------------------------------------------
- /**
- * The default class style is <code>section</code>.
- *
- * [EMAIL PROTECTED]
- * @see javax.swing.text.html.HTML.Tag#DIV
- */
+ /** [EMAIL PROTECTED] */
public void section1()
{
- onSection();
+ onSection( SECTION_LEVEL_1 );
}
- /**
- * [EMAIL PROTECTED]
- * @see javax.swing.text.html.HTML.Tag#H2
- */
+ /** [EMAIL PROTECTED] */
public void sectionTitle1()
{
- writeStartTag( Tag.H2 );
+ onSectionTitle( SECTION_LEVEL_1 );
}
- /**
- * [EMAIL PROTECTED]
- * @see javax.swing.text.html.HTML.Tag#H2
- */
+ /** [EMAIL PROTECTED] */
public void sectionTitle1_()
{
- writeEndTag( Tag.H2 );
+ onSectionTitle_( SECTION_LEVEL_1 );
}
- /**
- * [EMAIL PROTECTED]
- * @see javax.swing.text.html.HTML.Tag#DIV
- */
+ /** [EMAIL PROTECTED] */
public void section1_()
{
- writeEndTag( Tag.DIV );
+ onSection_( SECTION_LEVEL_1 );
}
- /**
- * The default class style is <code>section</code>.
- *
- * [EMAIL PROTECTED]
- * @see javax.swing.text.html.HTML.Tag#DIV
- */
+ /** [EMAIL PROTECTED] */
public void section2()
{
- onSection();
+ onSection( SECTION_LEVEL_2 );
}
- /**
- * [EMAIL PROTECTED]
- * @see javax.swing.text.html.HTML.Tag#H3
- */
+ /** [EMAIL PROTECTED] */
public void sectionTitle2()
{
- writeStartTag( Tag.H3 );
+ onSectionTitle( SECTION_LEVEL_2 );
}
- /**
- * [EMAIL PROTECTED]
- * @see javax.swing.text.html.HTML.Tag#H3
- */
+ /** [EMAIL PROTECTED] */
public void sectionTitle2_()
{
- writeEndTag( Tag.H3 );
+ onSectionTitle_( SECTION_LEVEL_2 );
}
- /**
- * [EMAIL PROTECTED]
- * @see javax.swing.text.html.HTML.Tag#DIV
- */
+ /** [EMAIL PROTECTED] */
public void section2_()
{
- writeEndTag( Tag.DIV );
+ onSection_( SECTION_LEVEL_2 );
}
- /**
- * The default class style is <code>section</code>.
- *
- * [EMAIL PROTECTED]
- * @see javax.swing.text.html.HTML.Tag#DIV
- */
+ /** [EMAIL PROTECTED] */
public void section3()
{
- onSection();
+ onSection( SECTION_LEVEL_3 );
}
- /**
- * [EMAIL PROTECTED]
- * @see javax.swing.text.html.HTML.Tag#H4
- */
+ /** [EMAIL PROTECTED] */
public void sectionTitle3()
{
- writeStartTag( Tag.H4 );
+ onSectionTitle( SECTION_LEVEL_3 );
}
- /**
- * [EMAIL PROTECTED]
- * @see javax.swing.text.html.HTML.Tag#H4
- */
+ /** [EMAIL PROTECTED] */
public void sectionTitle3_()
{
- writeEndTag( Tag.H4 );
+ onSectionTitle_( SECTION_LEVEL_3 );
}
- /**
- * [EMAIL PROTECTED]
- * @see javax.swing.text.html.HTML.Tag#DIV
- */
+ /** [EMAIL PROTECTED] */
public void section3_()
{
- writeEndTag( Tag.DIV );
+ onSection_( SECTION_LEVEL_3 );
}
- /**
- * The default class style is <code>section</code>.
- *
- * [EMAIL PROTECTED]
- * @see javax.swing.text.html.HTML.Tag#DIV
- */
+ /** [EMAIL PROTECTED] */
public void section4()
{
- onSection();
+ onSection( SECTION_LEVEL_4 );
}
- /**
- * [EMAIL PROTECTED]
- * @see javax.swing.text.html.HTML.Tag#H5
- */
+ /** [EMAIL PROTECTED] */
public void sectionTitle4()
{
- writeStartTag( Tag.H5 );
+ onSectionTitle( SECTION_LEVEL_4 );
}
- /**
- * [EMAIL PROTECTED]
- * @see javax.swing.text.html.HTML.Tag#H5
- */
+ /** [EMAIL PROTECTED] */
public void sectionTitle4_()
{
- writeEndTag( Tag.H5 );
+ onSectionTitle_( SECTION_LEVEL_4 );
}
- /**
- * [EMAIL PROTECTED]
- * @see javax.swing.text.html.HTML.Tag#DIV
- */
+ /** [EMAIL PROTECTED] */
public void section4_()
{
- writeEndTag( Tag.DIV );
+ onSection_( SECTION_LEVEL_4 );
}
- /**
- * The default class style is <code>section</code>.
- *
- * [EMAIL PROTECTED]
- * @see javax.swing.text.html.HTML.Tag#DIV
- */
+ /** [EMAIL PROTECTED] */
public void section5()
{
- onSection();
+ onSection( SECTION_LEVEL_5 );
}
- /**
- * [EMAIL PROTECTED]
- * @see javax.swing.text.html.HTML.Tag#H6
- */
+ /** [EMAIL PROTECTED] */
public void sectionTitle5()
{
- writeStartTag( Tag.H6 );
+ onSectionTitle( SECTION_LEVEL_5 );
}
- /**
- * [EMAIL PROTECTED]
- * @see javax.swing.text.html.HTML.Tag#H6
- */
+ /** [EMAIL PROTECTED] */
public void sectionTitle5_()
{
- writeEndTag( Tag.H6 );
+ onSectionTitle_( SECTION_LEVEL_5 );
+ }
+
+ /** [EMAIL PROTECTED] */
+ public void section5_()
+ {
+ onSection_( SECTION_LEVEL_5 );
}
/**
- * [EMAIL PROTECTED]
+ * Starts a section. The default class style is <code>section</code>.
+ *
+ * @param depth The level of the section.
* @see javax.swing.text.html.HTML.Tag#DIV
*/
- public void section5_()
+ private void onSection( int depth )
{
- writeEndTag( Tag.DIV );
+ if ( depth >= SECTION_LEVEL_1 && depth <= SECTION_LEVEL_5 )
+ {
+ MutableAttributeSet att = new SimpleAttributeSet();
+ att.addAttribute( Attribute.CLASS, "section" );
+
+ writeStartTag( Tag.DIV, att );
+ }
}
/**
- * Starts a section.
+ * Ends a section.
*
* @param depth The level of the section.
* @see javax.swing.text.html.HTML.Tag#DIV
*/
- private void onSection()
+ private void onSection_( int depth )
{
- MutableAttributeSet att = new SimpleAttributeSet();
- att.addAttribute( Attribute.CLASS, "section" );
+ if ( depth >= SECTION_LEVEL_1 && depth <= SECTION_LEVEL_5 )
+ {
+ writeEndTag( Tag.DIV );
+ }
+ }
- writeStartTag( Tag.DIV, att );
+ /**
+ * Starts a section title.
+ *
+ * @param depth The level of the section title.
+ * @see javax.swing.text.html.HTML.Tag#H2
+ * @see javax.swing.text.html.HTML.Tag#H3
+ * @see javax.swing.text.html.HTML.Tag#H4
+ * @see javax.swing.text.html.HTML.Tag#H5
+ * @see javax.swing.text.html.HTML.Tag#H6
+ */
+ private void onSectionTitle( int depth )
+ {
+ if ( depth == SECTION_LEVEL_1 )
+ {
+ writeStartTag( Tag.H2 );
+ }
+ else if ( depth == SECTION_LEVEL_2 )
+ {
+ writeStartTag( Tag.H3 );
+ }
+ else if ( depth == SECTION_LEVEL_3 )
+ {
+ writeStartTag( Tag.H4 );
+ }
+ else if ( depth == SECTION_LEVEL_4 )
+ {
+ writeStartTag( Tag.H5 );
+ }
+ else if ( depth == SECTION_LEVEL_5 )
+ {
+ writeStartTag( Tag.H6 );
+ }
}
- // ----------------------------------------------------------------------
+ /**
+ * Ends a section title.
+ *
+ * @param depth The level of the section title.
+ * @see javax.swing.text.html.HTML.Tag#H2
+ * @see javax.swing.text.html.HTML.Tag#H3
+ * @see javax.swing.text.html.HTML.Tag#H4
+ * @see javax.swing.text.html.HTML.Tag#H5
+ * @see javax.swing.text.html.HTML.Tag#H6
+ */
+ private void onSectionTitle_( int depth )
+ {
+ if ( depth == SECTION_LEVEL_1 )
+ {
+ writeEndTag( Tag.H2 );
+ }
+ else if ( depth == SECTION_LEVEL_2 )
+ {
+ writeEndTag( Tag.H3 );
+ }
+ else if ( depth == SECTION_LEVEL_3 )
+ {
+ writeEndTag( Tag.H4 );
+ }
+ else if ( depth == SECTION_LEVEL_4 )
+ {
+ writeEndTag( Tag.H5 );
+ }
+ else if ( depth == SECTION_LEVEL_5 )
+ {
+ writeEndTag( Tag.H6 );
+ }
+ }
+
+ // -----------------------------------------------------------------------
//
- // ----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
/**
* [EMAIL PROTECTED]
@@ -667,7 +695,11 @@
verbatimFlag = true;
MutableAttributeSet att = new SimpleAttributeSet();
- att.addAttribute( Attribute.CLASS, "source" );
+
+ if ( boxed )
+ {
+ att.addAttribute( Attribute.CLASS, "source" );
+ }
writeStartTag( Tag.DIV, att );
writeStartTag( Tag.PRE );
@@ -741,35 +773,28 @@
cellJustif = null;
}
- private int rowMarker = 0;
-
/**
* The default class style is <code>a</code> or <code>b</code> depending
the row id.
*
* [EMAIL PROTECTED]
* @see javax.swing.text.html.HTML.Tag#TR
*/
- //TODO: could probably make this more flexible but really i would just
like a standard xhtml structure.
public void tableRow()
{
- if ( rowMarker == 0 )
+ MutableAttributeSet att = new SimpleAttributeSet();
+
+ if ( evenTableRow )
{
- MutableAttributeSet att = new SimpleAttributeSet();
att.addAttribute( Attribute.CLASS, "a" );
-
- writeStartTag( Tag.TR, att );
-
- rowMarker = 1;
}
else
{
- MutableAttributeSet att = new SimpleAttributeSet();
att.addAttribute( Attribute.CLASS, "b" );
+ }
- writeStartTag( Tag.TR, att );
+ writeStartTag( Tag.TR, att );
- rowMarker = 0;
- }
+ evenTableRow = !evenTableRow;
cellCount = 0;
}
@@ -806,36 +831,7 @@
*/
public void tableCell( boolean headerRow )
{
- String justif = null;
-
- if ( cellJustif != null )
- {
- switch ( cellJustif[cellCount] )
- {
- case Parser.JUSTIFY_LEFT:
- justif = "left";
- break;
- case Parser.JUSTIFY_RIGHT:
- justif = "right";
- break;
- case Parser.JUSTIFY_CENTER:
- default:
- justif = "center";
- break;
- }
- }
-
- Tag t = ( headerRow ? Tag.TH : Tag.TD );
-
- MutableAttributeSet att = null;
-
- if ( justif != null )
- {
- att = new SimpleAttributeSet();
- att.addAttribute( Attribute.ALIGN, justif );
- }
-
- writeStartTag( t, att );
+ tableCell( headerRow, null );
}
/** [EMAIL PROTECTED] */
@@ -871,6 +867,7 @@
justif = "right";
break;
case Parser.JUSTIFY_CENTER:
+ default:
justif = "center";
break;
}
@@ -1212,39 +1209,27 @@
writer.close();
}
- /** [EMAIL PROTECTED] */
- protected void write( String text )
- {
- // TODO: this doesn't belong here
- if ( renderingContext != null )
- {
- String relativePathToBasedir = renderingContext.getRelativePath();
-
- if ( relativePathToBasedir == null )
- {
- text = StringUtils.replace( text, "$relativePath", "." );
- }
- else
- {
- text = StringUtils.replace( text, "$relativePath",
relativePathToBasedir );
- }
- }
-
- writer.write( text );
- }
-
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
+ /**
+ * Write HTML escaped text to output.
+ *
+ * @param text The text to write.
+ */
protected void content( String text )
{
write( escapeHTML( text ) );
}
+ /**
+ * Write HTML escaped text to output.
+ *
+ * @param text The text to write.
+ */
protected void verbatimContent( String text )
-
{
write( escapeHTML( text ) );
}
@@ -1281,6 +1266,27 @@
public static String encodeURL( String text )
{
return HtmlTools.encodeURL( text );
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected void write( String text )
+ {
+ // TODO: this doesn't belong here
+ if ( renderingContext != null )
+ {
+ String relativePathToBasedir = renderingContext.getRelativePath();
+
+ if ( relativePathToBasedir == null )
+ {
+ text = StringUtils.replace( text, "$relativePath", "." );
+ }
+ else
+ {
+ text = StringUtils.replace( text, "$relativePath",
relativePathToBasedir );
+ }
+ }
+
+ writer.write( text );
}
/**