Prettify code before compare for formats like css js and html.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • spry
    New User
    • Mar 2015
    • 1

    Prettify code before compare for formats like css js and html.

    Sorry if a duplicate but my search didn't return anything.

    Any way to format files with plugins like CSSTidy or JS-beautify to take care of mostly meaningless differences between the files?

    I do this manually now and it costs a fair amount of time.
  • Aaron
    Team Scooter
    • Oct 2007
    • 16026

    #2
    Hello,

    Yes, although we only have a few specific for download. You can find the Tidy variants we host here:
    http://www.scootersoftware.com/downl..._moreformatsv4

    And we have a KB article for how to define and use any custom command line conversion utility, add it to a File Format, and it will be used automatically whenever you open files with that file format:
    http://www.scootersoftware.com/suppo...rnalconversion
    Aaron P Scooter Software

    Comment

    • ccallendar
      New User
      • Feb 2016
      • 2

      #3
      I've made a new file format to accomplish that. It calls an external batch file that runs the python jsbeautify code.

      Steps:
      1. Download, pip install, or clone the jsbeautify source code from here:
      https://github.com/beautify-web/js-beautify

      2. Install python if you haven't already

      3. Create a new batch file in the Helpers folder (for me on Windows it is in my user folder under AppData\Roaming\Scooter Software\Beyond Compare 4), I called mine jsbeautify.bat

      4. Put the following code into that batch file:
      python C:\yourpath\js-beautify\python\js-beautify -i < %1 > %2

      This will run python on the js-beautify script using the source file as stdin and saving to the target file.

      5. Open Beyond Compare and make a new File Format ("JSBeautify") or copy an existing one which does the following Conversion:
      External program (ANSI)
      Loading:
      Helpers\jsbeautify.bat %s %t

      Make sure it is associated with .js files, and is at the top of your list if you want to override any existing JavaScript file format(s).

      Hope that helps.

      Comment

      Working...