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

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

  1. # HTML 格式化
  2. function beautify_html($html){
  3. $tidy_config = array(
  4. 'clean' => false,
  5. 'indent' => true,
  6. 'indent-spaces' => 4,
  7. 'output-xhtml' => false,
  8. 'show-body-only' => false,
  9. 'wrap' => 0
  10. );
  11. if(function_exists('tidy_parse_string')){
  12. $tidy = tidy_parse_string($html, $tidy_config, 'utf8');
  13. $tidy -> cleanRepair();
  14. return $tidy;
  15. }
  16. else return $html;
  17. }
  18.  
  19. # Install libtidy (needed for tidy2.0 compile)
  20. apt-get -y install libtidy-0.99-0
  21.  
  22. # Install GNU tools for compiling
  23. apt-get -y install build-essential
  24.  
  25. apt-get -y install libtidy-dev
  26.  
  27. # Download tidy2.0 source (this can also be found in the PHP5 sourcecode, I just tarred it up to make this easier)
  28. wget -c http://support.office-shadow.com/installer/tidy2.0.tar.gz
  29.  
  30. # Unpack the source
  31. tar xvzf tidy2.0.tar.gz
  32.  
  33. # Configure tidy for installed php5 API
  34. cd tidy
  35. phpize
  36.  
  37. # Configure & Compile the source
  38. ./configure
  39. make clean <-- Without this the compile builds a bad module for some reason
  40. make
  41. make install
  42.  
  43. # Install module into php.ini
  44. echo "extension=tidy.so" >> /etc/php5/apache2/php.ini;
  45. 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. android页面布局(listview填充中间)

    <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android=&q ...

  2. VS导出方法名和方法备注的方法

    VS导出方法名和方法备注的方法 方法一: 只能导出图片格式的UML 类图 1.点击查看类图 2.在空白处点击讲关系导出为图像 方法二: 是把整个类库的方法名都罗列出来 这个方便整理一些 具体方法如下 ...

  3. MyBatis+mysql查询和添加数据

    项目结构: Menu package com.mstf.dao; import java.util.Scanner; import org.apache.ibatis.session.SqlSessi ...

  4. PostgreSQL备份与还原

    物理备份:整个数据库的数据目录及文件做备份:备份整个数据库的文件系统. 物理恢复:恢复整个数据库的文静系统. 物理备份方法: 开启归档 select pg_start_backup('backup—— ...

  5. Monad的基本运算

    A monad is created by defining a type constructor M and two operations, bind and return (where retur ...

  6. vue下载模板、导出excle

    1.下载模板是 下载模版比较简单,就是跳一个新的页面 2.导出excle 就是get请求,把自己要导出的参数一一拼接起来 }

  7. js实现简易打点计时器

    很简单的实现一个打点计时器,规定从start至end,每次加1,每次打印间隔100ms,并且返回取消方法. 代码如下: //打点计时器,每间隔100毫秒+1 function count(start, ...

  8. [POI2009]KON-Ticket Inspector(二维前缀和+DP)

    题意 有n个车站,现在有一辆火车从1到n驶过,给出aij代表从i站上车j站下车的人的个数.列车行驶过程中你有K次检票机会,所有当前在车上的人会被检票,问最多能检多少个不同的人的票 (n<=600 ...

  9. spring-data-jpa 新增 修改 删除 查询 分页

      1.查询所有数据 findAll() 2.分页查询 findAll(new PageRequest(0, 2)) 3.根据id查询 findOne() 4.根据实体类属性查询: findByPro ...

  10. dstat---统计磁盘,CPU,IO,等相关信息

    dstat命令是一个用来替换vmstat.iostat.netstat.nfsstat和ifstat这些命令的工具,是一个全能系统信息统计工具.与sysstat相比,dstat拥有一个彩色的界面,在手 ...