private void renderElement()

in jspwiki-main/src/main/java/org/apache/wiki/render/CreoleRenderer.java [94:155]


    private void renderElement( final Element ce, final StringBuilder sb ) {
        String endEl = EMPTY_STRING;
        for( int i = 0; i < ELEMENTS.length; i+=3 ) {
            if( ELEMENTS[i].equals(ce.getName()) ) {
                sb.append( ELEMENTS[i+1] );
                endEl = ELEMENTS[i+2];
            }
        }

        if( UL.equals(ce.getName()) ) {
            m_listCount++;
            m_listChar = '*';
        } else if( OL.equals(ce.getName()) ) {
            m_listCount++;
            m_listChar = '#';
        } else if( LI.equals(ce.getName()) ) {
            sb.append(IntStream.range(0, m_listCount).mapToObj(i -> String.valueOf(m_listChar)).collect(Collectors.joining("", "", ONE_SPACE)));
        } else if( A.equals( ce.getName() ) ) {
            final String href = ce.getAttributeValue( HREF_ATTRIBUTE );
            final String text = ce.getText();

            if( href.equals( text ) ) {
                sb.append( HREF_START ).append( href ).append( HREF_END );
            } else {
                sb.append( HREF_START ).append( href ).append( HREF_DELIMITER ).append( text ).append( HREF_END);
            }
            // Do not render anything else
            return;
        } else if( PRE.equals( ce.getName() ) ) {
            sb.append( PRE_START );
            sb.append( ce.getText() );
            sb.append( PRE_END );

            return;
        }

        //  Go through the children
        for( final Content c : ce.getContent() ) {
            if( c instanceof PluginContent ) {
                final PluginContent pc = ( PluginContent )c;

                if( pc.getPluginName().equals( PLUGIN_IMAGE ) ) {
                    sb.append( IMG_START ).append( pc.getParameter( PARAM_SRC ) ).append( IMG_END );
                } else {
                    m_plugins.add(pc);
                    sb.append( PLUGIN_START ).append( pc.getPluginName() ).append( ONE_SPACE ).append( m_plugins.size() ).append( PLUGIN_END );
                }
            } else if( c instanceof Text ) {
                sb.append( ( ( Text )c ).getText() );
            } else if( c instanceof Element ) {
                renderElement( ( Element )c, sb );
            }
        }

        if( UL.equals( ce.getName() ) || OL.equals( ce.getName() ) ) {
            m_listCount--;
        } else if( P.equals( ce.getName() ) ) {
            sb.append( LINEBREAK );
        }

        sb.append(endEl);
    }