htmlcs
HTML code style check & format tool.
Install
npm i -g htmlcs
Usage
-
in CLI
Usage: htmlcs <command> [options] [target...]Commands:hint Do hint given fileformat Do format given fileOptions:-h, --help Show help [boolean]-c, --config Path to custom configuration file. [string]--diff Check code style and output char diff. [boolean]-i, --in-place Edit input files in place; use with care! [boolean]-v, --version Show version number [boolean]Examples:htmlcs hint foo.html do hint foo.htmlhtmlcs hint foo.html bar.html do hint foo.html & bar.htmlhtmlcs hint ./ do hint html files under ./htmlcs format foo.html do format foo.htmlhtmlcs format --diff foo.html do format foo.html & show diff resulthtmlcs format --in-place foo.html do format foo.html & write file in place -
in Node.js / browser (with browserify)
-
hint file
var htmlcs = ;var result = htmlcs; -
hint code (string)
var htmlcs = ;var result = htmlcs;// Orhtmlcs; -
use hint result
result; -
format file
var htmlcs = ;console; -
format code (string)
var htmlcs = ;console;// Orhtmlcs; -
add rule
var htmlcs = ;htmlcs;var result = htmlcs;
-
-
with Gulp/Grunt
There is no official Gulp/Grunt plugin yet. We recommend fecs, which uses htmlcs to hint HTML code and provides a wealth of tools.
Rules & Codes
Config
-
default: lib/default/.htmlcsrc
-
custom:
Custom rule file (.htmlcsrc) can be placed in the same/parent directory of target file, or the
~/
directory.If found in neither paths, the default config will be used.
-
inline:
-
disable
<!-- htmlcs-disable --><!-- htmlcs-disable img-alt --><!-- htmlcs-disable img-alt, img-src, attr-value-double-quotes --> -
enable
<!-- htmlcs-enable --><!-- htmlcs-enable img-alt --><!-- htmlcs-enable img-alt, img-src, attr-value-double-quotes --> -
config
<!-- htmlcs img-width-height: true --><!-- htmlcs img-width-height: true, indent-char: "tab" -->
-