-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.php
More file actions
executable file
·38 lines (36 loc) · 1.08 KB
/
example.php
File metadata and controls
executable file
·38 lines (36 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
# HTML 格式化
function beautify_html($html){
$tidy_config = array(
'clean' => false,
'indent' => true,
'indent-spaces' => 4,
'output-xhtml' => false,
'show-body-only' => false,
'wrap' => 0
);
if(function_exists('tidy_parse_string')){
$tidy = tidy_parse_string($html, $tidy_config, 'utf8');
$tidy -> cleanRepair();
return $tidy;
}else{
require_once('./beautify-html.php');
// Set the beautify options
$beautify = true;
if($shouldBeautify = true) {
$beautify = new Beautify_Html(array(
'indent_inner_html' => false,
'indent_char' => " ",
'indent_size' => 4,
'wrap_line_length' => 32786,
'unformatted' => ['code', 'pre'],
'preserve_newlines' => false,
'max_preserve_newlines' => 32786,
'indent_scripts' => 'normal' // keep|separate|normal
));
}
//$beautify = new Beautify_Html;
$html = $beautify->beautify($html);
return $html;
}
}