diff --git a/examples/nested-jsbeautifyrc/.jsbeautifyrc b/examples/nested-jsbeautifyrc/.jsbeautifyrc index 98eac37..57240ac 100644 --- a/examples/nested-jsbeautifyrc/.jsbeautifyrc +++ b/examples/nested-jsbeautifyrc/.jsbeautifyrc @@ -55,3 +55,7 @@ indent_size: 4 markdown: listItemIndent: 1 + jade: + indent_size: 4 + indent_char: " " + omit_div: true diff --git a/examples/nested-jsbeautifyrc/jade/expected/test.jade b/examples/nested-jsbeautifyrc/jade/expected/test.jade new file mode 100644 index 0000000..d9fd833 --- /dev/null +++ b/examples/nested-jsbeautifyrc/jade/expected/test.jade @@ -0,0 +1,30 @@ +extends ../layout/basiclayout + +block append stylesheets + link(rel='stylesheet', href='/bower_components/bootstrap-table/dist/bootstrap-table.css') + style. + .sample_id { + color: #337AB7; + cursor: pointer; + } + +block content + .container + .col-lg-10 + // Comment + .page-header + h1 Sample Anaysis + small Find a sample + div + #toolbar + table#table + + //- div.well + //- | Lorem ipsum dolor sit amet, natum bonorum expetendis usu ut. Eum impetus offendit disputationi eu, at vim aliquip lucilius praesent. Alia laudem antiopam te ius, sed ad munere integre, ubique facete sapientem nam ut. + //- br + //- br + //- ul + //- li Lorem ipsum dolor sit amet, natum bonorum expetendis usu ut. + //- li Lorem ipsum dolor sit amet, natum bonorum expetendis usu ut. +block append scripts + script(src='/bower_components/bootstrap-table/dist/bootstrap-table.js') \ No newline at end of file diff --git a/examples/nested-jsbeautifyrc/jade/original/test.jade b/examples/nested-jsbeautifyrc/jade/original/test.jade new file mode 100644 index 0000000..f860d54 --- /dev/null +++ b/examples/nested-jsbeautifyrc/jade/original/test.jade @@ -0,0 +1,30 @@ +extends ../layout/basiclayout + +block append stylesheets + link(rel='stylesheet', href='/bower_components/bootstrap-table/dist/bootstrap-table.css') + style. + .sample_id { + color: #337AB7; + cursor: pointer; + } + +block content + div.container + div.col-lg-10 + // Comment + div.page-header + h1 Sample Anaysis + small Find a sample + div + div#toolbar + table#table + + //- div.well + //- | Lorem ipsum dolor sit amet, natum bonorum expetendis usu ut. Eum impetus offendit disputationi eu, at vim aliquip lucilius praesent. Alia laudem antiopam te ius, sed ad munere integre, ubique facete sapientem nam ut. + //- br + //- br + //- ul + //- li Lorem ipsum dolor sit amet, natum bonorum expetendis usu ut. + //- li Lorem ipsum dolor sit amet, natum bonorum expetendis usu ut. +block append scripts + script(src='/bower_components/bootstrap-table/dist/bootstrap-table.js') \ No newline at end of file diff --git a/package.json b/package.json index ab09ae1..ae12aed 100644 --- a/package.json +++ b/package.json @@ -103,6 +103,7 @@ "node-dir": "^0.1.8", "node-uuid": "^1.4.3", "prettydiff": "^1.16.27", + "pug-beautify": "^0.1.1", "remark": "^3.2.2", "season": "^5.3.0", "space-pen": "^5.1.1", diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee index 9aeaf25..1846c15 100644 --- a/src/beautifiers/index.coffee +++ b/src/beautifiers/index.coffee @@ -52,6 +52,7 @@ module.exports = class Beautifiers extends EventEmitter 'php-cs-fixer' 'phpcbf' 'prettydiff' + 'pug-beautify' 'puppet-fix' 'remark' 'rubocop' diff --git a/src/beautifiers/pug-beautify.coffee b/src/beautifiers/pug-beautify.coffee new file mode 100644 index 0000000..df07892 --- /dev/null +++ b/src/beautifiers/pug-beautify.coffee @@ -0,0 +1,26 @@ +"use strict" +Beautifier = require('./beautifier') + +module.exports = class PugBeautify extends Beautifier + name: "Pug Beautify" + options: { + # Apply these options first / globally, for all languages + Jade: + fill_tab: ['indent_char', (indent_char) -> + # Should use tabs? + return (indent_char is "\t") + ] + omit_div: true + tab_size: "indent_size" + } + + beautify: (text, language, options) -> + + return new @Promise((resolve, reject) -> + pugBeautify = require("pug-beautify") + try + resolve(pugBeautify(text, options)) + catch error + # Error occurred + reject(error) + ) diff --git a/src/languages/html.coffee b/src/languages/html.coffee index a131be6..7043bf7 100644 --- a/src/languages/html.coffee +++ b/src/languages/html.coffee @@ -38,7 +38,6 @@ module.exports = { indent_char: type: 'string' default: defaultIndentChar - minimum: 0 description: "Indentation character" brace_style: type: 'string' diff --git a/src/languages/index.coffee b/src/languages/index.coffee index 8ad80e2..b6980eb 100644 --- a/src/languages/index.coffee +++ b/src/languages/index.coffee @@ -32,6 +32,7 @@ module.exports = class Languages "handlebars" "haskell" "html" + "jade" "java" "javascript" "json" diff --git a/src/languages/jade.coffee b/src/languages/jade.coffee new file mode 100644 index 0000000..2f2eb82 --- /dev/null +++ b/src/languages/jade.coffee @@ -0,0 +1,47 @@ +# Get Atom defaults +scope = ['text.jade'] +tabLength = atom?.config.get('editor.tabLength', scope: scope) ? 4 +softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true +defaultIndentSize = (if softTabs then tabLength else 1) +defaultIndentChar = (if softTabs then " " else "\t") +defaultIndentWithTabs = not softTabs + +module.exports = { + + name: "Jade" + namespace: "jade" + fallback: ['html'] + + ### + Supported Grammars + ### + grammars: [ + "Jade" + ] + + ### + Supported extensions + ### + extensions: [ + "jade" + ] + + options: [ + indent_size: + type: 'integer' + default: defaultIndentSize + minimum: 0 + description: "Indentation size/length" + indent_char: + type: 'string' + default: defaultIndentChar + description: "Indentation character" + omit_div: + type: 'boolean' + default: false + description: "Whether to omit/remove the 'div' tags." + ] + + defaultBeautifier: "Pug Beautify" + +}