Changeset 2015 for trunk/vendor/Text

Show
Ignore:
Timestamp:
07/20/07 09:03:04 (18 months ago)
Author:
jepso
Message:

- New feature in documentation: you can now link to other documentation sections with the following syntax:

  • [doc getting-started:installation], or
  • [doc getting-started:installation Custom link text]

- Updated Text_Wiki to 1.2.0
- Documentation should now pass XHTML validator
- Formatted DSN section so that it's easier on eyes
- The single quotes in <code type='php'> won't work anymore due to the Text_Wiki update. Use double quotes instead: <code type="php">. The single quotes have been converted to double quotes in documentation files.
- Modified the links in h1-h6 headings to use the same style as the headings.
- Some refactoring

Location:
trunk/vendor/Text
Files:
1 added
2 removed
22 modified

Legend:

Unmodified
Added
Removed
  • trunk/vendor/Text/Wiki.php

    r1128 r2015  
    1010 * @author     Paul M. Jones <pmjones@php.net> 
    1111 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1 
    12  * @version    CVS: $Id: Wiki.php,v 1.48 2006/10/10 19:34:38 justinpatrin Exp $ 
     12 * @version    CVS: $Id: Wiki.php,v 1.51 2007/06/09 23:17:46 justinpatrin Exp $ 
    1313 * @link       http://pear.php.net/package/Text_Wiki 
    1414 */ 
     
    3434 * @author     Paul M. Jones <pmjones@php.net> 
    3535 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1 
    36  * @version    Release: 1.2.0RC1 
     36 * @version    Release: 1.2.0 
    3737 * @link       http://pear.php.net/package/Text_Wiki 
    3838 */ 
     
    257257    var $source = ''; 
    258258 
     259    /** 
     260     * The output text 
     261     * 
     262     * @var string 
     263     */ 
     264    var $output = ''; 
     265 
    259266 
    260267    /** 
     
    338345    /** 
    339346     * Temporary configuration variable 
     347     * 
     348     * @var string 
    340349     */ 
    341350    var $renderingType = 'preg'; 
    342351 
    343352    /** 
     353     * Stack of rendering callbacks 
     354     * 
     355     * @var Array 
     356     */ 
     357    var $_renderCallbacks = array(); 
     358 
     359    /** 
     360     * Current output block 
     361     * 
     362     * @var string 
     363     */ 
     364    var $_block; 
     365 
     366    /** 
     367     * A stack of blocks 
     368     * 
     369     * @param Array 
     370     */ 
     371    var $_blocks; 
     372 
     373    /** 
    344374    * 
    345375    * Constructor. 
     
    357387    { 
    358388        if (is_array($rules)) { 
    359             $this->rules = $rules; 
     389            $this->rules = array(); 
     390            foreach ($rules as $rule) { 
     391                $this->rules[] = ucfirst($rule); 
     392            } 
    360393        } 
    361394 
     
    409442    * @return &object a reference to the Text_Wiki unique instantiation. 
    410443    */ 
    411     function singleton($parser = 'Default', $rules = null) 
     444    function &singleton($parser = 'Default', $rules = null) 
    412445    { 
    413446        static $only = array(); 
    414447        if (!isset($only[$parser])) { 
    415             $ret = Text_Wiki::factory($parser, $rules); 
     448            $ret = & Text_Wiki::factory($parser, $rules); 
    416449            if (Text_Wiki::isError($ret)) { 
    417450                return $ret; 
    418451            } 
    419             $only[$parser] = $ret; 
     452            $only[$parser] =& $ret; 
    420453        } 
    421454        return $only[$parser]; 
     
    433466     * @return Text_Wiki a Parser object extended from Text_Wiki 
    434467     */ 
    435     function factory($parser = 'Default', $rules = null) 
     468    function &factory($parser = 'Default', $rules = null) 
    436469    { 
    437470        $class = 'Text_Wiki_' . $parser; 
     
    446479        } 
    447480 
    448         $obj = new $class($rules); 
     481        $obj =& new $class($rules); 
    449482        return $obj; 
    450483    } 
     
    921954                // load may have failed; only parse if 
    922955                // an object is in the array now 
    923                 if (isset($this->parseObj[$name]) && is_object($this->parseObj[$name])) { 
     956                if (is_object($this->parseObj[$name])) { 
    924957                    $this->parseObj[$name]->parse(); 
    925958                } 
     
    949982 
    950983        // the eventual output text 
    951         $output = ''; 
     984        $this->output = ''; 
    952985 
    953986        // when passing through the parsed source text, keep track of when 
     
    966999        // pre-rendering activity 
    9671000        if (is_object($this->formatObj[$format])) { 
    968             $output .= $this->formatObj[$format]->pre(); 
     1001            $this->output .= $this->formatObj[$format]->pre(); 
    9691002        } 
    9701003 
     
    9751008 
    9761009        if ($this->renderingType == 'preg') { 
    977             $output = preg_replace_callback('/'.$this->delim.'(\d+)'.$this->delim.'/', 
     1010            $this->output = preg_replace_callback('/'.$this->delim.'(\d+)'.$this->delim.'/', 
    9781011                                            array(&$this, '_renderToken'), 
    9791012                                            $this->source); 
     1013            /* 
     1014//Damn strtok()! Why does it "skip" empty parts of the string. It's useless now! 
     1015        } elseif ($this->renderingType == 'strtok') { 
     1016            echo '<pre>'.htmlentities($this->source).'</pre>'; 
     1017            $t = strtok($this->source, $this->delim); 
     1018            $inToken = true; 
     1019            $i = 0; 
     1020            while ($t !== false) { 
     1021                echo 'Token: '.$i.'<pre>"'.htmlentities($t).'"</pre><br/><br/>'; 
     1022                if ($inToken) { 
     1023                    //$this->output .= $this->renderObj[$this->tokens[$t][0]]->token($this->tokens[$t][1]); 
     1024                } else { 
     1025                    $this->output .= $t; 
     1026                } 
     1027                $inToken = !$inToken; 
     1028                $t = strtok($this->delim); 
     1029                ++$i; 
     1030            } 
     1031            */ 
    9801032        } else { 
    9811033            // pass through the parsed source text character by character 
     1034            $this->_block = ''; 
     1035            $tokenStack = array(); 
    9821036            $k = strlen($this->source); 
    9831037            for ($i = 0; $i < $k; $i++) { 
     
    9911045                    // yes; are we ending the section? 
    9921046                    if ($char == $this->delim) { 
     1047 
     1048                        if (count($this->_renderCallbacks) == 0) { 
     1049                            $this->output .= $this->_block; 
     1050                            $this->_block = ''; 
     1051                        } 
     1052 
     1053                        if (isset($opts['type'])) { 
     1054                            if ($opts['type'] == 'start') { 
     1055                                array_push($tokenStack, $rule); 
     1056                            } elseif ($opts['type'] == 'end') { 
     1057                                if ($tokenStack[count($tokenStack) - 1] != $rule) { 
     1058                                    return Text_Wiki::error('Unbalanced tokens, check your syntax'); 
     1059                                } else { 
     1060                                    array_pop($tokenStack); 
     1061                                } 
     1062                            } 
     1063                        } 
    9931064 
    9941065                        // yes, get the replacement text for the delimited 
     
    9971068                        $rule = $this->tokens[$key][0]; 
    9981069                        $opts = $this->tokens[$key][1]; 
    999                         $output .= $this->renderObj[$rule]->token($opts); 
     1070                        $this->_block .= $this->renderObj[$rule]->token($opts); 
    10001071                        $in_delim = false; 
    10011072 
    10021073                    } else { 
    10031074 
    1004                         // no, add to the dlimited token key number 
     1075                        // no, add to the delimited token key number 
    10051076                        $key .= $char; 
    10061077 
     
    10161087                        $key = ''; 
    10171088                        $in_delim = true; 
     1089 
    10181090                    } else { 
    10191091                        // no, add to the output as-is 
    1020                         $output .= $char; 
     1092                        $this->_block .= $char; 
    10211093                    } 
    10221094                } 
     
    10241096        } 
    10251097 
     1098        if (count($this->_renderCallbacks)) { 
     1099            return $this->error('Render callbacks left over after processing finished'); 
     1100        } 
     1101        /* 
     1102        while (count($this->_renderCallbacks)) { 
     1103            $this->popRenderCallback(); 
     1104        } 
     1105        */ 
     1106        if (strlen($this->_block)) { 
     1107            $this->output .= $this->_block; 
     1108            $this->_block = ''; 
     1109        } 
     1110 
    10261111        // post-rendering activity 
    10271112        if (is_object($this->formatObj[$format])) { 
    1028             $output .= $this->formatObj[$format]->post(); 
     1113            $this->output .= $this->formatObj[$format]->post(); 
    10291114        } 
    10301115 
    10311116        // return the rendered source text. 
    1032         return $output; 
     1117        return $this->output; 
    10331118    } 
    10341119 
     
    10441129    } 
    10451130 
     1131    function registerRenderCallback($callback) { 
     1132        $this->_blocks[] = $this->_block; 
     1133        $this->_block = ''; 
     1134        $this->_renderCallbacks[] = $callback; 
     1135    } 
     1136 
     1137    function popRenderCallback() { 
     1138        if (count($this->_renderCallbacks) == 0) { 
     1139            return Text_Wiki::error('Render callback popped when no render callbacks in stack'); 
     1140        } else { 
     1141            $callback = array_pop($this->_renderCallbacks); 
     1142            $this->_block = call_user_func($callback, $this->_block); 
     1143            if (count($this->_blocks)) { 
     1144                $parentBlock = array_pop($this->_blocks); 
     1145                $this->_block = $parentBlock.$this->_block; 
     1146            } 
     1147            if (count($this->_renderCallbacks) == 0) { 
     1148                $this->output .= $this->_block; 
     1149                $this->_block = ''; 
     1150            } 
     1151        } 
     1152    } 
    10461153 
    10471154    /** 
     
    12231330        } 
    12241331 
    1225         $this->parseObj[$rule] = new $class($this); 
     1332        $this->parseObj[$rule] =& new $class($this); 
    12261333 
    12271334    } 
     
    12591366        } 
    12601367 
    1261         $this->renderObj[$rule] = new $class($this); 
     1368        $this->renderObj[$rule] =& new $class($this); 
    12621369    } 
    12631370 
     
    12921399        } 
    12931400 
    1294         $this->formatObj[$format] = new $class($this); 
     1401        $this->formatObj[$format] =& new $class($this); 
    12951402    } 
    12961403 
  • trunk/vendor/Text/Wiki/Parse.php

    r1162 r2015  
    234234        // find the =" sections; 
    235235        $tmp = explode('="', trim($text)); 
    236         $mark = '"'; 
    237  
    238         if (count($tmp) == 1) { 
    239             $tmp = explode("='", trim($text)); 
    240             $mark = "'"; 
    241         } 
    242236 
    243237        // basic setup 
     
    258252            // the part to the left is the value for the last key, 
    259253            // the part to the right is the next key name 
    260             $pos = strrpos($val, $mark); 
     254            $pos = strrpos($val, '"'); 
    261255            $attrs[$key] = stripslashes(substr($val, 0, $pos)); 
    262256            $key = trim(substr($val, $pos+1)); 
    263257 
    264258        } 
     259 
    265260        return $attrs; 
    266261 
  • trunk/vendor/Text/Wiki/Parse/Default/Blockquote.php

    r1125 r2015  
    1313* @license LGPL 
    1414*  
    15 * @version $Id: Blockquote.php,v 1.3 2005/02/23 17:38:29 pmjones Exp $ 
     15* @version $Id: Blockquote.php,v 1.4 2006/10/21 05:56:28 justinpatrin Exp $ 
    1616*  
    1717*/ 
     
    7777    { 
    7878        // the replacement text we will return to parse() 
    79         $return = ''; 
     79        $return = "\n"; 
    8080         
    8181        // the list of post-processing matches 
     
    9292        ); 
    9393         
    94         // a stack of starts and ends; we keep this so that we know what 
    95         // indent level we're at. 
    96         $stack = array(); 
    97          
     94        $curLevel = 0; 
     95 
    9896        // loop through each list-item element. 
    9997        foreach ($list as $key => $val) { 
     
    106104            $level = strlen($val[1]); 
    107105             
    108             // get the text of the line 
    109             $text = $val[2]; 
    110              
    111106            // add a level to the list? 
    112             while ($level > count($stack)) { 
    113                  
     107            while ($level > $curLevel) { 
    114108                // the current indent level is greater than the number 
    115109                // of stack elements, so we must be starting a new 
    116110                // level.  push the new level onto the stack with a  
    117111                // dummy value (boolean true)... 
    118                 array_push($stack, true); 
     112                ++$curLevel; 
    119113                 
    120                 $return .= "\n"; 
     114                //$return .= "\n"; 
    121115                 
    122116                // ...and add a start token to the return. 
     
    125119                    array( 
    126120                        'type' => 'start', 
    127                         'level' => $level - 1 
     121                        'level' => $curLevel 
    128122                    ) 
    129123                ); 
    130124                 
    131                 $return .= "\n\n"; 
     125                //$return .= "\n\n"; 
    132126            } 
    133127             
    134128            // remove a level? 
    135             while (count($stack) > $level) { 
     129            while ($curLevel > $level) { 
    136130                 
    137131                // as long as the stack count is greater than the 
     
    139133                // continue adding end-list tokens until the stack count 
    140134                // and the indent level are the same. 
    141                 array_pop($stack); 
    142135                 
    143                 $return .= "\n\n"; 
     136                //$return .= "\n\n"; 
    144137                 
    145138                $return .= $this->wiki->addToken( 
     
    147140                    array ( 
    148141                        'type' => 'end', 
    149                         'level' => count($stack) 
     142                        'level' => $curLevel 
    150143                    ) 
    151144                ); 
    152145                 
    153                 $return .= "\n"; 
     146                //$return .= "\n"; 
     147                --$curLevel; 
    154148            } 
    155149             
    156150            // add the line text. 
    157             $return .= $text; 
     151            $return .= $val[2]; 
    158152        } 
     153         
     154        // the last char of the matched pattern must be \n but we don't 
     155        // want this to be inside the tokens 
     156        $return = substr($return, 0, -1); 
    159157         
    160158        // the last line may have been indented.  go through the stack 
    161159        // and create end-tokens until the stack is empty. 
    162         $return .= "\n"; 
    163          
    164         while (count($stack) > 0) { 
    165             array_pop($stack); 
     160        //$return .= "\n"; 
     161 
     162        while ($curLevel > 0) { 
    166163            $return .= $this->wiki->addToken( 
    167164                $this->rule,  
    168165                array ( 
    169166                    'type' => 'end', 
    170                     'level' => count($stack) 
     167                    'level' => $curLevel 
    171168                ) 
    172169            ); 
     170            --$curLevel; 
    173171        } 
    174172         
     173        // put back the trailing \n 
     174        $return .= "\n"; 
     175 
    175176        // we're done!  send back the replacement text. 
    176         return "\n$return\n\n"; 
     177        return $return; 
    177178    } 
    178179} 
  • trunk/vendor/Text/Wiki/Parse/Default/Code.php

    r1760 r2015  
    1313* @license LGPL 
    1414*  
    15 * @version $Id: Code.php,v 1.10 2006/02/21 14:33:53 toggg Exp $ 
     15* @version $Id: Code.php,v 1.11 2007/06/09 23:11:25 justinpatrin Exp $ 
    1616*  
    1717*/ 
     
    5151     
    5252/*    var $regex = '/^(\<code( .+)?\>)\n(.+)\n(\<\/code\>)(\s|$)/Umsi';*/ 
    53 /*    var $regex = ';^<code(\s[^>]*)?>((?:(?R)|.)*?)\n</code>(\s|$);msi';*/ 
    54     var $regex = ';^<code(\s[^>]*)?>\n(.+?)\n</code>(\s|$);msi'; 
     53    var $regex = ';^<code(\s[^>]*)?>((?:(?R)|.*?)*)\n</code>(\s|$);msi'; 
    5554     
    5655    /** 
     
    7372        // are there additional attribute arguments? 
    7473        $args = trim($matches[1]); 
    75  
     74         
    7675        if ($args == '') { 
    7776            $options = array( 
     
    8281                // get the attributes... 
    8382                $attr = $this->getAttrs($args); 
    84  
     83                 
    8584                // ... and make sure we have a 'type' 
    8685                if (! isset($attr['type'])) { 
  • trunk/vendor/Text/Wiki/Parse/Default/Freelink.php

    r1125 r2015  
    1313* @license LGPL 
    1414*  
    15 * @version $Id: Freelink.php,v 1.4 2005/10/19 23:43:53 toggg Exp $ 
     15* @version $Id: Freelink.php,v 1.8 2006/12/08 08:23:51 justinpatrin Exp $ 
    1616*  
    1717*/ 
     
    4242class Text_Wiki_Parse_Freelink extends Text_Wiki_Parse { 
    4343     
     44    var $conf = array ( 
     45                       'utf-8' => false 
     46    ); 
    4447     
    4548    /** 
     
    5760    { 
    5861        parent::Text_Wiki_Parse($obj); 
    59          
     62        if ($this->getConf('utf-8')) { 
     63            $any = '\p{L}'; 
     64        } else { 
     65            $any = ''; 
     66        } 
    6067        $this->regex = 
    6168            '/' .                                                   // START regex 
    6269            "\\(\\(" .                                               // double open-parens 
    6370            "(" .                                                   // START freelink page patter 
    64             "[-A-Za-z0-9 _+\\/.,;:!?'\"\\[\\]\\{\\}&\xc0-\xff]+" . // 1 or more of just about any character 
     71            "[-A-Za-z0-9 _+\\/.,;:!?'\"\\[\\]\\{\\}&".$any."\xc0-\xff]+" . // 1 or more of just about any character 
    6572            ")" .                                                   // END  freelink page pattern 
    6673            "(" .                                                   // START display-name 
    6774            "\|" .                                                   // a pipe to start the display name 
    68             "[-A-Za-z0-9 _+\\/.,;:!?'\"\\[\\]\\{\\}&\xc0-\xff]+" . // 1 or more of just about any character 
     75            "[-A-Za-z0-9 _+\\/.,;:!?'\"\\[\\]\\{\\}&".$any."\xc0-\xff]+" . // 1 or more of just about any character 
    6976            ")?" .                                                   // END display-name pattern 0 or 1 
    7077            "(" .                                                   // START pattern for named anchors 
     
    7481            ")?" .                                                   // END named anchors pattern 0 or 1 
    7582            "()\\)\\)" .                                           // double close-parens 
    76             '/';                                                   // END regex 
     83            '/'.($this->getConf('utf-8') ? 'u' : '');              // END regex 
    7784    } 
    7885     
  • trunk/vendor/Text/Wiki/Parse/Default/Prefilter.php

    r1125 r2015  
    1313* @license LGPL 
    1414*  
    15 * @version $Id: Prefilter.php,v 1.3 2005/02/23 17:38:29 pmjones Exp $ 
     15* @version $Id: Prefilter.php,v 1.4 2006/12/08 08:30:37 justinpatrin Exp $ 
    1616*  
    1717*/ 
     
    6666        // seems to help many rules. 
    6767        $this->wiki->source = "\n" . $this->wiki->source . "\n\n"; 
     68 
     69        $this->wiki->source = str_replace("\n----\n","\n\n----\n\n", 
     70                                          $this->wiki->source); 
     71        $this->wiki->source = preg_replace("/\n(\\+{1,6})(.*)\n/m", 
     72                                           "\n\n\\1 \\2\n\n", 
     73                                           $this->wiki->source); 
    6874         
    6975        // finally, compress all instances of 3 or more newlines