#
Pretty Diff - Documentation

Color Scheme

Browse Pretty Diff on GitHub.

##

### Purpose

Pretty Diff is a language aware code comparison tool, beautifier, minifier, and parser for a variety of languages.

Pretty Diff was created to compare code samples for various languages regardless of differences in comments, white space, and other factors. Currently, the project operates by beautifying code and then comparing the beautified product of the code samples. The goal in a future version is to introduce the comparison step directly into the beautifiers between the parse step and the beautification step to become a truely language aware code comparison and analysis tool.

### Goals

portability
  The project should be immediately available cross platform, across various interfaces, and without a build process. All documentation and required supporting artifacts are included with the project code.
productivity
  The project should save a developer substantial time by making code easier to read against a variety of settings and reduce the steps to complete a given code analysis task.
reproducibility
  Code pushed through the project in any one mode should be equally restorable to its previous state using a different mode.
simplicity
  The project should do more with less code. The intended audience of this project are software developers, who may need to modify the project code to fit custom needs. Less code means increased portability. Clearer simple code allows separation of concerns, and cleaner organization.

### Supported Operations (modes)

Pretty Diff currently supports these four operations:

diff
  The code comparison mode. This is the default mode and the only mode to require two code samples.
beautify
  Pretty Diff has progressively moved from community driven dependencies to custom parsers to accomplish code beautification for a diversity of features and requests.
minify
  Each of Pretty Diff's beautification libraries has a minify feature. The goal is to reduce code size but only to such an extent that the code can be restored to its prior state through beautification, excluding code comments.
parse
  Most code parsers generate a final product called an Abstract Syntax Tree (AST). Pretty Diff, instead, leans on the sparser project which produces parse output as a data table.

##

### Key of terms

Environment
  Describes where the option is available, such as whether exclusively used with Node or in a browser.
Type
  The data type of the option's value, such as string, number, or boolean.
Mode
  Some options are only available in certain modes, such as beautification or minification.
Lexer
  Some options are only available to certain language groups. Markup specific options, for example, will not work with JavaScript language.
Default
  The option's default value.

1. #### brace_line

   - ##### Description

     If true an empty line will be inserted after opening curly braces and before closing curly braces.

   - ##### Environment

     any

   - ##### Type

     boolean

   - ##### Mode

     beautify

   - ##### Lexer

     script

   - ##### Default

     false

   - ##### As labeled in the HTML tool

     Brace Lines

2. #### brace_padding

   - ##### Description

     Inserts a space after the start of a container and before the end of the container if the contents of that container are not indented; such as: conditions, function arguments, and escaped sequences of template strings.

   - ##### Environment

     any

   - ##### Type

     boolean

   - ##### Mode

     beautify

   - ##### Lexer

     script

   - ##### Default

     false

   - ##### As labeled in the HTML tool

     Brace Padding

3. #### brace_style

   - ##### Description

     Emulates JSBeautify's brace_style option using existing Pretty Diff options.

   - ##### Environment

     any

   - ##### Type

     string

   - ##### Mode

     beautify

   - ##### Lexer

     script

   - ##### Accepted Values

     collapse
       Sets options.format_object to 'indent' and options.neverflatten to true.
     collapse-preserve-inline
       Sets options.bracepadding to true and options.format_object to 'inline'.
     expand
       Sets options.braces to true, options.format_object to 'indent', and options.neverflatten to true.
     none
       Ignores this option

   - ##### Default

     none

   - ##### As labeled in the HTML tool

     Brace Style

4. #### braces

   - ##### Description

     Determines if opening curly braces will exist on the same line as their condition or be forced onto a new line.

   - ##### Environment

     any

   - ##### Type

     boolean

   - ##### Mode

     beautify

   - ##### Lexer

     script

   - ##### Default

     false

   - ##### As labeled in the HTML tool

     Style of Indent

