{"id":24983710,"url":"https://github.com/posthtml/posthtml-beautify","last_synced_at":"2025-04-19T16:40:07.919Z","repository":{"id":3798471,"uuid":"50932605","full_name":"posthtml/posthtml-beautify","owner":"posthtml","description":"A posthtml plugin to beautify you html files. Online service - ","archived":false,"fork":false,"pushed_at":"2023-03-06T20:51:51.000Z","size":9494,"stargazers_count":28,"open_issues_count":32,"forks_count":9,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-29T21:06:03.978Z","etag":null,"topics":["beautify","code-quality","html","posthtml","posthtml-plugins"],"latest_commit_sha":null,"homepage":"https://posthtml.github.io/posthtml-beautify/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/posthtml.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-02-02T16:04:00.000Z","updated_at":"2023-10-23T14:44:08.000Z","dependencies_parsed_at":"2023-07-05T21:32:38.763Z","dependency_job_id":null,"html_url":"https://github.com/posthtml/posthtml-beautify","commit_stats":{"total_commits":379,"total_committers":10,"mean_commits":37.9,"dds":0.7335092348284961,"last_synced_commit":"0d349e522e2a28424abfd559975a7c83b75b4f11"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-beautify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-beautify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-beautify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-beautify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/posthtml","download_url":"https://codeload.github.com/posthtml/posthtml-beautify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245489786,"owners_count":20623795,"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","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":["beautify","code-quality","html","posthtml","posthtml-plugins"],"created_at":"2025-02-04T09:20:34.239Z","updated_at":"2025-03-29T10:12:56.509Z","avatar_url":"https://github.com/posthtml.png","language":"HTML","readme":"# posthtml-beautify\n\n\u003e A [posthtml](https://github.com/posthtml) plugin to beautify you html files\n\n[![Travis Build Status](https://img.shields.io/travis/posthtml/posthtml-beautify/master.svg?style=flat-square\u0026label=unix)](https://travis-ci.org/posthtml/posthtml-beautify)[![node](https://img.shields.io/node/v/post-sequence.svg?maxAge=2592000\u0026style=flat-square)]()[![npm version](https://img.shields.io/npm/v/posthtml-beautify.svg?style=flat-square)](https://www.npmjs.com/package/posthtml-beautify)[![Dependency Status](https://david-dm.org/gitscrum/posthtml-beautify.svg?style=flat-square)](https://david-dm.org/gitscrum/posthtml-beautify)[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg?style=flat-square)](https://github.com/sindresorhus/xo)[![Coveralls status](https://img.shields.io/coveralls/posthtml/posthtml-beautify.svg?style=flat-square)](https://coveralls.io/r/posthtml/posthtml-beautify)\n\n[![npm downloads](https://img.shields.io/npm/dm/posthtml-beautify.svg?style=flat-square)](https://www.npmjs.com/package/posthtml-beautify)[![npm](https://img.shields.io/npm/dt/posthtml-beautify.svg?style=flat-square)](https://www.npmjs.com/package/posthtml-beautify)[![Package Quality](http://npm.packagequality.com/shield/posthtml-beautify.svg?style=flat-square)](http://packagequality.com/#?package=posthtml-beautify)\n\n## Why?\nFormat your html and inline css markup according to the [HTML5 syntax Style Guide](http://www.w3schools.com/html/html5_syntax.asp), [Code Guide](http://codeguide.co/#html). Full list of supported options:\n- [x] Transform lower case element names\n- [x] Transform lower case attribute names\n- [x] Only double quotes\n- [x] Close all html elements \n- [x] Removing trailing slash in self-closing \n- [x] Removes spaces at the equal sign\n- [x] Add blank lines to separate large or logical code blocks\n- [x] Add 2 spaces of indentation. *Do not use TAB*.\n- [x] Add language attribute\n- [ ] Add character encoding\n- [x] Attribute order\n- [x] Boolean attributes\n- [ ] Creates file from the inline styles\n- [ ] Create scoped class name (*use css-modules*) instead inline styles\n- [ ] validate elements and attributes name\n- [x] parses Internet Explorer Conditional Comments (*not support Downlevel-revealed and valid version, [htmlparse2 invalid parses](https://github.com/posthtml/posthtml-beautify/issues/36)*)\n\n## Install\n\n```bash\nnpm i -S posthtml posthtml-beautify\n```\n\n\u003e **Note:** This project is compatible with node v10+\n\n## Usage\n\n```js\nimport {readFileSync, writeFileSync} from 'fs';\nimport posthtml from 'posthtml';\nimport beautify from 'posthtml-beautify';\n\nconst html = readFileSync('input.html', 'utf8');\n\nposthtml()\n  .use(beautify({rules: {indent: 4}}))\n  .process(html)\n  .then(result =\u003e {\n    writeFileSync('output.html', result.html);\n  });\n\n```\n*Returns html-formatted according to rules based on the use [HTML5 syntax Style Guide](http://www.w3schools.com/html/html5_syntax.asp), [Code Guide](http://codeguide.co/#html) with custom settings `indent: 4`*\n\n## [Example](https://posthtml.github.io/posthtml-beautify/)\n\n## Options\n\n### `rules`\nType: `Object`  \nDefault:\n\n  - **Indent**  \n  Type: `Number|String(only tab)`  \n  Default: 2  \n  Description: *A numeric value indicates specifies the number of spaces. The string value only `tab`*\n\n  - **blankLines**  \n  Type: `String|Boolean(only false)`  \n  Default: '\\n'  \n  Description: *Add or remove blank lines to separate large or logical code blocks*\n\n  - **eol** (*end of line*)  \n  Type: `String`  \n  Default: '\\n'  \n  Description: *As value is a string symbol which is added to the end of the row*\n\n  - **eof** (*end of file*)  \n  Type: `String|Boolean`  \n  Default: '\\n'  \n  Description: *As value is a string symbol which is added to the end of the file and will not adds if you specify a boolean value of `false`*\n\n  - **maxlen**  \n  Type: `Number`  \n  Default: '80'  \n  Description: *checks for the max length of the content, indents the whole content to a new line*\n\n  - **sortAttr**  \n  Type: `Boolean`  \n  Default: false  \n  Description: *Sort the order of attributes in elements*\n\n  - **lang**  \n  Type: `String | Boolean(only false)`  \n  Default: false  \n  Description: *Add a `lang` attribute in elements, eg: `{ lang: 'fr' }`*\n\n  - **commentFormat**  \n  Type: `Boolean`  \n  Default: true  \n  Description: Formats the comments. It does the following \n    - If there are multi line comments then there would be \n      leading and trailing newline like this \n\n      ```html\n      // Input\n\n      \u003c!-- multiline \n      comments--\u003e\n\n      // Output\n\n      \u003c!-- \n      multiline \n      comments\n      --\u003e\n      ``` \n    - If there is a single line comment, it would make it to a single line with the comment starting and ending\n      notation in same line\n\n      Input\n      ```\n      \u003c!-- \n        singleline comments\n      --\u003e\n      ```\n\n      Output\n\n      `\u003c!-- singleline comments --\u003e`\n\n\n### `mini`\nType: `Object`  \nDefault:\n\n  - **removeAttribute**  \n  Type: `String|Boolean`  \n  Default: false  \n  Description: *Removes attributes that do not matter. The string value only `empty`*\n\n### `jsBeautifyOptions`\nType: `Object`  \nDefault: *All options as per package [js-beautify](https://github.com/beautify-web/js-beautify) except, `indent_level` because calculated and set according to context*\n\n## Related\n  - [js-beautify](https://github.com/beautify-web/js-beautify) - Beautifier for javascript\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fposthtml-beautify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposthtml%2Fposthtml-beautify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fposthtml-beautify/lists"}