HTMLComb
A simple tool for combing HTML attributes.
Main
dist/
├── htmlcomb.js (8 KB)
└── htmlcomb.min.js (4 KB)
Getting started
Quick start
Three quick start options are available:
- Download the latest release.
- Clone the repository:
git clone https://github.com/fengyuanchen/htmlcomb.git
. - Install with NPM:
npm install htmlcomb
.
Usage
Browser
var htmlcomb = options; htmlcomb;
NodeJS
var fs = ;var HTMLComb = ;var htmlcomb = options; fs;
Options
requireDoubleQuotationMarks
- Type:
Boolean
- Default:
true
For example:
<!-- Source --> <!-- Result -->
replaceSingleQuotationMarks
- Type:
Boolean
- Default:
true
For example:
<!-- Source --> <!-- Result -->
removeEmptyValues
- Type:
Boolean
- Default:
true
For example:
<!-- Source --> <!-- Result -->
removeNewlines
- Type:
Boolean
- Default:
true
Also removes the indentation after the newline.
For example:
<!-- Source --> <!-- Result -->
removeMultipleSpaces
- Type:
Boolean
- Default:
true
For example:
<!-- Source --> <!-- Result -->
order
- Type:
Array
- Default:
"class" "id" "name" "data" "src" "for" "type" "href" "value" "title" "alt" "role" "aria"
The default order references to the Code Guide's attribute order.
For example:
<!-- Source --> <!-- Result -->
Methods
setup(options)
Parameters | Type | Description |
---|---|---|
options | Object |
Custom options |
Change the default options.
format(source[, options[, callback]])
- Alias: comb
Parameters | Type | Description |
---|---|---|
source | String |
The source text for combing |
options (optional) | Object |
Change the default options temporarily |
callback (optional) | Function |
e.g: function (result) {} |
Format source HTML attributes.
Browser support
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Opera (latest)
- Edge (latest)
- Internet Explorer 8+
Versioning
Maintained under the Semantic Versioning guidelines.