|
|
- /*prettydiff.com api.topcoms: true, api.insize: 4, api.inchar: " ", api.vertical: true */
- /*global pd, ace, exports, define */
- /*jslint for: true*/
- /*
-
- Execute in a NodeJS app:
-
- npm install prettydiff (local install)
-
- var prettydiff = require("prettydiff"),
- args = {
- source: "asdf",
- diff : "asdd",
- lang : "text"
- },
- output = prettydiff.api(args);
-
- Execute on command line with NodeJS:
-
- npm install prettydiff -g (global install)
-
- prettydiff source:"c:\mydirectory\myfile.js" readmethod:"file" diff:"c:\myotherfile.js"
-
- Execute with WSH:
- cscript prettydiff.wsf /source:"myFile.xml" /mode:"beautify"
-
- Execute from JavaScript:
- var args = {
- source: "asdf",
- diff : "asdd",
- lang : "text"
- },
- output = prettydiff(args);
-
-
- ******* license start *******
- @source: http://prettydiff.com/prettydiff.js
- @documentation - English: http://prettydiff.com/documentation.php
-
- @licstart The following is the entire license notice for Pretty Diff.
-
- This code may not be used or redistributed unless the following
- conditions are met:
-
- * Prettydiff created by Austin Cheney originally on 3 Mar 2009.
- http://prettydiff.com/
-
- * The use of diffview.js and prettydiff.js must contain the following
- copyright:
- Copyright (c) 2007, Snowtide Informatics Systems, Inc.
- All rights reserved.
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the
- distribution.
- - Neither the name of the Snowtide Informatics Systems nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written
- permission.
- - used as diffview function
- http://prettydiff.com/lib/diffview.js
-
- * The code mentioned above has significantly expanded documentation in
- each of the respective function's external JS file as linked from the
- documentation page:
- http://prettydiff.com/documentation.php
-
- * In addition to the previously stated requirements any use of any
- component, aside from directly using the full files in their entirety,
- must restate the license mentioned at the top of each concerned file.
-
- If each and all these conditions are met use, extension, alteration,
- and redistribution of Pretty Diff and its required assets is unlimited
- and free without author permission.
-
- @licend The above is the entire license notice for Pretty Diff.
- ******* license end *******
-
-
- Join the Pretty Diff mailing list at:
- https://groups.google.com/d/forum/pretty-diff
-
- Special thanks to:
-
- * Harry Whitfield for the numerous test cases provided against
- JSPretty. http://g6auc.me.uk/
-
- * Andreas Greuel for contributing samples to test diffview.js
- https://plus.google.com/105958105635636993368/posts
-
- */
- var prettydiff=function prettydiff(api){"use strict";var startTime=Date.now(),jsxstatus=false,summary="",charDecoder=function init_charDecoder(){return},csspretty=function init_csspretty(){return},csvbeauty=function init_csvbeauty(){return},csvmin=function init_csvmin(){return},diffview=function init_diffview(){return},jspretty=function init_jspretty(){return},markuppretty=function init_markuppretty(){return},safeSort=function safeSort(array,operation,recursive){var arTest=function safeSort_arTest(item){if(typeof item!=="object"||item.length===undefined||item.length<2){return false}return true},normal=function safeSort__normal(item){var done=[item[0]],storeb=item,child=function safeSort__normal_child(){var a=0,len=storeb.length;for(a=0;a<len;a+=1){if(arTest(storeb[a])===true){storeb[a]=safeSort__normal(storeb[a])}}},recurse=function safeSort__normal_recurse(x){var a=0,storea=[],len=storeb.length;for(a=0;a<len;a+=1){if(storeb[a]!==x){storea.push(storeb[a])}}storeb=storea;if(storea.length>0){done.push(storea[0]);safeSort__normal_recurse(storea[0])}else{if(recursive===true){child()}item=storeb}};recurse(array[0])},descend=function safeSort__descend(item){var c=0,storeb=item,len=item.length,child=function safeSort__descend_child(){var a=0,lenc=storeb.length;for(a=0;a<lenc;a+=1){if(arTest(storeb[a])===true){storeb[a]=safeSort__descend(storeb[a])}}},recurse=function safeSort__descend_recurse(){var a=0,b=0,d=0,e=0,ind=[],key=storeb[c],tstore="",tkey=typeof key;for(a=c;a<len;a+=1){tstore=typeof storeb[a];if(storeb[a]>key||(tstore>tkey)){key=storeb[a];ind=[a]}else if(storeb[a]===key){ind.push(a)}}d=ind.length;b=d+c;for(a=c;a<b;a+=1){storeb[ind[e]]=storeb[a];storeb[a]=key;e+=1}c+=d;if(c<len){safeSort__descend_recurse()}else{if(recursive===true){child()}item=storeb}};recurse();return item},ascend=function safeSort__ascend(item){var c=0,storeb=item,len=item.length,child=function safeSort__ascend_child(){var a=0,lenc=storeb.length;for(a=0;a<lenc;a+=1){if(arTest(storeb[a])===true){storeb[a]=safeSort__ascend(storeb[a])}}},recurse=function safeSort__ascend_recurse(){var a=0,b=0,d=0,e=0,ind=[],key=storeb[c],tstore="",tkey=typeof key;for(a=c;a<len;a+=1){tstore=typeof storeb[a];if(storeb[a]<key||tstore<tkey){key=storeb[a];ind=[a]}else if(storeb[a]===key){ind.push(a)}}d=ind.length;b=d+c;for(a=c;a<b;a+=1){storeb[ind[e]]=storeb[a];storeb[a]=key;e+=1}c+=d;if(c<len){safeSort__ascend_recurse()}else{if(recursive===true){child()}item=storeb}};recurse();return item};if(arTest(array)===false){return array}if(recursive==="true"){recursive=true}else if(recursive!==true){recursive=false}if(operation==="normal"){return normal(array)}if(operation==="descend"){return descend(array)}return ascend(array)},core=function core(api){var spacetest=(/^\s+$/g),apioutput="",apidiffout="",builder={},setlangmode=function core__langkey_setlangmode(input){if(input==="css"||input==="less"||input==="scss"){return "css"}if(input.indexOf("html")>-1||input==="html"||input==="ejs"||input==="html_ruby"||input==="handlebars"||input==="swig"||input==="twig"||input==="php"||input==="dustjs"){return "html"}if(input==="markup"||input==="jsp"||input==="xml"||input==="xhtml"){return "markup"}if(input==="javascript"||input==="json"||input==="jsx"){return "javascript"}if(input==="text"){return "text"}if(input==="csv"){return "csv"}if(input==="tss"||input==="titanium"){return "tss"}return "javascript"},nameproper=function core__langkey_nameproper(input){if(input==="javascript"){return "JavaScript"}if(input==="text"){return "Plain Text"}if(input==="jsx"){return "React JSX"}if(input==="scss"){return "SCSS (Sass)"}if(input==="ejs"){return "EJS Template"}if(input==="handlebars"){return "Handlebars Template"}if(input==="html_ruby"){return "ERB (Ruby) Template"}if(input==="tss"||input==="titanium"){return "Titanium Stylesheets"}if(input==="typescript"){return "TypeScript (not supported yet)"}if(input==="twig"){return "HTML TWIG Template"}if(input==="jsp"){return "JSTL (JSP)"}if(input==="java"){return "Java (not supported yet)"}return input.toUpperCase()},options={accessibility:(api.accessib
|