Lines Matching refs:html

8 function make_attr_value($attr, $html) {  argument
9 return preg_replace("#(<[^>]*\s){$attr}(\s|>|/>)#si","\\1{$attr}=\"{$attr}\"\\2",$html);
16 function process_html($html) { argument
20 if (!preg_match("#{$open}#is",$html)) {
21 $html = "<html>".$html;
28 while (preg_match("#{$open}(.*?){$open}#is", $html)) {
29 $html = preg_replace("#{$open}(.*?){$open}#is", "<html>\\2", $html);
32 if (!preg_match("#{$close}#is", $html)) {
33 $html = $html."</html>";
38 $html = preg_replace("#.*({$open})#is","\\1",$html);
45 $html = preg_replace("#^.*<html#is","<html",$html);
47 $html = preg_replace("#</html\s*>.*$#is","</html>",$html);
49 return $html;
52 function process_head($html) { argument
59 if (!preg_match("#{$open}#is",$html)) {
60 $html = preg_replace("#({$ohtml})(.*)({$obody})#is","\\1<head>\\3</head>\\4",$html);
61 } elseif (!preg_match("#{$close}#is",$html)) {
62 if (preg_match("#{$obody}#is",$html)) {
63 $html = preg_replace("#({$obody})#is","</head>\\1",$html);
65 $html = preg_replace("#({$chtml})#is","</head>\\1",$html);
68 return $html;
71 function process_body($html) { argument
78 if (!preg_match("#{$open}#is",$html)) {
79 if (preg_match("#{$chead}#is",$html)) {
80 $html = preg_replace("#({$chead})#is","\\1<body>",$html);
82 $html = preg_replace("#({$ohtml})#is","\\1<body>",$html);
85 if (!preg_match("#{$close}#is",$html)) {
86 $html = preg_replace("#({$chtml})#is","</body>\\1",$html);
90 $html = preg_replace("#({$chead})(.+)({$open})#is","\\1\\3\\2",$html);
92 $html = preg_replace("#({$close})(.+)({$chtml})#is","\\2\\1\\3",$html);
94 return $html;
98 function fix_tags($html) { argument
104 $html = preg_replace("#\s*/\s*>#is","/>",$html);
106 $html = preg_replace("#<\s*/\s*#is","</",$html);
108 $html = preg_replace("#<\s+#is","<",$html);
110 …match("#(.*?)(<([a-z\d]+)[^>]*/>|<([a-z\d]+)[^>]*(?<!/)>|</([a-z\d]+)[^>]*>)#is",$html,$matches)) {
112 $html = substr($html, strlen($matches[0]));
183 function quote_attrs($html) { argument
184 while (preg_match("!(<[^>]*)\s([^=>]+)=([^'\"\r\n >]+)([\r\n >])!si",$html, $matches)) {
185 … $html = preg_replace("#(<[^>]*)\s([^=>]+)=([^'\"\r\n >]+)([\r\n >])#si","\\1 \\2='\\3'\\4",$html);
187 return $html;
190 function escape_attr_value_entities($html) { argument
191 $html = str_replace("<","&lt;",$html);
192 $html = str_replace(">","&gt;",$html);
195 process_character_references($html);
196 $html = escape_amp($html);
197 return $html;
205 * @param String $html source HTML code
208 function escape_attrs_entities($html) { argument
215 while (preg_match("#^(.*)(<[^>]*)\s([^\s=>]+)=(['\"])([^\\4]*?)\\4(.*)$#si", $html, $matches)) {
219 $html = $matches[6];
222 return $result.$html;
225 function fix_attrs_spaces(&$html) { argument
226 while (preg_match("#(<[^>]*)\s([^\s=>]+)=\"([^\"]*?)\"([^\s])#si", $html)) {
227 … $html = preg_replace("#(<[^>]*)\s([^\s=>]+)=\"([^\"]*?)\"([^\s])#si","\\1 \\2=\"\\3\" \\4",$html);
230 while (preg_match("#(<[^>]*)\s([^\s=>]+)='([^']*?)'([^\s])#si", $html)) {
231 $html = preg_replace("#(<[^>]*)\s([^\s=>]+)='([^']*?)'([^\s])#si","\\1 \\2='\\3' \\4",$html);
313 function fix_attrs($html) { argument
316 while (preg_match("#^(.*?)(<[^/].*?>)#is",$html,$matches)) {
318 $html = substr($html, strlen($matches[0]));
321 return $result.$html;
324 function fix_closing_tags($html) { argument
325 return preg_replace("#</\s*(\w+).*?>#","</\\1>",$html);
328 function process_pagebreak_commands(&$html) { argument
329 $html = preg_replace("#<\?page-break>|<!--NewPage-->#","<pagebreak/>",$html);
332 function xhtml2xhtml($html) { argument
333 process_pagebreak_commands($html);
337 $styles = process_style($html);
341 process_character_references($html);
343 remove_comments($html);
346 $html = lowercase_tags($html);
347 $html = lowercase_closing_tags($html);
350 $html = process_script($html);
352 $html = insert_styles($html, $styles);
354 return $html;
357 function html2xhtml($html) { argument
358 process_pagebreak_commands($html);
362 $html = process_script($html);
366 $styles = process_style($html);
369 process_character_references($html);
371 remove_comments($html);
373 fix_attrs_spaces($html);
374 $html = quote_attrs($html);
375 $html = escape_attrs_entities($html);
377 $html = lowercase_tags($html);
378 $html = lowercase_closing_tags($html);
380 $html = fix_closing_tags($html);
382 $html = close_tag("area",$html);
383 $html = close_tag("base",$html);
384 $html = close_tag("basefont",$html);
385 $html = close_tag("br",$html);
386 $html = close_tag("col",$html);
387 $html = close_tag("embed",$html);
388 $html = close_tag("frame",$html);
389 $html = close_tag("hr",$html);
390 $html = close_tag("img",$html);
391 $html = close_tag("input",$html);
392 $html = close_tag("isindex",$html);
393 $html = close_tag("link",$html);
394 $html = close_tag("meta",$html);
395 $html = close_tag("param",$html);
397 $html = make_attr_value("checked",$html);
398 $html = make_attr_value("compact",$html);
399 $html = make_attr_value("declare",$html);
400 $html = make_attr_value("defer",$html);
401 $html = make_attr_value("disabled",$html);
402 $html = make_attr_value("ismap",$html);
403 $html = make_attr_value("multiple",$html);
404 $html = make_attr_value("nohref",$html);
405 $html = make_attr_value("noresize",$html);
406 $html = make_attr_value("noshade",$html);
407 $html = make_attr_value("nowrap",$html);
408 $html = make_attr_value("readonly",$html);
409 $html = make_attr_value("selected",$html);
411 $html = process_html($html);
412 $html = process_body($html);
414 $html = process_head($html);
415 $html = process_p($html);
417 $html = escape_amp($html);
418 $html = escape_lt($html);
419 $html = escape_gt($html);
421 $html = escape_textarea_content($html);
423 process_tables($html,0);
425 process_lists($html,0);
426 process_deflists($html,0);
427 process_selects($html,0);
429 $html = fix_tags($html);
430 $html = fix_attrs($html);
432 $html = insert_styles($html, $styles);
434 return $html;
437 function escape_textarea_content($html) { argument
438 …preg_match_all('#<textarea(.*)>(.*)<\s*/\s*textarea\s*>#Uis', $html, $matches, PREG_OFFSET_CAPTURE…
451 $html = substr_replace($html, $escaped_content, $match_offset, $match_length);
454 return $html;
457 function lowercase_tags($html) { argument
460 while (preg_match("#^(.*?)(</?)([a-zA-z0-9]+)([\s>])#is",$html,$matches)) {
462 $html = substr($html,strlen($matches[0]));
467 return $result.$html;
470 function lowercase_closing_tags($html) { argument
473 while (preg_match("#^(.*?)(<)([a-zA-z0-9]+)(\s*/\s*>)#is",$html,$matches)) {
475 $html = substr($html,strlen($matches[0]));
480 return $result.$html;