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 lt...@apache.org on 2007/10/29 13:04:57 UTC
svn commit: r589592 - in /maven/doxia/doxia/trunk/doxia-modules:
doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java
Author: ltheussl
Date: Mon Oct 29 05:04:56 2007
New Revision: 589592
URL: http://svn.apache.org/viewvc?rev=589592&view=rev
Log:
Add pre element to xdoc parser, unify with xhtml parser
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java
Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.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/XdocParser.java?rev=589592&r1=589591&r2=589592&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java Mon Oct 29 05:04:56 2007
@@ -191,6 +191,20 @@
{
sink.verbatim( true );
}
+ /*
+ * The PRE element tells visual user agents that the enclosed text is
+ * "preformatted". When handling preformatted text, visual user agents:
+ * - May leave white space intact.
+ * - May render text with a fixed-pitch font.
+ * - May disable automatic word wrap.
+ * - Must not disable bidirectional processing.
+ * Non-visual user agents are not required to respect extra white space
+ * in the content of a PRE element.
+ */
+ else if ( parser.getName().equals( Tag.PRE.toString() ) )
+ {
+ sink.verbatim( false );
+ }
else if ( parser.getName().equals( Tag.UL.toString() ) )
{
sink.list();
@@ -439,12 +453,23 @@
else if ( parser.getName().equals( Tag.IMG.toString() ) )
{
String src = parser.getAttributeValue( null, Attribute.SRC.toString() );
+ String title = parser.getAttributeValue( null, Attribute.TITLE.toString() );
String alt = parser.getAttributeValue( null, Attribute.ALT.toString() );
sink.figure();
- sink.figureGraphics( src );
- if ( alt != null )
+ if ( src != null )
+ {
+ sink.figureGraphics( src );
+ }
+
+ if ( title != null )
+ {
+ sink.figureCaption();
+ sink.text( title );
+ sink.figureCaption_();
+ }
+ else if ( alt != null )
{
sink.figureCaption();
sink.text( alt );
@@ -496,6 +521,10 @@
sink.paragraph_();
}
else if ( parser.getName().equals( SOURCE_TAG.toString() ) )
+ {
+ sink.verbatim_();
+ }
+ else if ( parser.getName().equals( Tag.PRE.toString() ) )
{
sink.verbatim_();
}
Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.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/XhtmlParser.java?rev=589592&r1=589591&r2=589592&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java Mon Oct 29 05:04:56 2007
@@ -56,6 +56,9 @@
/** Counts section level. */
private int sectionLevel;
+ /** For boxed verbatim. */
+ private boolean boxed;
+
/** {@inheritDoc} */
protected void handleStartTag( XmlPullParser parser, Sink sink )
throws XmlPullParserException, MacroExecutionException
@@ -149,6 +152,15 @@
{
sink.paragraph();
}
+ else if ( parser.getName().equals( Tag.DIV.toString() ) )
+ {
+ String divclass = parser.getAttributeValue( null, Attribute.CLASS.toString() );
+
+ if ( "source".equals( divclass ) )
+ {
+ this.boxed = true;
+ }
+ }
/*
* The PRE element tells visual user agents that the enclosed text is
* "preformatted". When handling preformatted text, visual user agents:
@@ -161,7 +173,14 @@
*/
else if ( parser.getName().equals( Tag.PRE.toString() ) )
{
- sink.verbatim( true );
+ if ( this.boxed )
+ {
+ sink.verbatim( true );
+ }
+ else
+ {
+ sink.verbatim( false );
+ }
}
else if ( parser.getName().equals( Tag.UL.toString() ) )
{
@@ -282,42 +301,7 @@
}
}
}
- else if ( parser.getName().equals( Tag.BR.toString() ) )
- {
- sink.lineBreak();
- }
- else if ( parser.getName().equals( Tag.HR.toString() ) )
- {
- sink.horizontalRule();
- }
- else if ( parser.getName().equals( Tag.IMG.toString() ) )
- {
- String src = parser.getAttributeValue( null, Attribute.SRC.toString() );
- String title = parser.getAttributeValue( null, Attribute.TITLE.toString() );
- String alt = parser.getAttributeValue( null, Attribute.ALT.toString() );
-
- sink.figure();
-
- if ( src != null )
- {
- sink.figureGraphics( src );
- }
-
- if ( title != null )
- {
- sink.figureCaption();
- sink.text( title );
- sink.figureCaption_();
- }
- else if ( alt != null )
- {
- sink.figureCaption();
- sink.text( alt );
- sink.figureCaption_();
- }
- sink.figure_();
- }
// ----------------------------------------------------------------------
// Tables
// ----------------------------------------------------------------------
@@ -386,6 +370,47 @@
this.hasCaption = true;
sink.tableCaption();
}
+
+ // ----------------------------------------------------------------------
+ // Empty elements: <br/>, <hr/> and <img />
+ // ----------------------------------------------------------------------
+
+ else if ( parser.getName().equals( Tag.BR.toString() ) )
+ {
+ sink.lineBreak();
+ }
+ else if ( parser.getName().equals( Tag.HR.toString() ) )
+ {
+ sink.horizontalRule();
+ }
+ else if ( parser.getName().equals( Tag.IMG.toString() ) )
+ {
+ String src = parser.getAttributeValue( null, Attribute.SRC.toString() );
+ String title = parser.getAttributeValue( null, Attribute.TITLE.toString() );
+ String alt = parser.getAttributeValue( null, Attribute.ALT.toString() );
+
+ sink.figure();
+
+ if ( src != null )
+ {
+ sink.figureGraphics( src );
+ }
+
+ if ( title != null )
+ {
+ sink.figureCaption();
+ sink.text( title );
+ sink.figureCaption_();
+ }
+ else if ( alt != null )
+ {
+ sink.figureCaption();
+ sink.text( alt );
+ sink.figureCaption_();
+ }
+
+ sink.figure_();
+ }
}
/** {@inheritDoc} */
@@ -414,6 +439,10 @@
else if ( parser.getName().equals( Tag.P.toString() ) )
{
sink.paragraph_();
+ }
+ else if ( parser.getName().equals( Tag.DIV.toString() ) )
+ {
+ this.boxed = false;
}
else if ( parser.getName().equals( Tag.PRE.toString() ) )
{