function finalize() { // get parent's output parent::finalize(); $output = parent::getOutput(); $tex_output = ''; foreach ($output as $token) { if ($this->_enumerated) { $class = $token[0]; $content = $token[1]; } else { $key = key($token); $class = $key; $content = $token[$key]; } $iswhitespace = ctype_space($content); if (!$iswhitespace) { if ($class === 'special') { $class = 'code'; } $tex_output .= sprintf('\\textcolor{%s}{%s}', $class, $this->escape($content)); } else { $tex_output .= $content; } } $this->_output = "\\begin{alltt}\n" . $tex_output . "\\end{alltt}"; }
/** * Signals that no more tokens are available * * @abstract * @access public */ function finalize() { // call parent's finalize(), then serialize array into XML parent::finalize(); $output = parent::getOutput(); $serializer = new XML_Serializer($this->_serializer_options); $result = $serializer->serialize($output); if ($result === true) { $this->_output = $serializer->getSerializedData(); } }
/** * Signals that no more tokens are available * * @abstract * @access public */ function finalize() { parent::finalize(); $output = parent::getOutput(); $json_array = array(); foreach ($output as $token) { if ($this->_enumerated) { $json_array[] = '["' . $token[0] . '","' . $token[1] . '"]'; } else { $key = key($token); $json_array[] = '{"class": "' . $key . '","content":"' . $token[$key] . '"}'; } } $this->_output = '[' . implode(',', $json_array) . ']'; $this->_output = str_replace("\n", '\\n', $this->_output); }
/** * Signals that no more tokens are available * * @abstract * @access public * */ function finalize() { // get parent's output parent::finalize(); $output = parent::getOutput(); $html_output = ''; // loop through each class=>content pair foreach ($output as $token) { if ($this->_enumerated) { $class = $token[0]; $content = $token[1]; } else { $key = key($token); $class = $key; $content = $token[$key]; } $iswhitespace = ctype_space($content); if (!$iswhitespace && !empty($this->_hilite_tags[$class])) { $html_output .= '<' . $this->_hilite_tags[$class] . '>' . $content . '</' . $this->_hilite_tags[$class] . '>'; } else { $html_output .= $content; } } if ($this->_numbers) { /* additional whitespace for browsers that do not display empty list items correctly */ $html_output = '<li> ' . str_replace("\n", "</li>\n<li> ", $html_output) . '</li>'; $this->_output = '<ol>' . str_replace(' ', ' ', $html_output) . '</ol>'; } else { $this->_output = '<pre>' . $html_output . '</pre>'; } }
/** * Signals that no more tokens are available * * @abstract * @access public * */ function finalize() { // get parent's output parent::finalize(); $output = parent::getOutput(); $bb_output = ''; $color_start = $this->_tag_brackets['start'] . $this->_bb_tags['color'] . '=%s' . $this->_tag_brackets['end']; $color_end = $this->_tag_brackets['start'] . '/' . $this->_bb_tags['color'] . $this->_tag_brackets['end']; // loop through each class=>content pair foreach ($output as $token) { if ($this->_enumerated) { $class = $token[0]; $content = $token[1]; } else { $key = key($token); $class = $key; $content = $token[$key]; } $iswhitespace = ctype_space($content); if (!$iswhitespace && !empty($this->_colors[$class])) { $bb_output .= sprintf($color_start, $this->_colors[$class]); $bb_output .= $content; $bb_output .= $color_end; } else { $bb_output .= $content; } } if ($this->_numbers) { $item_tag = $this->_tag_brackets['start'] . $this->_bb_tags['list_item'] . $this->_tag_brackets['end']; $this->_output = $item_tag . str_replace("\n", "\n" . $item_tag . ' ', $bb_output); $this->_output = $this->_tag_brackets['start'] . $this->_bb_tags['list'] . $this->_tag_brackets['end'] . $this->_output . $this->_tag_brackets['start'] . '/' . $this->_bb_tags['list'] . $this->_tag_brackets['end']; } else { $this->_output = $this->_tag_brackets['start'] . $this->_bb_tags['code'] . $this->_tag_brackets['end'] . $bb_output . $this->_tag_brackets['start'] . '/' . $this->_bb_tags['code'] . $this->_tag_brackets['end']; } }
/** * Signals that no more tokens are available * * @access public */ function finalize() { // get parent's output parent::finalize(); $output = parent::getOutput(); if (empty($output)) { return; } $html_output = ''; $numbers_li = false; if ($this->_numbers == HL_NUMBERS_LI || $this->_numbers == HL_NUMBERS_UL || $this->_numbers == HL_NUMBERS_OL) { $numbers_li = true; } // loop through each class=>content pair foreach ($output as $token) { if ($this->_enumerated) { $key = false; $the_class = $token[0]; $content = $token[1]; } else { $key = key($token); $the_class = $key; $content = $token[$key]; } $span = $this->_getStyling($the_class); $decorated_output = $this->_decorate($content, $key); //print "<pre> token = ".var_export($token, true)." -- span = " . htmlentities($span). "-- deco = ".$decorated_output."</pre>\n"; $html_output .= sprintf($span, $decorated_output); } // format lists if (!empty($this->_numbers) && $numbers_li == true) { //$html_output = "<pre>".$html_output."</pre>"; // additional whitespace for browsers that do not display // empty list items correctly $this->_output = '<li><pre> ' . str_replace("\n", "</pre></li>\n<li><pre> ", $html_output) . '</pre></li>'; $start = ''; if ($this->_numbers == HL_NUMBERS_OL && intval($this->_numbers_start) > 0) { $start = ' start="' . $this->_numbers_start . '"'; } $list_tag = 'ol'; if ($this->_numbers == HL_NUMBERS_UL) { $list_tag = 'ul'; } $this->_output = '<' . $list_tag . $start . ' ' . $this->_getStyling('main', false) . '>' . $this->_output . '</' . $list_tag . '>'; // render a table } else { if ($this->_numbers == HL_NUMBERS_TABLE) { $start_number = 0; if (intval($this->_numbers_start)) { $start_number = $this->_numbers_start - 1; } $numbers = ''; $nlines = substr_count($html_output, "\n") + 1; for ($i = 1; $i <= $nlines; $i++) { $numbers .= $start_number + $i . "\n"; } $this->_output = '<table ' . $this->_getStyling('table', false) . ' width="100%"><tr>' . '<td ' . $this->_getStyling('gutter', false) . ' align="right" valign="top">' . '<pre>' . $numbers . '</pre></td><td ' . $this->_getStyling('main', false) . ' valign="top"><pre>' . $html_output . '</pre></td></tr></table>'; } } if (!$this->_numbers) { $this->_output = '<pre>' . $html_output . '</pre>'; } $this->_output = '<div ' . $this->_getStyling('main', false) . '>' . $this->_output . '</div>'; }