Fixes #736. Change unformatted option default value to match js-beautify
This commit is contained in:
parent
9914fc35ab
commit
99299e5d30
|
@ -941,7 +941,7 @@ Number of line-breaks to be preserved in one chunk (Supported by JS Beautify)
|
||||||
|
|
||||||
**Key**: `unformatted`
|
**Key**: `unformatted`
|
||||||
|
|
||||||
**Default**: `a,sub,sup,b,i,u`
|
**Default**: `a,span,img,bdo,em,strong,dfn,code,samp,kbd,var,cite,abbr,acronym,q,sub,sup,tt,i,b,big,small,u,s,strike,font,ins,del,pre,address,dt,h1,h2,h3,h4,h5,h6`
|
||||||
|
|
||||||
**Type**: `array`
|
**Type**: `array`
|
||||||
|
|
||||||
|
@ -958,11 +958,42 @@ List of tags (defaults to inline) that should not be reformatted (Supported by J
|
||||||
"html": {
|
"html": {
|
||||||
"unformatted": [
|
"unformatted": [
|
||||||
"a",
|
"a",
|
||||||
|
"span",
|
||||||
|
"img",
|
||||||
|
"bdo",
|
||||||
|
"em",
|
||||||
|
"strong",
|
||||||
|
"dfn",
|
||||||
|
"code",
|
||||||
|
"samp",
|
||||||
|
"kbd",
|
||||||
|
"var",
|
||||||
|
"cite",
|
||||||
|
"abbr",
|
||||||
|
"acronym",
|
||||||
|
"q",
|
||||||
"sub",
|
"sub",
|
||||||
"sup",
|
"sup",
|
||||||
"b",
|
"tt",
|
||||||
"i",
|
"i",
|
||||||
"u"
|
"b",
|
||||||
|
"big",
|
||||||
|
"small",
|
||||||
|
"u",
|
||||||
|
"s",
|
||||||
|
"strike",
|
||||||
|
"font",
|
||||||
|
"ins",
|
||||||
|
"del",
|
||||||
|
"pre",
|
||||||
|
"address",
|
||||||
|
"dt",
|
||||||
|
"h1",
|
||||||
|
"h2",
|
||||||
|
"h3",
|
||||||
|
"h4",
|
||||||
|
"h5",
|
||||||
|
"h6"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5093,7 +5124,7 @@ Number of line-breaks to be preserved in one chunk (Supported by JS Beautify)
|
||||||
|
|
||||||
**Key**: `unformatted`
|
**Key**: `unformatted`
|
||||||
|
|
||||||
**Default**: `a,sub,sup,b,i,u`
|
**Default**: `a,span,img,bdo,em,strong,dfn,code,samp,kbd,var,cite,abbr,acronym,q,sub,sup,tt,i,b,big,small,u,s,strike,font,ins,del,pre,address,dt,h1,h2,h3,h4,h5,h6`
|
||||||
|
|
||||||
**Type**: `array`
|
**Type**: `array`
|
||||||
|
|
||||||
|
@ -5110,11 +5141,42 @@ List of tags (defaults to inline) that should not be reformatted (Supported by J
|
||||||
"html": {
|
"html": {
|
||||||
"unformatted": [
|
"unformatted": [
|
||||||
"a",
|
"a",
|
||||||
|
"span",
|
||||||
|
"img",
|
||||||
|
"bdo",
|
||||||
|
"em",
|
||||||
|
"strong",
|
||||||
|
"dfn",
|
||||||
|
"code",
|
||||||
|
"samp",
|
||||||
|
"kbd",
|
||||||
|
"var",
|
||||||
|
"cite",
|
||||||
|
"abbr",
|
||||||
|
"acronym",
|
||||||
|
"q",
|
||||||
"sub",
|
"sub",
|
||||||
"sup",
|
"sup",
|
||||||
"b",
|
"tt",
|
||||||
"i",
|
"i",
|
||||||
"u"
|
"b",
|
||||||
|
"big",
|
||||||
|
"small",
|
||||||
|
"u",
|
||||||
|
"s",
|
||||||
|
"strike",
|
||||||
|
"font",
|
||||||
|
"ins",
|
||||||
|
"del",
|
||||||
|
"pre",
|
||||||
|
"address",
|
||||||
|
"dt",
|
||||||
|
"h1",
|
||||||
|
"h2",
|
||||||
|
"h3",
|
||||||
|
"h4",
|
||||||
|
"h5",
|
||||||
|
"h6"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,6 @@
|
||||||
indent_size: 2
|
indent_size: 2
|
||||||
max_preserve_newlines: 1
|
max_preserve_newlines: 1
|
||||||
preserve_newlines: true
|
preserve_newlines: true
|
||||||
unformatted:
|
|
||||||
- "a"
|
|
||||||
- "sub"
|
|
||||||
- "sup"
|
|
||||||
- "b"
|
|
||||||
- "i"
|
|
||||||
- "u"
|
|
||||||
wrap_line_length: 0
|
wrap_line_length: 0
|
||||||
css:
|
css:
|
||||||
indent_char: " "
|
indent_char: " "
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
"indent_size": 6,
|
"indent_size": 6,
|
||||||
"max_preserve_newlines": 1,
|
"max_preserve_newlines": 1,
|
||||||
"preserve_newlines": true,
|
"preserve_newlines": true,
|
||||||
"unformatted": ["a", "sub", "sup", "b", "i", "u"],
|
|
||||||
"wrap_line_length": 0
|
"wrap_line_length": 0
|
||||||
},
|
},
|
||||||
"css": {
|
"css": {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<DOCTYPE "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" PUBLIC html>
|
<DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
|
|
||||||
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
<title>Shopping List for
|
<title>Shopping List for
|
||||||
<%= @date.strftime('%A, %d %B %Y') %></title>
|
<%= @date.strftime('%A, %d %B %Y') %></title>
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en-us" xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Test</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<ul>
|
||||||
|
<li><code>foo:bar</code></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</html>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE html><html lang="en-us" xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<title>Test</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<ul>
|
||||||
|
<li><code>foo:bar</code></li>
|
||||||
|
</ul>
|
||||||
|
</html>
|
|
@ -4,9 +4,7 @@
|
||||||
|
|
||||||
{{#items}}
|
{{#items}}
|
||||||
{{#first}}
|
{{#first}}
|
||||||
<li>
|
<li><strong>{{name}}</strong></li>
|
||||||
<strong>{{name}}</strong>
|
|
||||||
</li>
|
|
||||||
{{/first}}
|
{{/first}}
|
||||||
{{#link}}
|
{{#link}}
|
||||||
<li><a href="{{url}}">{{name}}</a></li>
|
<li><a href="{{url}}">{{name}}</a></li>
|
||||||
|
|
|
@ -12,8 +12,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h1>My Webpage</h1>
|
<h1>My Webpage</h1> {{ a_variable }}
|
||||||
{{ a_variable }}
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
|
@ -3,9 +3,9 @@
|
||||||
<!ENTITY nbsp "<xsl:text disable-output-escaping='yes'>&nbsp;</xsl:text>">
|
<!ENTITY nbsp "<xsl:text disable-output-escaping='yes'>&nbsp;</xsl:text>">
|
||||||
]>
|
]>
|
||||||
|
|
||||||
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
|
||||||
|
|
||||||
<xsl:output doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" encoding="utf-8" indent="yes" method="html"/>
|
<xsl:output method="html" indent="yes" encoding="utf-8" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/>
|
||||||
|
|
||||||
<xsl:template match="/">
|
<xsl:template match="/">
|
||||||
<html>
|
<html>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<apex:page standardController="Contact">
|
<apex:page standardController="Contact">
|
||||||
|
|
||||||
<apex:sectionHeader subtitle="{!contact.account.name}" title="{!contact.firstname}"/>
|
<apex:sectionHeader title="{!contact.firstname}" subtitle="{!contact.account.name}"/>
|
||||||
|
|
||||||
</apex:page>
|
</apex:page>
|
|
@ -1,6 +1,6 @@
|
||||||
<apex:page standardController="Contact">
|
<apex:page standardController="Contact">
|
||||||
|
|
||||||
<apex:sectionHeader subtitle="{!contact.account.name}" title="{!contact.firstname}"/>
|
<apex:sectionHeader title="{!contact.firstname}" subtitle="{!contact.account.name}"/>
|
||||||
|
|
||||||
<apex:form >
|
<apex:form >
|
||||||
<apex:pageBlock title="Contact">
|
<apex:pageBlock title="Contact">
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
<apex:inputfield value="{!contact.lastname}"/>
|
<apex:inputfield value="{!contact.lastname}"/>
|
||||||
<apex:inputfield value="{!contact.salutation}"/>
|
<apex:inputfield value="{!contact.salutation}"/>
|
||||||
<apex:inputfield value="{!contact.birthdate}"/>
|
<apex:inputfield value="{!contact.birthdate}"/>
|
||||||
<apex:commandButton action="{!save}" value="Save"/>
|
<apex:commandButton value="Save" action="{!save}"/>
|
||||||
</apex:pageBlockSection>
|
</apex:pageBlockSection>
|
||||||
</apex:pageBlock>
|
</apex:pageBlock>
|
||||||
</apex:form>
|
</apex:form>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<apex:page standardController="Contact">
|
<apex:page standardController="Contact">
|
||||||
|
|
||||||
<apex:sectionHeader subtitle="{!contact.account.name}" title="{!contact.firstname}"/>
|
<apex:sectionHeader title="{!contact.firstname}" subtitle="{!contact.account.name}"/>
|
||||||
|
|
||||||
<apex:pageBlock title="Contact">
|
<apex:pageBlock title="Contact">
|
||||||
<apex:pageBlockSection title="Details">
|
<apex:pageBlockSection title="Details">
|
||||||
|
|
|
@ -84,13 +84,13 @@
|
||||||
"extend": "^3.0.0",
|
"extend": "^3.0.0",
|
||||||
"gherkin": "2.12.2",
|
"gherkin": "2.12.2",
|
||||||
"handlebars": "^4.0.2",
|
"handlebars": "^4.0.2",
|
||||||
"js-beautify": "^1.5.7",
|
"js-beautify": "^1.5.10",
|
||||||
"jscs": "^2.1.1",
|
"jscs": "^2.1.1",
|
||||||
"lodash": "3.10.1",
|
"lodash": "3.10.1",
|
||||||
"loophole": "^1.0.0",
|
"loophole": "^1.0.0",
|
||||||
"node-dir": "^0.1.8",
|
"node-dir": "^0.1.8",
|
||||||
"node-uuid": "^1.4.3",
|
"node-uuid": "^1.4.3",
|
||||||
"prettydiff": "^1.16.5",
|
"prettydiff": "^1.16.8",
|
||||||
"season": "^5.3.0",
|
"season": "^5.3.0",
|
||||||
"space-pen": "^5.1.1",
|
"space-pen": "^5.1.1",
|
||||||
"strip-json-comments": "^1.0.2",
|
"strip-json-comments": "^1.0.2",
|
||||||
|
|
|
@ -156,6 +156,7 @@ describe "BeautifyLanguages", ->
|
||||||
|
|
||||||
beautifyCompleted = false
|
beautifyCompleted = false
|
||||||
completionFun = (text) ->
|
completionFun = (text) ->
|
||||||
|
try
|
||||||
expect(text instanceof Error).not.toEqual(true, text)
|
expect(text instanceof Error).not.toEqual(true, text)
|
||||||
return beautifyCompleted = true if text instanceof Error
|
return beautifyCompleted = true if text instanceof Error
|
||||||
# logger.verbose(expectedTestPath, text) if ext is ".less"
|
# logger.verbose(expectedTestPath, text) if ext is ".less"
|
||||||
|
@ -193,14 +194,21 @@ describe "BeautifyLanguages", ->
|
||||||
newStr, oldHeader, newHeader)
|
newStr, oldHeader, newHeader)
|
||||||
# Get options
|
# Get options
|
||||||
opts = beautifier.getOptionsForLanguage(allOptions, language)
|
opts = beautifier.getOptionsForLanguage(allOptions, language)
|
||||||
|
selectedBeautifier = beautifier.getBeautifierForLanguage(language)
|
||||||
|
if selectedBeautifier?
|
||||||
|
opts = beautifier.transformOptions(selectedBeautifier, language.name, opts)
|
||||||
|
|
||||||
# Show error message with debug information
|
# Show error message with debug information
|
||||||
expect(text).toEqual(expectedContents, \
|
expect(text).toEqual(expectedContents, \
|
||||||
"Beautifier output does not match expected \
|
"Beautifier '#{selectedBeautifier?.name}' output does not match expected \
|
||||||
output:\n#{diff}\n\n\
|
output:\n#{diff}\n\n\
|
||||||
With options:\n\
|
With options:\n\
|
||||||
#{JSON.stringify(opts, undefined, 4)}")
|
#{JSON.stringify(opts, undefined, 4)}")
|
||||||
# All done!
|
# All done!
|
||||||
beautifyCompleted = true
|
beautifyCompleted = true
|
||||||
|
catch e
|
||||||
|
console.error(e)
|
||||||
|
beautifyCompleted = e
|
||||||
|
|
||||||
runs ->
|
runs ->
|
||||||
try
|
try
|
||||||
|
|
|
@ -301,6 +301,16 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
_.contains(beautifier.languages, language)
|
_.contains(beautifier.languages, language)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
getBeautifierForLanguage : (language) ->
|
||||||
|
beautifiers = @getBeautifiers(language.name)
|
||||||
|
logger.verbose('beautifiers', _.map(beautifiers, 'name'))
|
||||||
|
# Select beautifier from language config preferences
|
||||||
|
preferredBeautifierName = atom.config.get("atom-beautify.language_#{language.namespace}_default_beautifier")
|
||||||
|
beautifier = _.find(beautifiers, (beautifier) ->
|
||||||
|
beautifier.name is preferredBeautifierName
|
||||||
|
) or beautifiers[0]
|
||||||
|
return beautifier
|
||||||
|
|
||||||
getLanguage : (grammar, filePath) ->
|
getLanguage : (grammar, filePath) ->
|
||||||
# Get language
|
# Get language
|
||||||
fileExtension = path.extname(filePath)
|
fileExtension = path.extname(filePath)
|
||||||
|
@ -415,7 +425,6 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
return resolve( null )
|
return resolve( null )
|
||||||
|
|
||||||
# Get more language config
|
# Get more language config
|
||||||
preferredBeautifierName = atom.config.get("atom-beautify.language_#{language.namespace}_default_beautifier")
|
|
||||||
beautifyOnSave = atom.config.get("atom-beautify.language_#{language.namespace}_beautify_on_save")
|
beautifyOnSave = atom.config.get("atom-beautify.language_#{language.namespace}_beautify_on_save")
|
||||||
legacyBeautifyOnSave = atom.config.get("atom-beautify.beautifyOnSave")
|
legacyBeautifyOnSave = atom.config.get("atom-beautify.beautifyOnSave")
|
||||||
|
|
||||||
|
@ -430,22 +439,17 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
|
|
||||||
# Get Beautifier
|
# Get Beautifier
|
||||||
logger.verbose(grammar, language)
|
logger.verbose(grammar, language)
|
||||||
beautifiers = @getBeautifiers(language.name)
|
|
||||||
|
|
||||||
logger.verbose("language options: #{JSON.stringify(options, null, 4)}")
|
logger.verbose("language options: #{JSON.stringify(options, null, 4)}")
|
||||||
logger.verbose('beautifiers', _.map(beautifiers, 'name'))
|
|
||||||
|
|
||||||
logger.verbose(language.name, filePath, options, allOptions)
|
logger.verbose(language.name, filePath, options, allOptions)
|
||||||
|
|
||||||
# Check if unsupported language
|
# Check if unsupported language
|
||||||
if beautifiers.length < 1
|
beautifier = @getBeautifierForLanguage(language)
|
||||||
|
if not beautifier?
|
||||||
unsupportedGrammar = true
|
unsupportedGrammar = true
|
||||||
logger.verbose('Beautifier for language not found')
|
logger.verbose('Beautifier for language not found')
|
||||||
else
|
else
|
||||||
# Select beautifier from language config preferences
|
|
||||||
beautifier = _.find(beautifiers, (beautifier) ->
|
|
||||||
beautifier.name is preferredBeautifierName
|
|
||||||
) or beautifiers[0]
|
|
||||||
logger.verbose('beautifier', beautifier.name)
|
logger.verbose('beautifier', beautifier.name)
|
||||||
|
|
||||||
# Apply language-specific option transformations
|
# Apply language-specific option transformations
|
||||||
|
@ -521,7 +525,6 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
findFileResults : {}
|
findFileResults : {}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -344,11 +344,8 @@ debug = () ->
|
||||||
|
|
||||||
# Beautifier
|
# Beautifier
|
||||||
beautifiers = beautifier.getBeautifiers(language.name)
|
beautifiers = beautifier.getBeautifiers(language.name)
|
||||||
preferredBeautifierName = atom.config.get("atom-beautify.language_#{language.namespace}_default_beautifier")
|
|
||||||
addInfo('Supported Beautifiers', _.map(beautifiers, 'name').join(', '))
|
addInfo('Supported Beautifiers', _.map(beautifiers, 'name').join(', '))
|
||||||
selectedBeautifier = _.find(beautifiers, (beautifier) ->
|
selectedBeautifier = beautifier.getBeautifierForLanguage(language)
|
||||||
beautifier.name is preferredBeautifierName
|
|
||||||
) or beautifiers[0]
|
|
||||||
addInfo('Selected Beautifier', selectedBeautifier.name)
|
addInfo('Selected Beautifier', selectedBeautifier.name)
|
||||||
|
|
||||||
# Get current editor's text
|
# Get current editor's text
|
||||||
|
|
|
@ -74,7 +74,9 @@ module.exports = {
|
||||||
description: "Number of line-breaks to be preserved in one chunk"
|
description: "Number of line-breaks to be preserved in one chunk"
|
||||||
unformatted:
|
unformatted:
|
||||||
type: 'array'
|
type: 'array'
|
||||||
default: ['a', 'sub', 'sup', 'b', 'i', 'u']
|
default: ['a', 'span', 'img', 'bdo', 'em', 'strong', 'dfn', 'code', 'samp', 'kbd',
|
||||||
|
'var', 'cite', 'abbr', 'acronym', 'q', 'sub', 'sup', 'tt', 'i', 'b', 'big', 'small', 'u', 's', 'strike',
|
||||||
|
'font', 'ins', 'del', 'pre', 'address', 'dt', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6']
|
||||||
items:
|
items:
|
||||||
type: 'string'
|
type: 'string'
|
||||||
description: "List of tags (defaults to inline) that should not be reformatted"
|
description: "List of tags (defaults to inline) that should not be reformatted"
|
||||||
|
|
Loading…
Reference in New Issue