Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: about 2 months ago
JSON representation

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

Awesome Lists containing this project

README

        

# XML + (X)HTML formatter / beautifier

[![Build Status](https://travis-ci.org/Machy8/xhtml-formatter.svg?branch=0.1)](https://travis-ci.org/Machy8/xhtml-formatter)

## Installation
````
composer require machy8/xhtml-formatter
````

## Usage
Compiles this 💩
````HTML

title

````

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);

````