Coda PHP & Web Toolkit: Keep single quotes with CSSTidy

My Coda plugin uses CSSTidy as a cleanup tool to (re)format CSS code. This works quite well, but it has a “feature” that isn’t always right: It removes single quotes from CSS. In this case the single quotes arond the url are removed:

background:#333 url('images/bg-stripes2.png') repeat 0 0;

In order to disable this behaviour here’s a quick workaround. Please note that updating the plugin removes this modification, so if I release the next version I hope I can add a configuration option for this but in the between time here’s how to quickly stop CSStidy from removing quotes:

  • Open the finder and go to (your user folder)/Library/Application Support/Coda 2/Plug-ins (Or “/Coda/” for Coda 1)
  • Right click on “PhpPlugin.codaplugin”, select “Show package contents”
  • Now navigate to “Contents” and then to “Resources”, you’ll see all the support files for the Coda PHP plugin
  • Find the file “csstidy.php” and open it with a Text Editor (I recommend TextMate or Coda itself)
  • Go to line 2958 which reads: $_cur_string = substr($_cur_string, 1, -1);
  • Add two slashes before this line, like this: // $_cur_string = substr($_cur_string, 1, -1);
  • Save the file, exit and restart Coda and you’re done

Of course making a backup of this file is recommended. If you totally screwed up something you can delete the plugin-file and reinstall it without problems :)