diff --git a/README.md b/README.md index 3db7fd350..31d569069 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ Or Settings/Preferences ➔ Packages ➔ Search for `atom-beautify` - Requires [python-sqlparse](https://github.com/andialbrecht/sqlparse) - [x] [Markdown](https://github.com/Glavin001/atom-beautify/issues/93#issuecomment-55642483) - Requires [Pandoc](http://johnmacfarlane.net/pandoc/) to be already installed +- [X] [Perl](https://github.com/Glavin001/atom-beautify/issues/33) - [x] [PHP](https://github.com/donaldpipowitch/atom-beautify/issues/26) - Requires [PHP_Beautifier](http://pear.php.net/package/PHP_Beautifier) to be already installed. - [x] [Python](https://github.com/donaldpipowitch/atom-beautify/issues/24) @@ -60,13 +61,6 @@ Or Settings/Preferences ➔ Packages ➔ Search for `atom-beautify` - Requires [Uncrustify](http://sourceforge.net/projects/uncrustify/) - [x] [TypeScript](https://github.com/Glavin001/atom-beautify/issues/49) -### Road Map - -#### Language support - -- [ ] [Perl](https://github.com/Glavin001/atom-beautify/issues/33) - - ## Usage Open the [Command Palette](https://github.com/atom/command-palette), and type `Beautify`. diff --git a/lib/langs/perl-beautify.coffee b/lib/langs/perl-beautify.coffee new file mode 100644 index 000000000..4f8b4a832 --- /dev/null +++ b/lib/langs/perl-beautify.coffee @@ -0,0 +1,24 @@ +### +// Requires [perltidy](http://perltidy.sourceforge.net) +### + +"use strict" + +getCmd = (inputPath, outputPath, options) -> + # console.debug "[perl-beautify] options: " + JSON.stringify(options) + args = [ + '"' + options.perltidy_path + '"' + '--standard-output' + '--standard-error-output' + '--quiet' + ] + if options.perltidy_profile + args.push '"--profile=' + options.perltidy_profile + '"' + args.push '"' + inputPath + '"' + cmd = args.join(' ') + # console.debug "[perl-beautify] cmd: " + cmd + return cmd + +cliBeautify = require("./cli-beautify") +isStdout = true +module.exports = cliBeautify(getCmd, isStdout) diff --git a/lib/language-options.coffee b/lib/language-options.coffee index 7b6c54dfc..2c7477911 100644 --- a/lib/language-options.coffee +++ b/lib/language-options.coffee @@ -10,6 +10,7 @@ beautifyJS = null beautifyHTML = null beautifyCSS = null beautifySQL = null +beautifyPerl = null beautifyPHP = null beautifyPython = null beautifyRuby = null @@ -38,6 +39,7 @@ module.exports = "html" "css" "sql" + "perl" "php" "python" "ruby" @@ -97,6 +99,10 @@ module.exports = # Markdown markdown_pandoc_path: "" + # Perl + perl_perltidy_path: "perltidy" + perl_perltidy_profile: "" + # PHP php_beautifier_path: "" @@ -183,6 +189,9 @@ module.exports = when "SQL (Rails)", "SQL" beautifySQL ?= require("./langs/sql-beautify") beautifySQL text, self.getOptions("sql", allOptions), beautifyCompleted + when "Perl" + beautifyPerl ?= require("./langs/perl-beautify") + beautifyPerl text, self.getOptions("perl", allOptions), beautifyCompleted when "PHP" beautifyPHP ?= require("./langs/php-beautify") beautifyPHP text, self.getOptions("php", allOptions), beautifyCompleted