Examples of ByLineReaderSource


Examples of org.apache.maven.doxia.util.ByLineReaderSource

    public final void testNumeringDecimal()
        throws ParseException
    {
        final String text = "" + "   1. item1\n" + "   1. item2\n" + "   1. item3";

        final ByLineSource source = new ByLineReaderSource( new StringReader( text ) );
        Block blocks, expected;
        expected =
            new NumeratedListBlock( Sink.NUMBERING_DECIMAL, new ListItemBlock[] {
                new ListItemBlock( new Block[] { new TextBlock( "item1" ) } ),
                new ListItemBlock( new Block[] { new TextBlock( "item2" ) } ),
                new ListItemBlock( new Block[] { new TextBlock( "item3" ) } ) } );
        blocks = listParser.visit( source.getNextLine(), source );
        assertEquals( expected, blocks );
    }
View Full Code Here

Examples of org.apache.maven.doxia.util.ByLineReaderSource

    {
        final String text =
            "" + "   A. item1\n" + "      * item1.1\n" + "      * item1.2\n" + "   B. item2\n"
                + "      i. item2.1\n" + "      i. item2.2\n" + "   C. item3";

        final ByLineSource source = new ByLineReaderSource( new StringReader( text ) );
        Block blocks, expected;
        expected =
            new NumeratedListBlock( Sink.NUMBERING_UPPER_ALPHA, new ListItemBlock[] {
                new ListItemBlock( new Block[] { new TextBlock( "item1" ) },
                                   new UnorderedListBlock( new ListItemBlock[] {
                                       new ListItemBlock( new Block[] { new TextBlock( "item1.1" ) } ),
                                       new ListItemBlock( new Block[] { new TextBlock( "item1.2" ) } ) } ) ),
                new ListItemBlock( new Block[] { new TextBlock( "item2" ) },
                                   new NumeratedListBlock( Sink.NUMBERING_LOWER_ROMAN, new ListItemBlock[] {
                                       new ListItemBlock( new Block[] { new TextBlock( "item2.1" ) } ),
                                       new ListItemBlock( new Block[] { new TextBlock( "item2.2" ) } ) } ) ),
                new ListItemBlock( new Block[] { new TextBlock( "item3" ) } ) } );
        blocks = listParser.visit( source.getNextLine(), source );
        assertEquals( expected, blocks );
    }
View Full Code Here

Examples of org.apache.maven.doxia.util.ByLineReaderSource

    public final void testTable()
        throws ParseException
    {
        final StringReader sw = new StringReader( "" + "  |cell1|cell2|  \n" + "|cell3|cell4|\n" );

        final ByLineSource source = new ByLineReaderSource( sw );

        Block block, expected;
        expected =
            new TableBlock( new Block[] {
                new TableRowBlock( new Block[] { new TableCellBlock( new Block[] { new TextBlock( "cell1" ) } ),
                    new TableCellBlock( new Block[] { new TextBlock( "cell2" ) } ) } ),
                new TableRowBlock( new Block[] { new TableCellBlock( new Block[] { new TextBlock( "cell3" ) } ),
                    new TableCellBlock( new Block[] { new TextBlock( "cell4" ) } ) } ) } );

        block = tableParser.visit( source.getNextLine(), source );
        assertEquals( block, expected );
    }
View Full Code Here

Examples of org.apache.maven.doxia.util.ByLineReaderSource

    public final void testTableHeader()
        throws ParseException
    {
        final StringReader sw = new StringReader( "|*cell1*|*cell2*|\n" );

        final ByLineSource source = new ByLineReaderSource( sw );

        Block block, expected;
        expected =
            new TableBlock( new Block[] { new TableRowBlock( new Block[] {
                new TableCellHeaderBlock( new Block[] { new TextBlock( "cell1" ) } ),
                new TableCellHeaderBlock( new Block[] { new TextBlock( "cell2" ) } ) } ) } );

        block = tableParser.visit( source.getNextLine(), source );
        assertEquals( block, expected );
    }
View Full Code Here

Examples of org.apache.maven.doxia.util.ByLineReaderSource

    {
        final String text =
            "" + "\n\n\n" + "para1 -> text1\n" + "para1 -> text2\n" + "\n" + "para2 -> text1\n"
                + "para2 -> text2\n" + "   \n   \n  " + "para2 -> text1\n" + "para2 -> text2\n";

        final ByLineReaderSource source = new ByLineReaderSource( new StringReader( text ) );
        final ParagraphBlockParser parser = paraParser;

        ParagraphBlock block;

        block = (ParagraphBlock) parser.visit( source.getNextLine(), source );
        assertNotNull( block );
        assertEquals( 1, block.getBlocks().length );
        assertEquals( "para1 -> text1 para1 -> text2", ( (TextBlock) block.getBlocks()[0] ).getText() );

        block = (ParagraphBlock) parser.visit( source.getNextLine(), source );
        assertNotNull( block );
        assertEquals( 1, block.getBlocks().length );
        assertEquals( "para2 -> text1 para2 -> text2", ( (TextBlock) block.getBlocks()[0] ).getText() );
    }
