├── .gitignore ├── README.ru.md ├── README.md ├── package.json └── techs ├── enb-beautify-css.js └── enb-beautify-html.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .DS_Store 3 | .idea 4 | npm-debug.log -------------------------------------------------------------------------------- /README.ru.md: -------------------------------------------------------------------------------- 1 | enb-beautify 2 | ============ 3 | 4 | [Enb](http://github.com/enb/enb) технологии для визуального форматирования HTML and CSS. 5 | 6 | ### Как включить 7 | 8 | 1. Добавьте пакет `enb-beautify` в зависимости в `package.json` 9 | 2. Добавьте требуемые технологии и цели в конфигурацию `make`: 10 | 11 | ```js 12 | 13 | var tech = { 14 | //... 15 | htmlBeautify: require('enb-beautify/techs/enb-beautify-html'), 16 | cssBeautify: require('enb-beautify/techs/enb-beautify-css'), 17 | //... 18 | } 19 | 20 | addTechs.push([tech.htmlBeautify]); 21 | addTechs.push([tech.cssBeautify]); 22 | 23 | addTargets.push('?.beauty.html'); 24 | addTargets.push('?.beauty.css'); 25 | 26 | ``` -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | enb-beautify 2 | ============ 3 | 4 | [Enb](http://github.com/enb/enb) techs for pretty format HTML and CSS. 5 | 6 | ### How to enable 7 | 8 | 1. Add `enb-beautify` dependency to your project `package.json`: 9 | 2. Add required techs and targets in `make` config like `addTechs.push([tech.htmlBeautify]);`: 10 | 11 | ```js 12 | 13 | var tech = { 14 | //... 15 | htmlBeautify: require('enb-beautify/techs/enb-beautify-html'), 16 | cssBeautify: require('enb-beautify/techs/enb-beautify-css'), 17 | //... 18 | } 19 | 20 | addTechs.push([tech.htmlBeautify]); 21 | addTechs.push([tech.cssBeautify]); 22 | 23 | addTargets.push('?.beauty.html'); 24 | addTargets.push('?.beauty.css'); 25 | 26 | ``` 27 | 28 | Russian readme available in [README.ru.md](README.ru.md). -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "enb-beautify", 3 | "version": "0.0.3", 4 | "description": "Make html/css pretty formatted", 5 | "scripts": { 6 | "test": "echo \"Error: no test specified\" && exit 1" 7 | }, 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/enb/enb-beautify.git" 11 | }, 12 | "keywords": [ 13 | "html", 14 | "css", 15 | "pretty view", 16 | "enb", 17 | "js-beautify" 18 | ], 19 | "author": "alexbaumgertner@yandex.ru", 20 | "license": "MIT", 21 | "bugs": { 22 | "url": "https://github.com/enb/enb-beautify/issues" 23 | }, 24 | "homepage": "https://github.com/enb/enb-beautify", 25 | "engines": { 26 | "node": ">= 0.10.0" 27 | }, 28 | "dependencies": { 29 | "enb": "~0.13", 30 | "js-beautify": "1.5.4" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /techs/enb-beautify-css.js: -------------------------------------------------------------------------------- 1 | /** 2 | * enb-beautify-css 3 | * ================= 4 | * 5 | * Форматирует *css*-файл в удобочитаемый вид с помощью пакета `js-beautify` 6 | * 7 | */ 8 | var vfs = require('enb/lib/fs/async-fs'), 9 | beautifyCss = require('js-beautify').css; 10 | 11 | module.exports = require('enb/lib/build-flow').create() 12 | .name('enb-beautify-css') 13 | .target('target', '?.beauty.css') 14 | 15 | .useSourceFilename('cssFile', '?.css') 16 | .optionAlias('cssFile', 'cssFileTarget') 17 | 18 | .optionAlias('target', 'destTarget') 19 | .builder(function(cssFileName) { 20 | 21 | return vfs.read(cssFileName, 'utf-8') 22 | .then(function(css) { 23 | return beautifyCss(css); 24 | }) 25 | .fail(function(data) { 26 | console.log('Fail with: ', data); 27 | }); 28 | }) 29 | .createTech(); 30 | -------------------------------------------------------------------------------- /techs/enb-beautify-html.js: -------------------------------------------------------------------------------- 1 | /** 2 | * enb-beautify-html 3 | * ================= 4 | * 5 | * Форматирует *html*-файл в удобочитаемый вид с помощью `js-beautify` 6 | * 7 | */ 8 | var vfs = require('enb/lib/fs/async-fs'), 9 | beautifyHtml = require('js-beautify').html; 10 | 11 | module.exports = require('enb/lib/build-flow').create() 12 | .name('enb-beautify-html') 13 | .target('target', '?.beauty.html') 14 | 15 | .useSourceFilename('htmlFile', '?.html') 16 | .optionAlias('htmlFile', 'htmlFileTarget') 17 | 18 | .optionAlias('target', 'destTarget') 19 | .builder(function(htmlFileName) { 20 | 21 | return vfs.read(htmlFileName, 'utf-8') 22 | .then(function(html) { 23 | return beautifyHtml(html); 24 | }) 25 | .fail(function(data) { 26 | console.log('Fail with: ', data); 27 | }); 28 | }) 29 | .createTech(); 30 | --------------------------------------------------------------------------------