You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Robert Scholte <rf...@apache.org> on 2015/12/11 20:18:48 UTC

Re: svn commit: r1719483 - in /maven/doxia/doxia/trunk: doxia-core/src/main/java/org/apache/maven/doxia/markup/ doxia-core/src/main/java/org/apache/maven/doxia/parser/ doxia-core/src/main/java/org/apache/maven/doxia/sink/ doxia-core/src/test/java/org/apach...

Hi Christian,

first of all: welcome!

about this commit: It took a while before I understood the term 'ssi'.
ssi is an abbreviation, not that clear and IMHO it suggest that this page  
includes dynamic content fro a server, making this content dynamic as  
well. That's not what's happening here, right?

How about renaming it to remoteInclude?

thanks,
Robert

Op Fri, 11 Dec 2015 19:01:20 +0100 schreef <sc...@apache.org>:

> Author: schulte
> Date: Fri Dec 11 18:01:19 2015
> New Revision: 1719483
>
> URL: http://svn.apache.org/viewvc?rev=1719483&view=rev
> Log:
> [DOXIA-532] Support for server side includes.
>
> o Updated to handle comments starting with a '#' character to represent  
> SSI expressions.
>
>
> Modified:
>     maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/markup/Markup.java
>     maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
>     maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/RandomAccessSink.java
>     maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/SinkAdapter.java
>     maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java
>     maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/XhtmlBaseParserTest.java
>     maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkEventTestingSink.java
>     maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/TextSink.java
>     maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/WellformednessCheckingSink.java
>     maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java
>     maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSink.java
>     maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java
>     maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/resources/test/comments.apt
>     maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookSink.java
>     maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
>     maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java
>     maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java
>
> Modified:  
> maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/markup/Markup.java
> URL:  
> http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/markup/Markup.java?rev=1719483&r1=1719482&r2=1719483&view=diff
> ==============================================================================
> ---  
> maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/markup/Markup.java  
> (original)
> +++  
> maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/markup/Markup.java  
> Fri Dec 11 18:01:19 2015
> @@ -80,4 +80,8 @@ public interface Markup
>     /** semicolon character: ';' */
>      char SEMICOLON = ';';
> +
> +    /** hash character: '#' */
> +    char HASH = '#';
> +
>  }
>
> Modified:  
> maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
> URL:  
> http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java?rev=1719483&r1=1719482&r2=1719483&view=diff
> ==============================================================================
> ---  
> maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java  
> (original)
> +++  
> maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java  
> Fri Dec 11 18:01:19 2015
> @@ -260,7 +260,7 @@ public abstract class AbstractXmlParser
>              }
>              else if ( eventType == XmlPullParser.COMMENT )
>              {
> -                handleComment( parser, sink );
> +                handleCommentOrSsi( parser, sink );
>              }
>              else if ( eventType == XmlPullParser.ENTITY_REF )
>              {
> @@ -359,6 +359,31 @@ public abstract class AbstractXmlParser
>      }
>     /**
> +     * Decides whether a comment is a SSI directive and delegates to the
> +     * corresponding method.
> +     *
> +     * @param parser A parser, not null.
> +     * @param sink the sink to receive the events. Not null.
> +     *
> +     * @throws org.codehaus.plexus.util.xml.pull.XmlPullParserException  
> if there's a problem parsing the model
> +     * @since 1.7
> +     */
> +    private void handleCommentOrSsi( XmlPullParser parser, Sink sink )
> +        throws XmlPullParserException
> +    {
> +        final String text = getText( parser ).trim();
> +
> +        if ( text.indexOf( HASH ) == 0 )
> +        {
> +            handleSsi( parser, sink );
> +        }
> +        else
> +        {
> +            handleComment( parser, sink );
> +        }
> +    }
> +
> +    /**
>       * Handles comments.
>       *
>       * <p>This is a default implementation, all data are emitted as  
> comment
> @@ -375,6 +400,23 @@ public abstract class AbstractXmlParser
>      }
>     /**
> +     * Handles SSI directives.
> +     *
> +     * <p>This is a default implementation, all data are emitted as SSI
> +     * events into the specified sink.</p>
> +     *
> +     * @param parser A parser, not null.
> +     * @param sink the sink to receive the events. Not null.
> +     * @throws org.codehaus.plexus.util.xml.pull.XmlPullParserException  
> if there's a problem parsing the model
> +     * @since 1.7
> +     */
> +    protected void handleSsi( XmlPullParser parser, Sink sink )
> +        throws XmlPullParserException
> +    {
> +        sink.ssi( getText( parser ).trim().substring( 1 ) );
> +    }
> +
> +    /**
>       * Handles entities.
>       *
>       * <p>This is a default implementation, all entities are resolved  
> and emitted as text
>
> Modified:  
> maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/RandomAccessSink.java
> URL:  
> http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/RandomAccessSink.java?rev=1719483&r1=1719482&r2=1719483&view=diff
> ==============================================================================
> ---  
> maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/RandomAccessSink.java  
> (original)
> +++  
> maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/RandomAccessSink.java  
> Fri Dec 11 18:01:19 2015
> @@ -726,6 +726,15 @@ public class RandomAccessSink
>          currentSink.section_( level );
>      }
> +    /**
> +     * {@inheritDoc}
> +     * @since 1.7
> +     */
> +    public void ssi( final String directive )
> +    {
> +        currentSink.ssi( directive );
> +    }
> +
>      /** {@inheritDoc} */
>      public void table()
>      {
>
> Modified:  
> maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/SinkAdapter.java
> URL:  
> http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/SinkAdapter.java?rev=1719483&r1=1719482&r2=1719483&view=diff
> ==============================================================================
> ---  
> maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/SinkAdapter.java  
> (original)
> +++  
> maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/SinkAdapter.java  
> Fri Dec 11 18:01:19 2015
> @@ -212,6 +212,15 @@ public class SinkAdapter
>          // nop
>      }
> +    /**
> +     * {@inheritDoc}
> +     * @since 1.7
> +     */
> +    public void ssi( final String directive )
> +    {
> +        // nop
> +    }
> +
>      /** {@inheritDoc} */
>      public void table()
>      {
>
> Modified:  
> maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java
> URL:  
> http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java?rev=1719483&r1=1719482&r2=1719483&view=diff
> ==============================================================================
> ---  
> maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java  
> (original)
> +++  
> maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java  
> Fri Dec 11 18:01:19 2015
> @@ -1904,6 +1904,22 @@ public class XhtmlBaseSink
>      }
>     /**
> +     * {@inheritDoc}
> +     * @sine 1.7
> +     */
> +    @Override
> +    public void ssi( final String directive )
> +    {
> +        final StringBuilder buf = new StringBuilder( directive.length()  
> + 9 );
> +
> +        buf.append( LESS_THAN ).append( BANG ).append( MINUS ).append(  
> MINUS ).append( HASH );
> +        buf.append( directive );
> +        buf.append( SPACE ).append( MINUS ).append( MINUS ).append(  
> GREATER_THAN );
> +
> +        write( buf.toString() );
> +    }
> +
> +    /**
>       * Add an unknown event.
>       * This can be used to generate html tags for which no  
> corresponding sink event exists.
>       *
>
> Modified:  
> maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/XhtmlBaseParserTest.java
> URL:  
> http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/XhtmlBaseParserTest.java?rev=1719483&r1=1719482&r2=1719483&view=diff
> ==============================================================================
> ---  
> maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/XhtmlBaseParserTest.java  
> (original)
> +++  
> maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/XhtmlBaseParserTest.java  
> Fri Dec 11 18:01:19 2015
> @@ -597,13 +597,14 @@ public class XhtmlBaseParserTest
>      public void testSpecial()
>          throws Exception
>      {
> -        String text = "<p><!-- a pagebreak: --><!-- PB  
> -->&nbsp;&#160;<unknown /></p>";
> +        String text = "<p><!-- a pagebreak: --><!-- PB --><!--#echo  
> var=\"code\" -->&nbsp;&#160;<unknown /></p>";
>          parser.parse( text, sink );
>          Iterator<SinkEventElement> it = sink.getEventList().iterator();
>         assertEquals( "paragraph", it.next().getName() );
>          assertEquals( "comment", it.next().getName() );
>          assertEquals( "pageBreak", it.next().getName() );
> +        assertEquals( "ssi", it.next().getName() );
>          assertEquals( "nonBreakingSpace", it.next().getName() );
>          assertEquals( "nonBreakingSpace", it.next().getName() );
>          // unknown events are not reported by the base parser
>
> Modified:  
> maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkEventTestingSink.java
> URL:  
> http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkEventTestingSink.java?rev=1719483&r1=1719482&r2=1719483&view=diff
> ==============================================================================
> ---  
> maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkEventTestingSink.java  
> (original)
> +++  
> maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkEventTestingSink.java  
> Fri Dec 11 18:01:19 2015
> @@ -236,6 +236,15 @@ public class SinkEventTestingSink
>          addEvent( "figure_" );
>      }
> +    /**
> +     * {@inheritDoc}
> +     * @since 1.7
> +     */
> +    public void ssi( final String directive )
> +    {
> +        addEvent( "ssi" );
> +    }
> +
>      /** {@inheritDoc} */
>      public void table()
>      {
>
> Modified:  
> maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/TextSink.java
> URL:  
> http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/TextSink.java?rev=1719483&r1=1719482&r2=1719483&view=diff
> ==============================================================================
> ---  
> maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/TextSink.java  
> (original)
> +++  
> maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/TextSink.java  
> Fri Dec 11 18:01:19 2015
> @@ -222,6 +222,15 @@ public class TextSink
>          writeln( "end:figure" );
>      }
> +    /**
> +     * {@inheritDoc}
> +     * @since 1.7
> +     */
> +    public void ssi( final String directive )
> +    {
> +        writeln( "ssi:" + directive );
> +    }
> +
>      /** {@inheritDoc} */
>      public void table()
>      {
>
> Modified:  
> maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/WellformednessCheckingSink.java
> URL:  
> http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/WellformednessCheckingSink.java?rev=1719483&r1=1719482&r2=1719483&view=diff
> ==============================================================================
> ---  
> maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/WellformednessCheckingSink.java  
> (original)
> +++  
> maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/WellformednessCheckingSink.java  
> Fri Dec 11 18:01:19 2015
> @@ -218,6 +218,15 @@ public class WellformednessCheckingSink
>          checkWellformedness( "figure" );
>      }
> +    /**
> +     * {@inheritDoc}
> +     * @since 1.7
> +     */
> +    public void ssi( final String directive )
> +    {
> +        // ignore
> +    }
> +
>      /** {@inheritDoc} */
>      public void table()
>      {
>
> Modified:  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java
> URL:  
> http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java?rev=1719483&r1=1719482&r2=1719483&view=diff
> ==============================================================================
> ---  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java  
> (original)
> +++  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java  
> Fri Dec 11 18:01:19 2015
> @@ -112,6 +112,9 @@ public class AptParser
>      /** Comment event id. */
>      private static final int COMMENT_BLOCK = 17;
> +    /** SSI event id. */
> +    private static final int SSI_BLOCK = 18;
> +
>      /** String representations of event ids */
>      private static final String TYPE_NAMES[] = {
>          "TITLE",
> @@ -131,7 +134,8 @@ public class AptParser
>          "PG_BREAK",
>          "LIST_BREAK",
>          "MACRO",
> -        "COMMENT_BLOCK" };
> +        "COMMENT_BLOCK",
> +        "SSI_BLOCK" };
>     /** An array of 85 spaces. */
>      protected static final char[] SPACES;
> @@ -218,8 +222,8 @@ public class AptParser
>              // Lookahead block.
>              nextBlock( /*first*/true );
> -            // traverse comments
> -            while ( ( block != null ) && ( block.getType() ==  
> COMMENT_BLOCK ) )
> +            // traverse comments and SSI directives
> +            while ( ( block != null ) && ( block.getType() ==  
> COMMENT_BLOCK || block.getType() == SSI_BLOCK ) )
>              {
>                  block.traverse();
>                  nextBlock( /*first*/true );
> @@ -1368,7 +1372,10 @@ public class AptParser
>              case COMMENT:
>                  if ( charAt( line, length, i + 1 ) == COMMENT )
>                  {
> -                    block = new Comment( line.substring( i + 2 ).trim()  
> );
> +                    block = charAt( line, length, i + 2 ) == HASH
> +                                ? new SSI( line.substring( i + 3  
> ).trim() )
> +                                : new Comment( line.substring( i + 2  
> ).trim() );
> +
>                  }
>                  break;
>              default:
> @@ -2235,6 +2242,30 @@ public class AptParser
>          }
>      }
> +    /** A SSI Block. */
> +    private class SSI
> +        extends Block
> +    {
> +        /**
> +         * Constructor.
> +         *
> +         * @param line the SSI directive.
> +         * @throws AptParseException AptParseException
> +         */
> +        public SSI( String line )
> +            throws AptParseException
> +        {
> +            super( SSI_BLOCK, 0, line );
> +        }
> +
> +        /** {@inheritDoc} */
> +        public void traverse()
> +            throws AptParseException
> +        {
> +            AptParser.this.sink.ssi( text );
> +        }
> +    }
> +
>      /** A Verbatim Block. */
>      private class Verbatim
>          extends Block
>
> Modified:  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSink.java
> URL:  
> http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSink.java?rev=1719483&r1=1719482&r2=1719483&view=diff
> ==============================================================================
> ---  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSink.java  
> (original)
> +++  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSink.java  
> Fri Dec 11 18:01:19 2015
> @@ -912,6 +912,15 @@ public class AptSink
>     /**
>       * {@inheritDoc}
> +     * @since 1.7
> +     */
> +    public void ssi( final String directive )
> +    {
> +        rawText( ( startFlag ? "" : EOL ) + COMMENT + COMMENT + HASH +  
> SPACE + directive );
> +    }
> +
> +    /**
> +     * {@inheritDoc}
>       *
>       * Unkown events just log a warning message but are ignored  
> otherwise.
>       * @see  
> org.apache.maven.doxia.sink.Sink#unknown(String,Object[],SinkEventAttributes)
>
> Modified:  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java
> URL:  
> http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java?rev=1719483&r1=1719482&r2=1719483&view=diff
> ==============================================================================
> ---  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java  
> (original)
> +++  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java  
> Fri Dec 11 18:01:19 2015
> @@ -101,14 +101,20 @@ public class AptParserTest
>          assertTrue( macro.indexOf(  
> "<modelVersion\\>4.0.0\\</modelVersion\\>" ) != -1 );
>      }
> -    /** @throws Exception  */
> +    /** @throws Exception */
>      public void testCommentsBeforeTitle()
>          throws Exception
>      {
>          String comments = parseFileToAptSink( "test/comments" );
> -        assertEquals( 0, comments.indexOf( "~~ comments before title" +  
> EOL + "~~ like a license header, for example"
> -            + EOL + " -----" + EOL + " Test DOXIA-379" ) );
> +        assertEquals( 0, comments.indexOf( "~~ " + EOL
> +                                               + "~~ comments before  
> title" + EOL
> +                                               + "~~ like a license  
> header, for example" + EOL
> +                                               + "~~# " + EOL
> +                                               + "~~# echo  
> var=\"code\"" + EOL
> +                                               + " -----" + EOL
> +                                               + " Test DOXIA-379" ) );
> +
>      }
>     /** @throws Exception  */
>
> Modified:  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/resources/test/comments.apt
> URL:  
> http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/resources/test/comments.apt?rev=1719483&r1=1719482&r2=1719483&view=diff
> ==============================================================================
> ---  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/resources/test/comments.apt  
> (original)
> +++  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/resources/test/comments.apt  
> Fri Dec 11 18:01:19 2015
> @@ -1,5 +1,8 @@
> +~~
>  ~~ comments before title
>  ~~ like a license header, for example
> +~~#
> +~~# echo var="code"
>   -----
>   Test DOXIA-379
>   -----
>
> Modified:  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookSink.java
> URL:  
> http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookSink.java?rev=1719483&r1=1719482&r2=1719483&view=diff
> ==============================================================================
> ---  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookSink.java  
> (original)
> +++  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookSink.java  
> Fri Dec 11 18:01:19 2015
> @@ -1589,6 +1589,21 @@ public class DocBookSink
>     /**
>       * {@inheritDoc}
> +     * @since 1.7
> +     */
> +    public void ssi( final String directive )
> +    {
> +        final StringBuilder buf = new StringBuilder( directive.length()  
> + 10 );
> +
> +        buf.append( LESS_THAN ).append( BANG ).append( MINUS ).append(  
> MINUS ).append( HASH ).append( SPACE );
> +        buf.append( directive );
> +        buf.append( SPACE ).append( MINUS ).append( MINUS ).append(  
> GREATER_THAN );
> +
> +        write( buf.toString() );
> +    }
> +
> +    /**
> +     * {@inheritDoc}
>       *
>       * Unknown events just log a warning message but are ignored  
> otherwise.
>       * @see  
> org.apache.maven.doxia.sink.Sink#unknown(String,Object[],SinkEventAttributes)
>
> Modified:  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
> URL:  
> http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java?rev=1719483&r1=1719482&r2=1719483&view=diff
> ==============================================================================
> ---  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java  
> (original)
> +++  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java  
> Fri Dec 11 18:01:19 2015
> @@ -408,6 +408,26 @@ public class FmlParser
>          }
>      }
> +    /**
> +     * {@inheritDoc}
> +     * @sine 1.7
> +     */
> +    protected void handleSsi( XmlPullParser parser, Sink sink )
> +        throws XmlPullParserException
> +    {
> +        final String directive = parser.getText().trim().substring( 1 );
> +
> +        if ( buffer != null )
> +        {
> +            buffer.append( LESS_THAN ).append( BANG ).append( MINUS  
> ).append( MINUS ).append( HASH ).append( SPACE )
> +                .append( directive ).append( SPACE ).append( MINUS  
> ).append( MINUS ).append( GREATER_THAN );
> +        }
> +        else
> +        {
> +            sink.ssi( directive );
> +        }
> +    }
> +
>      /** {@inheritDoc} */
>      protected void handleEntity( XmlPullParser parser, Sink sink )
>          throws XmlPullParserException
>
> Modified:  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java
> URL:  
> http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java?rev=1719483&r1=1719482&r2=1719483&view=diff
> ==============================================================================
> ---  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java  
> (original)
> +++  
> maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java  
> Fri Dec 11 18:01:19 2015
> @@ -1393,6 +1393,21 @@ public class FoSink
>      }
>     /**
> +     * {@inheritDoc}
> +     * @since 1.7
> +     */
> +    public void ssi( final String directive )
> +    {
> +        final StringBuilder buf = new StringBuilder( directive.length()  
> + 10 );
> +
> +        buf.append( LESS_THAN ).append( BANG ).append( MINUS ).append(  
> MINUS ).append( HASH ).append( SPACE );
> +        buf.append( directive );
> +        buf.append( SPACE ).append( MINUS ).append( MINUS ).append(  
> GREATER_THAN );
> +
> +        write( buf.toString() );
> +    }
> +
> +    /**
>       * Writes the beginning of a FO document.
>       */
>      public void beginDocument()
>
> Modified:  
> maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java
> URL:  
> http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java?rev=1719483&r1=1719482&r2=1719483&view=diff
> ==============================================================================
> ---  
> maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java  
> (original)
> +++  
> maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java  
> Fri Dec 11 18:01:19 2015
> @@ -1345,6 +1345,14 @@ public interface Sink
>      void comment( String comment );
>     /**
> +     * Add a SSI directive.
> +     *
> +     * @param directive The directive to write.
> +     * @since 1.7
> +     */
> +    void ssi( String directive );
> +
> +    /**
>       * Add an unknown event. This may be used by parsers to notify a  
> general Sink about
>       * an event that doesn't fit into any event defined by the Sink API.
>       * Depending on the parameters, a Sink may decide whether or not to  
> process the event,
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: svn commit: r1719483 - in /maven/doxia/doxia/trunk: doxia-core/src/main/java/org/apache/maven/doxia/markup/ doxia-core/src/main/java/org/apache/maven/doxia/parser/ doxia-core/src/main/java/org/apache/maven/doxia/sink/ doxia-core/src/test/java/org/apach...

Posted by Robert Scholte <rf...@apache.org>.
Op Fri, 11 Dec 2015 22:01:11 +0100 schreef Christian Schulte  
<cs...@schulte.it>:

> Am 12/11/15 um 20:18 schrieb Robert Scholte:
>> Hi Christian,
>>
>> first of all: welcome!
>>
>> about this commit: It took a while before I understood the term 'ssi'.
>> ssi is an abbreviation, not that clear and IMHO it suggest that this  
>> page
>> includes dynamic content fro a server, making this content dynamic as
>> well. That's not what's happening here, right?
>>
>> How about renaming it to remoteInclude?
>
> I wasn't sure how to name it since it's just a special handling of  
> comments starting with a '#' character. That need not be server side  
> include directives. Maybe the method should just be named
>
> 'directive( String directive )'
>
> with the logic of any comment starting with a '#' character being  
> interpreted as some directive and the directive being the trimmed  
> comment with the '#' character removed. WDYT?

Already better. And don't mind adding javadoc/comments to better explain  
its purpose ;)
In general it is good habit to add @since on new (public) methods.

thanks,
Robert

>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: svn commit: r1719483 - in /maven/doxia/doxia/trunk: doxia-core/src/main/java/org/apache/maven/doxia/markup/ doxia-core/src/main/java/org/apache/maven/doxia/parser/ doxia-core/src/main/java/org/apache/maven/doxia/sink/ doxia-core/src/test/java/org/apach...

Posted by Michael Osipov <mi...@apache.org>.
Am 2015-12-11 um 22:01 schrieb Christian Schulte:
> Am 12/11/15 um 20:18 schrieb Robert Scholte:
>> Hi Christian,
>>
>> first of all: welcome!
>>
>> about this commit: It took a while before I understood the term 'ssi'.
>> ssi is an abbreviation, not that clear and IMHO it suggest that this page
>> includes dynamic content fro a server, making this content dynamic as
>> well. That's not what's happening here, right?
>>
>> How about renaming it to remoteInclude?
>
> I wasn't sure how to name it since it's just a special handling of
> comments starting with a '#' character. That need not be server side
> include directives. Maybe the method should just be named
>
> 'directive( String directive )'
>
> with the logic of any comment starting with a '#' character being
> interpreted as some directive and the directive being the trimmed
> comment with the '#' character removed. WDYT?

I have anticipated such a discussion. That is why I recommended to 
improve the comment parsing rather than adding custom support for SSIs.

Michael


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: svn commit: r1719483 - in /maven/doxia/doxia/trunk: doxia-core/src/main/java/org/apache/maven/doxia/markup/ doxia-core/src/main/java/org/apache/maven/doxia/parser/ doxia-core/src/main/java/org/apache/maven/doxia/sink/ doxia-core/src/test/java/org/apach...

Posted by Hervé BOUTEMY <he...@free.fr>.
yes, it seems perfectly adapted: yes, what was thought as beautification seems 
to cause trouble
And beautification of comments is not really a string feature :)

thank you for your efforts and accepting discussions on first commits: once 
again, welcome :)

Regards,

Hervé

Le samedi 12 décembre 2015 12:12:11 Christian Schulte a écrit :
> Am 12/12/15 um 11:52 schrieb Hervé BOUTEMY:
> > what means "a directive" in markdown? fml? confluence? LaTex? xdoc?
> > I know "directive" word is more generic than "ssi", but the only useful
> > case I know is when generated html is put on a web server that supports
> > such directives
> > then just handling this special comment on xhtml Sink implementation looks
> > an adapted hack IMHO
> > 
> > Enhancing Sink API is not forbidden: it just requires to have a good
> > meaning in most supported formats [1], both when parsing and generating
> > markup
> The cause for having to do anything is the (wrong IMHO) handling of
> comments. If I can updated/fix that, nothing needs to be changed. That
> just means no more trimming when parsing comments and no more addition
> of whitespace when writing. So that "<!--# whatever -->" will be parsed
> to "# whatever " and written as "<!--# whatver -->" and "<!-- #
> whatever-->" will be parsed to " # whatever" and will be written as
> "<!-- # whatever-->". So after that change comments will be passed
> through unchanged. I would need to update some test cases testing the
> current handling for this. Would that be ok?
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: svn commit: r1719483 - in /maven/doxia/doxia/trunk: doxia-core/src/main/java/org/apache/maven/doxia/markup/ doxia-core/src/main/java/org/apache/maven/doxia/parser/ doxia-core/src/main/java/org/apache/maven/doxia/sink/ doxia-core/src/test/java/org/apach...

Posted by Christian Schulte <cs...@schulte.it>.
Am 12/12/15 um 11:52 schrieb Hervé BOUTEMY:
> what means "a directive" in markdown? fml? confluence? LaTex? xdoc?
> I know "directive" word is more generic than "ssi", but the only useful case I
> know is when generated html is put on a web server that supports such
> directives
> then just handling this special comment on xhtml Sink implementation looks an
> adapted hack IMHO
>
> Enhancing Sink API is not forbidden: it just requires to have a good meaning
> in most supported formats [1], both when parsing and generating markup

The cause for having to do anything is the (wrong IMHO) handling of 
comments. If I can updated/fix that, nothing needs to be changed. That 
just means no more trimming when parsing comments and no more addition 
of whitespace when writing. So that "<!--# whatever -->" will be parsed 
to "# whatever " and written as "<!--# whatver -->" and "<!-- # 
whatever-->" will be parsed to " # whatever" and will be written as 
"<!-- # whatever-->". So after that change comments will be passed 
through unchanged. I would need to update some test cases testing the 
current handling for this. Would that be ok?

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: svn commit: r1719483 - in /maven/doxia/doxia/trunk: doxia-core/src/main/java/org/apache/maven/doxia/markup/ doxia-core/src/main/java/org/apache/maven/doxia/parser/ doxia-core/src/main/java/org/apache/maven/doxia/sink/ doxia-core/src/test/java/org/apach...

Posted by Hervé BOUTEMY <he...@free.fr>.
what means "a directive" in markdown? fml? confluence? LaTex? xdoc?
I know "directive" word is more generic than "ssi", but the only useful case I 
know is when generated html is put on a web server that supports such 
directives
then just handling this special comment on xhtml Sink implementation looks an 
adapted hack IMHO

Enhancing Sink API is not forbidden: it just requires to have a good meaning 
in most supported formats [1], both when parsing and generating markup

Regards,

Hervé

[1] http://maven.apache.org/doxia/references/index.html

Le samedi 12 décembre 2015 11:42:22 Christian Schulte a écrit :
> Am 12/12/15 um 11:20 schrieb Hervé BOUTEMY:
> > is an API change in Doxia Sink API really necessary to add this
> > HTML-specific feature (in very specific context)?
> 
> Not really that HTML-specific any more. I just renamed the method from
> 'ssi' to 'directive' locally.
> 
> > Because whatever how the method is named, it won't have general meaning
> > for
> > most parsers and sink implementations
> 
> Depends on how it is used. It's just a comment starting with a '#'
> character which is handled differently than comments not starting with
> that character.
> 
> > notice that this API change was detected and the CI is now failing...
> 
> Noticed it. Nobody can ever enhance the Sink API?
> 
> > And instead of accepting this Sink API change, I would prefer to avoid it
> > for this feature
> 
> If a new method cannot be added to the Sink API, the only option would
> be to handle the directives in every implementation of the following method.
> 
>      /**
>       * Add a comment.
>       *
>       * @param comment The comment to write.
>       * @since 1.1
>       */
>      void comment( String comment );
> 
> So every Sink implementation would need to start parsing comments then.
> I'd like to avoid that.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: svn commit: r1719483 - in /maven/doxia/doxia/trunk: doxia-core/src/main/java/org/apache/maven/doxia/markup/ doxia-core/src/main/java/org/apache/maven/doxia/parser/ doxia-core/src/main/java/org/apache/maven/doxia/sink/ doxia-core/src/test/java/org/apach...

