用 PHP 编写的 HTML/PHP 美化器/格式化程序库 [英] HTML/PHP beautifier/formatter library written in PHP

查看:42
本文介绍了用 PHP 编写的 HTML/PHP 美化器/格式化程序库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找用 PHP 编写的 HTML 美化器.我的唯一目的是对我的程序生成的几个 html/php 文件进行格式化或制表.我不需要检查它是否有效.

I am trying to find a HTML beautifier written in PHP. My sole purpose is to format or tabify few html/php files that are generated by my program. I don't need to check whether it is valid or not.

我尝试查找不同的库,例如 Tidy 等,但我无法决定使用哪个库.鉴于我的目的只是格式化服务器上​​的文件,我不希望检查这些文件的有效性的开销.我需要支持 HTML5 标签,但很多这些库都不支持它们.因此,我唯一要寻找的是能够格式化文件.就像 http://tools.arantius.com/tabifier 但对于可以在服务器端运行的 PHP.

I tried looking up different libraries like Tidy etc. but I couldn't decide which one to use. Given my purpose is just to format the files on the server, I don't want the overhead of checking for the validity of these files. I need to have support for HTML5 tags and a lot of these libraries do not support them. Hence the only thing I am looking for is to be able to format the files.Something exactly like http://tools.arantius.com/tabifier but for PHP which can be run on the server side.

文件是使用 PHP DomDocument 库生成的.我尝试使用

The files are generated using PHP DomDocument libraries. I tried to use

file_doc->formatOutput = TRUE;
file_doc->preserveWhiteSpace = FALSE;
$this->file_doc->saveHTMLFile($this->filepath);

但它不起作用.

这些文件不是完全从头开始生成的.我的程序运行时添加的标签很少,并且数据被发送回服务器,这些标签被附加到文件并保存.

The files are not generated totally from scratch. Few tags are added when my program is run and the data is sent back to the server where these tags get appended to the file and saved.

推荐答案

这个问题很老但是你可以使用 HTML purifierhttp://htmlpurifier.org/它有很多选择,它有一个可以整理 html 代码.

This question is old but you can use HTML purifier http://htmlpurifier.org/ its has many option, it has one to tidy html code.

这篇关于用 PHP 编写的 HTML/PHP 美化器/格式化程序库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