Skip to content

Commit

Permalink
fixes #43. Empty lines are now preserved for CSS like languages.
Browse files Browse the repository at this point in the history
  • Loading branch information
prettydiff committed Jan 10, 2015
1 parent 58a600e commit 843185f
Show file tree
Hide file tree
Showing 13 changed files with 563 additions and 393 deletions.
2 changes: 1 addition & 1 deletion .bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name" : "prettydiff",
"version" : "1.7.1",
"version" : "1.7.2",
"description" : "Pretty Diff can minify, beautify (pretty print), or diff code to normalize white space and comments so that only code is being compared.",
"keywords" : [
"pretty diff", "minify", "beautify", "pretty print", "white space", "whitespace", "diff", "compare", "html", "javascript", "xml", "json", "css", "less", "scss", "scope", "analysis", "node", "nodejs", "wsh"
Expand Down
304 changes: 173 additions & 131 deletions api/dom.js

Large diffs are not rendered by default.

24 changes: 13 additions & 11 deletions api/node-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Examples:
obfuscate : false,
objsort : "none",
output : "",
preserve : true,
preserve : "none",
quote : false,
readmethod : "screen",
report : true,
Expand Down Expand Up @@ -288,7 +288,7 @@ Examples:
a.push("Arguments - Type - Definition");
a.push("-------------------------------------");
a.push("* color - string - The color scheme of the reports. Default is shadow.");
a.push(" Accepted values: default, coffee, dark, canvas, shadow, white");
a.push(" Accepted values: default, canvas, shadow, white");
a.push("");
a.push("* comments - string - If mode is 'beautify' this will determine whether");
a.push(" comments should always start at position 0 of each");
Expand Down Expand Up @@ -403,10 +403,11 @@ Examples:
a.push(" the output. If the directory path or file exists it");
a.push(" will be over written else it will be created.");
a.push("");
a.push("* preserve - boolean - Should empty lines be removed during JavaScript");
a.push(" beautification? Default value is true which retains");
a.push(" one empty line for any series of empty lines in the");
a.push(" code input.");
a.push("* preserve - string - Should empty lines be removed during JavaScript or");
a.push(" CSS beautification? Default value is true which");
a.push(" retains one empty line for any series of empty lines");
a.push(" in the code input.");
a.push(" Accepted values: all, css, js, none");
a.push("");
a.push("* quote - boolean - If true and mode is 'diff' then all single quote");
a.push(" characters will be replaced by double quote");
Expand Down Expand Up @@ -577,9 +578,6 @@ Examples:
if (d[b][0] === "" && d[b][1] === "help") {
help = true;
}
if (d[b][0] === "alphasort" && d[b][1] === "true") {
alphasort = true;
}
if (d[b][0] === "color" && (d[b][1] === "default" || d[b][1] === "coffee" || d[b][1] === "dark" || d[b][1] === "canvas" || d[b][1] === "white")) {
options.color = d[b][1];
}
Expand Down Expand Up @@ -672,8 +670,12 @@ Examples:
if (d[b][0] === "output" && d[b][1].length > 0) {
options.output = pathslash(d[b][0], d[b][1]);
}
if (d[b][0] === "preserve" && d[b][1] === "false") {
options.preserve = false;
if (d[b][0] === "preserve") {
if (d[b][1] === "all" || d[b][1] === "css" || d[b][1] === "js")) {
options.preserve = d[b][1];
} else if (d[b][1] === "true") {
options.preserve = "all";
}
}
if (d[b][0] === "quote" && d[b][1] === "true") {
options.quote = true;
Expand Down
10 changes: 7 additions & 3 deletions api/prettydiff.wsf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
error.push("Arguments - Type - Definition");
error.push("-------------------------------------");
error.push("* color - string - The color scheme of the reports. Default is shadow.");
error.push(" Accepted values: default, coffee, dark, canvas, shadow, white");
error.push(" Accepted values: default, canvas, shadow, white");
error.push("");
error.push("* comments - string - If mode is 'beautify' this will determine whether comments should always start at position 0 of each line or if comments should be indented according to the code. Default is 'indent'.");
error.push(" Accepted values: indent, noindent");
Expand Down Expand Up @@ -86,7 +86,8 @@
error.push("");
error.push("* output - string - The location of the output file. If the file does not exist it will be created. If this argument is missing output will print to screen.");
error.push("");
error.push("* preserve - boolean - If true runs of empty lines are condensed into a single empty line of beautified JavaScript. If false empty lines are removed. Default is true.");
error.push("* preserve - string - Runs of empty lines are condensed into a single empty line of beautified JavaScript or CSS. Default is 'none'.");
error.push(" Accepted values: all, css, js, none");
error.push("");
error.push("* quote - boolean - 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.");
error.push("");
Expand Down Expand Up @@ -276,7 +277,7 @@
args.obfuscate = WScript.Arguments.Named("obfuscate") || false;
args.objsort = (WScript.Arguments.Named("objsort") === "all" || WScript.Arguments.Named("objsort") === "css" || WScript.Arguments.Named("objsort") === "js") ? WScript.Arguments.Named("objsort") : "none";
args.quote = (WScript.Arguments.Named("quote") === "true" || WScript.Arguments.Named("quote") === true) ? true : false;
args.preserve = (WScript.Arguments.Named("preserve") === "false" || WScript.Arguments.Named("preserve") === false) ? false : true;
args.preserve = (WScript.Arguments.Named("preserve") === "all" || WScript.Arguments.Named("preserve") === "css" || WScript.Arguments.Named("preserve") === "js") ? WScript.Arguments.Named("preserve") : "none";
args.semicolon = (WScript.Arguments.Named("semicolon") === "true" || WScript.Arguments.Named("semicolon") === true) ? true : false;
args.sourcelabel = WScript.Arguments.Named("sourcelabel") || "base";
args.space = (WScript.Arguments.Named("space") === "false" || WScript.Arguments.Named("space") === false) ? false : true;
Expand All @@ -292,6 +293,9 @@
if (WScript.Arguments.Named("objsort") === "true" || WScript.Arguments.Named("alphasort") === "true") {
args.objsort = "all";
}
if (WScript.Arguments.Named("preserve") === "true") {
args.preserve = "all";
}
if (WScript.Arguments.Named("vertical") === "true") {
args.vertical = "all";
}
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name" : "prettydiff",
"version" : "1.7.1",
"version" : "1.7.2",
"main" : "./",
"dependencies": {},
"ignore" : [
Expand Down
2 changes: 1 addition & 1 deletion diffview.css

Large diffs are not rendered by default.

58 changes: 54 additions & 4 deletions documentation.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,18 @@
included with report output based upon the operating environment.</li>
</ul>
</li>
<li><h4>color <strong>(node-local.js only)</strong></h4>
<ul>
<li><h5>Description</h5>
Specifies which color scheme to apply to the output file.</li>
<li><h5>Type</h5>
string</li>
<li><h5>Default</h5>
white</li>
<li><h5>Accepted values</h5>
canvas, default, shadow, white</li>
</ul>
</li>
<li><h4>comments</h4>
<ul>
<li><h5>Description</h5>Determines whether comments should be indented.
Expand Down Expand Up @@ -537,6 +549,12 @@
Force Indentation (Markup Only)</li>
</ul>
</li>
<li><h4>help (node-local.js only)</h4>
<ul>
<li><h5>Description</h5>
Displays documenation to the command line or console.</li>
</ul>
</li>
<li><h4>html</h4>
<ul>
<li><h5>Description</h5>
Expand Down Expand Up @@ -712,17 +730,27 @@
Property Sorting (CSS / JavaScript)</li>
</ul>
</li>
<li><h4>output <strong>(node-local.js only)</strong></h4>
<ul>
<li><h5>Description</h5>
Determines the location of where files should be saved.</li>
<li><h5>Type</h5>
string</li>
</ul>
</li>
<li><h4>preserve</h4>
<ul>
<li><h5>Description</h5>
Retain empty lines in JavaScript. A consecutive empty lines will be
Retain empty lines in either JavaScript or CSS like languages. Consecutive empty lines will be
converted to a single empty line.</li>
<li><h5>Type</h5>
boolean</li>
string</li>
<li><h5>Accepted values</h5>
all, css, js, none</li>
<li><h5>Default</h5>
true</li>
none</li>
<li><h5>As labeled in the HTML tool</h5>
Empty Lines (JavaScript Only)</li>
Empty Lines (CSS / JavaScript)</li>
</ul>
</li>
<li><h4>quote</h4>
Expand All @@ -738,6 +766,28 @@
Diff Quotes</li>
</ul>
</li>
<li><h4>readmethod <strong>(node-local.js only)</strong></h4>
<ul>
<li><h5>Description</h5>
Determines how input should be received. The value <em>auto</em> changes to directory, file, or screen depending on the source type. The value <em>directory</em> will read all files from a single directory. The value <em>file</em> reads the contents of a single file. The value <em>filescreen</em> reads the contents of a file but outputs the result to the console. The value <em>screen</em> will look to the console for code input and outputs to the console. The value <em>subdirectory</em> will recursively read files in subdirectories.</li>
<li><h5>Type</h5>
string</li>
<li><h5>Default</h5>
screen</li>
<li><h5>Accepted values</h5>
auto, directory, file, filescreen, screen, subdirectory</li>
</ul>
</li>
<li><h4>report <strong>(node-local.js only)</strong></h4>
<ul>
<li><h5>Description</h5>
Determines if a meta data report should be generated.</li>
<li><h5>Type</h5>
boolean</li>
<li><h5>Default</h5>
true</li>
</ul>
</li>
<li><h4>semicolon</h4>
<ul>
<li><h5>Descriptiong</h5>
Expand Down
14 changes: 8 additions & 6 deletions guide/guide.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ div {
}
#doc .beautify {
font-family: "Courier New",Courier,"Lucida Console",monospace;
padding : 0;
overflow : scroll;
max-width : 100%;
overflow : scroll;
padding : 0;
}
#dcolorScheme {
margin-top: -3em;
Expand Down Expand Up @@ -67,12 +67,14 @@ code span {
}
code.commandLine {
background : #000;
border : 0.1em solid #999;
border-radius: 0.5em;
color : #fff;
font-family : monospace;
max-width : 100%;
overflow : scroll;
padding : 0.2em;
white-space : pre-wrap;
border : 0.1em solid #999;
}
code.commandLine .delete {
color: #b00;
Expand Down Expand Up @@ -103,22 +105,22 @@ h1 span {
margin-top: 1em;
}
#doc h2 {
border-style: none;
clear : both;
display : block;
float : none;
border-style: none;
margin : 0 0 2em;
}
#doc h4 {
margin-top: 0;
}
#doc .beautify h4 {
position: absolute;
left : -200em;
position: absolute;
}
h1 svg {
border : 0.025em solid #000;
width : 1.475em;
height : 1.475em;
margin-bottom: -0.1em;
width : 1.475em;
}
Loading

0 comments on commit 843185f

Please sign in to comment.