5. #### color

   - ##### Description

     The color scheme of the reports.

   - ##### Environment

     any

   - ##### Type

     string

   - ##### Mode

     any

   - ##### Lexer

     any

   - ##### Accepted Values

     canvas
       A light brown color scheme
     shadow
       A black and ashen color scheme
     white
       A white and pale grey color scheme

   - ##### Default

     white

   - ##### As labeled in the HTML tool

     Color

6. #### comment_line

   - ##### Description

     If a blank new line should be forced above comments.

   - ##### Environment

     any

   - ##### Type

     boolean

   - ##### Mode

     beautify

   - ##### Lexer

     markup

   - ##### Default

     false

   - ##### As labeled in the HTML tool

     Force an Empty Line Above Comments

7. #### comments

   - ##### Description

     This will determine whether comments should always start at position 0 of each line or if comments should be indented according to the code.

   - ##### Environment

     any

   - ##### Type

     boolean

   - ##### Mode

     beautify

   - ##### Lexer

     any

   - ##### Default

     false

   - ##### As labeled in the HTML tool

     Indent Comments

8. #### complete_document

   - ##### Description

     Allows a preference for generating a complete HTML document instead of only generating content.

   - ##### Environment

     any

   - ##### Type

     boolean

   - ##### Mode

     any

   - ##### Lexer

     markup

   - ##### Default

     false

   - ##### As labeled in the HTML tool

     Generate A Complete HTML File

9. #### compressed_css

   - ##### Description

     If CSS should be beautified in a style where the properties and values are minifed for faster reading of selectors.

   - ##### Environment

     any

   - ##### Type

     boolean

   - ##### Mode

     beautify

   - ##### Lexer

     style

   - ##### Default

     false

   - ##### As labeled in the HTML tool

     Compressed CSS

10. #### conditional

    - ##### Description

      If true then conditional comments used by Internet Explorer are preserved at minification of markup.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      minify

    - ##### Lexer

      markup

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      IE Comments (HTML Only)

11. #### content

    - ##### Description

      This will normalize all string content to 'text' so as to eliminate some differences from the output.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      diff

    - ##### Lexer

      any

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Ignore Content

12. #### correct

    - ##### Description

      Automatically correct some sloppiness in code.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      any

    - ##### Lexer

      any

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Fix Sloppy Code

13. #### crlf

    - ##### Description

      If line termination should be Windows (CRLF) format. Unix (LF) format is the default.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      any

    - ##### Lexer

      any

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Line Termination

14. #### css_insert_lines

    - ##### Description

      Inserts new line characters between every CSS code block.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      beautify

    - ##### Lexer

      style

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Insert Empty Lines

15. #### diff

    - ##### Description

      The code sample to be compared to 'source' option. This is required if mode is 'diff'.

    - ##### Environment

      any

    - ##### Type

      string

    - ##### Mode

      diff

    - ##### Lexer

      any

    - ##### Default

    - ##### As labeled in the HTML tool

      Code to Compare

16. #### diff_comments

    - ##### Description

      If true then comments will be preserved so that both code and comments are compared by the diff engine.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      diff

    - ##### Lexer

      any

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Code Comments

17. #### diff_context

    - ##### Description

      This shortens the diff output by allowing a specified number of equivalent lines between each line of difference. This option is only used with diff_format:html.

    - ##### Environment

      any

    - ##### Type

      number

    - ##### Mode

      diff

    - ##### Lexer

      any

    - ##### Default

      -1

    - ##### As labeled in the HTML tool

      Context Size

18. #### diff_format

    - ##### Description

      The format of the output. The command line output format is text, similar to Unix 'diff'.

    - ##### Environment

      any

    - ##### Type

      string

    - ##### Mode

      diff

    - ##### Lexer

      any

    - ##### Accepted Values

      html
        An HTML format for embedding in web pages, or as a complete web page if document_complete is true.
      json
        A JSON format.
      text
        Formatted similar to the Unix 'diff' command line utility.

    - ##### Default

      text

    - ##### As labeled in the HTML tool

      Diff Format

