php 内置的 html 格式化/美化tidy函数

https://github.com/htacg/tidy-html5

# 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 return $html;
}

# Install libtidy (needed for tidy2.0 compile)
apt-get -y install libtidy-0.99-0

# Install GNU tools for compiling
apt-get -y install build-essential

apt-get -y install libtidy-dev

# Download tidy2.0 source (this can also be found in the PHP5 sourcecode, I just tarred it up to make this easier)
wget -c http://support.office-shadow.com/installer/tidy2.0.tar.gz

# Unpack the source
tar xvzf tidy2.0.tar.gz

# Configure tidy for installed php5 API
cd tidy
phpize 

# Configure & Compile the source
./configure
make clean    <-- Without this the compile builds a bad module for some reason
make
make install

# Install module into php.ini
echo "extension=tidy.so" >> /etc/php5/apache2/php.ini;
see: http://ubuntuforums.org/showthread.php?t=195636&highlight=php5+tidy

php 内置的 html 格式化/美化tidy函数 -- 让你的HTML更美观的更多相关文章

  1. python内置函数,匿名函数

    一.匿名函数 匿名函数:为了解决那些功能很简单的需求而设计的一句话函数 def calc(n): return n**n print(calc(10)) #换成匿名函数 calc = lambda n ...

  2. python成长之路八 -- 内置函数

    1,python内置函数     内置函数     abs() dict() help() min() setattr() all()  dir()  hex() next()  slice()  a ...

  3. python - format函数 /class内置format方法

    format函数 # format函数 # 用于字符串格式化 # 基本用法: # 方式一:(位置方式) x = "{0}{1}{2}".format(1,2,3) print('1 ...

  4. 2019-03-18-day013-装饰器与内置函数

    上周回顾 函数: def 函数名(): 缩进 函数体 闭包: a = 50 def func(): a = 10 def avg(): print(a) 函数名的使用: 当做值被赋值给变量 当做返回值 ...

  5. Python3中的内置函数

    内置函数 我们一起来看看python里的内置函数.什么是内置函数?就是Python给你提供的,拿来直接用的函数,比如print,input等等.截止到python版本3.6.2,现在python一共为 ...

  6. beetl的内置函数 (如strutil 工具类)

    转自:http://ibeetl.com/guide/ 2.19. 函数调用 Beetl内置函数请参考附录,以下列出了常用的函数 date 返回一个java.util.Date类型的变量,如 date ...

  7. 总结day13 ----内置函数

    内置函数 我们一起来看看python里的内置函数.什么是内置函数?就是Python给你提供的,拿来直接用的函数,比如print,input等等.截止到python版本3.6.2,现在python一共为 ...

  8. python 基础篇 15 内置函数和匿名函数

    ------------------------>>>>>>>>>>>>>>>内置函数<<< ...

  9. Python笔记_第四篇_高阶编程_再议装饰器和再议内置函数

    1. 概述: 我们在前面用了很多的装饰器这个工具的方法.这个位置要系统的讲一下装饰器. 1.2 为什么需要装饰器. 装饰器本质是一个Python函数,它可以让其他函数在不需要任何代码变动的前提下增加额 ...

随机推荐

  1. 31.ng-init 指令初始化 AngularJS 应用程序变量。

    转自:https://www.cnblogs.com/best/tag/Angular/ 1. <html> <head> <meta charset="utf ...

  2. rsync同步操作命令

    在本地磁盘同步数据 将/home做个备份 # rsync -a --delete /home /backups -a 归档模式,表示以递归方式传输文件, -delete 删除那些接收端还有而发送端已经 ...

  3. 使用regasm注册.net com组件出现不是有效的.net程序集的解决办法

    作者:朱金灿 来源:http://blog.csdn.net/clever101 在电脑上装有VS 2008和VS 2010.使用VS 2010编写了一个C# com组件:MyCom(基于.net f ...

  4. c# static 常量

    1 关键字 static 修饰 类  字段 属性 方法 ,标记static的就不用创建类的实例调用了,直接通过类名点出来 2 用于变量前,表示每次重新使用该变量所在的方法,类或者自定义的类时,变量的值 ...

  5. WLAN STA/AP 并发

    WLAN STA/AP 并发 Android 9 引入了可让设备同时在 STA 和 AP 模式下运行的功能.对于支持双频并发 (DBS) 的设备,此功能让一些新功能得以实现,例如在用户想要启用热点 ( ...

  6. [APIO2014]回文串 后缀自动机_Manancher_倍增

    Code: // luogu-judger-enable-o2 #include <cstdio> #include <algorithm> #include <cstr ...

  7. 洛谷 P2147 [SDOI2008]洞穴勘测 LCT

    Code: #include <cstdio> #include <algorithm> #include <string> #include <cstrin ...

  8. 负载均衡集群总结(Haproxy)

    环境:Centos 6.9,Mysql 8.0 首先要先配置mysql主从复制集,可以参考我的上一篇>>Mysql 主从复制总结(详细) 我的主节点在(master):192.168.11 ...

  9. 学习Go语言之模板方法模式

    模板方法模式结构图如下.原理是过程实现不一样,但是执行的顺序是按照模板固定好了的.即简单理解为都有1,2,3步骤,但是每一步的实现交由具体实现类不同实现. 1.过程式编程 // 模板方法模式 pack ...

  10. Object-C,NumberDemo和StringDemo

    晚上抽空写了2个Demo.第1个是演示字符串,第2个是演示数组和可变数组.只用到了几个基本的方法和基本语句. NSString字符串对象,NSNumber和NSMutableNumber,if语句,N ...