View Full Code Here

Examples of org.apache.maven.doxia.util.ByLineReaderSource

    {
        final String text =
            "" + "Description text:\n" + "   * item1\n" + "   * item2\n"
                + "This is more text in the same paragraph\n" + "\n" + "Another paragraph";

        final ByLineReaderSource source = new ByLineReaderSource( new StringReader( text ) );
        final ParagraphBlockParser parser = paraParser;

        ParagraphBlock block;

        block = (ParagraphBlock) parser.visit( source.getNextLine(), source );
        assertNotNull( block );
        final Block[] firstLevelChilds = block.getBlocks();
        final int numberOfChilds = 3;
        assertEquals( numberOfChilds, firstLevelChilds.length );
        assertEquals( TextBlock.class, firstLevelChilds[0].getClass() );
View Full Code Here

Examples of org.apache.maven.doxia.util.ByLineReaderSource

    {
        final String text =
            "" + "   * item1\n" + "   * item2\n" + "This is more text in the same paragraph\n" + "\n"
                + "Another paragraph";

        final ByLineReaderSource source = new ByLineReaderSource( new StringReader( text ) );
        final ParagraphBlockParser parser = paraParser;

        ParagraphBlock block;

        block = (ParagraphBlock) parser.visit( source.getNextLine(), source );
        assertNotNull( block );
        final Block[] firstLevelChilds = block.getBlocks();
        assertEquals( 2, firstLevelChilds.length );
        assertEquals( UnorderedListBlock.class, firstLevelChilds[0].getClass() );
        assertEquals( TextBlock.class, firstLevelChilds[1].getClass() );
View Full Code Here

Examples of org.apache.maven.doxia.util.ByLineReaderSource

     */
    public final void testHorizontalRule()
        throws ParseException
    {
        Block block, expected;
        ByLineReaderSource source;

        assertTrue( hruleParser.accept( "---" ) );
        assertFalse( hruleParser.accept( "---+ asdas" ) );

        source = new ByLineReaderSource( new StringReader( "" ) );
        expected = new HorizontalRuleBlock();
        block = hruleParser.visit( "---", source );
        assertNull( source.getNextLine() );
        assertEquals( expected, block );

        source = new ByLineReaderSource( new StringReader( "" ) );
        expected = new HorizontalRuleBlock();
        block = hruleParser.visit( "--- Some text ---- And some more", source );
        assertEquals( expected, block );
        expected = new ParagraphBlock( new Block[] { new TextBlock( "Some text ---- And some more" ) } );
        block = paraParser.visit( source.getNextLine(), source );
        assertEquals( expected, block );
    }
View Full Code Here

Examples of org.apache.maven.doxia.util.ByLineReaderSource

                for ( int i = 0; i < text.length; i++ )
                {
                    List<Block> textBlocks = new ArrayList<Block>();

                    textBlocks.add( parseLine( text[i], new ByLineReaderSource( new StringReader( EMPTY_STRING ) ) ) );

                    List<Block> blocks = new ArrayList<Block>();

                    blocks.add( new BoldBlock( textBlocks ) );

                    cells.add( new TableCellHeaderBlock( blocks ) );
                }
            }
            else
            {
                int it = 0;
                String[] text = StringUtils.split( l, "|" );
                List<String> texts = new LinkedList<String>();

                while ( it < text.length )
                {
                    if ( text[it].matches( ANY_CHARACTER + ESCAPE_CHARACTER + ConfluenceMarkup.LINK_START_MARKUP
                        + ANY_CHARACTER )
                        && !text[it].matches( ANY_CHARACTER + ESCAPE_CHARACTER + ConfluenceMarkup.LINK_END_MARKUP
                            + ANY_CHARACTER ) )
                    {
                        texts.add( text[it] + ConfluenceMarkup.TABLE_CELL_MARKUP + text[it + 1] );
                        it += 2;
                        continue;
                    }
                    texts.add( text[it] );
                    it++;
                }

                String[] pText = texts.toArray( new String[0] );
                for ( int i = 0; i < pText.length; i++ )
                {
                    List<Block> blocks = new ArrayList<Block>();

                    blocks.add( parseLine( pText[i], new ByLineReaderSource( new StringReader( EMPTY_STRING ) ) ) );

                    cells.add( new TableCellBlock( blocks ) );
                }
            }
View Full Code Here

Examples of org.apache.maven.doxia.util.ByLineReaderSource

     */
    public final void testHorizontalRuleAndParagraph()
        throws ParseException
    {
        Block[] blocks, expected;
        ByLineReaderSource source;

        source = new ByLineReaderSource( new StringReader( "" + "Some text\n" + "-----------\n" + "More text" ) );
        expected =
            new Block[] { new ParagraphBlock( new Block[] { new TextBlock( "Some text" ) } ),
                new HorizontalRuleBlock(), new ParagraphBlock( new Block[] { new TextBlock( "More text" ) } ) };
        blocks = (Block[]) twikiParser.parse( source ).toArray( new Block[] {} );
        assertTrue( Arrays.equals( expected, blocks ) );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.