19. #### diff_label

    - ##### Description

      This allows for a descriptive label for the diff file code of the diff HTML output.

    - ##### Environment

      any

    - ##### Type

      string

    - ##### Mode

      diff

    - ##### Lexer

      any

    - ##### Default

      New Sample

    - ##### As labeled in the HTML tool

      Label for Diff Sample

20. #### diff_rendered_html

    - ##### Description

      Compares complete HTML documents and injects custom CSS so that the differences display not in the code, but in the rendered page in a browser. This option is currently confined only to markup languages, read_method file, and mode diff. Option diff_format is ignored.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      diff

    - ##### Lexer

      markup

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Compare Rendered HTML

21. #### diff_space_ignore

    - ##### Description

      If white space only differences should be ignored by the diff tool.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      diff

    - ##### Lexer

      any

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Remove White Space

22. #### diff_view

    - ##### Description

      This determines whether the diff HTML output should display as a side-by-side comparison or if the differences should display in a single table column.

    - ##### Environment

      any

    - ##### Type

      string

    - ##### Mode

      diff

    - ##### Lexer

      any

    - ##### Accepted Values

      inline
        A single column where insertions and deletions are vertically adjacent.
      sidebyside
        Two column comparison of changes.

    - ##### Default

      sidebyside

    - ##### As labeled in the HTML tool

      Diff View Type

23. #### else_line

    - ##### Description

      If else_line is true then the keyword 'else' is forced onto a new line.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      beautify

    - ##### Lexer

      script

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Else On New Line

24. #### end

    - ##### Description

      The last index to process. This option is useful internally when recursively sliding between various libraries. The default value of 0 means to ignore this option.

    - ##### Environment

      any

    - ##### Type

      number

    - ##### Mode

      any

    - ##### Lexer

      any

    - ##### Default

      0

    - ##### As labeled in the HTML tool

      End Index

25. #### end_comma

    - ##### Description

      If there should be a trailing comma in arrays and objects. Value "multiline" only applies to modes beautify and diff.

    - ##### Environment

      any

    - ##### Type

      string

    - ##### Mode

      beautify

    - ##### Lexer

      script

    - ##### Accepted Values

      always
        Always ensure there is a tailing comma
      never
        Remove trailing commas
      none
        Ignore this option

    - ##### Default

      never

    - ##### As labeled in the HTML tool

      Trailing Comma

26. #### end_quietly

    - ##### Description

      A node only option to determine if terminal summary data should be logged to the console.

    - ##### Environment

      node

    - ##### Type

      string

    - ##### Mode

      any

    - ##### Lexer

      any

    - ##### Accepted Values

      default
        Default minimal summary
      log
        Verbose logging
      quiet
        No extraneous logging

    - ##### Default

      default

    - ##### As labeled in the HTML tool

      Log Summary to Console

27. #### force_attribute

    - ##### Description

      If all markup attributes should be indented each onto their own line.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      beautify

    - ##### Lexer

      markup

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Force Indentation of All Attributes

28. #### force_indent

    - ##### Description

      Will force indentation upon all content and tags without regard for the creation of new text nodes.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      beautify

    - ##### Lexer

      markup

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Force Indentation of All Content

29. #### format_array

    - ##### Description

      Determines if all array indexes should be indented, never indented, or left to the default.

    - ##### Environment

      any

    - ##### Type

      string

    - ##### Mode

      beautify

    - ##### Lexer

      script

    - ##### Accepted Values

      default
        Default formatting
      indent
        Always indent each index of an array
      inline
        Ensure all array indexes appear on a single line

    - ##### Default

      default

    - ##### As labeled in the HTML tool

      Formatting Arrays

30. #### format_object

    - ##### Description

      Determines if all object keys should be indented, never indented, or left to the default.

    - ##### Environment

      any

    - ##### Type

      string

    - ##### Mode

      beautify

    - ##### Lexer

      script

    - ##### Accepted Values

      default
        Default formatting
      indent
        Always indent each key/value pair
      inline
        Ensure all key/value pairs appear on the same single line

    - ##### Default

      default

    - ##### As labeled in the HTML tool

      Formatting Objects

