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

Add original phptidy and setting to select between phptidy and wp-phptidy #7

Merged
merged 2 commits into from Sep 7, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion PhpTidy.sublime-settings
@@ -1,4 +1,7 @@
{
//Filetypes that PhpTidy can run on.
"filetypes": [".php", ".module", ".inc"]
"filetypes": [".php", ".module", ".inc"],

//Selected Tidy Type (phptidy, wp)
"tidytype": "wp"
}
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -16,7 +16,7 @@ http://magp.ie/2011/01/10/tidy-and-format-your-php-and-meet-wordpress-standards-
ctrl + shift + P and type `Tidy PHP`, or you can use the ctrl + alt + T keybinding.

## Customize
Custom settings file (for choosing between original phptidy and wp-phptidy) coming soon.
Custom settings file (for choosing between original phptidy and wp-phptidy).

## Known issues
Running phptidy on your file will clear all bookmarks and foldings.
Expand Down
12 changes: 10 additions & 2 deletions php_tidy.py
Expand Up @@ -13,9 +13,17 @@ def run(self, edit):

print('PhpTidy: Ok, this seems to be PHP')

# set tidy type
tidy_type = settings.get('tidytype') or 'wp'

if tidy_type == 'wp':
tidy_file = 'wp-phptidy.php'
else:
tidy_file = 'phptidy.php'

# path to plugin - <sublime dir>/Packages/PhpTidy
pluginpath = sublime.packages_path() + '/PhpTidy'
scriptpath = pluginpath + '/wp-phptidy.php'
scriptpath = pluginpath + '/' + tidy_file

# path to temp file
tmpfile = '/tmp/phptidy-sublime-buffer.php'
Expand Down Expand Up @@ -48,7 +56,7 @@ def run(self, edit):


# call phptidy on tmpfile
scriptpath = pluginpath + '/wp-phptidy.php'
scriptpath = pluginpath + '/' + tidy_file
print('PhpTidy: calling script: %s "%s" replace "%s"' % ( phppath, scriptpath, tmpfile ) )
retval = os.system( '%s "%s" replace "%s"' % ( phppath, scriptpath, tmpfile ) )
if not ((retval == 0) or (retval == 1)):
Expand Down
Binary file modified php_tidy.pyc
Binary file not shown.