70 $this->_scriptFix =
$config->get(
'Output.CommentScriptContents');
71 $this->_innerHTMLFix =
$config->get(
'Output.FixInnerHTML');
72 $this->_sortAttr =
$config->get(
'Output.SortAttr');
73 $this->_flashCompat =
$config->get(
'Output.FlashCompat');
74 $this->_def =
$config->getHTMLDefinition();
75 $this->_xhtml = $this->_def->doctype->xml;
91 for ($i = 0,
$size = count($tokens); $i <
$size; $i++) {
92 if ($this->_scriptFix && $tokens[$i]->name ===
'script' 104 if (extension_loaded(
'tidy') && $this->config->get(
'Output.TidyFormat')) {
110 'output-xhtml' => $this->_xhtml,
111 'show-body-only' =>
true,
112 'indent-spaces' => 2,
117 $tidy->cleanRepair();
122 if ($this->config->get(
'Core.NormalizeNewlines')) {
123 $nl = $this->config->get(
'Output.Newline');
142 trigger_error(
'Cannot generate HTML from non-HTMLPurifier_Token object', E_USER_WARNING);
147 if ($this->_flashCompat) {
148 if ($token->name ==
"object") {
149 $flash =
new stdclass();
150 $flash->attr = $token->attr;
151 $flash->param =
array();
152 $this->_flashStack[] = $flash;
155 return '<' . $token->name . ($attr ?
' ' :
'') . $attr .
'>';
159 if ($this->_flashCompat) {
160 if ($token->name ==
"object" && !empty($this->_flashStack)) {
164 return $_extra .
'</' . $token->name .
'>';
167 if ($this->_flashCompat && $token->name ==
"param" && !empty($this->_flashStack)) {
168 $this->_flashStack[count($this->_flashStack)-1]->param[$token->attr[
'name']] = $token->attr[
'value'];
171 return '<' . $token->name . ($attr ?
' ' :
'') . $attr .
172 ( $this->_xhtml ?
' /':
'' )
176 return $this->
escape($token->data, ENT_NOQUOTES);
179 return '<!--' . $token->data .
'-->';
199 $data = preg_replace(
'#//\s*$#',
'', $token->data);
200 return '<!--//--><![CDATA[//><!--' .
"\n" . trim(
$data) .
"\n" .
'//--><!]]>';
214 if ($this->_sortAttr) {
215 ksort($assoc_array_of_attributes);
217 foreach ($assoc_array_of_attributes as $key => $value) {
218 if (!$this->_xhtml) {
220 if (strpos($key,
':') !==
false) {
224 if ($element && !empty($this->_def->info[$element]->attr[$key]->minimized)) {
250 if ($this->_innerHTMLFix) {
251 if (strpos($value,
'`') !==
false) {
254 if (strcspn($value,
'"\' <>') === strlen($value)) {
275 public function escape($string, $quote = null)
279 if ($quote === null) {
282 return htmlspecialchars($string, $quote,
'UTF-8');
Concrete end token class.
$_flashCompat
Cache of Output.FlashCompat.
generateFromTokens($tokens)
Generates HTML from an array of tokens.
Generates HTML from tokens.
$_innerHTMLFix
Cache of Output.FixInnerHTML.
generateScriptFromToken($token)
Special case processor for the contents of script tags.
$_scriptFix
:HACK: Whether or not generator should comment the insides of <script> tags.
Concrete start token class.
$_xhtml
Whether or not generator should produce XML output.
$_def
Cache of HTMLDefinition during HTML output to determine whether or not attributes should be minimized...
Add rich text string
The name of the decorator.
__construct($config, $context)
if($is_dev) echo "Review changes write something in WHATSNEW and and then commit with log PHP_EOL
generateAttributes($assoc_array_of_attributes, $element='')
Generates attribute declarations from attribute array.
Create styles array
The data for the language used.
Abstract base token class that all others inherit from.
Concrete empty token class.
$config
Configuration for the generator HTMLPurifier_Config.
escape($string, $quote=null)
Escapes raw text data.
Concrete text token class.
$_sortAttr
Cache of Output.SortAttr.
generateFromToken($token)
Generates HTML from a single token.
$_flashStack
Stack for keeping track of object information when outputting IE compatibility code.