31. #### function_name

    - ##### Description

      If a space should follow a JavaScript function name.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      beautify

    - ##### Lexer

      script

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Space After Function Name

32. #### help

    - ##### Description

      A node only option to print documentation to the console. The value determines where to wrap text.

    - ##### Environment

      node

    - ##### Type

      number

    - ##### Mode

      any

    - ##### Lexer

      any

    - ##### Default

      80

    - ##### As labeled in the HTML tool

      Help Wrapping Limit

33. #### indent_char

    - ##### Description

      The string characters to comprise a single indentation. Any string combination is accepted.

    - ##### Environment

      any

    - ##### Type

      string

    - ##### Mode

      beautify

    - ##### Lexer

      any

    - ##### Default

    - ##### As labeled in the HTML tool

      Indentation Characters

34. #### indent_level

    - ##### Description

      How much indentation padding should be applied to beautification? This option is internally used for code that requires switching between libraries.

    - ##### Environment

      any

    - ##### Type

      number

    - ##### Mode

      beautify

    - ##### Lexer

      any

    - ##### Default

      0

    - ##### As labeled in the HTML tool

      Indentation Padding

35. #### indent_size

    - ##### Description

      The number of 'inchar' values to comprise a single indentation.

    - ##### Environment

      any

    - ##### Type

      number

    - ##### Mode

      beautify

    - ##### Lexer

      any

    - ##### Default

      4

    - ##### As labeled in the HTML tool

      Indent Size

36. #### jsscope

    - ##### Description

      An educational tool to generate HTML output of JavaScript code to identify scope regions and declared references by color. This option is ignored unless the code language is JavaScript or TypeScript.

    - ##### Environment

      any

    - ##### Type

      string

    - ##### Mode

      beautify

    - ##### Lexer

      script

    - ##### Accepted Values

      html
        generates HTML output with escaped angle braces and ampersands for embedding as code, which is handy in code producing tools
      none
        prevents use of this option
      report
        generates HTML output that renders in web browsers

    - ##### Default

      none

    - ##### As labeled in the HTML tool

      JavaScript Scope Identification

37. #### language

    - ##### Description

      The lowercase single word common name of the source code's programming language. The value 'auto' imposes language and lexer auto-detection, which ignores deliberately specified lexer values. The value 'text' is converted to 'auto' if options 'mode' is not 'diff'. Value 'text' allows literal comparisons.

    - ##### Environment

      any

    - ##### Type

      string

    - ##### Mode

      any

    - ##### Lexer

      any

    - ##### Default

      auto

    - ##### As labeled in the HTML tool

      Language

38. #### language_default

    - ##### Description

      The fallback option if option 'lang' is set to 'auto' and a language cannot be detected.

    - ##### Environment

      any

    - ##### Type

      string

    - ##### Mode

      any

    - ##### Lexer

      any

    - ##### Default

      text

    - ##### As labeled in the HTML tool

      Language Auto-Detection Default

39. #### language_name

    - ##### Description

      The formatted proper name of the code sample's language for use in reports read by people.

    - ##### Environment

      any

    - ##### Type

      string

    - ##### Mode

      any

    - ##### Lexer

      any

    - ##### Default

      JavaScript

    - ##### As labeled in the HTML tool

      Formatted Name of the Code's Language

40. #### lexer

    - ##### Description

      This option determines which sets of rules to use in the language parser. If option 'language' has a value of 'auto', which is the default value, this option is ignored. The value 'text' is converted to 'auto' if options 'mode' is not 'diff'. Value 'text' allows literal comparisons.

    - ##### Environment

      any

    - ##### Type

      string

    - ##### Mode

      any

    - ##### Lexer

      any

    - ##### Accepted Values

      auto
        The value 'auto' imposes language and lexer auto-detection, which ignores deliberately specified language values.
      markup
        parses languages like XML and HTML
      script
        parses languages with a C style syntax, such as JavaScript
      style
        parses CSS like languages

    - ##### Default

      auto

    - ##### As labeled in the HTML tool

      Parsing Lexer

