/** * Track the line number and column in the text. * @param MUNGER_TOKEN $token * @access private */ protected function _update_position($token) { $text = $token->data(); $pos = strpos($text, "\n"); if ($pos !== false) { $last_pos = $pos + 1; while ($pos !== false) { $this->_line_number += 1; $this->_column = 1; $pos = strpos($text, "\n", $last_pos); if ($pos !== false) { $last_pos = $pos + 1; } } $this->_column += strlen($text) - $last_pos; } else { $this->_column += strlen($text); } }
/** * Format the text for the given footnote number. * @param MUNGER $munger The transformation context. * @param MUNGER_TOKEN $token * @param MUNGER_FOOTNOTE_INFO $info * @return string * @access private */ protected function _format_text($munger, $token, $info) { if (!$token->is_start_tag()) { return '</div>'; } return parent::_format_text($munger, $token, $info); }
/** * Convert the given token to the output format. * @param MUNGER $munger The transformation context. * @param MUNGER_TOKEN $token * @return string */ public function transform($munger, $token) { if ($token->is_start_tag()) { return str_repeat('-', $munger->available_width()) . "\n"; } return ''; }
/** * Replace a known tag with its actual content. * @param MUNGER_TOKEN $token * @return string * @access private */ protected function _known_tag_as_text($token) { return $token->data(); }
/** * Convert the given token to the output format. * @param HTML_MUNGER $munger The transformation context. * @param MUNGER_TOKEN $token * @return string */ public function transform($munger, $token) { if ($token->is_start_tag()) { $attributes = $token->attributes(); $this->_level = read_array_index($attributes, 'level'); if (!is_numeric($this->_level)) { $this->_level = $this->default_level; } $builder = $munger->make_tag_builder("h{$this->_level}"); $builder->add_array_attribute('class', $attributes); $builder->add_array_attribute('style', $attributes); return $builder->as_html(); } return "</h{$this->_level}>"; }
/** Transform a token as text. * @param MUNGER_TOKEN $token * @access private */ protected function _transform_as_text($token) { $this->_output .= $token->data(); }