⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jspwikimarkupparser.java

📁 jspwiki source code,jspwiki source code
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                    {                        makeLink( EDIT, linkref, linktext, null, link.getAttributes() );                    }                }                else                {                    // It's an internal Wiki link                    linkref = MarkupParser.cleanLink( linkref );                    callMutatorChain( m_localLinkMutatorChain, linkref );                    String matchedLink = linkExists( linkref );                    if( matchedLink != null )                    {                        makeLink( READ, matchedLink, linktext, null, link.getAttributes() );                    }                    else                    {                        makeLink( EDIT, linkref, linktext, null, link.getAttributes() );                    }                }            }        }        catch( ParseException e )        {            log.info("Parser failure: ",e);            Object[] args = { e.getMessage() };            addElement( makeError( MessageFormat.format( rb.getString( "markupparser.error.parserfailure" ), args ) ) );        }        return m_currentElement;    }    private String findAttachment( String linktext )    {        AttachmentManager mgr = m_engine.getAttachmentManager();        Attachment att = null;        try        {            att = mgr.getAttachmentInfo( m_context, linktext );        }        catch( ProviderException e )        {            log.warn("Finding attachments failed: ",e);            return null;        }        if( att != null )        {            return att.getName();        }        else if( linktext.indexOf('/') != -1 )        {            return linktext;        }        return null;    }    /**     *  Pushes back any string that has been read.  It will obviously     *  be pushed back in a reverse order.     *     *  @since 2.1.77     */    private void pushBack( String s )        throws IOException    {        for( int i = s.length()-1; i >= 0; i-- )        {            pushBack( s.charAt(i) );        }    }    private Element handleBackslash()        throws IOException    {        int ch = nextToken();        if( ch == '\\' )        {            int ch2 = nextToken();            if( ch2 == '\\' )            {                pushElement( new Element("br").setAttribute("clear","all"));                return popElement("br");            }            pushBack( ch2 );            pushElement( new Element("br") );            return popElement("br");        }        pushBack( ch );        return null;    }    private Element handleUnderscore()        throws IOException    {        int ch = nextToken();        Element el = null;        if( ch == '_' )        {            if( m_isbold )            {                el = popElement("b");            }            else            {                el = pushElement( new Element("b") );            }            m_isbold = !m_isbold;        }        else        {            pushBack( ch );        }        return el;    }    /**     *  For example: italics.     */    private Element handleApostrophe()        throws IOException    {        int ch = nextToken();        Element el = null;        if( ch == '\'' )        {            if( m_isitalic )            {                el = popElement("i");            }            else            {                el = pushElement( new Element("i") );            }            m_isitalic = !m_isitalic;        }        else        {            pushBack( ch );        }        return el;    }    private Element handleOpenbrace( boolean isBlock )        throws IOException    {        int ch = nextToken();        if( ch == '{' )        {            int ch2 = nextToken();            if( ch2 == '{' )            {                m_isPre = true;                m_isEscaping = true;                m_isPreBlock = isBlock;                if( isBlock )                {                    startBlockLevel();                    return pushElement( new Element("pre") );                }                return pushElement( new Element("span").setAttribute("style","font-family:monospace; white-space:pre;") );            }            pushBack( ch2 );            return pushElement( new Element("tt") );        }        pushBack( ch );        return null;    }    /**     *  Handles both }} and }}}     */    private Element handleClosebrace()        throws IOException    {        int ch2 = nextToken();        if( ch2 == '}' )        {            int ch3 = nextToken();            if( ch3 == '}' )            {                if( m_isPre )                {                    if( m_isPreBlock )                    {                        popElement( "pre" );                    }                    else                    {                        popElement( "span" );                    }                    m_isPre = false;                    m_isEscaping = false;                    return m_currentElement;                }                m_plainTextBuf.append("}}}");                return m_currentElement;            }            pushBack( ch3 );            if( !m_isEscaping )            {                return popElement("tt");            }        }        pushBack( ch2 );        return null;    }    private Element handleDash()        throws IOException    {        int ch = nextToken();        if( ch == '-' )        {            int ch2 = nextToken();            if( ch2 == '-' )            {                int ch3 = nextToken();                if( ch3 == '-' )                {                    // Empty away all the rest of the dashes.                    // Do not forget to return the first non-match back.                    while( (ch = nextToken()) == '-' );                    pushBack(ch);                    startBlockLevel();                    pushElement( new Element("hr") );                    return popElement( "hr" );                }                pushBack( ch3 );            }            pushBack( ch2 );        }        pushBack( ch );        return null;    }    private Element handleHeading()        throws IOException    {        Element el = null;        int ch  = nextToken();        Heading hd = new Heading();        if( ch == '!' )        {            int ch2 = nextToken();            if( ch2 == '!' )            {                String title = peekAheadLine();                el = makeHeading( Heading.HEADING_LARGE, title, hd);            }            else            {                pushBack( ch2 );                String title = peekAheadLine();                el = makeHeading( Heading.HEADING_MEDIUM, title, hd );            }        }        else        {            pushBack( ch );            String title = peekAheadLine();            el = makeHeading( Heading.HEADING_SMALL, title, hd );        }        callHeadingListenerChain( hd );        m_lastHeading = hd;                if( el != null ) pushElement(el);        return el;    }    /**     *  Reads the stream until the next EOL or EOF.  Note that it will also read the     *  EOL from the stream.     */    private StringBuilder readUntilEOL()        throws IOException    {        int ch;        StringBuilder buf = new StringBuilder( 256 );        while( true )        {            ch = nextToken();            if( ch == -1 )                break;            buf.append( (char) ch );            if( ch == '\n' )                break;        }        return buf;    }    /** Controls whether italic is restarted after a paragraph shift */    private boolean m_restartitalic = false;    private boolean m_restartbold   = false;    private boolean m_newLine;    /**     *  Starts a block level element, therefore closing     *  a potential open paragraph tag.     */    private void startBlockLevel()    {        // These may not continue over block level limits in XHTML        popElement("i");        popElement("b");        popElement("tt");        if( m_isOpenParagraph )        {            m_isOpenParagraph = false;            popElement("p");            m_plainTextBuf.append("\n"); // Just small beautification        }        m_restartitalic = m_isitalic;        m_restartbold   = m_isbold;        m_isitalic = false;        m_isbold   = false;    }    private static String getListType( char c )    {        if( c == '*' )        {            return "ul";        }        else if( c == '#' )        {            return "ol";        }        throw new InternalWikiException("Parser got faulty list type: "+c);    }    /**     *  Like original handleOrderedList() and handleUnorderedList()     *  however handles both ordered ('#') and unordered ('*') mixed together.     */    // FIXME: Refactor this; it's a bit messy.    private Element handleGeneralList()        throws IOException    {         startBlockLevel();         String strBullets = readWhile( "*#" );         // String strBulletsRaw = strBullets;      // to know what was original before phpwiki style substitution         int numBullets = strBullets.length();   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -