Skip to content

Commit

Permalink
Perl support (using perltidy) (see #33)
Browse files Browse the repository at this point in the history
  • Loading branch information
biffen committed Nov 5, 2014
1 parent a25ad22 commit f64d2ba
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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`.
Expand Down
24 changes: 24 additions & 0 deletions lib/langs/perl-beautify.coffee
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 9 additions & 0 deletions lib/language-options.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ beautifyJS = null
beautifyHTML = null
beautifyCSS = null
beautifySQL = null
beautifyPerl = null
beautifyPHP = null
beautifyPython = null
beautifyRuby = null
Expand Down Expand Up @@ -38,6 +39,7 @@ module.exports =
"html"
"css"
"sql"
"perl"
"php"
"python"
"ruby"
Expand Down Expand Up @@ -97,6 +99,10 @@ module.exports =
# Markdown
markdown_pandoc_path: ""

# Perl
perl_perltidy_path: "perltidy"
perl_perltidy_profile: ""

# PHP
php_beautifier_path: ""

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f64d2ba

Please sign in to comment.