|
@@ -201,12 +201,12 @@ discard block |
|
|
block discarded – undo |
201
|
201
|
$functionalBoxElements = 'dd|dt|frameset|li|tbody|td|tfoot|th|thead|tr|colgroup'; |
202
|
202
|
$usableBoxElements = 'applet|button|del|iframe|ins|map|object|script'; |
203
|
203
|
$imagineBoxElements = 'html|body|head|meta|title|link|script|base|!--'; |
204
|
|
- $allBoxLikeElements = '(?>' . $trueBoxElements . '|' . $functionalBoxElements . '|' . $usableBoxElements . '|' . $imagineBoxElements . ')'; |
|
204
|
+ $allBoxLikeElements = '(?>'.$trueBoxElements.'|'.$functionalBoxElements.'|'.$usableBoxElements.'|'.$imagineBoxElements.')'; |
205
|
205
|
$esteticBoxLikeElements = '(?>html|head|body|meta name|title|div|table|h1|h2|h3|h4|h5|h6|p|form|pre|center|!--)'; |
206
|
206
|
$structureBoxLikeElements = '(?>html|head|body|div|!--)'; |
207
|
207
|
|
208
|
208
|
// split html into it's elements |
209
|
|
- $html_array_temp = preg_split('/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', $html, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
|
209
|
+ $html_array_temp = preg_split('/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', $html, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); |
210
|
210
|
// remove empty lines |
211
|
211
|
$html_array = array(''); |
212
|
212
|
$z = 1; |
|
@@ -233,20 +233,20 @@ discard block |
|
|
block discarded – undo |
233
|
233
|
$newline = TRUE; |
234
|
234
|
} elseif ($this->formatType == 2 && ( // minimalistic line break |
235
|
235
|
# this element has a line break before itself |
236
|
|
- preg_match('/<' . $structureBoxLikeElements . '(.*)>/Usi', $html_array[$x]) || preg_match('/<' . $structureBoxLikeElements . '(.*) \/>/Usi', $html_array[$x]) || # one element before is a element that has a line break after |
237
|
|
- preg_match('/<\/' . $structureBoxLikeElements . '(.*)>/Usi', $html_array[$x - 1]) || substr($html_array[$x - 1], 0, 4) == '<!--' || preg_match('/<' . $structureBoxLikeElements . '(.*) \/>/Usi', $html_array[$x - 1])) |
|
236
|
+ preg_match('/<'.$structureBoxLikeElements.'(.*)>/Usi', $html_array[$x]) || preg_match('/<'.$structureBoxLikeElements.'(.*) \/>/Usi', $html_array[$x]) || # one element before is a element that has a line break after |
|
237
|
+ preg_match('/<\/'.$structureBoxLikeElements.'(.*)>/Usi', $html_array[$x - 1]) || substr($html_array[$x - 1], 0, 4) == '<!--' || preg_match('/<'.$structureBoxLikeElements.'(.*) \/>/Usi', $html_array[$x - 1])) |
238
|
238
|
) { |
239
|
239
|
$newline = TRUE; |
240
|
240
|
} elseif ($this->formatType == 3 && ( // aestetic line break |
241
|
241
|
# this element has a line break before itself |
242
|
|
- preg_match('/<' . $esteticBoxLikeElements . '(.*)>/Usi', $html_array[$x]) || preg_match('/<' . $esteticBoxLikeElements . '(.*) \/>/Usi', $html_array[$x]) || # one element before is a element that has a line break after |
243
|
|
- preg_match('/<\/' . $esteticBoxLikeElements . '(.*)>/Usi', $html_array[$x - 1]) || substr($html_array[$x - 1], 0, 4) == '<!--' || preg_match('/<' . $esteticBoxLikeElements . '(.*) \/>/Usi', $html_array[$x - 1])) |
|
242
|
+ preg_match('/<'.$esteticBoxLikeElements.'(.*)>/Usi', $html_array[$x]) || preg_match('/<'.$esteticBoxLikeElements.'(.*) \/>/Usi', $html_array[$x]) || # one element before is a element that has a line break after |
|
243
|
+ preg_match('/<\/'.$esteticBoxLikeElements.'(.*)>/Usi', $html_array[$x - 1]) || substr($html_array[$x - 1], 0, 4) == '<!--' || preg_match('/<'.$esteticBoxLikeElements.'(.*) \/>/Usi', $html_array[$x - 1])) |
244
|
244
|
) { |
245
|
245
|
$newline = TRUE; |
246
|
246
|
} elseif ($this->formatType >= 4 && ( // logical line break |
247
|
247
|
# this element has a line break before itself |
248
|
|
- preg_match('/<' . $allBoxLikeElements . '(.*)>/Usi', $html_array[$x]) || preg_match('/<' . $allBoxLikeElements . '(.*) \/>/Usi', $html_array[$x]) || # one element before is a element that has a line break after |
249
|
|
- preg_match('/<\/' . $allBoxLikeElements . '(.*)>/Usi', $html_array[$x - 1]) || substr($html_array[$x - 1], 0, 4) == '<!--' || preg_match('/<' . $allBoxLikeElements . '(.*) \/>/Usi', $html_array[$x - 1])) |
|
248
|
+ preg_match('/<'.$allBoxLikeElements.'(.*)>/Usi', $html_array[$x]) || preg_match('/<'.$allBoxLikeElements.'(.*) \/>/Usi', $html_array[$x]) || # one element before is a element that has a line break after |
|
249
|
+ preg_match('/<\/'.$allBoxLikeElements.'(.*)>/Usi', $html_array[$x - 1]) || substr($html_array[$x - 1], 0, 4) == '<!--' || preg_match('/<'.$allBoxLikeElements.'(.*) \/>/Usi', $html_array[$x - 1])) |
250
|
250
|
) { |
251
|
251
|
$newline = TRUE; |
252
|
252
|
} |
|
@@ -299,7 +299,7 @@ discard block |
|
|
block discarded – undo |
299
|
299
|
|
300
|
300
|
// include debug comment at the end |
301
|
301
|
if ($tabs != 0 && $this->debugComment === TRUE) { |
302
|
|
- $html .= '<!--' . $tabs . " open elements found-->\r\n"; |
|
302
|
+ $html .= '<!--'.$tabs." open elements found-->\r\n"; |
303
|
303
|
} |
304
|
304
|
} |
305
|
305
|
|
|
@@ -426,7 +426,7 @@ discard block |
|
|
block discarded – undo |
426
|
426
|
'textarea', |
427
|
427
|
'pre' |
428
|
428
|
); // eventuell auch: span, script, style |
429
|
|
- $peaces = preg_split('#(<(' . implode('|', $splitArray) . ').*>.*</\2>)#Uis', $html, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
429
|
+ $peaces = preg_split('#(<('.implode('|', $splitArray).').*>.*</\2>)#Uis', $html, -1, PREG_SPLIT_DELIM_CAPTURE); |
430
|
430
|
$html = ""; |
431
|
431
|
for ($i = 0; $i < count($peaces); $i++) { |
432
|
432
|
if (($i + 1) % 3 == 0) { |
|
@@ -561,8 +561,8 @@ discard block |
|
|
block discarded – undo |
561
|
561
|
if (!empty($this->headerComment)) { |
562
|
562
|
$html = preg_replace_callback( |
563
|
563
|
'/<meta http-equiv(.*)>/Usi', |
564
|
|
- function ($matches) { |
565
|
|
- return trim($matches[0] . $this->newline . $this->tab . $this->tab . '<!-- ' . $this->headerComment . '-->'); |
|
564
|
+ function($matches) { |
|
565
|
+ return trim($matches[0].$this->newline.$this->tab.$this->tab.'<!-- '.$this->headerComment.'-->'); |
566
|
566
|
}, |
567
|
567
|
$html, |
568
|
568
|
1 |