includes/wikiengine/parse_mediawiki.php
changeset 1078 67a4c839c7e1
parent 1073 b19a9bcb6a45
child 1081 745200a9cc2a
equal deleted inserted replaced
1077:7f621a3a9cbf 1078:67a4c839c7e1
    19     'italic' => "/''(.+?)''/",
    19     'italic' => "/''(.+?)''/",
    20     'underline' => '/__(.+?)__/',
    20     'underline' => '/__(.+?)__/',
    21     'externalwithtext' => '#\[((?:https?|irc|ftp)://.+?) (.+?)\]#',
    21     'externalwithtext' => '#\[((?:https?|irc|ftp)://.+?) (.+?)\]#',
    22     'externalnotext' => '#\[((?:https?|irc|ftp)://.+?)\]#'
    22     'externalnotext' => '#\[((?:https?|irc|ftp)://.+?)\]#'
    23   );
    23   );
       
    24   
       
    25   private $blockquote_rand_id;
    24   
    26   
    25   public function lang(&$text)
    27   public function lang(&$text)
    26   {
    28   {
    27     global $lang;
    29     global $lang;
    28     
    30     
   150     return $pieces;
   152     return $pieces;
   151   }
   153   }
   152   
   154   
   153   public function blockquote(&$text)
   155   public function blockquote(&$text)
   154   {
   156   {
   155     if ( !preg_match_all('/^(?:(>+) *.+(?:\r?\n|$))+/m', $text, $quotes) )
   157     $rand_id = hexencode(AESCrypt::randkey(16), '', '');
   156       return array();
   158     
   157    
   159     while ( preg_match_all('/^(?:(>+) *.+(?:\r?\n|$))+/m', $text, $quotes) )
   158     $pieces = array();
   160     {
   159     foreach ( $quotes[0] as $quote )
   161       foreach ( $quotes[0] as $quote )
   160       $pieces[] = "\t" . trim(preg_replace('/^>+ */m', "\t", $quote));
   162       {
   161     
   163         $piece = trim(preg_replace('/^> */m', '', $quote));
   162     $text = Carpenter::tokenize($text, $quotes[0]);
   164         $text = str_replace_once($quote, "{blockquote:$rand_id}\n$piece\n{/blockquote:$rand_id}\n", $text);
   163     return $pieces;
   165       }
       
   166     }
       
   167     //die('<pre>' . htmlspecialchars($text) . '</pre>');
       
   168     
       
   169     $this->blockquote_rand_id = $rand_id;
       
   170   }
       
   171   
       
   172   public function blockquotepost(&$text)
       
   173   {
       
   174     return $this->blockquote_rand_id;
   164   }
   175   }
   165   
   176   
   166   public function paragraph(&$text)
   177   public function paragraph(&$text)
   167   {
   178   {
   168     // The trick with paragraphs is to not turn things into them when a block level element already wraps the block of text.
   179     // The trick with paragraphs is to not turn things into them when a block level element already wraps the block of text.