Textile2 Plugin

textile2 plugin by Ryan Schwartz
parses textile markup

Last updated on 2007-02-06. Provides Syntax.
No compatibility info given!

Tagged with markup_language.

    Install

    To install through the plugin manager use http://ryanschwartz.net/dokuwiki_textile2.tgz. To install manually, create a textile2 directory inside your plugins directory, and in put both the below php as syntax.php, and http://svn.textpattern.com/releases/4.0.3/source/textpattern/lib/classTextile.php into it.

    Any possibility of just uploading that here and linking it for a centralized location?

    Usage

    To use textile markup in your page, mark an area in a textile block. For example:

    <textile>
    
    h1. Hi
    </textile>
    

    will result in a textile rendering of an h1 header saying “Hi”. Note the newline following the first textile, that seems to be a requirement of the plug-in.

    syntax.php

    <?php
    /**
     * Textile2-Plugin: Parses Textile2-blocks
     *
     * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
     * @author     Ryan Schwartz <textile@ryanschwartz.net>
     */
     
    // must be run within Dokuwiki
    if(!defined('DOKU_INC')) die();
     
    if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
    require_once(DOKU_PLUGIN.'syntax.php');
    require_once(DOKU_PLUGIN.'textile2/classTextile.php');
     
     
    /**
     * All DokuWiki plugins to extend the parser/rendering mechanism
     * need to inherit from this class
     */
    class syntax_plugin_textile2 extends DokuWiki_Syntax_Plugin {
     
        /**
         * return some info
         */
        function getInfo(){
            return array(
                'author' => 'Ryan Schwartz',
                'email'  => 'textile@ryanschwartz.net',
                'date'   => '2007-02-06',
                'name'   => 'Textile2 Plugin',
                'desc'   => 'Parses Textile2-blocks',
                'url'    => 'http://www.dokuwiki.org/plugin:textile2',
            );
        }
     
        /**
         * What kind of syntax are we?
         */
        function getType(){
            return 'protected';
        }
     
        /**
         * Where to sort in?
         */
        function getSort(){
            return 69;
        }
     
        function getPType() {
            return 'block';
        }
     
        /**
         * Connect pattern to lexer
         */
        function connectTo($mode) {
            $this->Lexer->addEntryPattern('<textile>(?=.*</textile>)',$mode,'plugin_textile2');
        }
     
        function postConnect() {
          $this->Lexer->addExitPattern('</textile>','plugin_textile2');
        }
     
        /**
         * Handle the match
         */
        function handle($match, $state, $pos, &$handler){
            return array($match);
        }
     
        /**
         * Create output
         */
        function render($mode, &$renderer, $data) {
            if($mode == 'xhtml' && $data[0] != "<textile>" && $data[0] != "</textile>") {
                $renderme = new Textile;
                $renderer->doc .= $renderme->TextileThis($data[0]);
                return true;
            }
            return false;
        }
     
    }
     
    //Setup VIM: ex: et ts=4 enc=utf-8 :
     
    plugin/textile2.txt · Last modified: 2009/10/10 18:37 by laynee
     
    Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
    Imprint Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
    WikiForumIRCBugsGitXRefTranslate