Closes #199. Add Jade/Pug beautify support

This commit is contained in:
Glavin Wiechert 2016-03-30 10:34:49 -03:00
parent 50ad73d324
commit d48768e503
9 changed files with 140 additions and 1 deletions

View File

@ -55,3 +55,7 @@
indent_size: 4
markdown:
listItemIndent: 1
jade:
indent_size: 4
indent_char: " "
omit_div: true

View File

@ -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')

View File

@ -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')

View File

@ -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",

View File

@ -52,6 +52,7 @@ module.exports = class Beautifiers extends EventEmitter
'php-cs-fixer'
'phpcbf'
'prettydiff'
'pug-beautify'
'puppet-fix'
'remark'
'rubocop'

View File

@ -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)
)

View File

@ -38,7 +38,6 @@ module.exports = {
indent_char:
type: 'string'
default: defaultIndentChar
minimum: 0
description: "Indentation character"
brace_style:
type: 'string'

View File

@ -32,6 +32,7 @@ module.exports = class Languages
"handlebars"
"haskell"
"html"
"jade"
"java"
"javascript"
"json"

47
src/languages/jade.coffee Normal file
View File

@ -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"
}