41. #### list_options

    - ##### Description

      A Node.js only option that writes current option settings to the console.

    - ##### Environment

      node

    - ##### Type

      boolean

    - ##### Mode

      any

    - ##### Lexer

      any

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Options List

42. #### method_chain

    - ##### Description

      When to break consecutively chained methods and properties onto separate lines. A negative value disables this option. A value of 0 ensures method chains are never broken.

    - ##### Environment

      any

    - ##### Type

      number

    - ##### Mode

      beautify

    - ##### Lexer

      script

    - ##### Default

      3

    - ##### As labeled in the HTML tool

      Method Chains

43. #### minify_wrap

    - ##### Description

      Whether minified script should wrap after a specified character width. This option requires a value from option 'wrap'.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      minify

    - ##### Lexer

      script

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Minification Wrapping

44. #### mode

    - ##### Description

      The operation to be performed.

    - ##### Environment

      any

    - ##### Type

      string

    - ##### Mode

      any

    - ##### Lexer

      any

    - ##### Accepted Values

      beautify
        beautifies code and returns a string
      diff
        returns either command line list of differences or an HTML report
      minify
        minifies code and returns a string
      parse
        using option 'parseFormat' returns an object with shallow arrays, a multidimensional array, or an HTML report

    - ##### Default

      diff

    - ##### As labeled in the HTML tool

      Mode

45. #### never_flatten

    - ##### Description

      If destructured lists in script should never be flattend.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      beautify

    - ##### Lexer

      script

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Never Flatten Destructured Lists

46. #### new_line

    - ##### Description

      Insert an empty line at the end of output.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      any

    - ##### Lexer

      any

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      New Line at End of Code

47. #### no_case_indent

    - ##### Description

      If a case statement should receive the same indentation as the containing switch block.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      beautify

    - ##### Lexer

      script

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Case Indentation

48. #### no_lead_zero

    - ##### Description

      Whether leading 0s in CSS values immediately preceeding a decimal should be removed or prevented.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      any

    - ##### Lexer

      style

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Leading 0s

49. #### node_error

    - ##### Description

      A Node.js only option if parse errors should be written to the console.

    - ##### Environment

      node

    - ##### Type

      boolean

    - ##### Mode

      any

    - ##### Lexer

      any

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Write Parse Errors in Node

50. #### object_sort

    - ##### Description

      Sorts markup attributes and properties by key name in script and style.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      beautify

    - ##### Lexer

      any

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Object/Attribute Sort

51. #### output

    - ##### Description

      A file path for which to write output. If this option is not specified output will be printed to the shell.

    - ##### Environment

      node

    - ##### Type

      string

    - ##### Mode

      any

    - ##### Lexer

      any

    - ##### Default

    - ##### As labeled in the HTML tool

      Output Location

52. #### parse_format

    - ##### Description

      Determines the output format for 'parse' mode.

    - ##### Environment

      any

    - ##### Type

      string

    - ##### Mode

      parse

    - ##### Lexer

      any

    - ##### Accepted Values

      htmltable
        generates the 'table' type output for the DOM but escapes the HTML tags for rendering as HTML code in a HTML tool
      parallel
        returns an object containing series of parallel arrays
      sequential
        returns an array where each index is a child object containing the parsed token and all descriptive data
      table
        generates a colorful grid of output for either the dom or command line interface

    - ##### Default

      parallel

    - ##### As labeled in the HTML tool

      Parse Format

53. #### parse_space

    - ##### Description

      Whether whitespace tokens should be included in markup parse output.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      parse

    - ##### Lexer

      markup

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Retain White Space Tokens in Parse Output

54. #### preserve

    - ##### Description

      The maximum number of consecutive empty lines to retain.

    - ##### Environment

      any

    - ##### Type

      number

    - ##### Mode

      beautify

    - ##### Lexer

      any

    - ##### Default

      0

    - ##### As labeled in the HTML tool

      Preserve Consecutive New Lines

55. #### preserve_comment

    - ##### Description

      Prevent comment reformatting due to option wrap.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      beautify

    - ##### Lexer

      any

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Eliminate Word Wrap Upon Comments

