Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

converting prettydiff to prettydiff2 #1750

Closed
wants to merge 14 commits into from
4 changes: 2 additions & 2 deletions examples/nested-jsbeautifyrc/html-erb/expected/test.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!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>
Expand All @@ -12,7 +12,7 @@
<p>You need to buy:</p>
<ul>
<% for @item in @items %>
<li><%= h(@item) %></li>
<li><%= h(@item) %></li>
<% end %>
</ul>
</body>
Expand Down
2 changes: 1 addition & 1 deletion examples/nested-jsbeautifyrc/html-erb/original/test.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<!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">
Expand Down
4 changes: 4 additions & 0 deletions examples/nested-jsbeautifyrc/less/expected/test2.less
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
.slideIn {
.animation(SlideIn, 0.5s);
}

@-webkit-keyframes SlideIn {
0% {
.transform(translateY(-100%));
Expand All @@ -127,6 +128,7 @@
display: block;
.animation(FadeIn, 0.5s);
}

@-webkit-keyframes FadeIn {
0% {
opacity: 0;
Expand All @@ -140,6 +142,7 @@
.slideOut {
.animation(SlideOut, 0.5s);
}

@-webkit-keyframes SlideOut {
0% {
.transform(translateY(0%));
Expand All @@ -153,6 +156,7 @@
.fadeOut {
.animation(FadeOut, 0.5s);
}

@-webkit-keyframes FadeOut {
0% {
opacity: 1;
Expand Down
2 changes: 1 addition & 1 deletion examples/nested-jsbeautifyrc/riotjs/expected/test.tag
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
]
</script>

<style scoped>
<style scoped="scoped">
:scope {
font-size: 2rem;
}
Expand Down
1 change: 1 addition & 0 deletions examples/nested-jsbeautifyrc/sass/expected/kendo_ui.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* kendo UI */

@import "variables";

// slider
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
"node-dir": "0.1.17",
"node-uuid": "1.4.8",
"open": "0.0.5",
"prettydiff": "1.16.37",
"prettydiff2": ">2.2.5",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does prettydiff2 follow semver? If so, this should be ^2.2.5 so no major version is updated.

"pug-beautify": "^0.1.1",
"remark": "6.0.1",
"season": "6.0.0",
Expand Down Expand Up @@ -225,6 +225,7 @@
"atom-beautify:beautify-language-go",
"atom-beautify:beautify-language-golang template",
"atom-beautify:beautify-language-fortran",
"atom-beautify:beautify-language-fuse",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Fuse the Atom-Beautify language? I thought it was UX Markup.

Note that these should be automatically generated/added, so if you find yourself adding this option, it should actually not be there 😜 .

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing...

"atom-beautify:beautify-language-handlebars",
"atom-beautify:beautify-language-haskell",
"atom-beautify:beautify-language-html",
Expand Down Expand Up @@ -422,7 +423,7 @@
"typescript-formatter",
"tidy-markdown",
"underscore-plus",
"prettydiff"
"prettydiff2"
]
}
},
Expand All @@ -434,7 +435,7 @@
"typescript-formatter",
"tidy-markdown",
"underscore-plus",
"prettydiff"
"prettydiff2"
]
}
}
11 changes: 5 additions & 6 deletions spec/beautify-languages-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,11 @@ describe "BeautifyLanguages", ->

# Activate all of the languages
allLanguages = [
"c", "clojure", "coffee-script", "css", "d", "html",
"java", "javascript", "json", "less",
"mustache", "objective-c", "perl", "php",
"python", "ruby", "sass", "sql", "svg",
"xml", "csharp", "gfm", "marko",
"go", "html-swig", "lua"
"c", "clojure", "coffee-script", "css", "csharp", "d", "fuse",
"gfm", "go", "html", "html-swig", "java", "javascript",
"json", "less", "lua", "marko", "mustache", "objective-c",
"perl", "php", "python", "ruby", "sass", "sql",
"svg", "xml"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why but adding language-fuse to the build artifacts makes the build time out.

]
# All Atom packages that Atom Beautify is dependent on
dependentPackages = [
Expand Down
5 changes: 2 additions & 3 deletions src/beautifiers/prettydiff.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = class PrettyDiff extends Beautifier
beautify: (text, language, options) ->
options.crlf = @getDefaultLineEnding(true,false,options.end_of_line)
return new @Promise((resolve, reject) =>
prettydiff = require("prettydiff")
prettydiff = require("prettydiff2")
_ = require('lodash')

# Select Prettydiff language
Expand Down Expand Up @@ -127,8 +127,7 @@ module.exports = class PrettyDiff extends Beautifier

# Beautify
@verbose('prettydiff', options)
output = prettydiff.api(options)
result = output[0]
result = prettydiff(options)

# Return beautified text
resolve(result)
Expand Down
6 changes: 3 additions & 3 deletions src/beautifiers/vue-beautifier.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = class VueBeautifier extends Beautifier

beautify: (text, language, options) ->
return new @Promise((resolve, reject) =>
prettydiff = require("prettydiff")
prettydiff = require("prettydiff2")
_ = require('lodash')
regexp = /(^<(template|script|style)[^>]*>)((\s|\S)*?)^<\/\2>/gim

Expand All @@ -37,14 +37,14 @@ module.exports = class VueBeautifier extends Beautifier
lang: "scss"
mode: "beautify"
)
prettydiff.api(options)[0]
prettydiff(options)
when "less"
options = _.merge(options,
source: text
lang: "less"
mode: "beautify"
)
prettydiff.api(options)[0]
prettydiff(options)
when undefined
require("js-beautify").css(text, options)
else
Expand Down
2 changes: 1 addition & 1 deletion src/languages/ux_markup.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {

name: "UX Markup"
namespace: "ux"
fallback: ['html']
fallback: ['xml']
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may change the behaviour for current users of UX Markup. Did this solve anything by changing it to xml?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just figured this grammar was more closely related to XML than HTML. It did not appear to have any effect in the build.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just figured this grammar was more closely related to XML than HTML.

This is true, however any users who are leveraging the html fallback will experience an unforeseen breaking change.

It did not appear to have any effect in the build.

Unfortunately, our builds do not have great coverage 😝 . Something I hope to address with Unibeautify.


###
Supported Grammars
Expand Down