定制 machy8/xhtml-formatter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

machy8/xhtml-formatter

最新稳定版本:v1.0.0

Composer 安装命令:

composer require machy8/xhtml-formatter

包简介

Simple, lightweight, customizable (X)HTML and XML formatter / beautifier.

README 文档

README

Build Status

Installation

composer require machy8/xhtml-formatter

Usage

Compiles this 💩

<!DOCTYPE html>
<html lang="en">
    <head><meta charset="utf-8"><title>title</title>
    <link rel="stylesheet" href="style.css">
<script src="script.js"></script></head><body><!-- page content --></body></html>

into this 😱😭

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<title>
			title
		</title>
		<link rel="stylesheet" href="style.css">
		<script src="script.js"></script>
	</head>
	<body>
		<!-- page content -->
	</body>
</html>

and all you need is

use XhtmlFormatter\Formatter;

$formatter = new Formatter();

$output = $formatter->format($string);

and if you want to disable formatting

<div>
	<formatter-off>
		<p>
			<b>Unformatted code goes <u>here</u></b>!
		</p>
	</formatter-off>
</div>

Setup

$formatter

	// Change the content type from CONTENT_HTML (default) to CONTENT_XML or CONTENT_XHTML
	->setContentType(Formatter::CONTENT_XML)

	// Add new unpaired element
	->addUnpairedElement('element', Formatter::CONTENT_XML)

	// Add skipped elements
	->addSkippedElement('elementA elementB')

	// Indent file by 4 spaces instead of tabs
	->setSpacesIndentationMethod(4);

统计信息

  • 总下载量: 172.88k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 13
  • 点击次数: 1
  • 依赖项目数: 6
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: New
  • 更新时间: 2017-05-30