/** * Validate the token against this tag's rules. * @param MUNGER_VALIDATOR $validator * @param MUNGER_TOKEN $token */ public function validate($validator, $token) { $attrs = $token->attributes(); foreach (array_keys($attrs) as $key) { if (!isset($this->properties[strtolower($key)])) { $validator->add_error('Invalid attribute [' . $key . '] for [' . $token->name() . ']', $token); } } }
/** * Read the quote style from a token. * @param boolean $value * @param MUNGER_TOKEN $token Token that caused the activation. * @return string * @access private */ protected function _quote_style_from_token($value, $token) { $Result = ''; if ($value) { $attributes = $token->attributes(); $Result = read_array_index($attributes, 'quote-style'); if (!$Result) { // Support the legacy attribute form, so that older articles still format as expected $Result = read_array_index($attributes, 'quote_style'); if (!$Result) { $Result = $this->default_quote_style; } } } return $Result; }
/** * 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()) { $attrs = $token->attributes(); $this->_title = read_array_index($attrs, 'title'); if ($this->_title) { $border = str_repeat('-', strlen($this->_title) + 4); return "{$border}\n| {$this->_title} |\n{$border}\n\n"; } } else { if ($this->_title) { return "\n" . str_repeat('-', strlen($this->_title) + 4); } } return ''; }
/** * 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}>"; }