FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

updated parser to latest major version · prettydiff/prettydiff@ba1f982 · GitHub

Commit ba1f982

Browse files
committed
updated parser to latest major version
1 parent 601f7a2 commit ba1f982

31 files changed

Lines changed: 431 additions & 406 deletions

‎.eslintrc.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
],
2323
"no-console": "error",
2424
"no-continue": "error",
25+
"no-control-regex": 0,
2526
"no-else-return": "error",
2627
"no-empty": "error",
2728
"no-invalid-this": "error",

‎.gitignore‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
api/language.ts
21
js
32
node_modules

‎.gitmodules‎

Whitespace-only changes.

‎.npmignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

‎api/optionDef.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*global global*/
22
(function options_init(): void {
33
"use strict";
4-
const optionDef = {
4+
const optionDef:optionDef = {
55
brace_line : {
66
api : "any",
77
default : false,
@@ -32,9 +32,9 @@
3232
mode : "beautify",
3333
type : "string",
3434
values : {
35-
"collapse" : "Sets options.formatObject to 'indent' and options.neverflatten to true.",
36-
"collapse-preserve-inline": "Sets options.bracepadding to true and options.formatObject to 'inline'.",
37-
"expand" : "Sets options.braces to true, options.formatObject to 'indent', and options.never" +
35+
"collapse" : "Sets options.format_object to 'indent' and options.neverflatten to true.",
36+
"collapse-preserve-inline": "Sets options.bracepadding to true and options.format_object to 'inline'.",
37+
"expand" : "Sets options.braces to true, options.format_object to 'indent', and options.never" +
3838
"flatten to true.",
3939
"none" : "Ignores this option"
4040
}
@@ -98,7 +98,7 @@
9898
definition: "If CSS should be beautified in a style where the properties and values are minif" +
9999
"ed for faster reading of selectors.",
100100
label : "Compressed CSS",
101-
lexer : "css",
101+
lexer : "style",
102102
mode : "beautify",
103103
type : "boolean"
104104
},
@@ -146,7 +146,7 @@
146146
default : false,
147147
definition: "Inserts new line characters between every CSS code block.",
148148
label : "Insert Empty Lines",
149-
lexer : "css",
149+
lexer : "style",
150150
mode : "beautify",
151151
type : "boolean"
152152
},
@@ -486,7 +486,7 @@
486486
lexer : "any",
487487
mode : "any",
488488
type : "string",
489-
values : { // analysis: "returns a code examination report",
489+
values : {
490490
beautify: "beautifies code and returns a string",
491491
diff : "returns either command line list of differences or an HTML report",
492492
minify : "minifies code and returns a string",

‎beautify/markup.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
(function beautify_markup_init():void {
33
"use strict";
44
const markup = function beautify_markup(options:any):string {
5-
const data:parsedArray = options.parsed,
5+
const data:data = options.parsed,
66
lexer:string = "markup",
77
c:number = (options.end < 1 || options.end > data.token.length)
88
? data.token.length

‎beautify/script.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
const script = function beautify_script(options:any):string {
55
let scolon:number = 0,
66
news:number = 0;
7-
const data:parsedArray = options.parsed,
7+
const data:data = options.parsed,
88
lexer:string = "script",
99
scopes:scriptScopes = prettydiff.scopes,
1010
b:number = (options.end < 1 || options.end > data.token.length)
@@ -93,9 +93,9 @@
9393
if (a < b - 1 && data.stack[aa] !== "block" && (data.token[aa] === "{" || data.token[aa] === "x{")) {
9494
let bb:number = scopes.length;
9595
data.begin.splice(a, 0, data.begin[aa]);
96+
data.ender.splice(a, 0, data.ender[aa]);
9697
data.lexer.splice(a, 0, data.lexer[aa]);
9798
data.lines.splice(a, 0, data.lines[aa]);
98-
data.presv.splice(a, 0, data.presv[aa]);
9999
data.stack.splice(a, 0, data.stack[aa]);
100100
data.token.splice(a, 0, data.token[aa]);
101101
data.types.splice(a, 0, data.types[aa]);
@@ -111,9 +111,9 @@
111111
}
112112
aa = aa + 1;
113113
data.begin.splice(aa, 1);
114+
data.ender.splice(aa, 1);
114115
data.lexer.splice(aa, 1);
115116
data.lines.splice(aa, 1);
116-
data.presv.splice(aa, 1);
117117
data.stack.splice(aa, 1);
118118
data.token.splice(aa, 1);
119119
data.types.splice(aa, 1);
@@ -300,7 +300,7 @@
300300
destructfix(true, false);
301301
}
302302
if (data.stack[a] !== "attribute") {
303-
if (ctoke !== ")" && ctoke !== "x)" && (ltype !== "markup" || (ltype === "markup" && data.token[a - 2] !== "return"))) {
303+
if (ctoke !== ")" && ctoke !== "x)" && (data.lexer[a - 1] !== "markup" || (data.lexer[a - 1] === "markup" && data.token[a - 2] !== "return"))) {
304304
indent = indent - 1;
305305
}
306306
if (ctoke === "}" && data.stack[a] === "switch" && options.no_case_indent === false) {

‎beautify/style.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
(function beautify_style_init():void {
33
"use strict";
44
const style = function beautify_style(options:any):string {
5-
const data:parsedArray = options.parsed,
5+
const data:data = options.parsed,
66
lf:"\r\n"|"\n" = (options.crlf === true)
77
? "\r\n"
88
: "\n",

‎documentation.xhtml‎

Lines changed: 6 additions & 6 deletions
Large diffs are not rendered by default.

‎index.d.ts‎

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ declare var prettydiff: any;
44
declare var window: Window;
55
declare module NodeJS {
66
interface Global {
7-
parseFramework: any;
7+
sparser: any;
88
prettydiff: any
99
}
1010
}
1111
type api = "any" | "dom" | "node";
1212
type codes = [string, number, number, number, number];
1313
type languageAuto = [string, string, string];
14-
type lexer = "markup" | "script" | "style";
15-
type mode = "analysis" | "beautify" | "diff" | "minify" | "parse";
14+
type lexer = "any" | "markup" | "script" | "style";
15+
type mode = "beautify" | "diff" | "minify" | "parse";
1616
type qualifier = "begins" | "contains" | "ends" | "file begins" | "file contains" | "file ends" | "file is" | "file not" | "file not contains" | "filesystem contains" | "filesystem not contains" | "is" | "not" | "not contains";
1717
interface commandList {
1818
[key: string]: {
@@ -26,6 +26,15 @@ interface commandList {
2626
interface compareStore extends Array<[number, number]>{
2727
[index:number]: [number, number];
2828
}
29+
interface data {
30+
begin: number[];
31+
ender: number[];
32+
lexer: string[];
33+
lines: number[];
34+
stack: string[];
35+
token: string[];
36+
types: string[];
37+
}
2938
interface diffJSON extends Array<["+"|"-"|"=", string]|["r", string, string]> {
3039
[index:number]: ["+"|"-"|"=", string]|["r", string, string];
3140
}
@@ -40,6 +49,9 @@ interface diffStatus {
4049
interface difftable {
4150
[key: string]: [number, number];
4251
}
52+
interface diffview {
53+
(): [string, number, number]
54+
}
4355
interface dom {
4456
[key: string]: any;
4557
}
@@ -51,9 +63,6 @@ interface domMethods {
5163
[key: string]: any;
5264
};
5365
}
54-
interface diffview {
55-
(): [string, number, number]
56-
}
5766
interface externalIndex {
5867
[key: string]: number;
5968
}
@@ -124,6 +133,7 @@ interface nodeLists {
124133
heading: string;
125134
obj: any;
126135
property: "eachkey" | string;
136+
total: boolean;
127137
}
128138
interface opcodes extends Array<codes> {
129139
[index: number]: codes;
@@ -134,7 +144,7 @@ interface option {
134144
definition: string;
135145
label: string;
136146
lexer: lexer;
137-
mode: mode;
147+
mode: "any" | mode;
138148
type: "boolean" | "number" | "string";
139149
values?: {
140150
[key: string]: string;
@@ -147,28 +157,6 @@ interface optionFunctions {
147157
definitions?: {};
148158

149159
}
150-
interface parsedArray {
151-
begin: number[];
152-
lexer: string[];
153-
lines: number[];
154-
presv: boolean[];
155-
stack: string[];
156-
token: string[];
157-
types: string[];
158-
}
159-
interface parsedObject {
160-
[index: number]: record;
161-
}
162-
interface parseOptions {
163-
lexer: "string";
164-
lexerOptions: {
165-
[key: string]: {
166-
[key: string]: any;
167-
}
168-
};
169-
outputFormat: "objects" | "arrays";
170-
source: "string";
171-
}
172160
interface performance {
173161
codeLength: number;
174162
diff: string;
@@ -188,9 +176,9 @@ interface readDirectory {
188176
}
189177
interface record {
190178
begin: number;
179+
ender: number;
191180
lexer: string;
192181
lines: number;
193-
presv: boolean;
194182
stack: string;
195183
token: string;
196184
types: string;
@@ -206,5 +194,5 @@ interface simulationItem {
206194
test: string;
207195
}
208196
interface Window {
209-
parseFramework: any;
197+
sparser: any;
210198
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL