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. Metasploit的攻击实例讲解----ms10_046快捷方式图标漏洞

    不多说,直接上干货! 准备工具 1.Kali linux 2016.2(Rolling)系统  IP:  192.168.1.103 2.受害者机子(windows XP系统)   IP: 10.10 ...

  2. SparkCore基础(一)

    * SparkCore基础(一) 学习Spark,首先要熟悉Scala,当然你说你会Python或者Java能不能玩Spark?能!但是不推荐,首推Scala,因为Scala非常便捷,而且Scala有 ...

  3. Django分页和查询参数的问题

    查询是通过get的方式,之前没有分页之前,url是这样的: http://hostname/search?query=port%3A8080 那么我的想法是如果分页了. 1,不带page参数了.nex ...

  4. WinDBG help

    WinDBG is a great, free tool. It is more powerful than Visual Studio's built-in debugger, but is har ...

  5. UI Framework-1: Ash Color Chooser

    Ash Color Chooser Overview This document describes how to achieve <input type=”color”> UI in C ...

  6. JDBC连接ORACLE无法登陆java.sql.SQLException: ORA-01017: invalid username/password; logon denied

    当用jdbc连接Oracle数据库的时候 private Connection getConnection() throws SQLException { OracleDataSource ods = ...

  7. vue+element的表格分页和前端搜索

    1.前端后台管理会存在很多表格,表格数据过多就需要分页;2.前端交互每次搜索如果都请求服务器会加大服务器的压力,所以在数据量不是很大的情况下可以一次性将数据返回,前端做检索3.下面贴上一个demo & ...

  8. POJ3904 Sky Code【容斥原理】

    题目链接: http://poj.org/problem?id=3904 题目大意: 给你N个整数.从这N个数中选择4个数,使得这四个数的公约数为1.求满足条件的 四元组个数. 解题思路: 四个数的公 ...

  9. 每天一个linux命令(九月)

    2014-09-02 top 实时显示系统中各个进程的资源占用状况,类似于Windows的任务管理器 命令參数: -b 批处理 -c 显示完整的治命令 -I 忽略失效过程 -s 保密模式 -S 累积模 ...

  10. 《R实战》读书笔记二

    第一章 R简单介绍 本章概要 1安装R 2理解R语言 3执行R程序 本章所介绍的内容概括例如以下. 一个典型的数据分析步骤如图1所看到的. 图1:典型数据分析步骤 简而言之,现今的数据分析要求我们从多 ...