https://github.com/machy8/xhtml-formatter
⚒ Simple, lightweight, customizable (X)HTML and XML formatter / beautifier
https://github.com/machy8/xhtml-formatter
beautifier formatter html xhtml xml
Last synced: 17 days ago
JSON representation
⚒ Simple, lightweight, customizable (X)HTML and XML formatter / beautifier
- Host: GitHub
- URL: https://github.com/machy8/xhtml-formatter
- Owner: Machy8
- License: bsd-3-clause
- Created: 2017-05-30T17:01:45.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-01T20:21:48.000Z (over 7 years ago)
- Last Synced: 2025-06-27T10:07:22.928Z (17 days ago)
- Topics: beautifier, formatter, html, xhtml, xml
- Language: PHP
- Homepage:
- Size: 38.1 KB
- Stars: 10
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license.md
Awesome Lists containing this project
README
# XML + (X)HTML formatter / beautifier
[](https://travis-ci.org/Machy8/xhtml-formatter)
## Installation
````
composer require machy8/xhtml-formatter
````## Usage
Compiles this 💩
````HTMLtitle
````
into this 😱😭
````HTML
title
````
and all you need is
````PHP
use XhtmlFormatter\Formatter;$formatter = new Formatter();
$output = $formatter->format($string);
````and if you want to disable formatting
````HTML
Unformatted code goes here!
````
## Setup
````PHP
$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);````