Node utility for formatting SASS, HTML, Angular1 HTML and Angular2 HTML
npm install toris-formattoris-format is a Node utility for formatting SASS, HTML, Angular1 HTML and Angular2 HTML
https://trello.com/b/2mSSarol/product-toris-format
sh
$ npm install toris-format
`Examples
Here are some example usages
$3
Create and run a node file with:
`js
const format = require('toris-format');
const unformattedHTML =
const config = {
definition_type: 'HTML'
}
const formattedHTML = format.formatContents(unformattedHTML, config);
console.log(formattedHTML);
`This will return:
`sh
class="title"
style="font-weight:bold">HI
`$3
Create and run a node file with:
`js
const format = require('toris-format');
const unformattedCSS = width:-2; border: 0 -2px 0 0;
margin-top: -($unit / 2);
margin-bottom: -(1.25 * $unit);
padding: (0.2 * $unit) $unit;
}`
const config = {
definition_type: 'SCSS'
}
const formattedCSS = format.formatContents(unformattedCSS, config);
console.log(formattedCSS);
This will return:
`css`
.class {
padding-left: -$unit;
padding-top: 2 -$unit;
padding-right: -2 2 -$unit;
width: -2;
border: 0 -2px 0 0;
margin-top: -($unit / 2);
margin-bottom: -(1.25 * $unit);
padding: (0.2 * $unit) $unit;
}
Create and run a node file with:
`js`
const format = require('toris-format');
const filePath = './file.css'
const config = {} // Don't need to set the definition type since this gets deduced from the file extension
const formatted = format.formatFile(filePath, config);
// To overwrite file, you'll need to write the formatted contents to the file
`js`
const config = {
definition_type: 'HTML',
add_noopener_noreferrer: false, // true or false
angular_version: 1, // 1 or 2
remove_css: false, // true or false
allow_empty_files: false, // true or false
indent: ' ', // spaces, tabs etc...
convert_line_endings: true, // true or false
line_ending: '\n', // \n, \r, \r\n
}
#### definition_type
Either HTML or SCSS, set to HTML for formatting HTML contentnoopener noreferrer
#### add_noopener_noreferrer
If set to true, adds to links with the _blank targetAngularJS
See this link for more details
#### angular_version
Which angular syntax to use for formatting, 1 refers to /Angular1, 2 refers to Angular/Angular2,3,4, etc...convert_line_endings
#### remove_css
Removes inline CSS from HTML and leaves a comment in place
#### allow_empty_files
Shows a warning on empty content
#### indent
The indent to use for formatting, can be any string, but spaces or tabs are recommended
#### convert_line_endings
If set to true, converts line endings
#### line_ending
Line ending to use for conversion if is true, one of \n, \r, \r\n
`js`
const config = {
definition_type: 'SCSS',
allow_empty: false, // true or false
convert_line_endings: true, // true or false
line_ending: '\n', // \n, \r, \r\n
}
#### definition_type
Either HTML or SCSS, set to SCSS for formattting CSS/SCSS contentconvert_line_endings
#### allow_empty
Shows a warning on empty content
#### indent
The indent to use for formatting, can be any string, but spaces or tabs are recommended
#### convert_line_endings
If set to true, converts line endings
#### line_ending
Line ending to use for conversion if is true, one of \n, \r, \r\n`
License
----
ISC