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. Laravel-自定全局函数

    Laravel-自定全局函数 标签(空格分隔): php 习惯了 使用 ThinkPHP 框架,有一个公共方法类在代码编写上会快捷很多,所以有必要在此进行配置一番. 实现 在 app 创建文件夹 He ...

  2. POJ 3667 线段树+标记

    自从某次考试写线段树写挂了以后 这是第一次写线段树,,,,,, 这是一个伤心的故事-- 题意: 思路: 标记 维护从左到右的最大值 从右到左的最大值 区间内的最大值-- 然后就一搞 就出来了 //By ...

  3. sql server 中查询数据库下有多少张表以及同义词等信息

    --查询数据库有多少张表SELECT count(0) from sysobjects where xtype = 'u' 复制代码 解释:sysobjects系统对象表. 保存当前数据库的对象.如约 ...

  4. centeros安装jdk

    准备工作: java se下载网址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.ht ...

  5. python 异步IO-aiohttp与简单的异步HTTP客户端/服务器

    参考链接:https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/00143209814 ...

  6. 极速响应Excel数据报表请求的一种方法

    摘要 通过缓存和维护Excel Workbook实例,极速响应Excel数据报表请求. 这是一个真实的大数据"云计算"项目中的解决方案,在给定的时间和资源下,只有这种方法是最简单并 ...

  7. Unity Shader (三)Surface Shader机制

    转自:http://blog.csdn.net/candycat1992/article/details/39994049 写在前面 一直以来,Unity Surface Shader背后的机制一直是 ...

  8. Spring Cloud学习笔记【五】Hystrix Dashboard监控面板

    ystrix除了隔离依赖服务的调用以外,Hystrix 还提供了准实时的调用监控(Hystrix Dashboard),Hystrix 会持续地记录所有通过 Hystrix 发起的请求的执行信息,并以 ...

  9. Highcharts图表插件的简单使用说明

    Highcharts图表控件是眼下使用最为广泛的图表控件.本文将从零開始逐步为你介绍Highcharts图表控件. 通过本文.你将学会怎样配置Highcharts以及动态生成Highchart图表. ...

  10. DataTable转成Json

    /// <summary>         /// DataTable转成Json /// </summary>         /// <param name=&quo ...