package
A posthtml plugin to beautify you html files
npm install posthtml-beautifyGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
A posthtml plugin to beautify you html files
Format your html and inline css markup according to the HTML5 syntax Style Guide, Code Guide. Full list of supported options:
npm i -S posthtml posthtml-beautifyNote: This project is compatible with node v10+
import {readFileSync, writeFileSync} from 'fs';
import posthtml from 'posthtml';
import beautify from 'posthtml-beautify';
const html = readFileSync('input.html', 'utf8');
posthtml()
.use(beautify({rules: {indent: 4}}))
.process(html)
.then(result => {
writeFileSync('output.html', result.html);
});
Returns html-formatted according to rules based on the use HTML5 syntax Style Guide, Code Guide with custom settings indent: 4
rulesType: Object
Default:
Indent
Type: Number|String(only tab)
Default: 2
Description: A numeric value indicates specifies the number of spaces. The string value only tab
blankLines
Type: String|Boolean(only false)
Default: '\n'
Description: Add or remove blank lines to separate large or logical code blocks
eol (end of line)
Type: String
Default: '\n'
Description: As value is a string symbol which is added to the end of the row
eof (end of file)
Type: String|Boolean
Default: '\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
maxlen
Type: Number
Default: '80'
Description: checks for the max length of the content, indents the whole content to a new line
sortAttr
Type: Boolean
Default: false
Description: Sort the order of attributes in elements
lang
Type: String | Boolean(only false)
Default: false
Description: Add a lang attribute in elements, eg: { lang: 'fr' }
commentFormat
Type: Boolean
Default: true
Description: Formats the comments. It does the following
If there are multi line comments then there would be leading and trailing newline like this
miniType: Object
Default:
String|BooleanemptyjsBeautifyOptionsType: Object
Default: All options as per package js-beautify except, indent_level because calculated and set according to context
scrum
scrum@list.ru
// Input
<!-- multiline
comments-->
// Output
<!--
multiline
comments
-->If there is a single line comment, it would make it to a single line with the comment starting and ending notation in same line
Input
<!--
singleline comments
-->Output
<!-- singleline comments -->
Estimated unpacked size across 26 packages.
5.6 MB
Includes dependencies.
5 direct · 4 outdated
^4.2.2
4.3.1
^1.11.0
2.0.3
^7.10.2
8.1.2
^0.4.2
0.13.0
^1.2.2
3.0.0