/** * Renders a token into text matching the requested format. * * @param array $options The "options" portion of the token (second * element). * * @return string The text rendered from the token options. */ public function token($options) { extract($options); if ($type == 'start') { return ''; } if ($type == 'end') { return Text_Wiki_Render_Rst_Links::append() . "\n\n"; } }
/** * Render the header. * * @param array $options The rendering options. * * @return string The output string. */ public function token($options) { // get nice variable names (type, level) extract($options); if ($type == 'start') { $length = strlen($text); switch ($level) { case '1': $overline = '='; $underline = '='; $length += 2; break; case '2': $overline = '-'; $underline = '-'; $length += 2; break; case '3': $overline = null; $underline = '='; break; case '4': $overline = null; $underline = '*'; break; case '5': $overline = null; $underline = '-'; break; case '6': $overline = null; $underline = '`'; break; } $output = Text_Wiki_Render_Rst_Links::append(); if ($output) { $output = trim($output) . "\n\n"; } if ($overline !== null) { $output .= str_repeat($overline, $length) . "\n "; } $previous = $options; $previous['length'] = $length; $previous['underline'] = $underline; $this->_previous[] = $previous; return $output; } if ($type == 'end') { $previous = array_pop($this->_previous); if ($level != $previous['level']) { return sprintf('UNEXPECTED HEADER LEVEL: %s [expected %s]', $level, $previous['level']); } return "\n" . str_repeat($previous['underline'], $previous['length']) . "\n\n"; } }
/** * Renders a token into text matching the requested format. * * @param array $options The "options" portion of the token (second * element). * * @return string The text rendered from the token options. */ public function token($options) { $type = $options['type']; switch ($type) { case 'list_start': $this->wiki->registerRenderCallback(array($this, 'deflist')); return ''; case 'list_end': $this->wiki->popRenderCallback(); return Text_Wiki_Render_Rst_Links::append(); case 'term_end': case 'narr_end': return $this->wiki->delim; case 'term_start': case 'narr_start': default: return ''; } }