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

📄 translatorreader.java

📁 wiki建站资源 java编写的 很好用
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        String res = "{";        if( ch == '{' )        {            int ch2 = nextToken();            if( ch2 == '{' )            {                res = startBlockLevel()+m_renderer.openPreformatted( isBlock );                m_isPre = true;                m_isEscaping = true;            }            else            {                pushBack( ch2 );                                res = m_renderer.openTextEffect(TYPED);                m_isTypedText = true;           }        }        else        {            pushBack( ch );        }        return res;    }    /**     *  Handles both }} and }}}     */    private String handleClosebrace()        throws IOException    {        String res = "}";        int ch2 = nextToken();        if( ch2 == '}' )        {            int ch3 = nextToken();            if( ch3 == '}' )            {                if( m_isPre )                {                    m_isPre = false;		    m_isEscaping = false;                    res = m_renderer.closePreformatted();                }                else                {                    res = "}}}";                }            }            else            {                pushBack( ch3 );                if( !m_isEscaping )                {                    res = m_renderer.closeTextEffect(TYPED);                    m_isTypedText = false;                }                else                {                    pushBack( ch2 );                }            }        }        else        {            pushBack( ch2 );        }        return res;    }    private String 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);                    return startBlockLevel()+m_renderer.makeRuler();                }                        pushBack( ch3 );            }            pushBack( ch2 );        }        pushBack( ch );        return "-";    }    /**     *  This method peeks ahead in the stream until EOL and returns the result.     *  It will keep the buffers untouched.     *     *  @return The string from the current position to the end of line.     */    // FIXME: Always returns an empty line, even if the stream is full.    private String peekAheadLine()        throws IOException    {        String s = readUntilEOL().toString();        pushBack( s );        return s;    }    private String handleHeading()        throws IOException    {        StringBuffer buf = new StringBuffer();        int ch  = nextToken();        Heading hd = new Heading();        if( ch == '!' )        {            int ch2 = nextToken();            if( ch2 == '!' )            {                String title = peekAheadLine();                                buf.append( m_renderer.makeHeading( Heading.HEADING_LARGE, title, hd) );            }            else            {                pushBack( ch2 );                String title = peekAheadLine();                buf.append( m_renderer.makeHeading( Heading.HEADING_MEDIUM, title, hd ) );            }        }        else        {            pushBack( ch );            String title = peekAheadLine();            buf.append( m_renderer.makeHeading( Heading.HEADING_SMALL, title, hd ) );        }        callHeadingListenerChain( hd );        return buf.toString();    }    /**     *  Reads the stream until the next EOL or EOF.  Note that it will also read the     *  EOL from the stream.     */    private StringBuffer readUntilEOL()        throws IOException    {        int ch;        StringBuffer buf = new StringBuffer();        while( true )        {            ch = nextToken();            if( ch == -1 )                break;            buf.append( (char) ch );            if( ch == '\n' )                 break;        }        return buf;    }    /**     *  Starts a block level element, therefore closing the     *  a potential open paragraph tag.     */    private String startBlockLevel()    {        if( m_isOpenParagraph )        {            m_isOpenParagraph = false;            return m_renderer.closeParagraph();        }        return "";    }    /**     *  Like original handleOrderedList() and handleUnorderedList()     *  however handles both ordered ('#') and unordered ('*') mixed together.     */    // FIXME: Refactor this; it's a bit messy.    private String handleGeneralList()        throws IOException    {         String cStrShortName = "handleGeneralList()";   //put log messages in some context         StringBuffer buf = new StringBuffer();         buf.append( startBlockLevel() );         String strBullets = readWhile( "*#" );         String strBulletsRaw = strBullets;      // to know what was original before phpwiki style substitution         int numBullets = strBullets.length();         // override the beginning portion of bullet pattern to be like the previous         // to simulate PHPWiki style lists         if(m_allowPHPWikiStyleLists)         {             // only substitute if different             if(!( strBullets.substring(0,Math.min(numBullets,m_genlistlevel)).equals                   (m_genlistBulletBuffer.substring(0,Math.min(numBullets,m_genlistlevel)) ) ) )             {                 if(numBullets <= m_genlistlevel)                 {                     // Substitute all but the last character (keep the expressed bullet preference)                     strBullets  = (numBullets > 1 ? m_genlistBulletBuffer.substring(0, numBullets-1) : "")                                   + strBullets.substring(numBullets-1, numBullets);                 }                 else                 {                     strBullets = m_genlistBulletBuffer + strBullets.substring(m_genlistlevel, numBullets);                 }             }         }         //         //  Check if this is still of the same type         //         if( strBullets.substring(0,Math.min(numBullets,m_genlistlevel)).equals            (m_genlistBulletBuffer.substring(0,Math.min(numBullets,m_genlistlevel)) ) )         {             int chBullet;             if( numBullets > m_genlistlevel )             {                 buf.append( m_renderer.openList(strBullets.charAt(m_genlistlevel++)) );                 for( ; m_genlistlevel < numBullets; m_genlistlevel++ )                 {                     // bullets are growing, get from new bullet list                     buf.append( m_renderer.openListItem() );                     buf.append( m_renderer.openList(strBullets.charAt(m_genlistlevel)) );                 }             }             else if( numBullets < m_genlistlevel )             {                 //  Close the previous list item.                 buf.append( m_renderer.closeListItem() );                 for( ; m_genlistlevel > numBullets; m_genlistlevel-- )                 {                     // bullets are shrinking, get from old bullet list                     buf.append( m_renderer.closeList(m_genlistBulletBuffer.charAt(m_genlistlevel - 1)) );                     if( m_genlistlevel > 0 ) buf.append( m_renderer.closeListItem() );                 }             }             else             {                 if( m_genlistlevel > 0 ) buf.append( m_renderer.closeListItem() );             }         }         else         {             //             //  The pattern has changed, unwind and restart             //             char chBullet;             int  numEqualBullets;             int  numCheckBullets;             // find out how much is the same             numEqualBullets = 0;             numCheckBullets = Math.min(numBullets,m_genlistlevel);             while( numEqualBullets < numCheckBullets )             {                 // if the bullets are equal so far, keep going                 if( strBullets.charAt(numEqualBullets) == m_genlistBulletBuffer.charAt(numEqualBullets))                     numEqualBullets++;                 // otherwise giveup, we have found how many are equal                 else                     break;             }             //unwind             for( ; m_genlistlevel > numEqualBullets; m_genlistlevel-- )             {                 buf.append( m_renderer.closeList( m_genlistBulletBuffer.charAt(m_genlistlevel - 1) ) );                 if( m_genlistlevel > 0 ) buf.append( m_renderer.closeListItem() );             }             //rewind             buf.append( m_renderer.openList( strBullets.charAt(numEqualBullets++) ) );             for(int i = numEqualBullets; i < numBullets; i++)             {                 buf.append( m_renderer.openListItem() );                 buf.append( m_renderer.openList( strBullets.charAt(i) ) );             }             m_genlistlevel = numBullets;         }         buf.append( m_renderer.openListItem() );         // work done, remember the new bullet list (in place of old one)         m_genlistBulletBuffer.setLength(0);         m_genlistBulletBuffer.append(strBullets);         return buf.toString();    }    private String unwindGeneralList()    {        // String cStrShortName = "unwindGeneralList()";        StringBuffer buf = new StringBuffer();        int bulletCh;        //unwind        for( ; m_genlistlevel > 0; m_genlistlevel-- )        {            buf.append(m_renderer.closeListItem());            buf.append( m_renderer.closeList( m_genlistBulletBuffer.charAt(m_genlistlevel - 1) ) );        }        m_genlistBulletBuffer.setLength(0);        return buf.toString();    }    private String handleDefinitionList()        throws IOException    {        if( !m_isdefinition )        {            m_isdefinition = true;            m_closeTag = m_renderer.closeDefinitionItem()+m_renderer.closeDefinitionList();            return startBlockLevel()+m_renderer.openDefinitionList()+m_renderer.openDefinitionTitle();        }        return ";";    }    private String handleOpenbracket()        throws IOException    {        StringBuffer sb = new StringBuffer();        int ch;        boolean isPlugin = false;        while( (ch = nextToken()) == '[' )        {            sb.append( (char)ch );        }        if( ch == '{' )        {            isPlugin = true;        }        pushBack( ch );        if( sb.length() > 0 )        {            return sb.toString();        }        //        //  Find end of hyperlink        //        ch = nextToken();        while( ch != -1 )        {            if( ch == ']' && (!isPlugin || sb.charAt( sb.length()-1 ) == '}' ) )            {                break;            }            sb.append( (char) ch );            ch = nextToken();        }        if( ch == -1 )        {            log.debug("Warning: unterminated link detected!");            return sb.toString();        }        return handleHyperlinks( sb.toString() );    }    /**     *  Reads the stream until the current brace is closed or stream end.      */    private String readBraceContent( char opening, char closing )        throws IOException    {        StringBuffer sb = new StringBuffer();        int braceLevel = 1;            int ch;                while(( ch = nextToken() ) != -1 )        {            if( ch == '\\' )             {                continue;            }            else if ( ch == opening )             {                braceLevel++;            }

⌨️ 快捷键说明

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