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 2009/08/25 15:43:52 UTC
svn commit: r807625 - in
/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/index:
IndexEntry.java IndexingSink.java
Author: vsiveton
Date: Tue Aug 25 13:43:52 2009
New Revision: 807625
URL: http://svn.apache.org/viewvc?rev=807625&view=rev
Log:
DOXIA-366: Wrong TOC when styles
o take care of style in section title
o Lukas will add tests :)
Modified:
maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexEntry.java
maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexingSink.java
Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexEntry.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexEntry.java?rev=807625&r1=807624&r2=807625&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexEntry.java (original)
+++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexEntry.java Tue Aug 25 13:43:52 2009
@@ -38,7 +38,7 @@
private final IndexEntry parent;
/** The id of the entry. */
- private final String id;
+ private String id;
/** The entry title. */
private String title;
@@ -97,6 +97,16 @@
}
/**
+ * Set the id.
+ *
+ * @since 1.1.2
+ */
+ protected void setId( String id )
+ {
+ this.id = id;
+ }
+
+ /**
* Returns the title.
*
* @return the title.
Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexingSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexingSink.java?rev=807625&r1=807624&r2=807625&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexingSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexingSink.java Tue Aug 25 13:43:52 2009
@@ -70,6 +70,9 @@
/** The stack. */
private final Stack stack;
+ /** The current type. */
+ private IndexEntry currentEntry;
+
/**
* Default constructor.
*
@@ -108,9 +111,15 @@
/** {@inheritDoc} */
public void sectionTitle1()
{
+ this.currentEntry = null;
type = TYPE_SECTION_1;
}
+ public void sectionTitle1_()
+ {
+ type = 0;
+ }
+
/** {@inheritDoc} */
public void section1_()
{
@@ -120,9 +129,15 @@
/** {@inheritDoc} */
public void sectionTitle2()
{
+ this.currentEntry = null;
type = TYPE_SECTION_2;
}
+ public void sectionTitle2_()
+ {
+ type = 0;
+ }
+
/** {@inheritDoc} */
public void section2_()
{
@@ -132,9 +147,15 @@
/** {@inheritDoc} */
public void sectionTitle3()
{
+ this.currentEntry = null;
type = TYPE_SECTION_3;
}
+ public void sectionTitle3_()
+ {
+ type = 0;
+ }
+
/** {@inheritDoc} */
public void section3_()
{
@@ -144,9 +165,15 @@
/** {@inheritDoc} */
public void sectionTitle4()
{
+ this.currentEntry = null;
type = TYPE_SECTION_4;
}
+ public void sectionTitle4_()
+ {
+ type = 0;
+ }
+
/** {@inheritDoc} */
public void section4_()
{
@@ -156,35 +183,39 @@
/** {@inheritDoc} */
public void sectionTitle5()
{
+ this.currentEntry = null;
type = TYPE_SECTION_5;
}
+ public void sectionTitle5_()
+ {
+ type = 0;
+ }
+
/** {@inheritDoc} */
public void section5_()
{
pop();
}
- // public void definedTerm()
- // {
- // type = TYPE_DEFINED_TERM;
- // }
+ // public void definedTerm()
+ // {
+ // type = TYPE_DEFINED_TERM;
+ // }
//
- // public void figureCaption()
- // {
- // type = TYPE_FIGURE;
- // }
+ // public void figureCaption()
+ // {
+ // type = TYPE_FIGURE;
+ // }
//
- // public void tableCaption()
- // {
- // type = TYPE_TABLE;
- // }
+ // public void tableCaption()
+ // {
+ // type = TYPE_TABLE;
+ // }
/** {@inheritDoc} */
public void text( String text )
{
- IndexEntry entry;
-
switch ( type )
{
case TITLE:
@@ -199,13 +230,26 @@
// Sanitize the id. The most important step is to remove any blanks
// -----------------------------------------------------------------------
- String id = HtmlTools.encodeId( text );
+ if ( currentEntry == null )
+ {
+ currentEntry = new IndexEntry( peek(), HtmlTools.encodeId( text ) );
+
+ currentEntry.setTitle( text );
+
+ push( currentEntry );
+ }
+ else
+ {
+ IndexEntry entry = (IndexEntry) stack.lastElement();
- entry = new IndexEntry( peek(), id );
+ String title = currentEntry.getTitle() + text;
+ title = title.replaceAll( "[\\r\\n]+", "" );
- entry.setTitle( text );
+ entry.setId( HtmlTools.encodeId( title ) );
+
+ entry.setTitle( title );
+ }
- push( entry );
break;
// Dunno how to handle these yet
case TYPE_DEFINED_TERM:
@@ -214,8 +258,6 @@
default:
break;
}
-
- type = 0;
}
/**