includes/wikiengine/render_xhtml.php
author Dan
Mon, 16 Nov 2009 20:37:39 -0500
changeset 1137 9f928ce05b6b
parent 1127 4b858862c35c
child 1156 417e66a664d0
permissions -rw-r--r--
Fixed some open_basedir errors in SpecialPageFuncs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1027
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
     1
<?php
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
     2
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
     3
/*
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
     4
 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
1081
745200a9cc2a Fixed some upgrade bugs; added support for choosing one's own date/time formats; rebrand as 1.1.7
Dan
parents: 1078
diff changeset
     5
 * Copyright (C) 2006-2009 Dan Fuhry
1027
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
     6
 *
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
     7
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
     8
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
     9
 *
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    11
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    12
 */
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    13
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    14
class Carpenter_Render_Xhtml
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    15
{
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    16
  public $rules = array(
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    17
    'lang'   => '',
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    18
    'templates' => '',
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    19
    'bold'   => '<strong>\\1</strong>',
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    20
    'italic' => '<em>\\1</em>',
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    21
    'underline' => '<span style="text-decoration: underline;">\\1</span>',
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    22
    'externalwithtext' => '<a href="\\1" onclick="window.open(this.href); return false;">\\2</a>',
1106
01315acbc22b Wikitext: added horizontal rule support
Dan
parents: 1096
diff changeset
    23
    'externalnotext' => '<a href="\\1" onclick="window.open(this.href); return false;">\\1</a>',
01315acbc22b Wikitext: added horizontal rule support
Dan
parents: 1096
diff changeset
    24
    'hr' => '<hr />'
1027
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    25
  );
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    26
  
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    27
  public function heading($text, $pieces)
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    28
  {
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    29
    foreach ( $pieces as $i => $piece )
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    30
    {
1096
86feb1c7ca3f Wiki formatter: heading IDs are now name based ("head:" . sanitize_page_id($text)) instead of tocN.
Dan
parents: 1081
diff changeset
    31
      $tocid = sanitize_page_id(trim($piece['text']));
1127
4b858862c35c More parser work: fixed a few bugs with [[intlinks]] in headers, a bug that caused the paragraph parser to return an empty string, and added a warning/backup-and-restore for when a render stage returns an empty string.
Dan
parents: 1106
diff changeset
    32
      // (bad) workaround for links in headings
4b858862c35c More parser work: fixed a few bugs with [[intlinks]] in headers, a bug that caused the paragraph parser to return an empty string, and added a warning/backup-and-restore for when a render stage returns an empty string.
Dan
parents: 1106
diff changeset
    33
      $tocid = str_replace(array('[', ']'), '', $tocid);
1096
86feb1c7ca3f Wiki formatter: heading IDs are now name based ("head:" . sanitize_page_id($text)) instead of tocN.
Dan
parents: 1081
diff changeset
    34
      $tag = '<h' . $piece['level'] . ' id="head:' . $tocid . '">';
1027
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    35
      $tag .= trim($piece['text']);
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    36
      $tag .= '</h' . $piece['level'] . '>';
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    37
      
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    38
      $text = str_replace(Carpenter::generate_token($i), $tag, $text);
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    39
    }
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    40
    
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    41
    return $text;
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    42
  }
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    43
  
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    44
  public function multilist($text, $pieces)
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    45
  {
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    46
    foreach ( $pieces as $i => $piece )
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    47
    {
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    48
      switch($piece['type'])
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    49
      {
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    50
        case 'unordered':
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    51
        default:
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    52
          $btag = 'ul';
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    53
          $itag = 'li';
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    54
          break;
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    55
        case 'ordered':
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    56
          $btag = 'ol';
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    57
          $itag = 'li';
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    58
          break;
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    59
        case 'indent':
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    60
          $btag = 'dl';
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    61
          $itag = 'dd';
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    62
          break;
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    63
      }
1073
b19a9bcb6a45 More work on rendering engine. Fixed some bugs with paragraph skipping and added (incomplete) support for blockquotes.
Dan
parents: 1044
diff changeset
    64
      $list = "<_paragraph_bypass><$btag>\n";
1027
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    65
      $spacing = '';
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    66
      $depth = 1;
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    67
      foreach ( $piece['items'] as $j => $item )
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    68
      {
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    69
        // most of this just goes into pretty formatting.
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    70
        // everything else goes into meeting the PITA requirement that if you're going
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    71
        // another level deep, HTML requires the next level to be INSIDE of the <dd>/<li> tag.
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    72
        $itemdepth = $item['depth'];
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    73
        if ( $itemdepth > $depth )
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    74
        {
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    75
          while ( $depth < $itemdepth )
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    76
          {
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    77
            $spacing .= '    ';
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    78
            $list .= "{$spacing}<$btag>\n";
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    79
            $depth++;
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    80
          }
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    81
        }
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    82
        else if ( $itemdepth < $depth )
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    83
        {
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    84
          while ( $depth > $itemdepth )
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    85
          {
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    86
            $list .= "{$spacing}</$btag>\n";
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    87
            $spacing = substr($spacing, 4);
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    88
            $list .= "{$spacing}</$itag>\n";
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    89
            $spacing = substr($spacing, 4);
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    90
            $depth--;
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    91
          }
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    92
        }
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    93
        $list .= "{$spacing}    <$itag>" . nl2br($item['text']);
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    94
        if ( ( isset($piece['items'][ ++$j ]) && $piece['items'][ $j ]['depth'] <= $itemdepth ) || !isset($piece['items'][ $j ]) ) 
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    95
        {
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    96
          $list .= "</$itag>\n";
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    97
        }
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    98
        else
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
    99
        {
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   100
          $list .= "\n";
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   101
          $spacing .= "    ";
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   102
        }
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   103
      }
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   104
      while ( $depth > 1 )
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   105
      {
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   106
        $list .= "{$spacing}</$btag>\n";
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   107
        $spacing = substr($spacing, 4);
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   108
        $list .= "{$spacing}</$itag>\n";
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   109
        $spacing = substr($spacing, 4);
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   110
        $depth--;
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   111
      }
1073
b19a9bcb6a45 More work on rendering engine. Fixed some bugs with paragraph skipping and added (incomplete) support for blockquotes.
Dan
parents: 1044
diff changeset
   112
      $list .= "</$btag></_paragraph_bypass>\n";
1027
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   113
      $text = str_replace(Carpenter::generate_token($i), $list, $text);
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   114
    }
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   115
    return $text;
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   116
  }
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   117
  
1078
67a4c839c7e1 Blockquote functionality in wikitext parser now allows rendering of other block level elements properly
Dan
parents: 1073
diff changeset
   118
  public function blockquote($text)
67a4c839c7e1 Blockquote functionality in wikitext parser now allows rendering of other block level elements properly
Dan
parents: 1073
diff changeset
   119
  {
67a4c839c7e1 Blockquote functionality in wikitext parser now allows rendering of other block level elements properly
Dan
parents: 1073
diff changeset
   120
    return $text;
67a4c839c7e1 Blockquote functionality in wikitext parser now allows rendering of other block level elements properly
Dan
parents: 1073
diff changeset
   121
  }
67a4c839c7e1 Blockquote functionality in wikitext parser now allows rendering of other block level elements properly
Dan
parents: 1073
diff changeset
   122
  
67a4c839c7e1 Blockquote functionality in wikitext parser now allows rendering of other block level elements properly
Dan
parents: 1073
diff changeset
   123
  public function blockquotepost($text, $rand_id)
1073
b19a9bcb6a45 More work on rendering engine. Fixed some bugs with paragraph skipping and added (incomplete) support for blockquotes.
Dan
parents: 1044
diff changeset
   124
  {
1078
67a4c839c7e1 Blockquote functionality in wikitext parser now allows rendering of other block level elements properly
Dan
parents: 1073
diff changeset
   125
    $text = strtr($text, array(
67a4c839c7e1 Blockquote functionality in wikitext parser now allows rendering of other block level elements properly
Dan
parents: 1073
diff changeset
   126
        "<p>{blockquote:$rand_id}<br />"  => '<blockquote>',
67a4c839c7e1 Blockquote functionality in wikitext parser now allows rendering of other block level elements properly
Dan
parents: 1073
diff changeset
   127
        "<br />\n{/blockquote:$rand_id}</p>" => '</blockquote>',
67a4c839c7e1 Blockquote functionality in wikitext parser now allows rendering of other block level elements properly
Dan
parents: 1073
diff changeset
   128
        "{blockquote:$rand_id}"  => '<blockquote>',
67a4c839c7e1 Blockquote functionality in wikitext parser now allows rendering of other block level elements properly
Dan
parents: 1073
diff changeset
   129
        "{/blockquote:$rand_id}" => '</blockquote>'
67a4c839c7e1 Blockquote functionality in wikitext parser now allows rendering of other block level elements properly
Dan
parents: 1073
diff changeset
   130
      ));
67a4c839c7e1 Blockquote functionality in wikitext parser now allows rendering of other block level elements properly
Dan
parents: 1073
diff changeset
   131
    $text = strtr($text, array(
67a4c839c7e1 Blockquote functionality in wikitext parser now allows rendering of other block level elements properly
Dan
parents: 1073
diff changeset
   132
        "<blockquote><br />" => '<blockquote>',
67a4c839c7e1 Blockquote functionality in wikitext parser now allows rendering of other block level elements properly
Dan
parents: 1073
diff changeset
   133
        "</blockquote><br />" => '</blockquote>'
67a4c839c7e1 Blockquote functionality in wikitext parser now allows rendering of other block level elements properly
Dan
parents: 1073
diff changeset
   134
      ));
1073
b19a9bcb6a45 More work on rendering engine. Fixed some bugs with paragraph skipping and added (incomplete) support for blockquotes.
Dan
parents: 1044
diff changeset
   135
    return $text;
b19a9bcb6a45 More work on rendering engine. Fixed some bugs with paragraph skipping and added (incomplete) support for blockquotes.
Dan
parents: 1044
diff changeset
   136
  }
b19a9bcb6a45 More work on rendering engine. Fixed some bugs with paragraph skipping and added (incomplete) support for blockquotes.
Dan
parents: 1044
diff changeset
   137
  
1027
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   138
  public function paragraph($text, $pieces)
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   139
  {
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   140
    foreach ( $pieces as $i => $piece )
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   141
    {
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   142
      $text = str_replace(Carpenter::generate_token($i), '<p>' . nl2br($piece) . '</p>', $text);
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   143
    }
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   144
    
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   145
    return $text;
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   146
  }
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   147
}
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   148
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   149
// Alias internal link parsing to RenderMan's method
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   150
function parser_mediawiki_xhtml_internallink($text)
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   151
{
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   152
  return RenderMan::parse_internal_links($text);
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   153
}
98c052fc3337 First implementation of new parser; Text_Wiki is now gone. VERY BETA! WiP.
Dan
parents:
diff changeset
   154