<metacontent="Pretty Diff - The difference tool" name="DC.title"/>
<meta
content="(pics-1.1 'http://www.icra.org/pics/vocabularyv03/' l gen true for 'https://prettydiff.com' r (n 0 s 0 v 0 l 0 oa 0 ob 0 oc 0 od 0 oe 0 of 0 og 0 oh 0 c 1) gen true for 'http://www.prettydiff.com' r (n 0 s 0 v 0 l 0 oa 0 ob 0 oc 0 od 0 oe 0 of 0 og 0 oh 0 c 1))"
http-equiv="pics-Label"/>
<metacontent="Austin Cheney" name="author"/>
<meta
content="Pretty Diff tool can minify, beautify (pretty-print), or diff between minified and beautified code. This tool can even beautify and minify HTML."
<p>Pretty Diff is a language aware code comparison tool, beautifier, minifier,
and parser for a variety of languages.</p>
<p>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
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.</p>
</div>
<divclass="segment" id="goals">
<h3>Goals</h3>
<dl>
<dt>portability</dt>
<dd>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.</dd>
<dt>productivity</dt>
<dd>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.</dd>
<dt>reproducibility</dt>
<dd>Code pushed through the project in any one mode should be equally restorable
to its previous state using a different mode.</dd>
<dt>simplicity</dt>
<dd>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.</dd>
</dl>
</div>
<divclass="segment" id="modes">
<h3>Supported Operations (modes)</h3>
<p>Pretty Diff currently supports these four operations:</p>
<dl>
<dt>diff</dt>
<dd>The code comparison mode. This is the default mode and the only mode to
require two code samples.</dd>
<dt>beautify</dt>
<dd>Pretty Diff has progressively moved from community driven dependencies to
custom parsers to accomplish code beautification for a diversity of features and
requests.</dd>
<dt>minify</dt>
<dd>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.</dd>
<dt>parse</dt>
<dd>Most code parsers generate a final product called an Abstract Syntax Tree
(AST). Pretty Diff, instead, leans on the <ahref="http://github.com/unibeautify/sparser">sparser</a> project which produces parse output as a data table.</dd>
<!--dt>analysis</dt>
<dd>HTML formatted reports evaluating the code. The reports differ in content
and structure by the parser(s) used.</dd-->
</dl>
</div>
<divclass="segment" id="languages">
<h3>Supported Languages</h3>
<!-- documentation languages start --><ul><li>markup <ul><li><ahref="https://velocity.apache.org/">Apache Velocity</a>
<dd>Describes where the option is available, such as whether exclusively used with Node or in a browser.</dd>
<dt>Type</dt>
<dd>The data type of the option's value, such as <em>string</em>, <em>number</em>, or <em>boolean</em>.</dd>
<dt>Mode</dt>
<dd>Some options are only available in certain modes, such as beautification or minification.</dd>
<dt>Lexer</dt>
<dd>Some options are only available to certain language groups. Markup specific options, for example, will not work with JavaScript language.</dd>
<dt>Default</dt>
<dd>The option's default value.</dd>
</dl>
</div>
<olclass="segment" id="options">
<!-- option list start --><liid="attribute_sort"><h4>attribute_sort</h4><ul><li><h5>Description</h5>Alphanumerically sort markup attributes. Attribute sorting is ignored on tags that contain attributes template attributes.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>markup</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Sort Attributes</li></ul></li><liid="attribute_sort_list"><h4>attribute_sort_list</h4><ul><li><h5>Description</h5>A comma separated list of attribute names. Attributes will be sorted according to this list and then alphanumerically. This option requires 'attribute_sort' have a value of true.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>markup</li><li><h5>Default</h5></li><li><h5>As labeled in the HTML tool</h5>Sort Attribute List</li></ul></li><liid="brace_line"><h4>brace_line</h4><ul><li><h5>Description</h5>If true an empty line will be inserted after opening curly braces and before closing curly braces.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>script</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Brace Lines</li></ul></li><liid="brace_padding"><h4>brace_padding</h4><ul><li><h5>Description</h5>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.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>script</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Brace Padding</li></ul></li><liid="brace_style"><h4>brace_style</h4><ul><li><h5>Description</h5>Emulates JSBeautify's brace_style option using existing Pretty Diff options.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>script</li><li><h5>Accepted Values</h5><dl><dt>collapse</dt><dd>Sets options.format_object to 'indent' and options.neverflatten to true.</dd><dt>collapse-preserve-inline</dt><dd>Sets options.bracepadding to true and options.format_object to 'inline'.</dd><dt>expand</dt><dd>Sets options.braces to true, options.format_object to 'indent', and options.neverflatten to true.</dd><dt>none</dt><dd>Ignores this option</dd></dl></li><li><h5>Default</h5>none</li><li><h5>As labeled in the HTML tool</h5>Brace Style</li></ul></li><liid="braces"><h4>braces</h4><ul><li><h5>Description</h5>Determines if opening curly braces will exist on the same line as their condition or be forced onto a new line. (Allman style indentation).</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>script</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Style of Indent</li></ul></li><liid="case_space"><h4>case_space</h4><ul><li><h5>Description</h5>If the colon separating a case's expression (of a switch/case block) from its statement should be followed by a space instead of indentation, thereby keeping the case on a single line of code.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>script</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Space Following Case</li></ul></li><liid="color"><h4>color</h4><ul><li><h5>Description</h5>The color scheme of the reports.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>any</li><li><h5>Accepted Values</h5><dl><dt>canvas</dt><dd>A light brown color scheme</dd><dt>shadow</dt><dd>A black and ashen color scheme</dd><dt>white</dt><dd>A white and pale grey color scheme</dd></dl></li><li><h5>Default</h5>white</li><li><h5>As labeled in the HTML tool</h5>Color</li></ul></li><liid="comment_line"><h4>comment_line</h4><ul><li><h5>Description</h5>If a blank new line should be forced above comments.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>markup</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Force an Empty Line Above Comments</li></ul></li><li id="comments"><h4>comments</h4><ul><li><h5>Description</h5>This will determine whether comments should always start at position 0 of each line or if comments should be indented according to the code.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Indent Comments</li></ul></li><li id="complete_document"><h4>complete_document</h4><ul><li><h5>Description</h5>Allows a preference for generating a complete HTML document instead of only generating content.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>markup</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Generate A Complete HTML File</li></ul></li><li id="compressed_css"><h4>compressed_css</h4><ul><li><h5>Description</h5>If CSS should be beautified in a style where the properties and values are minifed for faster reading of selectors.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>style</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Compressed CSS</li></ul></li><li id="conditional"><h4>conditional</h4><ul><li><h5>Description</h5>If true then conditional comments used by Internet Explorer are preserved at minification of markup.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>minify</li><li><h5>Lexer</h5>markup</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>IE Comments (HTML Only)</li></ul></li><li id="config"><h4>config</h4><ul><li><h5>Description</h5>By default Pretty Diff will look into the directory structure contain the value of option 'source' for a file named `.prettydiffrc` for saved option settings. This option allows a user to specify any file at any location in the local file system for configuration settings. A value of 'none' tells the application to bypass reading any configuration file.</li><li><h5>Environment</h5>node</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5></li><li><h5>As labeled in the HTML tool</h5>Custom Config File Location</li></ul></li><li id="content"><h4>content</h4><ul><li><h5>Description</h5>This will normalize all string content to 'text' so as to eliminate some differences from the output.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>diff</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Ignore Content</li></ul></li><li id="correct"><h4>correct</h4><ul><li><h5>Description</h5>Automatically correct some sloppiness in code.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Fix Sloppy Code</li></ul></li><li id="crlf"><h4>crlf</h4><ul><li><h5>Description</h5>If line termination should be Windows (CRLF) format. Unix (LF) format is the default.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Line Termination</li></ul></li><li id="css_insert_lines"><h4>css_insert_lines</h4><ul><li><h5>Description</h5>Inserts new line characters between every CSS code block.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>style</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Insert Empty Lines</li></ul></li><li id="diff"><h4>diff</h4><ul><li><h5>Description</h5>The code sample to be compared to 'source' option. This is required if mode is 'diff'.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>diff</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5></li><li><h5>As labeled in the HTML tool</h5>Code to Compare</li></ul></li><li id="diff_comments"><h4>diff_comments</h4><ul><li><h5>Description</h5>If true then comments will be preserved so that both code and comments are compared by the diff engine.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>diff</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Code Comments</li></ul></li><li id="diff_context"><h4>diff_context</h4><ul><li><h5>Description</h5>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.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>number</li><li><h5>Mode</h5>diff</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>-1</li><li><h5>As labeled in the HTML tool</h5>Context Size</li></ul></li><li id="diff_format"><h4>diff_format</h4><ul><li><h5>Description</h5>The format of the output. The command line output format is text, similar to Unix 'diff'.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>diff</li><li><h5>Lexer</h5>any</li><li><h5>Accepted Values</h5><dl><dt>html</dt><dd>An HTML format for embedding in web pages, or as a complete web page if document_complete is true.</dd><dt>json</dt><dd>A JSON format.</dd><dt>text</dt><dd>Formatted similar to the Unix 'diff' command line utility.</dd></dl></li><li><h5>Default</h5>text</li><li><h5>As labeled in the HTML tool</h5>Diff Format</li></ul></li><li id="diff_label"><h4>diff_label</h4><ul><li><h5>Description</h5>This allows for a descriptive label for the diff file code of the diff HTML output.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>diff</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>New Sample</li><li><h5>As labeled in the HTML tool</h5>Label for Diff Sample</li></ul></li><li id="diff_rendered_html"><h4>diff_rendered_html</h4><ul><li><h5>Description</h5>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.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>diff</li><li><h5>Lexer</h5>markup</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Compare Rendered HTML</li></ul></li><li id="diff_space_ignore"><h4>diff_space_ignore</h4><ul><li><h5>Description</h5>If white space only differences should be ignored by the diff tool.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>diff</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Remove White Space</li></ul></li><li id="diff_view"><h4>diff_view</h4><ul><li><h5>Description</h5>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.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>diff</li><li><h5>Lexer</h5>any</li><li><h5>Accepted Values</h5><dl><dt>inline</dt><dd>A single column where insertions and deletions are vertically adjacent.</dd><dt>sidebyside</dt><dd>Two column comparison of changes.</dd></dl></li><li><h5>Default</h5>sidebyside</li><li><h5>As labeled in the HTML tool</h5>Diff View Type</li></ul></li><li id="else_line"><h4>else_line</h4><ul><li><h5>Description</h5>If else_line is true then the keyword 'else' is forced onto a new line.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>script</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Else On New Line</li></ul></li><li id="end_comma"><h4>end_comma</h4><ul><li><h5>Description</h5>If there should be a trailing comma in arrays and objects. Value "multiline" only applies to modes beautify and diff.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>script</li><li><h5>Accepted Values</h5><dl><dt>always</dt><dd>Always ensure there is a tailing comma</dd><dt>never</dt><dd>Remove trailing commas</dd><dt>none</dt><dd>Ignore this option</dd></dl></li><li><h5>Default</h5>never</li><li><h5>As labeled in the HTML tool</h5>Trailing Comma</li></ul></li><li id="end_quietly"><h4>end_quietly</h4><ul><li><h5>Description</h5>A node only option to determine if terminal summary data should be logged to the console.</li><li><h5>Environment</h5>node</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>any</li><li><h5>Accepted Values</h5><dl><dt>default</dt><dd>Default minimal summary</dd><dt>log</dt><dd>Verbose logging</dd><dt>quiet</dt><dd>No extraneous logging</dd></dl></li><li><h5>Default</h5>default</li><li><h5>As labeled in the HTML tool</h5>Log Summary to Console</li></ul></li><li id="force_attribute"><h4>force_attribute</h4><ul><li><h5>Description</h5>If all markup attributes should be indented each onto their own line.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>markup</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Force Indentation of All Attributes</li></ul></li><li id="force_indent"><h4>force_indent</h4><ul><li><h5>Description</h5>Will force indentation upon all content and tags without regard for the creation of new text nodes.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>markup</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Force Indentation of All Content</li></ul></li><li id="format_array"><h4>format_array</h4><ul><li><h5>Description</h5>Determines if all array indexes should be indented, never indented, or left to the default.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>script</li><li><h5>Accepted Values</h5><dl><dt>default</dt><dd>Default formatting</dd><dt>indent</dt><dd>Always indent each index of an array</dd><dt>inline</dt><dd>Ensure all array indexes appear on a single line</dd></dl></li><li><h5>Default</h5>default</li><li><h5>As labeled in the HTML tool</h5>Formatting Arrays</li></ul></li><li id="format_object"><h4>format_object</h4><ul><li><h5>Description</h5>Determines if all object keys should be indented, never indented, or left to the default.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>script</li><li><h5>Accepted Values</h5><dl><dt>default</dt><dd>Default formatting</dd><dt>indent</dt><dd>Always indent each key/value pair</dd><dt>inline</dt><dd>Ensure all key/value pairs appear on the same single line</dd></dl></li><li><h5>Default</h5>default</li><li><h5>As labeled in the HTML tool</h5>Formatting Objects</li></ul></li><li id="function_name"><h4>function_name</h4><ul><li><h5>Description</h5>If a space should follow a JavaScript function name.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>script</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Space After Function Name</li></ul></li><li id="help"><h4>help</h4><ul><li><h5>Description</h5>A node only option to print documentation to the console. The value determines where to wrap text.</li><li><h5>Environment</h5>node</li><li><h5>Type</h5>number</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>80</li><li><h5>As labeled in the HTML tool</h5>Help Wrapping Limit</li></ul></li><li id="indent_char"><h4>indent_char</h4><ul><li><h5>Description</h5>The string characters to comprise a single indentation. Any string combination is accepted.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5> </li><li><h5>As labeled in the HTML tool</h5>Indentation Characters</li></ul></li><li id="indent_level"><h4>indent_level</h4><ul><li><h5>Description</h5>How much indentation padding should be applied to beautification? This option is internally used for code that requires switching between libraries.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>number</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>0</li><li><h5>As labeled in the HTML tool</h5>Indentation Padding</li></ul></li><li id="indent_size"><h4>indent_size</h4><ul><li><h5>Description</h5>The number of 'indent_char' values to comprise a single indentation.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>number</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>4</li><li><h5>As labeled in the HTML tool</h5>Indent Size</li></ul></li><li id="jsscope"><h4>jsscope</h4><ul><li><h5>Description</h5>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.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>script</li><li><h5>Accepted Values</h5><dl><dt>html</dt><dd>generates HTML output with escaped angle braces and ampersands for embedding as code, which is handy in code producing tools</dd><dt>none</dt><dd>prevents use of this option</dd><dt>report</dt><dd>generates HTML output that renders in web browsers</dd></dl></li><li><h5>Default</h5>none</li><li><h5>As labeled in the HTML tool</h5>JavaScript Scope Identification</li></ul></li><li id="language"><h4>language</h4><ul><li><h5>Description</h5>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.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>auto</li><li><h5>As labeled in the HTML tool</h5>Language</li></ul></li><li id="language_default"><h4>language_default</h4><ul><li><h5>Description</h5>The fallback option if option 'lang' is set to 'auto' and a language cannot be detected.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>text</li><li><h5>As labeled in the HTML tool</h5>Language Auto-Detection Default</li></ul></li><li id="language_name"><h4>language_name</h4><ul><li><h5>Description</h5>The formatted proper name of the code sample's language for use in reports read by people.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>JavaScript</li><li><h5>As labeled in the HTML tool</h5>Formatted Name of the Code's Language</li></ul></li><li id="lexer"><h4>lexer</h4><ul><li><h5>Description</h5>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.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>any</li><li><h5>Accepted Values</h5><dl><dt>auto</dt><dd>The value 'auto' imposes language and lexer auto-detection, which ignores deliberately specified language values.</dd><dt>markup</dt><dd>parses languages like XML and HTML</dd><dt>script</dt><dd>parses languages with a C style syntax, such as JavaScript</dd><dt>style</dt><dd>parses CSS like languages</dd></dl></li><li><h5>Default</h5>auto</li><li><h5>As labeled in the HTML tool</h5>Parsing Lexer</li></ul></li><li id="list_options"><h4>list_options</h4><ul><li><h5>Description</h5>A Node.js only option that writes current option settings to the console.</li><li><h5>Environment</h5>node</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Options List</li></ul></li><li id="method_chain"><h4>method_chain</h4><ul><li><h5>Description</h5>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.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>number</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>script</li><li><h5>Default</h5>3</li><li><h5>As labeled in the HTML tool</h5>Method Chains</li></ul></li><li id="minify_keep_comments"><h4>minify_keep_comments</h4><ul><li><h5>Description</h5>Prevents minification from stripping out comments.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>minify</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Keep Comments</li></ul></li><li id="minify_wrap"><h4>minify_wrap</h4><ul><li><h5>Description</h5>Whether minified script should wrap after a specified character width. This option requires a value from option 'wrap'.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>minify</li><li><h5>Lexer</h5>script</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Minification Wrapping</li></ul></li><li id="mode"><h4>mode</h4><ul><li><h5>Description</h5>The operation to be performed.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>any</li><li><h5>Accepted Values</h5><dl><dt>beautify</dt><dd>beautifies code and returns a string</dd><dt>diff</dt><dd>returns either command line list of differences or an HTML report</dd><dt>minify</dt><dd>minifies code and returns a string</dd><dt>parse</dt><dd>using option 'parseFormat' returns an object with shallow arrays, a multidimensional array, or an HTML report</dd></dl></li><li><h5>Default</h5>diff</li><li><h5>As labeled in the HTML tool</h5>Mode</li></ul></li><li id="never_flatten"><h4>never_flatten</h4><ul><li><h5>Description</h5>If destructured lists in script should never be flattend.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>script</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Never Flatten Destructured Lists</li></ul></li><li id="new_line"><h4>new_line</h4><ul><li><h5>Description</h5>Insert an empty line at the end of output.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>New Line at End of Code</li></ul></li><li id="no_case_indent"><h4>no_case_indent</h4><ul><li><h5>Description</h5>If a case statement should receive the same indentation as the containing switch block.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>script</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Case Indentation</li></ul></li><li id="no_lead_zero"><h4>no_lead_zero</h4><ul><li><h5>Description</h5>Whether leading 0s in CSS values immediately preceding a decimal should be removed or prevented.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>style</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Leading 0s</li></ul></li><li id="no_semicolon"><h4>no_semicolon</h4><ul><li><h5>Description</h5>Removes semicolons that would be inserted by ASI. This option is in conflict with option 'correct' and takes precedence over conflicting features. Use of this option is a possible security/stability risk.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>script</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>No Semicolons</li></ul></li><li id="node_error"><h4>node_error</h4><ul><li><h5>Description</h5>A Node.js only option if parse errors should be written to the console.</li><li><h5>Environment</h5>node</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Write Parse Errors in Node</li></ul></li><li id="object_sort"><h4>object_sort</h4><ul><li><h5>Description</h5>Sorts markup attributes and properties by key name in script and style.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Object/Attribute Sort</li></ul></li><li id="output"><h4>output</h4><ul><li><h5>Description</h5>A file path for which to write output. If this option is not specified output will be printed to the shell.</li><li><h5>Environment</h5>node</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5></li><li><h5>As labeled in the HTML tool</h5>Output Location</li></ul></li><li id="parse_format"><h4>parse_format</h4><ul><li><h5>Description</h5>Determines the output format for 'parse' mode.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>parse</li><li><h5>Lexer</h5>any</li><li><h5>Accepted Values</h5><dl><dt>htmltable</dt><dd>generates the 'table' type output for the DOM but escapes the HTML tags for rendering as HTML code in a HTML tool</dd><dt>parallel</dt><dd>returns an object containing series of parallel arrays</dd><dt>sequential</dt><dd>returns an array where each index is a child object containing the parsed token and all descriptive data</dd><dt>table</dt><dd>generates a colorful grid of output for either the dom or command line interface</dd></dl></li><li><h5>Default</h5>parallel</li><li><h5>As labeled in the HTML tool</h5>Parse Format</li></ul></li><li id="parse_space"><h4>parse_space</h4><ul><li><h5>Description</h5>Whether whitespace tokens should be included in markup parse output.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>parse</li><li><h5>Lexer</h5>markup</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Retain White Space Tokens in Parse Output</li></ul></li><li id="preserve"><h4>preserve</h4><ul><li><h5>Description</h5>The maximum number of consecutive empty lines to retain.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>number</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>0</li><li><h5>As labeled in the HTML tool</h5>Preserve Consecutive New Lines</li></ul></li><li id="preserve_comment"><h4>preserve_comment</h4><ul><li><h5>Description</h5>Prevent comment reformatting due to option wrap.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Eliminate Word Wrap Upon Comments</li></ul></li><li id="preserve_text"><h4>preserve_text</h4><ul><li><h5>Description</h5>If text in the provided markup code should be preserved exactly as provided. This option eliminates beautification and wrapping of text content.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>markup</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Preserve Markup Text White Space</li></ul></li><li id="quote"><h4>quote</h4><ul><li><h5>Description</h5>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.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>diff</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Normalize Quotes</li></ul></li><li id="quote_convert"><h4>quote_convert</h4><ul><li><h5>Description</h5>If the quotes of script strings or markup attributes should be converted to single quotes or double quotes.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>any</li><li><h5>Accepted Values</h5><dl><dt>double</dt><dd>Converts single quotes to double quotes</dd><dt>none</dt><dd>Ignores this option</dd><dt>single</dt><dd>Converts double quotes to single quotes</dd></dl></li><li><h5>Default</h5>none</li><li><h5>As labeled in the HTML tool</h5>Indent Size</li></ul></li><li id="read_method"><h4>read_method</h4><ul><li><h5>Description</h5>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.</li><li><h5>Environment</h5>node</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>any</li><li><h5>Accepted Values</h5><dl><dt>auto</dt><dd>changes to value subdirectory, file, or screen depending on source resolution</dd><dt>directory</dt><dd>process all files in the specified directory only</dd><dt>file</dt><dd>reads a file and outputs to a file. file requires option 'output'</dd><dt>screen</dt><dd>reads from screen and outputs to screen</dd><dt>subdirectory</dt><dd>process all files in a directory and its subdirectories</dd></dl></li><li><h5>Default</h5>auto</li><li><h5>As labeled in the HTML tool</h5>Read Method</li></ul></li><li id="selector_list"><h4>selector_list</h4><ul><li><h5>Description</h5>If comma separated CSS selectors should present on a single line of code.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>style</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Indent Size</li></ul></li><li id="semicolon"><h4>semicolon</h4><ul><li><h5>Description</h5>If true and mode is 'diff' and lang is 'javascript' all semicolon characters that immediately precede any white space containing a new line character will be removed so as to eliminate some differences from the code comparison.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>diff</li><li><h5>Lexer</h5>script</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Indent Size</li></ul></li><li id="source"><h4>source</h4><ul><li><h5>Description</h5>The source code or location for interpretation. This option is required for all modes.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5></li><li><h5>As labeled in the HTML tool</h5>Source Sample</li></ul></li><li id="source_label"><h4>source_label</h4><ul><li><h5>Description</h5>This allows for a descriptive label of the source file code for the diff HTML output.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>diff</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>Source Sample</li><li><h5>As labeled in the HTML tool</h5>Label for Source Sample</li></ul></li><li id="space"><h4>space</h4><ul><li><h5>Description</h5>Inserts a space following the function keyword for anonymous functions.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>script</li><li><h5>Default</h5>true</li><li><h5>As labeled in the HTML tool</h5>Function Space</li></ul></li><li id="space_close"><h4>space_close</h4><ul><li><h5>Description</h5>Markup self-closing tags end will end with ' />' instead of '/>'.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>markup</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Close Markup Self-Closing Tags with a Space</li></ul></li><li id="styleguide"><h4>styleguide</h4><ul><li><h5>Description</h5>Provides a collection of option presets to easily conform to popular JavaScript style guides.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>script</li><li><h5>Accepted Values</h5><dl><dt>airbnb</dt><dd>https://github.com/airbnb/javascript</dd><dt>crockford</dt><dd>http://jslint.com/</dd><dt>google</dt><dd>https://google.github.io/styleguide/jsguide.html</dd><dt>jquery</dt><dd>https://contribute.jquery.org/style-guide/js/</dd><dt>jslint</dt><dd>http://jslint.com/</dd><dt>mediawiki</dt><dd>https://www.mediawiki.org/wiki/Manual:Coding_conventions/JavaScript</dd><dt>mrdoob</dt><dd>https://github.com/mrdoob/three.js/wiki/Mr.doob's-Code-Style%E2%84%A2</dd><dt>none</dt><dd>Ignores this option</dd><dt>semistandard</dt><dd>https://github.com/Flet/semistandard</dd><dt>standard</dt><dd>https://standardjs.com/</dd><dt>yandex</dt><dd>https://github.com/ymaps/codestyle/blob/master/javascript.md</dd></dl></li><li><h5>Default</h5>none</li><li><h5>As labeled in the HTML tool</h5>Script Styleguide</li></ul></li><li id="summary_only"><h4>summary_only</h4><ul><li><h5>Description</h5>Node only option to output only number of differences.</li><li><h5>Environment</h5>node</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>diff</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Output Diff Only Without A Summary</li></ul></li><li id="tag_merge"><h4>tag_merge</h4><ul><li><h5>Description</h5>Allows immediately adjacement start and end markup tags of the same name to be combined into a single self-closing tag.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>markup</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Merge Adjacent Start and End tags</li></ul></li><li id="tag_sort"><h4>tag_sort</h4><ul><li><h5>Description</h5>Sort child items of each respective markup parent element.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>markup</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Sort Markup Child Items</li></ul></li><li id="ternary_line"><h4>ternary_line</h4><ul><li><h5>Description</h5>If ternary operators in JavaScript ? and : should remain on the same line.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>script</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Keep Ternary Statements On One Line</li></ul></li><li id="top_comments"><h4>top_comments</h4><ul><li><h5>Description</h5>If mode is 'minify' this determines whether comments above the first line of code should be kept.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>minify</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Retain Comment At Code Start</li></ul></li><li id="unformatted"><h4>unformatted</h4><ul><li><h5>Description</h5>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.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>markup</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Markup Tag Preservation</li></ul></li><li id="variable_list"><h4>variable_list</h4><ul><li><h5>Description</h5>If consecutive JavaScript variables should be merged into a comma separated list or if variables in a list should be separated.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>string</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>script</li><li><h5>Accepted Values</h5><dl><dt>each</dt><dd>Ensurce each reference is a single declaration statement.</dd><dt>list</dt><dd>Ensure consecutive declarations are a comma separated list.</dd><dt>none</dt><dd>Ignores this option.</dd></dl></li><li><h5>Default</h5>none</li><li><h5>As labeled in the HTML tool</h5>Variable Declaration Lists</li></ul></li><li id="version"><h4>version</h4><ul><li><h5>Description</h5>A Node.js only option to write the version information to the console.</li><li><h5>Environment</h5>node</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Version</li></ul></li><li id="vertical"><h4>vertical</h4><ul><li><h5>Description</h5>If lists of assignments and properties should be vertically aligned. This option is not used with the markup lexer.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>boolean</li><li><h5>Mode</h5>beautify</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>false</li><li><h5>As labeled in the HTML tool</h5>Vertical Alignment</li></ul></li><li id="wrap"><h4>wrap</h4><ul><li><h5>Description</h5>Character width limit before applying word wrap. A 0 value disables this option. A negative value concatenates script strings.</li><li><h5>Environment</h5>any</li><li><h5>Type</h5>number</li><li><h5>Mode</h5>any</li><li><h5>Lexer</h5>any</li><li><h5>Default</h5>0</li><li><h5>As labeled in the HTML tool</h5>Wrap</li></ul></li>
<!-- option list end -->
</ol>
</div>
</div>
<div>
<h2>
<buttonaria-disabled="true" class="heading" role="presentation">Run the Application
<spanaria-hidden="true">Show</span>
</button>
</h2>
<divclass="content-hide">
<divclass="segment" id="getcode">
<h3>Get the Code</h3>
<p>Various options are available for greater portability</p>
<p>To get started with the application on the command line try the <em>commands</em> command to see a list of available features and detailed instructions: <code>node js/services commands</code></p>
<p>To run the application in a web browser with Pretty Diff's HTML execute the <em>server</em> command: <code>node js/services server</code> or simply navigate your browser to the project's <em>index.xhtml</em> file in the local filesystem.</p>
<p>To run the application in a different browser application simply reference or include the built <em>js/browser.js</em> file. See the <ahref="tests/browser.html">third party demo</a> for an example.</p>
</div>
<divclass="segment" id="prettydiffrc">
<h3>The .prettydiffrc File</h3>
<p>To ease configuration Pretty Diff provides support for a <ahref=".prettydiffrc">.prettydiffrc</a> file that stores option settings as a sort of saved preferences. The .prettydiffrc file is only used when the application is executed via Node.js via the supplied <em>js/services.js</em> file, but is checked each time the application executes. This file supports two formats: JavaScript logic and JSON. Options <strong>api</strong>, <strong>diff</strong>, and <strong>source</strong> are not supported in the .prettydiffrc file.</p>
<p>Pretty Diff will look for the .prettydiffrc file starting in the directory specified or the directory containing a specified file. If no .prettydiffrc file is present Pretty Diff will check the next higher directory until reaching root. If the option <em>read_method</em> is value <em>screen</em> or <em>auto</em> and resolves to value screen then the starting location to look for the .prettydiffrc file will be the terminal's current working directory.</p>
<h4>JSON Format</h4>
<p>In order for the options to be accepted by the application the provided options must match a defined option name and the corresponding value must be the proper data type. In the case where an option is string type and accepts a specified set of values the specified value much match one of the supported value names. Here are some examples:</p>
<p><strong>Bad</strong><code>{"indent_size": " ", "format_object": "inline"}</code> This is bad, because the "indent_size" option is provided a value with the incorrect data type. It will be ignored from the application, but the specified "format_object" option will be accepted.</p>
<p><strong>Bad</strong><code>{"indent_size": 3, "format_object": "never"}</code> The value for option "format_object" is the correct data type, but that option accepts one of three values and "never" is not a supported value. Pretty Diff will accept the "indent_size" option with value 3, but will ignore the specified "format_object".</p>
<h4>JavaScript Format</h4>
<p>To give users greater control and flexibility over the application a JavaScript format is also accepted. This will allow users to specify options conditionally. Please start with this following template:</p>
<p>
<code>(function rc() {</code>
<code> "use strict";</code>
<code> const rclogic = function rc_logic(options) {</code>
<code> // edit below this line</code>
<code></code>
<code></code>
<code></code>
<code></code>
<code></code>
<code></code>
<code></code>
<code> // edit above this line</code>
<code> return options;</code>
<code> };</code>
<code> module.exports = rclogic;</code>
<code>}());</code>
</p>
<p>JavaScript logic that deviates from the template may result in an error causing the Pretty Diff application to no longer run. For security concerns no use of <em>require</em>, <em>import</em>, and no other use of <em>export</em> is permitted. Ignoring these security concerns will cause the file to be ignored. The options must be assigned with conforming value data types exactly as specified under the <em>JSON Format</em> section in order to be accepted. Examples:</p>
<p>
<code>(function rc() {</code>
<code> "use strict";</code>
<code> const rclogic = function rc_logic(options) {</code>
<code> // edit below this line</code>
<code></code>
<code> if (options.mode === "beautify" && options.lexer === "style") {</code>
<buttonaria-disabled="true" class="heading" role="presentation">Contributor Information
<spanaria-hidden="true">Show</span>
</button>
</h2>
<divclass="content-hide">
<divclass="segment">
<h3>Contribution Guide</h3>
<p>For questions, features, or bug reports please open an issue on
<ahref="https://github.com/prettydiff/prettydiff/issues">Github</a>. If you are executing from the command line insert the <em>debug</em> 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.</p>
<p>If you wish to propose code changes then follow these steps:</p>
<ol>
<li>Fork the repository on Github and then clone down the fork to your local computer.</li>
<li>Create a new branch for your changes:
<code>git checkout -b <em>branchName</em></code>
</li>
<li>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.
<ul>
<li>The <strong>simulation</strong> command runs just the simulation tests. These tests validate features of the command line operation. These tests are stored in the file <em>tests/simulations.ts</em>.</li>
<li>The <strong>validation</strong> command runs the code unit tests that validate the beautification and minification functions. These tests are stored in the <em>tests/formatted</em> and <em>tests/raw</em> 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.</li>
<li>The diff tests are execution as a part of the simulation tests. The code units for the diff tests are stored in the directories <em>tests/diffbase</em> and <em>tests/diffnew</em>.</li>
<li>The parser has its own unit tests that are part of that project. Please see its Github repository: <ahref="http://github.com/unibeautify/sparser">sparser</a>.</li>
</ul>
</li>
<li>Run the unit tests to verify if your changes are breaking things:
<code>node js/services test</code>
</li>
<li>Finally, open a pull request on Github or if you are having trouble with the build open a Github issue and ask for help.</li>
</ol>
</div>
<divclass="segment">
<h3>Troubleshooting Help</h3>
<p>A few helpful tips in case you get stuck.</p>
<ul>
<li>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 <code>tsc --pretty</code>.</li>
<li>Ensure dependencies are up to date. Try running <code>npm update</code>. A version mismatch between Pretty Diff and the parser could result in unpredictable behavior.</li>
<li>If you need help generating the appropriate details for a Github issue try using the <em>debug</em> feature. Simply run your command on the terminal and add <em>debug</em> or <em>prettydiff_debug</em> to generate an issue template in markdown format.</li>
<li>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 <em>validation</em> command. You could also use the parser's <em>server</em> command to run a frontend in your browser that is easier to read. The parser is at <ahref="http://github.com/unibeautify/sparser">sparser</a></li>
<li>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.</li>