1: <?php
2: /**
3: * Renders quoted text for a Wiki page.
4: *
5: * Copyright 2013 Horde LLC (http://www.horde.org/)
6: *
7: * See the enclosed file COPYING for license information (GPLv2). If
8: * you did not receive this file, see http://www.horde.org/licenses/gpl
9: *
10: * @category Horde
11: * @package Wicked
12: * @author Jan Schneider <jan@horde.org>
13: * @link http://www.horde.org/apps/wicked
14: * @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
15: */
16:
17: /**
18: * Renders quoted text for a Wiki page.
19: *
20: * @category Horde
21: * @package Wicked
22: * @author Jan Schneider <jan@horde.org>
23: * @link http://www.horde.org/apps/wicked
24: * @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
25: */
26: class Text_Wiki_Render_Rst_Blockquote extends Text_Wiki_Render
27: {
28: /**
29: * Renders a token into text matching the requested format.
30: *
31: * @param array $options The "options" portion of the token (second
32: * element).
33: *
34: * @return string The text rendered from the token options.
35: */
36: public function token($options)
37: {
38: // starting
39: if ($options['type'] == 'start') {
40: $this->wiki->registerRenderCallback(array($this, 'renderInsideText'));
41: $this->_level = $options['level'];
42: return '';
43: }
44:
45: // ending
46: if ($options['type'] == 'end') {
47: $this->wiki->popRenderCallback();
48: return "\n";
49: }
50: }
51:
52: public function renderInsideText($text)
53: {
54: return preg_replace('/(^|\n)(>*) */',
55: '\1' . str_repeat(' ', $this->_level * 2). '\2',
56: trim($text))
57: . "\n";
58: }
59: }
60: