diff --git a/.travis.yml b/.travis.yml index 4264fcd..857ec27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ notifications: script: sh build-package.sh env: - - APM_TEST_PACKAGES="language-typescript language-marko" + - APM_TEST_PACKAGES="language-typescript language-marko language-tss" before_install: # Update Homebrew diff --git a/examples/simple-jsbeautifyrc/tss/expected/random_indent.tss b/examples/simple-jsbeautifyrc/tss/expected/random_indent.tss new file mode 100644 index 0000000..cfc6b94 --- /dev/null +++ b/examples/simple-jsbeautifyrc/tss/expected/random_indent.tss @@ -0,0 +1,97 @@ +"Window": { + exitOnClose: true, + backgroundColor: "#fff", + title: "Kochgut" +} + +"Label": { + width: Ti.UI.SIZE, + height: Ti.UI.SIZE, + color: "#555", + touchEnabled: false +} + +"Button": { + backgroundColor: "#03a9f4", + color: "#fff", + borderRadius: 2 +} + +"#menu": { + backgroundImage: "/images/bg.png" +} + +".button": { + backgroundColor: "#03a9f4", + color: "#fff", + borderRadius: 2, + width: Ti.UI.SIZE, + height: 48, + top: 16, + bottom: 16 +} + +".lbl_button": { + left: 20, + right: 20, + color: "#fff" +} + +".headline": { + color: "#aaa", + left: 16, + height: 48, + font: { + fontWeight: "bold" + } +} + +".grid": { + left: 2, + right: 2, + layout: "horizontal", + height: Ti.UI.SIZE +} + +".card [platform=tablet]": { + width: "33%", + height: 150, + bottom: 2 +} + +".card": { + width: "50%", + height: 150, + bottom: 2 +} + +".padding": { + right: 2, + left: 0, + top: 0, + bottom: 0, + backgroundImage: "/images/essen.jpg" +} +".card_overlay": { + bottom: 0, + left: 0, + right: 0, + height: 48 +} + +".card_overlay_bg": { + left: 0, + right: 0, + bottom: 0, + top: 0, + backgroundColor: "#000", + opacity: 0.3 +} + +".card_lbl": { + color: "#fff", + left: 16, + font: { + fontSize: 16 + } +} \ No newline at end of file diff --git a/examples/simple-jsbeautifyrc/tss/expected/test2.tss b/examples/simple-jsbeautifyrc/tss/expected/test2.tss new file mode 100644 index 0000000..93ab172 --- /dev/null +++ b/examples/simple-jsbeautifyrc/tss/expected/test2.tss @@ -0,0 +1,31 @@ +".container": { + backgroundImage: 'images/bgbg-builder.png', + width: 1024, + height: 752, + top: 0, + left: 0 +}, +"#blackArrow": { + touchEnabled: false, + backgroundImage: 'images/arrow-builder.png', + width: 15, + height: 10, + top: 128, + left: 165, + pos0: { + left: 165, + duration: 200 + }, + pos1: { + left: 301, + duration: 200 + }, + pos2: { + left: 437, + duration: 200 + }, + pos3: { + left: 573, + duration: 200 + } +}, \ No newline at end of file diff --git a/examples/simple-jsbeautifyrc/tss/original/_random_indent.tss b/examples/simple-jsbeautifyrc/tss/original/random_indent.tss similarity index 100% rename from examples/simple-jsbeautifyrc/tss/original/_random_indent.tss rename to examples/simple-jsbeautifyrc/tss/original/random_indent.tss diff --git a/examples/simple-jsbeautifyrc/tss/original/_test2.tss b/examples/simple-jsbeautifyrc/tss/original/test2.tss similarity index 100% rename from examples/simple-jsbeautifyrc/tss/original/_test2.tss rename to examples/simple-jsbeautifyrc/tss/original/test2.tss diff --git a/lib/langs/tss-prettydiff-beautify.coffee b/lib/langs/tss-prettydiff-beautify.coffee new file mode 100644 index 0000000..ef23f61 --- /dev/null +++ b/lib/langs/tss-prettydiff-beautify.coffee @@ -0,0 +1,17 @@ +"use strict" +prettydiff = require("prettydiff") +module.exports = (text, options, callback) -> + args = + source: text + lang: "tss" + mode: "beautify" + inchar: options.indent_char + insize: options.indent_size + alphasort: options.alphasort or false + preserve: (if (options.preserve_newlines is true ) then \ + "all" else "none") + + output = prettydiff.api(args) + result = output[0] + callback result + result diff --git a/lib/language-options.coffee b/lib/language-options.coffee index 81d67d3..f725834 100644 --- a/lib/language-options.coffee +++ b/lib/language-options.coffee @@ -20,6 +20,7 @@ uncrustifyBeautifier = null beautifyHTMLERB = null beautifyMarkdown = null beautifyTypeScript = null +beautifyTSS = null Analytics = null # Misc @@ -446,6 +447,9 @@ module.exports = when "Sass", "SCSS", "LESS" beautifyLESS ?= require("./langs/css-prettydiff-beautify") beautifyLESS text, self.getOptions("css", allOptions), beautifyCompleted + when "TSS" + beautifyTSS ?= require("./langs/tss-prettydiff-beautify") + beautifyTSS text, self.getOptions("css", allOptions), beautifyCompleted when "SQL (Rails)", "SQL" beautifySQL ?= require("./langs/sql-beautify") beautifySQL text, self.getOptions("sql", allOptions), beautifyCompleted diff --git a/spec/beautify-languages-spec.coffee b/spec/beautify-languages-spec.coffee index da9ce3d..950bb5c 100644 --- a/spec/beautify-languages-spec.coffee +++ b/spec/beautify-languages-spec.coffee @@ -21,7 +21,7 @@ describe "BeautifyLanguages", -> "java", "javascript", "json", "less", "mustache", "objective-c", "perl", "php", "python", "ruby", "sass", "sql", - "typescript", "xml", "csharp", "gfm", "marko" + "typescript", "xml", "csharp", "gfm", "marko", "tss" ] beforeEach ->