Posted by Christian Schulte <cs...@schulte.it>.
Am 12/12/15 um 11:20 schrieb Hervé BOUTEMY:
> is an API change in Doxia Sink API really necessary to add this HTML-specific
> feature (in very specific context)?

Not really that HTML-specific any more. I just renamed the method from 
'ssi' to 'directive' locally.

> Because whatever how the method is named, it won't have general meaning for
> most parsers and sink implementations

Depends on how it is used. It's just a comment starting with a '#' 
character which is handled differently than comments not starting with 
that character.

> notice that this API change was detected and the CI is now failing...

Noticed it. Nobody can ever enhance the Sink API?

> And instead of accepting this Sink API change, I would prefer to avoid it for
> this feature

If a new method cannot be added to the Sink API, the only option would 
be to handle the directives in every implementation of the following method.

     /**
      * Add a comment.
      *
      * @param comment The comment to write.
      * @since 1.1
      */
     void comment( String comment );

So every Sink implementation would need to start parsing comments then. 
I'd like to avoid that.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: svn commit: r1719483 - in /maven/doxia/doxia/trunk: doxia-core/src/main/java/org/apache/maven/doxia/markup/ doxia-core/src/main/java/org/apache/maven/doxia/parser/ doxia-core/src/main/java/org/apache/maven/doxia/sink/ doxia-core/src/test/java/org/apach...

