diff -r de56132c008d -r bdac73ed481e includes/wikiengine/render_xhtml.php
--- a/includes/wikiengine/render_xhtml.php Sun Mar 28 21:49:26 2010 -0400
+++ b/includes/wikiengine/render_xhtml.php Sun Mar 28 23:10:46 2010 -0400
@@ -13,159 +13,159 @@
class Carpenter_Render_Xhtml
{
- public $rules = array(
- 'lang' => '',
- 'templates' => '',
- 'bold' => '\\1',
- 'italic' => '\\1',
- 'underline' => '\\1',
- 'externalwithtext' => '\\2',
- 'externalnotext' => '\\1',
- 'hr' => '
'
- );
-
- public function heading($text, $pieces)
- {
- foreach ( $pieces as $i => $piece )
- {
- $tocid = sanitize_page_id(trim($piece['text']));
- // (bad) workaround for links in headings
- $tocid = str_replace(array('[', ']'), '', $tocid);
- $tag = '';
- $tag .= trim($piece['text']);
- $tag .= '';
-
- $text = str_replace(Carpenter::generate_token($i), $tag, $text);
- }
-
- return $text;
- }
-
- public function multilist($text, $pieces)
- {
- foreach ( $pieces as $i => $piece )
- {
- switch($piece['type'])
- {
- case 'unordered':
- default:
- $btag = 'ul';
- $itag = 'li';
- break;
- case 'ordered':
- $btag = 'ol';
- $itag = 'li';
- break;
- case 'indent':
- $btag = 'dl';
- $itag = 'dd';
- break;
- }
- $list = "<_paragraph_bypass><$btag>\n";
- $spacing = '';
- $depth = 1;
- foreach ( $piece['items'] as $j => $item )
- {
- // most of this just goes into pretty formatting.
- // everything else goes into meeting the PITA requirement that if you're going
- // another level deep, HTML requires the next level to be INSIDE of the / tag.
- $itemdepth = $item['depth'];
- if ( $itemdepth > $depth )
- {
- while ( $depth < $itemdepth )
- {
- $spacing .= ' ';
- $list .= "{$spacing}<$btag>\n";
- $depth++;
- }
- }
- else if ( $itemdepth < $depth )
- {
- while ( $depth > $itemdepth )
- {
- $list .= "{$spacing}$btag>\n";
- $spacing = substr($spacing, 4);
- $list .= "{$spacing}$itag>\n";
- $spacing = substr($spacing, 4);
- $depth--;
- }
- }
- $list .= "{$spacing} <$itag>" . nl2br($item['text']);
- if ( ( isset($piece['items'][ ++$j ]) && $piece['items'][ $j ]['depth'] <= $itemdepth ) || !isset($piece['items'][ $j ]) )
- {
- $list .= "$itag>\n";
- }
- else
- {
- $list .= "\n";
- $spacing .= " ";
- }
- }
- while ( $depth > 1 )
- {
- $list .= "{$spacing}$btag>\n";
- $spacing = substr($spacing, 4);
- $list .= "{$spacing}$itag>\n";
- $spacing = substr($spacing, 4);
- $depth--;
- }
- $list .= "$btag>\n";
- $text = str_replace(Carpenter::generate_token($i), $list, $text);
- }
- return $text;
- }
-
- public function blockquote($text)
- {
- return $text;
- }
-
- public function blockquotepost($text, $rand_id)
- {
- $text = strtr($text, array(
- "{blockquote:$rand_id}
" => '
',
- "
\n{/blockquote:$rand_id}" => '
',
- "{blockquote:$rand_id}" => '',
- "{/blockquote:$rand_id}" => '
'
- ));
- $text = strtr($text, array(
- "
" => '',
- "
" => '
'
- ));
- return $text;
- }
-
- public function paragraph($text, $pieces)
- {
- foreach ( $pieces as $i => $piece )
- {
- $text = str_replace(Carpenter::generate_token($i), '' . nl2br($piece) . '
', $text);
- }
-
- return $text;
- }
-
- public function mailtonotext($pieces)
- {
- $pieces[2] = $pieces[1];
- return $this->mailtowithtext($pieces);
- }
-
- public function mailtowithtext($pieces)
- {
- global $email;
- return $email->encryptEmail($pieces[1], '', '', $pieces[2]);
- }
-
- public function code($match)
- {
- return '' . htmlspecialchars($match[1]) . '
';
- }
+ public $rules = array(
+ 'lang' => '',
+ 'templates' => '',
+ 'bold' => '\\1',
+ 'italic' => '\\1',
+ 'underline' => '\\1',
+ 'externalwithtext' => '\\2',
+ 'externalnotext' => '\\1',
+ 'hr' => '
'
+ );
+
+ public function heading($text, $pieces)
+ {
+ foreach ( $pieces as $i => $piece )
+ {
+ $tocid = sanitize_page_id(trim($piece['text']));
+ // (bad) workaround for links in headings
+ $tocid = str_replace(array('[', ']'), '', $tocid);
+ $tag = '';
+ $tag .= trim($piece['text']);
+ $tag .= '';
+
+ $text = str_replace(Carpenter::generate_token($i), $tag, $text);
+ }
+
+ return $text;
+ }
+
+ public function multilist($text, $pieces)
+ {
+ foreach ( $pieces as $i => $piece )
+ {
+ switch($piece['type'])
+ {
+ case 'unordered':
+ default:
+ $btag = 'ul';
+ $itag = 'li';
+ break;
+ case 'ordered':
+ $btag = 'ol';
+ $itag = 'li';
+ break;
+ case 'indent':
+ $btag = 'dl';
+ $itag = 'dd';
+ break;
+ }
+ $list = "<_paragraph_bypass><$btag>\n";
+ $spacing = '';
+ $depth = 1;
+ foreach ( $piece['items'] as $j => $item )
+ {
+ // most of this just goes into pretty formatting.
+ // everything else goes into meeting the PITA requirement that if you're going
+ // another level deep, HTML requires the next level to be INSIDE of the / tag.
+ $itemdepth = $item['depth'];
+ if ( $itemdepth > $depth )
+ {
+ while ( $depth < $itemdepth )
+ {
+ $spacing .= ' ';
+ $list .= "{$spacing}<$btag>\n";
+ $depth++;
+ }
+ }
+ else if ( $itemdepth < $depth )
+ {
+ while ( $depth > $itemdepth )
+ {
+ $list .= "{$spacing}$btag>\n";
+ $spacing = substr($spacing, 4);
+ $list .= "{$spacing}$itag>\n";
+ $spacing = substr($spacing, 4);
+ $depth--;
+ }
+ }
+ $list .= "{$spacing} <$itag>" . nl2br($item['text']);
+ if ( ( isset($piece['items'][ ++$j ]) && $piece['items'][ $j ]['depth'] <= $itemdepth ) || !isset($piece['items'][ $j ]) )
+ {
+ $list .= "$itag>\n";
+ }
+ else
+ {
+ $list .= "\n";
+ $spacing .= " ";
+ }
+ }
+ while ( $depth > 1 )
+ {
+ $list .= "{$spacing}$btag>\n";
+ $spacing = substr($spacing, 4);
+ $list .= "{$spacing}$itag>\n";
+ $spacing = substr($spacing, 4);
+ $depth--;
+ }
+ $list .= "$btag>\n";
+ $text = str_replace(Carpenter::generate_token($i), $list, $text);
+ }
+ return $text;
+ }
+
+ public function blockquote($text)
+ {
+ return $text;
+ }
+
+ public function blockquotepost($text, $rand_id)
+ {
+ $text = strtr($text, array(
+ "{blockquote:$rand_id}
" => '
',
+ "
\n{/blockquote:$rand_id}" => '
',
+ "{blockquote:$rand_id}" => '',
+ "{/blockquote:$rand_id}" => '
'
+ ));
+ $text = strtr($text, array(
+ "
" => '',
+ "
" => '
'
+ ));
+ return $text;
+ }
+
+ public function paragraph($text, $pieces)
+ {
+ foreach ( $pieces as $i => $piece )
+ {
+ $text = str_replace(Carpenter::generate_token($i), '' . nl2br($piece) . '
', $text);
+ }
+
+ return $text;
+ }
+
+ public function mailtonotext($pieces)
+ {
+ $pieces[2] = $pieces[1];
+ return $this->mailtowithtext($pieces);
+ }
+
+ public function mailtowithtext($pieces)
+ {
+ global $email;
+ return $email->encryptEmail($pieces[1], '', '', $pieces[2]);
+ }
+
+ public function code($match)
+ {
+ return '' . htmlspecialchars($match[1]) . '
';
+ }
}
// Alias internal link parsing to RenderMan's method
function parser_mediawiki_xhtml_internallink($text)
{
- return RenderMan::parse_internal_links($text);
+ return RenderMan::parse_internal_links($text);
}