protected int parseToken()

in jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java [1733:1867]


    protected int parseToken( final int ch ) throws IOException {
        Element el = null;
        //  Now, check the incoming token.
        switch( ch ) {
          case '\r':
            // DOS linefeeds we forget
            return IGNORE;

          case '\n':
            //  Close things like headings, etc.
            // FIXME: This is not really very fast
            closeHeadings();

            popElement( "dl" ); // Close definition lists.
            if( m_istable ) {
                popElement("tr");
            }
            m_isdefinition = false;
            if( m_newLine ) {
                // Paragraph change.
                startBlockLevel();
                //  Figure out which elements cannot be enclosed inside a <p></p> pair according to XHTML rules.
                final String nextLine = peekAheadLine();
                if( nextLine.isEmpty() ||
                     ( !nextLine.isEmpty() &&
                       !nextLine.startsWith( "{{{" ) &&
                       !nextLine.startsWith( "----" ) &&
                       !nextLine.startsWith( "%%" ) &&
                       "*#!;".indexOf( nextLine.charAt( 0 ) ) == -1 ) ) {
                    pushElement( new Element( "p" ) );
                    m_isOpenParagraph = true;

                    if( m_restartitalic ) {
                        pushElement( new Element( "i" ) );
                        m_isitalic = true;
                        m_restartitalic = false;
                    }
                    if( m_restartbold ) {
                        pushElement( new Element( "b" ) );
                        m_isbold = true;
                        m_restartbold = false;
                    }
                }
            } else {
                m_plainTextBuf.append("\n");
                m_newLine = true;
            }
            return IGNORE;

          case '\\':
            el = handleBackslash();
            break;

          case '_':
            el = handleUnderscore();
            break;

          case '\'':
            el = handleApostrophe();
            break;

          case '{':
            el = handleOpenbrace( m_newLine );
            break;

          case '}':
            el = handleClosebrace();
            break;

          case '-':
            if( m_newLine ) {
                el = handleDash();
            }
            break;

          case '!':
            if( m_newLine ) {
                el = handleHeading();
            }
            break;

          case ';':
            if( m_newLine ) {
                el = handleDefinitionList();
            }
            break;

          case ':':
            if( m_isdefinition ) {
                popElement( "dt" );
                el = pushElement( new Element( "dd" ) );
                m_isdefinition = false;
            }
            break;

          case '[':
            el = handleOpenbracket();
            break;

          case '*':
            if( m_newLine ) {
                pushBack( '*' );
                el = handleGeneralList();
            }
            break;

          case '#':
            if( m_newLine ) {
                pushBack( '#' );
                el = handleGeneralList();
            }
            break;

          case '|':
            el = handleBar( m_newLine );
            break;

          case '~':
            el = handleTilde();
            break;

          case '%':
            el = handleDiv();
            break;

          case '/':
            el = handleSlash();
            break;

          default:
            break;
        }

        return el != null ? ELEMENT : CHARACTER;
    }