Posted by Hervé BOUTEMY <he...@free.fr>.
is an API change in Doxia Sink API really necessary to add this HTML-specific 
feature (in very specific context)?
Because whatever how the method is named, it won't have general meaning for 
most parsers and sink implementations

notice that this API change was detected and the CI is now failing...
And instead of accepting this Sink API change, I would prefer to avoid it for 
this feature

Regards,

Hervé

Le vendredi 11 décembre 2015 22:01:11 Christian Schulte a écrit :
> Am 12/11/15 um 20:18 schrieb Robert Scholte:
> > Hi Christian,
> > 
> > first of all: welcome!
> > 
> > about this commit: It took a while before I understood the term 'ssi'.
> > ssi is an abbreviation, not that clear and IMHO it suggest that this page
> > includes dynamic content fro a server, making this content dynamic as
> > well. That's not what's happening here, right?
> > 
> > How about renaming it to remoteInclude?
> 
> I wasn't sure how to name it since it's just a special handling of
> comments starting with a '#' character. That need not be server side
> include directives. Maybe the method should just be named
> 
> 'directive( String directive )'
> 
> with the logic of any comment starting with a '#' character being
> interpreted as some directive and the directive being the trimmed
> comment with the '#' character removed. WDYT?
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: svn commit: r1719483 - in /maven/doxia/doxia/trunk: doxia-core/src/main/java/org/apache/maven/doxia/markup/ doxia-core/src/main/java/org/apache/maven/doxia/parser/ doxia-core/src/main/java/org/apache/maven/doxia/sink/ doxia-core/src/test/java/org/apach...

Posted by Christian Schulte <cs...@schulte.it>.
Am 12/11/15 um 20:18 schrieb Robert Scholte:
> Hi Christian,
>
> first of all: welcome!
>
> about this commit: It took a while before I understood the term 'ssi'.
> ssi is an abbreviation, not that clear and IMHO it suggest that this page
> includes dynamic content fro a server, making this content dynamic as
> well. That's not what's happening here, right?
>
> How about renaming it to remoteInclude?

I wasn't sure how to name it since it's just a special handling of 
comments starting with a '#' character. That need not be server side 
include directives. Maybe the method should just be named

'directive( String directive )'

with the logic of any comment starting with a '#' character being 
interpreted as some directive and the directive being the trimmed 
comment with the '#' character removed. WDYT?


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org