56. #### preserve_text

    - ##### Description

      If text in the provided markup code should be preserved exactly as provided. This option eliminates beautification and wrapping of text content.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      any

    - ##### Lexer

      markup

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Preserve Markup Text White Space

57. #### quote

    - ##### Description

      If true and mode is 'diff' then all single quote characters will be replaced by double quote characters in both the source and diff file input so as to eliminate some differences from the diff report HTML output.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      diff

    - ##### Lexer

      any

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Normalize Quotes

58. #### quote_convert

    - ##### Description

      If the quotes of script strings or markup attributes should be converted to single quotes or double quotes.

    - ##### Environment

      any

    - ##### Type

      string

    - ##### Mode

      any

    - ##### Lexer

      any

    - ##### Accepted Values

      double
        Converts single quotes to double quotes
      none
        Ignores this option
      single
        Converts double quotes to single quotes

    - ##### Default

      none

    - ##### As labeled in the HTML tool

      Indent Size

59. #### read_method

    - ##### Description

      The option determines how Node.js should receive input. All output will be printed to the shell unless the option 'output' is specified, which will write output to a file.

    - ##### Environment

      node

    - ##### Type

      string

    - ##### Mode

      any

    - ##### Lexer

      any

    - ##### Accepted Values

      auto
        changes to value subdirectory, file, or screen depending on source resolution
      directory
        process all files in the specified directory only
      file
        reads a file and outputs to a file. file requires option 'output'
      screen
        reads from screen and outputs to screen
      subdirectory
        process all files in a directory and its subdirectories

    - ##### Default

      auto

    - ##### As labeled in the HTML tool

      Read Method

60. #### selector_list

    - ##### Description

      If comma separated CSS selectors should present on a single line of code.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      beautify

    - ##### Lexer

      style

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Indent Size

61. #### semicolon

    - ##### Description

      If true and mode is 'diff' and lang is 'javascript' all semicolon characters that immediately preceed any white space containing a new line character will be removed so as to elimate some differences from the code comparison.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      diff

    - ##### Lexer

      script

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Indent Size

62. #### source

    - ##### Description

      The source code or location for interpretation. This option is required for all modes.

    - ##### Environment

      any

    - ##### Type

      string

    - ##### Mode

      any

    - ##### Lexer

      any

    - ##### Default

    - ##### As labeled in the HTML tool

      Source Sample

63. #### source_label

    - ##### Description

      This allows for a descriptive label of the source file code for the diff HTML output.

    - ##### Environment

      any

    - ##### Type

      string

    - ##### Mode

      diff

    - ##### Lexer

      any

    - ##### Default

      Source Sample

    - ##### As labeled in the HTML tool

      Label for Source Sample

64. #### space

    - ##### Description

      Inserts a space following the function keyword for anonymous functions.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      beautify

    - ##### Lexer

      script

    - ##### Default

      true

    - ##### As labeled in the HTML tool

      Function Space

65. #### space_close

    - ##### Description

      Markup self-closing tags end will end with ' />' instead of '/>'.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      beautify

    - ##### Lexer

      markup

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Close Markup Self-Closing Tags with a Space

66. #### start

    - ##### Description

      The parse table index to start working from. This is internally used for code samples that require switching between different libraries.

    - ##### Environment

      any

    - ##### Type

      number

    - ##### Mode

      any

    - ##### Lexer

      any

    - ##### Default

      0

    - ##### As labeled in the HTML tool

      Start Index

67. #### styleguide

    - ##### Description

      Provides a collection of option presets to easily conform to popular JavaScript style guides.

    - ##### Environment

      any

    - ##### Type

      string

    - ##### Mode

      beautify

    - ##### Lexer

      script

    - ##### Accepted Values

      airbnb
        https://github.com/airbnb/javascript
      crockford
        http://jslint.com/
      google
        https://google.github.io/styleguide/jsguide.html
      jquery
        https://contribute.jquery.org/style-guide/js/
      jslint
        http://jslint.com/
      mediawiki
        https://www.mediawiki.org/wiki/Manual:Coding_conventions/JavaScript
      mrdoob
        https://github.com/mrdoob/three.js/wiki/Mr.doob's-Code-Style%E2%84%A2
      none
        Ignores this option
      standard
        https://standardjs.com/
      yandex
        https://github.com/ymaps/codestyle/blob/master/javascript.md

    - ##### Default

      none

    - ##### As labeled in the HTML tool

      Script Styleguide

