{"id":19559362,"url":"https://github.com/machy8/xhtml-formatter","last_synced_at":"2025-07-22T17:36:45.683Z","repository":{"id":62521473,"uuid":"92856455","full_name":"Machy8/xhtml-formatter","owner":"Machy8","description":"⚒ Simple, lightweight, customizable (X)HTML and XML formatter / beautifier","archived":false,"fork":false,"pushed_at":"2018-02-01T20:21:48.000Z","size":39,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-19T08:24:58.524Z","etag":null,"topics":["beautifier","formatter","html","xhtml","xml"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Machy8.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-30T17:01:45.000Z","updated_at":"2023-03-12T10:16:10.000Z","dependencies_parsed_at":"2022-11-02T10:31:17.840Z","dependency_job_id":null,"html_url":"https://github.com/Machy8/xhtml-formatter","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Machy8/xhtml-formatter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Machy8%2Fxhtml-formatter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Machy8%2Fxhtml-formatter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Machy8%2Fxhtml-formatter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Machy8%2Fxhtml-formatter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Machy8","download_url":"https://codeload.github.com/Machy8/xhtml-formatter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Machy8%2Fxhtml-formatter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266540914,"owners_count":23945320,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["beautifier","formatter","html","xhtml","xml"],"created_at":"2024-11-11T05:00:23.343Z","updated_at":"2025-07-22T17:36:45.616Z","avatar_url":"https://github.com/Machy8.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# XML + (X)HTML formatter / beautifier\r\n\r\n[![Build Status](https://travis-ci.org/Machy8/xhtml-formatter.svg?branch=0.1)](https://travis-ci.org/Machy8/xhtml-formatter)\r\n\r\n## Installation\r\n````\r\ncomposer require machy8/xhtml-formatter\r\n````\r\n\r\n## Usage\r\nCompiles this 💩\r\n````HTML\r\n\u003c!DOCTYPE html\u003e\r\n\u003chtml lang=\"en\"\u003e\r\n    \u003chead\u003e\u003cmeta charset=\"utf-8\"\u003e\u003ctitle\u003etitle\u003c/title\u003e\r\n    \u003clink rel=\"stylesheet\" href=\"style.css\"\u003e\r\n\u003cscript src=\"script.js\"\u003e\u003c/script\u003e\u003c/head\u003e\u003cbody\u003e\u003c!-- page content --\u003e\u003c/body\u003e\u003c/html\u003e\r\n````\r\n\r\ninto this 😱😭\r\n````HTML\r\n\u003c!DOCTYPE html\u003e\r\n\u003chtml lang=\"en\"\u003e\r\n\t\u003chead\u003e\r\n\t\t\u003cmeta charset=\"utf-8\"\u003e\r\n\t\t\u003ctitle\u003e\r\n\t\t\ttitle\r\n\t\t\u003c/title\u003e\r\n\t\t\u003clink rel=\"stylesheet\" href=\"style.css\"\u003e\r\n\t\t\u003cscript src=\"script.js\"\u003e\u003c/script\u003e\r\n\t\u003c/head\u003e\r\n\t\u003cbody\u003e\r\n\t\t\u003c!-- page content --\u003e\r\n\t\u003c/body\u003e\r\n\u003c/html\u003e\r\n````\r\n\r\nand all you need is\r\n````PHP\r\nuse XhtmlFormatter\\Formatter;\r\n\r\n$formatter = new Formatter();\r\n\r\n$output = $formatter-\u003eformat($string);\r\n````\r\n\r\nand if you want to disable formatting\r\n````HTML\r\n\r\n\u003cdiv\u003e\r\n\t\u003cformatter-off\u003e\r\n\t\t\u003cp\u003e\r\n\t\t\t\u003cb\u003eUnformatted code goes \u003cu\u003ehere\u003c/u\u003e\u003c/b\u003e!\r\n\t\t\u003c/p\u003e\r\n\t\u003c/formatter-off\u003e\r\n\u003c/div\u003e\r\n\r\n````\r\n\r\n## Setup\r\n\r\n````PHP\r\n$formatter\r\n\r\n\t// Change the content type from CONTENT_HTML (default) to CONTENT_XML or CONTENT_XHTML\r\n\t-\u003esetContentType(Formatter::CONTENT_XML)\r\n\r\n\t// Add new unpaired element\r\n\t-\u003eaddUnpairedElement('element', Formatter::CONTENT_XML)\r\n\r\n\t// Add skipped elements\r\n\t-\u003eaddSkippedElement('elementA elementB')\r\n\r\n\t// Indent file by 4 spaces instead of tabs\r\n\t-\u003esetSpacesIndentationMethod(4);\r\n\r\n````\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmachy8%2Fxhtml-formatter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmachy8%2Fxhtml-formatter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmachy8%2Fxhtml-formatter/lists"}