Closes #264. Choose Pretty Diff beautifier as default for ERB

- Add indent_size option to htmlbeautifier
- Make Pretty Diff default beautifier for ERB
This commit is contained in:
Glavin Wiechert 2015-06-11 18:20:24 -03:00
parent 7ee517a5d4
commit 4d8d09a601
8 changed files with 38 additions and 25 deletions

View File

@ -42,3 +42,5 @@
indent_size: 1
ruby:
indent_size: 4
erb:
indent_size: 4

View File

@ -0,0 +1,18 @@
<DOCTYPE "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" PUBLIC html>
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<title>Shopping List for
<%= @date.strftime('%A, %d %B %Y') %></title>
</head>
<body>
<h1>Shopping List for
<%= @date.strftime('%A, %d %B %Y') %></h1>
<p>You need to buy:</p>
<ul>
<% for @item in @items %>
<li><%= h(@item) %></li>
<% end %>
</ul>
</body>
</html>

View File

@ -1,17 +0,0 @@
<DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Shopping List for <%= @date.strftime('%A, %d %B %Y') %></title>
</head>
<body>
<h1>Shopping List for <%= @date.strftime('%A, %d %B %Y') %></h1>
<p>You need to buy:</p>
<ul>
<% for @item in @items %>
<li><%= h(@item) %></li>
<% end %>
</ul>
</body>
</html>

View File

@ -8,11 +8,14 @@ Beautifier = require('./beautifier')
module.exports = class HTMLBeautifier extends Beautifier
name: "HTML Beautifier"
options: {
ERB: true
ERB:
indent_size: true
}
beautify: (text, language, options) ->
console.log('erb', options)
@run("htmlbeautifier", [
"--tab-stops", options.indent_size
tempFile = @tempFile("temp", text)
])
.then(=>

View File

@ -305,8 +305,8 @@ module.exports = class Beautifiers extends EventEmitter
getOptionsForLanguage : (allOptions, language) ->
# Options for Language
options = @getOptions([language.namespace]\
.concat(language.fallback or []), allOptions) or {}
selections = (language.fallback or []).concat([language.namespace])
options = @getOptions(selections, allOptions) or {}
beautify : (text, allOptions, grammar, filePath, {onSave} = {}) ->
return Promise.all(allOptions)
@ -364,7 +364,7 @@ module.exports = class Beautifiers extends EventEmitter
return resolve( null )
# Options for Language
options = @getOptions([language.namespace].concat(language.fallback or []), allOptions) or {}
options = @getOptionsForLanguage(allOptions, language)
# Get Beautifier
logger.verbose(grammar, language)
@ -767,7 +767,7 @@ module.exports = class Beautifiers extends EventEmitter
_ ?= require("lodash")
extend ?= require("extend")
logger.verbose(selections, allOptions)
logger.verbose('getOptions selections', selections, allOptions)
# logger.verbose(selection, allOptions);
# Reduce all options into correctly merged options.

View File

@ -15,7 +15,11 @@ module.exports = {
###
Supported extensions
###
extensions: []
extensions: [
'erb'
]
defaultBeautifier: "Pretty Diff"
options: []

View File

@ -47,13 +47,16 @@ module.exports = do ->
]
})
wlogger.on('logging', (transport, level, msg, meta)->
loggerLevel = atom?.config.get('atom-beautify._loggerLevel') ? "warn"
loggerLevel = atom?.config.get(\
'atom-beautify._loggerLevel') ? "warn"
# console.log('logging', loggerLevel, arguments)
loggerLevelNum = levels[loggerLevel]
levelNum = levels[level]
if loggerLevelNum <= levelNum
path = require('path')
label = path.basename(transport.label)
label = "#{path.dirname(transport.label)\
.split(path.sep).reverse()[0]}\
#{path.sep}#{path.basename(transport.label)}"
console.log("#{label} [#{level}]: #{msg}", meta)
)
# Export logger methods