68. #### summary_only

    - ##### Description

      Node only option to output only number of differences.

    - ##### Environment

      node

    - ##### Type

      boolean

    - ##### Mode

      diff

    - ##### Lexer

      any

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Output Diff Only Without A Summary

69. #### tag_merge

    - ##### Description

      Allows immediately adjacement start and end markup tags of the same name to be combined into a single self-closing tag.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      any

    - ##### Lexer

      markup

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Merge Adjacent Start and End tags

70. #### tag_sort

    - ##### Description

      Sort child items of each respective markup parent element.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      any

    - ##### Lexer

      markup

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Sort Markup Child Items

71. #### ternary_line

    - ##### Description

      If ternary operators in JavaScript ? and : should remain on the same line.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      beautify

    - ##### Lexer

      script

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Keep Ternary Statements On One Line

72. #### top_comments

    - ##### Description

      If mode is 'minify' this determines whether comments above the first line of code should be kept.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      minify

    - ##### Lexer

      any

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Retain Comment At Code Start

73. #### unformatted

    - ##### Description

      If markup tags should have their insides preserved. This option is only available to markup and does not support child tokens that require a different lexer.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      any

    - ##### Lexer

      markup

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Markup Tag Preservation

74. #### variable_list

    - ##### Description

      If consecutive JavaScript variables should be merged into a comma separated list or if variables in a list should be separated.

    - ##### Environment

      any

    - ##### Type

      string

    - ##### Mode

      any

    - ##### Lexer

      script

    - ##### Accepted Values

      each
        Ensurce each reference is a single declaration statement.
      list
        Ensure consecutive declarations are a comma separated list.
      none
        Ignores this option.

    - ##### Default

      none

    - ##### As labeled in the HTML tool

      Variable Declaration Lists

75. #### version

    - ##### Description

      A Node.js only option to write the version information to the console.

    - ##### Environment

      node

    - ##### Type

      boolean

    - ##### Mode

      any

    - ##### Lexer

      any

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Version

76. #### vertical

    - ##### Description

      If lists of assignments and properties should be vertically aligned. This option is not used with the markup lexer.

    - ##### Environment

      any

    - ##### Type

      boolean

    - ##### Mode

      beautify

    - ##### Lexer

      any

    - ##### Default

      false

    - ##### As labeled in the HTML tool

      Vertical Alignment

77. #### wrap

    - ##### Description

      Character width limit before applying word wrap. A 0 value disables this option. A negative value concatenates script strings.

    - ##### Environment

      any

    - ##### Type

      number

    - ##### Mode

      any

    - ##### Lexer

      any

    - ##### Default

      0

    - ##### As labeled in the HTML tool

      Wrap

##

### Get the Code

Various options are available for greater portability

- #### Github

  `git clone https://github.com/prettydiff/prettydiff.git`

- #### NPM, Pretty Diff

  Pretty Diff is available on NPM at https://www.npmjs.com/package/prettydiff.

### Setup/Run the Application

#### Setup as a local application

1. `git clone https://github.com/prettydiff/prettydiff.git`
2. `cd prettydiff`
3. `npm install typescript -g`
4. `npm install eslint -g`
5. `npm install`
6. `tsc --pretty`
7. `node js/services build`

#### Setup as a global NPM package

1. `npm install typescript -g`
2. `npm install eslint -g`
3. `npm install prettydiff -g`
4. `prettydiff build`

To get started with the application on the command line try the commands command to see a list of available features and detailed instructions: `node js/services commands`

To run the application in a web browser with Pretty Diff's HTML execute the server command: `node js/services server` or simply navigate your browser to the project's index.xhtml file in the local filesystem.

To run the application in a different browser application simply reference or include the built js/browser.js file. See the third party demo for an example.

##

### @source

https://github.com/prettydiff/prettydiff

### @documentation

https://prettydiff.com/documentation.xhtml

Prettydiff created by Austin Cheney originally on 3 Mar 2009. https://prettydiff.com/

As of version 2.1.17 Pretty Diff is licensed under CC0. Please see license for additional information.

##

### Precedence

Pretty Diff sets option values according to this order of precedence from highest priority to lowest:

1. The styleguide option, which is only used in the beautify/script.ts library.
2. The Pretty Diff comment.
3. User supplied options
4. Default option values

### Pretty Diff Comment

The Pretty Diff option comment is similar in convention to the JSLint option comment. In the case where multiple Pretty Diff option comments are present in a document only the first will be processed. If in diff mode and an option comment is present in the diff code but not the source code then this option comment will be processed. In order for the option comment to be recognized it must start with prettydiff.com. The options are listed in this comment separated by commas as a colon separated name value pair. The options match the exact value definition for the Pretty Diff application properties above and options that allow abstract values must have their values enclosed in either single or double quotes. The options can be listed in any order. The option comment should be separated from other comments to prevent any possibility of corrupted interpretation. These are examples of appropriate option strings:

- `/*prettydiff.com mode:beautify, language:javascript, indent_char:"abc"*/`
- `<!--prettydiff.com mode: beautify, language: javascript, indent_char: "abc", html: true -->`

### Web Tool URI Parameters

ace
  If this parameter is provided with a false value the Ace code editor will be discarded in favor of regular HTML textarea elements.
localstorage
  Disables or enables all storage in the browser.

Any defined option name is also supported as a parameter.

Here is an example: `https://prettydiff.com/?source=https://duckduckgo.com&mode=beautify&correct=true&localstorage=false`

##

### Contribution Guide

For questions, features, or bug reports please open an issue on Github. If you are executing from the command line insert the debug word at the end of your command and Pretty Diff will generate an issue template in markdown format that you can simply copy and paste into Github.

If you wish to propose code changes then follow these steps:

1. Fork the repository on Github and then clone down the fork to your local computer.
2. Create a new branch for your changes: `git checkout -b branchName`
3. Create test units. A pull request will be rejected without tests unless there is a strong expection. The build process employs different kinds of tests.
   - The simulation command runs just the simulation tests. These tests validate features of the command line operation. These tests are stored in the file tests/simulations.ts.
   - The validation command runs the code unit tests that validate the beautification and minification functions. These tests are stored in the tests/formatted and tests/raw directories. A file in the raw directory containing a test unit is compared against a same named file in the formatted directory storing the Pretty Diff output.
   - The diff tests are execution as a part of the simulation tests. The code units for the diff tests are stored in the directories tests/diffbase and tests/diffnew.
   - The parser has its own unit tests that are part of that project. Please see its Github repository: sparser.
4. Run the unit tests to verify if your changes are breaking things: `node js/services test`
5. Finally, open a pull request on Github or if you are having trouble with the build open a Github issue and ask for help.

### Troubleshooting Help

A few helpful tips in case you get stuck.

- If an update to the code breaks the build and the application can no longer build try recompiling from TypeScript and then running the Pretty Diff build again. The command is `tsc --pretty`.
- Ensure dependencies are up to date. Try running `npm update`. A version mismatch between Pretty Diff and the parser could result in unpredictable behavior.
- If you need help generating the appropriate details for a Github issue try using the debug feature. Simply run your command on the terminal and add debug or prettydiff_debug to generate an issue template in markdown format.
- When everything seems correct on the Pretty Diff side but the result is still wrong there could be a defect in the parser. Clone the parser as a separate project and run its tests by using the validation command. You could also use the parser's server command to run a frontend in your browser that is easier to read. The parser is at sparser
- If you modify the build code you have to rebuild twice to test the changes. This is because the first build compiles the updated code and the second build executes the updated code.