parse-framework
Advanced tools
Comparing version 2.4.18 to 2.5.0
@@ -47,2 +47,3 @@ declare var ace: any; | ||
safeSort(array : any[], operation : string, recursive : boolean): any[]; | ||
sortCorrection(start:number, end:number) : void; | ||
spacer(args : spacer) : number; | ||
@@ -98,4 +99,20 @@ splice(spliceData : splice) : void; | ||
index : number; | ||
record : record; | ||
record ?: record; | ||
} | ||
interface style_properties { | ||
data: style_properties_data; | ||
last: style_properties_last; | ||
removes: style_properties_removes; | ||
} | ||
interface style_properties_data { | ||
margin: [string, string, string, string]; | ||
padding: [string, string, string, string] | ||
} | ||
interface style_properties_last { | ||
margin: number, | ||
padding: number | ||
} | ||
interface style_properties_removes extends Array<[number, string]> { | ||
[index:number]: [number, string]; | ||
} | ||
interface wrapConfig { | ||
@@ -102,0 +119,0 @@ chars : string[]; |
@@ -292,3 +292,3 @@ (function language_init() { | ||
if (((/\n\s*#{1,6}\s+/).test(sample) === true || (/\n\s*(\*|-|(\d+\.))\s/).test(sample) === true) && | ||
((/\s\*\*\S\D/).test(sample) === true || (/\n\s*```/).test(sample) === true || ((/-+\|(-+\|)+/).test(sample) === true && (/<!--/).test(sample) === false))) { | ||
((/\[( |x|X)\]/).test(sample) === true || (/\s\*\*\S\D/).test(sample) === true || (/\n\s*```/).test(sample) === true || ((/-+\|(-+\|)+/).test(sample) === true && (/<!--/).test(sample) === false))) { | ||
return output("markdown"); | ||
@@ -295,0 +295,0 @@ } |
@@ -5,3 +5,3 @@ /*global global*/ | ||
const framework = global.parseFramework, style = function lexer_style(source) { | ||
let a = 0, ltype = "", ltoke = "", endtest = false; | ||
let a = 0, ltype = "", ltoke = ""; | ||
const parse = framework.parse, data = parse.data, options = parse.parseOptions, colors = [], colorNames = { | ||
@@ -155,13 +155,3 @@ aliceblue: 0.9288006825347457, | ||
yellowgreen: 0.5076295720870697 | ||
}, b = source.split(""), len = source.length, mapper = [], nosort = [], recordStore = function lexer_style_recordStore(index) { | ||
return { | ||
begin: data.begin[index], | ||
lexer: data.lexer[index], | ||
lines: data.lines[index], | ||
presv: data.presv[index], | ||
stack: data.stack[index], | ||
token: data.token[index], | ||
types: data.types[index] | ||
}; | ||
}, recordPush = function lexer_style_recordPush(structure) { | ||
}, b = source.split(""), len = source.length, mapper = [], nosort = [], recordPush = function lexer_style_recordPush(structure) { | ||
const record = { | ||
@@ -543,11 +533,3 @@ begin: parse.structure[parse.structure.length - 1][1], | ||
lines = data.lines[cc]; | ||
parse.splice({ data: data, howmany: dd, index: cc, record: { | ||
begin: 0, | ||
lexer: "", | ||
lines: 0, | ||
presv: false, | ||
stack: "", | ||
token: "", | ||
types: "" | ||
} }); | ||
parse.splice({ data: data, howmany: dd, index: cc }); | ||
aa = aa - dd; | ||
@@ -932,203 +914,187 @@ data.token[aa] = parts | ||
}, | ||
//do fancy things to property types like: sorting, consolidating, and padding | ||
properties = function lexer_style_properties() { | ||
let aa = parse.count, bb = 1, cc = 0, dd = 0, next = 0, leng = 0; | ||
const p = [], lines = parse.linesSpace, set = [ | ||
[] | ||
], store = { | ||
begin: [], | ||
lexer: [], | ||
lines: [], | ||
presv: [], | ||
stack: [], | ||
token: [], | ||
types: [] | ||
}, fourcount = function lexer_style_properties_propcheck_fourcount(name) { | ||
let test = [ | ||
false, false, false, false | ||
], val = [ | ||
"0", "0", "0", "0" | ||
], valsplit = [], start = aa, yy = -1, zz = 0; | ||
const zero = (/^(0+([a-z]+|%))/), storage = function lexer_style_properties_propcheck_fourcount_storage(side) { | ||
yy = yy + 1; | ||
val[side] = data.token[set[aa][2]]; | ||
test[side] = true; | ||
if (start < 0) { | ||
start = aa; | ||
//consolidate margin and padding values | ||
margin_padding = function lexer_style_properties() { | ||
const lines = parse.linesSpace, props = { | ||
data: { | ||
margin: ["", "", "", ""], | ||
padding: ["", "", "", ""] | ||
}, | ||
last: { | ||
margin: 0, | ||
padding: 0 | ||
}, | ||
removes: [] | ||
}, begin = (data.begin[parse.count] < 0) | ||
? 0 | ||
: data.begin[parse.count], populate = function lexer_style_properties_populate(prop) { | ||
if (data.token[aa - 2] === prop) { | ||
const values = data.token[aa].split(" "), vlen = values.length; | ||
if (vlen > 3) { | ||
if (props.data[prop][0] === "") { | ||
props.data[prop][0] = values[0]; | ||
} | ||
if (props.data[prop][1] === "") { | ||
props.data[prop][1] = values[1]; | ||
} | ||
if (props.data[prop][2] === "") { | ||
props.data[prop][2] = values[2]; | ||
} | ||
if (props.data[prop][3] === "") { | ||
props.data[prop][3] = values[3]; | ||
} | ||
} | ||
}; | ||
if (aa < leng) { | ||
do { | ||
if (data.token[set[aa][2]] !== undefined && data.token[set[aa][0]].indexOf(name) === 0) { | ||
if (data.token[set[aa][0]] === name || data.token[set[aa][0]].indexOf(name + " ") === 0) { | ||
yy = yy + 1; | ||
valsplit = data | ||
.token[set[aa][2]] | ||
.split(" "); | ||
if (valsplit.length === 1) { | ||
val = [ | ||
data.token[set[aa][2]], | ||
data.token[set[aa][2]], | ||
data.token[set[aa][2]], | ||
data.token[set[aa][2]] | ||
]; | ||
} | ||
else if (valsplit.length === 2) { | ||
val = [ | ||
valsplit[0], valsplit[1], valsplit[0], valsplit[1] | ||
]; | ||
} | ||
else if (valsplit.length === 3) { | ||
val = [ | ||
valsplit[0], valsplit[1], valsplit[2], valsplit[1] | ||
]; | ||
} | ||
else if (valsplit.length === 4) { | ||
val = [ | ||
valsplit[0], valsplit[1], valsplit[2], valsplit[3] | ||
]; | ||
} | ||
else { | ||
return; | ||
} | ||
test = [true, true, true, true]; | ||
} | ||
else if (data.token[set[aa][0]].indexOf(name + "-bottom") === 0) { | ||
storage(2); | ||
} | ||
else if (data.token[set[aa][0]].indexOf(name + "-left") === 0) { | ||
storage(3); | ||
} | ||
else if (data.token[set[aa][0]].indexOf(name + "-right") === 0) { | ||
storage(1); | ||
} | ||
else if (data.token[set[aa][0]].indexOf(name + "-top") === 0) { | ||
storage(0); | ||
} | ||
else if (vlen > 2) { | ||
if (props.data[prop][0] === "") { | ||
props.data[prop][0] = values[0]; | ||
} | ||
if (aa === leng - 1 || set[aa + 1] === undefined || data.token[set[aa + 1][0]].indexOf(name) < 0) { | ||
if (test[0] === true && test[1] === true && test[2] === true && test[3] === true) { | ||
set.splice(start + 1, yy); | ||
leng = leng - yy; | ||
aa = aa - yy; | ||
zz = 0; | ||
bb = p.length; | ||
do { | ||
if (p[zz] === set[start][0]) { | ||
break; | ||
} | ||
zz = zz + 1; | ||
} while (zz < bb); | ||
if (zz < bb) { | ||
p.splice(zz + 1, yy); | ||
} | ||
data.token[set[start][0]] = name; | ||
if (zero.test(val[0]) === true) { | ||
val[0] = "0"; | ||
} | ||
if (zero.test(val[1]) === true) { | ||
val[1] = "0"; | ||
} | ||
if (zero.test(val[2]) === true) { | ||
val[2] = "0"; | ||
} | ||
if (zero.test(val[3]) === true) { | ||
val[3] = "0"; | ||
} | ||
if (val[1] === val[3]) { | ||
val.pop(); | ||
if (val[0] === val[2]) { | ||
val.pop(); | ||
if (val[0] === val[1]) { | ||
val.pop(); | ||
} | ||
} | ||
} | ||
data.token[set[start][2]] = val.join(" "); | ||
} | ||
break; | ||
if (props.data[prop][1] === "") { | ||
props.data[prop][1] = values[1]; | ||
} | ||
aa = aa + 1; | ||
} while (aa < leng); | ||
} | ||
}; | ||
//identify properties and build out prop/val sets | ||
do { | ||
if (data.types[aa] === "start") { | ||
bb = bb - 1; | ||
if (bb === 0) { | ||
next = aa; | ||
set.pop(); | ||
aa = set.length - 1; | ||
if (aa > -1) { | ||
do { | ||
set[aa].reverse(); | ||
aa = aa - 1; | ||
} while (aa > -1); | ||
if (props.data[prop][2] === "") { | ||
props.data[prop][2] = values[2]; | ||
} | ||
break; | ||
if (props.data[prop][3] === "") { | ||
props.data[prop][3] = values[1]; | ||
} | ||
} | ||
else if (vlen > 1) { | ||
if (props.data[prop][0] === "") { | ||
props.data[prop][0] = values[0]; | ||
} | ||
if (props.data[prop][1] === "") { | ||
props.data[prop][1] = values[1]; | ||
} | ||
if (props.data[prop][2] === "") { | ||
props.data[prop][2] = values[0]; | ||
} | ||
if (props.data[prop][3] === "") { | ||
props.data[prop][3] = values[1]; | ||
} | ||
} | ||
else { | ||
if (props.data[prop][0] === "") { | ||
props.data[prop][0] = values[0]; | ||
} | ||
if (props.data[prop][1] === "") { | ||
props.data[prop][1] = values[0]; | ||
} | ||
if (props.data[prop][2] === "") { | ||
props.data[prop][2] = values[0]; | ||
} | ||
if (props.data[prop][3] === "") { | ||
props.data[prop][3] = values[0]; | ||
} | ||
} | ||
} | ||
if (data.types[aa] === "end") { | ||
bb = bb + 1; | ||
else if (data.token[aa - 2] === `${prop}-bottom`) { | ||
if (props.data[prop][2] === "") { | ||
props.data[prop][2] = data.token[aa]; | ||
} | ||
} | ||
if (bb === 1 && (data.types[aa] === "property" || (data.types[aa] === "variable" && data.types[aa + 1] === "colon"))) { | ||
p.push(aa); | ||
else if (data.token[aa - 2] === `${prop}-left`) { | ||
if (props.data[prop][3] === "") { | ||
props.data[prop][3] = data.token[aa]; | ||
} | ||
} | ||
set[set.length - 1].push(aa); | ||
if (bb === 1 && (data.types[aa - 1] === "comment" || data.types[aa - 1] === "semi" || data.types[aa - 1] === "end" || data.types[aa - 1] === "start") && data.types[aa] !== "start" && data.types[aa] !== "end") { | ||
set.push([]); | ||
else if (data.token[aa - 2] === `${prop}-right`) { | ||
if (props.data[prop][1] === "") { | ||
props.data[prop][1] = data.token[aa]; | ||
} | ||
} | ||
aa = aa - 1; | ||
} while (aa > -1); | ||
//this reverse fixes the order of consecutive comments | ||
set.reverse(); | ||
p.reverse(); | ||
//consolidate margin and padding | ||
leng = set.length; | ||
aa = 0; | ||
if (aa < leng) { | ||
do { | ||
if (data.types[set[aa][0]] === "property") { | ||
if (data.token[set[aa][0]].indexOf("margin") === 0) { | ||
fourcount("margin"); | ||
} | ||
if (data.token[set[aa][0]].indexOf("padding") === 0) { | ||
fourcount("padding"); | ||
} | ||
else if (data.token[aa - 2] === `${prop}-top`) { | ||
if (props.data[prop][0] === "") { | ||
props.data[prop][0] = data.token[aa]; | ||
} | ||
aa = aa + 1; | ||
} while (aa < leng); | ||
} | ||
bb = set.length; | ||
aa = 0; | ||
if (aa < bb) { | ||
do { | ||
dd = set[aa].length; | ||
cc = 0; | ||
if (cc < dd) { | ||
} | ||
else { | ||
return; | ||
} | ||
props.removes.push([aa, prop]); | ||
props.last[prop] = aa; | ||
}, removes = function lexer_style_properties_removes() { | ||
let cc = 0, values = ""; | ||
const zero = (/^(0+([a-z]+|%))/), bb = props.removes.length, tmargin = (props.data.margin[0] !== "" && props.data.margin[1] !== "" && props.data.margin[2] !== "" && props.data.margin[3] !== ""), tpadding = (props.data.padding[0] !== "" && props.data.padding[1] !== "" && props.data.padding[2] !== "" && props.data.padding[3] !== ""), applyValues = function lexer_style_properties_removes_applyValues(prop) { | ||
if (zero.test(props.data[prop][0]) === true) { | ||
props.data[prop][0] = "0"; | ||
} | ||
if (zero.test(props.data[prop][1]) === true) { | ||
props.data[prop][1] = "0"; | ||
} | ||
if (zero.test(props.data[prop][2]) === true) { | ||
props.data[prop][2] = "0"; | ||
} | ||
if (zero.test(props.data[prop][3]) === true) { | ||
props.data[prop][3] = "0"; | ||
} | ||
if (props.data[prop][0] === props.data[prop][1] && props.data[prop][0] === props.data[prop][2] && props.data[prop][0] === props.data[prop][3]) { | ||
values = props.data[prop][0]; | ||
} | ||
else if (props.data[prop][0] === props.data[prop][2] && props.data[prop][1] === props.data[prop][3] && props.data[prop][0] !== props.data[prop][1]) { | ||
values = `${props.data[prop][0]} ${props.data[prop][1]}`; | ||
} | ||
else if (props.data[prop][0] !== props.data[prop][1] && props.data[prop][1] === props.data[prop][3] && props.data[prop][0] !== props.data[prop][2]) { | ||
values = `${props.data[prop][0]} ${props.data[prop][1]} ${props.data[prop][2]}`; | ||
} | ||
else { | ||
values = `${props.data[prop][0]} ${props.data[prop][1]} ${props.data[prop][2]} ${props.data[prop][3]}`; | ||
} | ||
if (props.last[prop] > parse.count) { | ||
cc = (begin < 1) | ||
? 1 | ||
: begin + 1; | ||
do { | ||
parse.push(store, recordStore(set[aa][cc]), ""); | ||
if (data.begin[cc] === begin && data.types[cc] === "value" && data.token[cc - 2].indexOf(prop) === 0) { | ||
props.last[prop] = cc; | ||
break; | ||
} | ||
cc = cc + 1; | ||
} while (cc < dd); | ||
} while (cc < parse.count); | ||
} | ||
aa = aa + 1; | ||
} while (aa < bb); | ||
} | ||
//replace a block's data with sorted analyzed data | ||
parse.splice({ | ||
data: data, | ||
howmany: parse.count - next, | ||
index: next + 1, | ||
record: { | ||
begin: 0, | ||
lexer: "", | ||
lines: 0, | ||
presv: false, | ||
stack: "", | ||
token: "", | ||
types: "" | ||
data.token[props.last[prop]] = values; | ||
data.token[props.last[prop] - 2] = prop; | ||
}; | ||
if (bb > 1 && (tmargin === true || tpadding === true)) { | ||
do { | ||
if (props.removes[cc][0] !== props.last.margin && props.removes[cc][0] !== props.last.padding && ((tmargin === true && props.removes[cc][1] === "margin") || (tpadding === true && props.removes[cc][1] === "padding"))) { | ||
parse.splice({ | ||
data: data, | ||
howmany: (data.types[props.removes[cc][0] + 1] === "semi") | ||
? 4 | ||
: 3, | ||
index: props.removes[cc][0] - 2 | ||
}); | ||
} | ||
cc = cc + 1; | ||
} while (cc < bb - 1); | ||
} | ||
}); | ||
parse.concat(data, store); | ||
if (tmargin === true) { | ||
applyValues("margin"); | ||
} | ||
if (tpadding === true) { | ||
applyValues("padding"); | ||
} | ||
// this is necessary to fix the "begin" values of descendent blocks | ||
if (endtest === true && options.lexerOptions.style.objectSort === false) { | ||
parse.sortCorrection(begin, parse.count); | ||
} | ||
}; | ||
let aa = parse.count, endtest = false; | ||
do { | ||
aa = aa - 1; | ||
if (data.begin[aa] === begin) { | ||
if (data.types[aa] === "value" && data.types[aa - 2] === "property") { | ||
if (data.token[aa - 2].indexOf("margin") === 0) { | ||
populate("margin"); | ||
} | ||
else if (data.token[aa - 2].indexOf("padding") === 0) { | ||
populate("padding"); | ||
} | ||
} | ||
} | ||
else { | ||
endtest = true; | ||
aa = data.begin[aa]; | ||
} | ||
} while (aa > begin); | ||
removes(); | ||
parse.linesSpace = lines; | ||
@@ -1200,3 +1166,2 @@ }; | ||
else if (b[a] === "}" || (b[a] === ")" && parse.structure[parse.structure.length - 1][0] === "map" && mapper[mapper.length - 1] === 0)) { | ||
endtest = true; | ||
if (b[a] === "}" && data.types[parse.count] === "item" && data.token[parse.count - 1] === "{" && data.token[parse.count - 2] !== undefined && data.token[parse.count - 2].charAt(data.token[parse.count - 2].length - 1) === "@") { | ||
@@ -1229,3 +1194,2 @@ data.token[parse.count - 2] = data.token[parse.count - 2] + "{" + data.token[parse.count] + | ||
} | ||
properties(); | ||
ltype = "end"; | ||
@@ -1239,2 +1203,5 @@ nosort.pop(); | ||
recordPush(""); | ||
if (b[a] === "}") { | ||
margin_padding(); | ||
} | ||
} | ||
@@ -1267,5 +1234,2 @@ } | ||
} | ||
if (endtest === false && data.types.indexOf("end") > -1) { | ||
properties(); | ||
} | ||
return data; | ||
@@ -1272,0 +1236,0 @@ }; |
113
js/parse.js
@@ -245,12 +245,3 @@ /* | ||
howmany: ff, | ||
index: cc + 1, | ||
record: { | ||
begin: 0, | ||
lexer: "", | ||
lines: 0, | ||
presv: false, | ||
stack: "", | ||
token: "", | ||
types: "" | ||
} | ||
index: cc + 1 | ||
}); | ||
@@ -489,2 +480,3 @@ parse.linesSpace = lines; | ||
}, | ||
sortCorrection: function parse_sortCorrection_init() { }, | ||
spacer: function parse_spacer(args) { | ||
@@ -513,3 +505,3 @@ // * array - the characters to scan | ||
// * record - A new record to insert | ||
if (spliceData.record.token !== "") { | ||
if (spliceData.record !== undefined && spliceData.record.token !== "") { | ||
parse | ||
@@ -585,3 +577,3 @@ .datanames | ||
if (framework.lexer[parseOptions.lexer] === undefined) { | ||
framework.parseerror = "Lexer '" + parseOptions.lexer + "' isn't available."; | ||
framework.parseerror = `Lexer "${parseOptions.lexer}" isn't available.`; | ||
} | ||
@@ -597,6 +589,6 @@ if (typeof framework.lexer[parseOptions.lexer] === "function") { | ||
// This line parses the code using a lexer file | ||
framework.lexer[parseOptions.lexer](parseOptions.source + " "); | ||
framework.lexer[parseOptions.lexer](`${parseOptions.source} `); | ||
} | ||
else { | ||
framework.parseerror = "Specified lexer, " + parseOptions.lexer + ", is not a function."; | ||
framework.parseerror = `Specified lexer, ${parseOptions.lexer}, is not a function.`; | ||
} | ||
@@ -611,4 +603,3 @@ // validate that all the data arrays are the same length | ||
if (parse.data[keys[a]].length !== parse.data[keys[b]].length) { | ||
framework.parseerror = "'" + keys[a] + "' array is of different length than '" + | ||
keys[b] + "'"; | ||
framework.parseerror = `"${keys[a]}" array is of different length than "${keys[b]}"`; | ||
break; | ||
@@ -634,44 +625,3 @@ } | ||
if (parse.data.begin.length > 0 && (parse.parseOptions.lexerOptions[parseOptions.lexer].objectSort === true || parse.parseOptions.lexerOptions.markup.tagSort === true)) { | ||
let a = 0; | ||
const data = parse.data, b = data.begin.length, structure = [-1]; | ||
do { | ||
if (a > 0 && | ||
data.types[a].indexOf("attribute") > -1 && | ||
data.types[a].indexOf("end") < 0 && | ||
data.types[a - 1].indexOf("start") < 0 && | ||
data.types[a - 1].indexOf("attribute") < 0 && | ||
data.lexer[a] === "markup") { | ||
structure.push(a - 1); | ||
} | ||
if (a > 0 && | ||
data.types[a - 1].indexOf("attribute") > -1 && | ||
data.types[a].indexOf("attribute") < 0 && | ||
data.lexer[structure[structure.length - 1]] === "markup" && | ||
data.types[structure[structure.length - 1]].indexOf("start") < 0) { | ||
structure.pop(); | ||
} | ||
if (data.begin[a] !== structure[structure.length - 1]) { | ||
if (structure.length > 0) { | ||
data.begin[a] = structure[structure.length - 1]; | ||
} | ||
else { | ||
data.begin[a] = -1; | ||
} | ||
} | ||
if (data.types[a].indexOf("else") > -1) { | ||
if (structure.length > 0) { | ||
structure[structure.length - 1] = a; | ||
} | ||
else { | ||
structure.push(a); | ||
} | ||
} | ||
if (data.types[a].indexOf("end") > -1) { | ||
structure.pop(); | ||
} | ||
if (data.types[a].indexOf("start") > -1) { | ||
structure.push(a); | ||
} | ||
a = a + 1; | ||
} while (a < b); | ||
parse.sortCorrection(0, parse.data.begin.length); | ||
} | ||
@@ -700,2 +650,46 @@ }, parserArrays = function parserArrays(parseOptions) { | ||
}; | ||
parse.sortCorrection = function parse_sortCorrection(start, end) { | ||
let a = start; | ||
const data = parse.data, structure = [-1]; | ||
do { | ||
if (a > 0 && | ||
data.types[a].indexOf("attribute") > -1 && | ||
data.types[a].indexOf("end") < 0 && | ||
data.types[a - 1].indexOf("start") < 0 && | ||
data.types[a - 1].indexOf("attribute") < 0 && | ||
data.lexer[a] === "markup") { | ||
structure.push(a - 1); | ||
} | ||
if (a > 0 && | ||
data.types[a - 1].indexOf("attribute") > -1 && | ||
data.types[a].indexOf("attribute") < 0 && | ||
data.lexer[structure[structure.length - 1]] === "markup" && | ||
data.types[structure[structure.length - 1]].indexOf("start") < 0) { | ||
structure.pop(); | ||
} | ||
if (data.begin[a] !== structure[structure.length - 1]) { | ||
if (structure.length > 0) { | ||
data.begin[a] = structure[structure.length - 1]; | ||
} | ||
else { | ||
data.begin[a] = -1; | ||
} | ||
} | ||
if (data.types[a].indexOf("else") > -1) { | ||
if (structure.length > 0) { | ||
structure[structure.length - 1] = a; | ||
} | ||
else { | ||
structure.push(a); | ||
} | ||
} | ||
if (data.types[a].indexOf("end") > -1) { | ||
structure.pop(); | ||
} | ||
if (data.types[a].indexOf("start") > -1) { | ||
structure.push(a); | ||
} | ||
a = a + 1; | ||
} while (a < end); | ||
}; | ||
// parsing block comments and simultaneously applying word wrap | ||
@@ -720,2 +714,5 @@ parse.wrapCommentBlock = function parse_wrapCommentBlock(config) { | ||
build.push(config.chars[a]); | ||
if (config.chars[a] === "\n") { | ||
parse.lineNumber = parse.lineNumber + 1; | ||
} | ||
if (config.chars[a] === term && config.chars.slice(a - terml, a + 1).join("") === config.terminator) { | ||
@@ -722,0 +719,0 @@ break; |
@@ -315,3 +315,3 @@ (function language_init():void { | ||
((/\n\s*#{1,6}\s+/).test(sample) === true || (/\n\s*(\*|-|(\d+\.))\s/).test(sample) === true) && | ||
((/\s\*\*\S\D/).test(sample) === true || (/\n\s*```/).test(sample) === true || ((/-+\|(-+\|)+/).test(sample) === true && (/<!--/).test(sample) === false)) | ||
((/\[( |x|X)\]/).test(sample) === true || (/\s\*\*\S\D/).test(sample) === true || (/\n\s*```/).test(sample) === true || ((/-+\|(-+\|)+/).test(sample) === true && (/<!--/).test(sample) === false)) | ||
) { | ||
@@ -318,0 +318,0 @@ return output("markdown"); |
@@ -43,3 +43,3 @@ { | ||
}, | ||
"version": "2.4.18" | ||
"version": "2.5.0" | ||
} |
120
parse.ts
@@ -263,12 +263,3 @@ /* | ||
howmany: ff, | ||
index : cc + 1, | ||
record : { | ||
begin: 0, | ||
lexer: "", | ||
lines: 0, | ||
presv: false, | ||
stack: "", | ||
token: "", | ||
types: "" | ||
} | ||
index : cc + 1 | ||
}); | ||
@@ -523,2 +514,3 @@ parse.linesSpace = lines; | ||
}, | ||
sortCorrection: function parse_sortCorrection_init():void {}, | ||
spacer: function parse_spacer(args:spacer): number { | ||
@@ -547,3 +539,3 @@ // * array - the characters to scan | ||
// * record - A new record to insert | ||
if (spliceData.record.token !== "") { | ||
if (spliceData.record !== undefined && spliceData.record.token !== "") { | ||
parse | ||
@@ -622,3 +614,3 @@ .datanames | ||
if (framework.lexer[parseOptions.lexer] === undefined) { | ||
framework.parseerror = "Lexer '" + parseOptions.lexer + "' isn't available."; | ||
framework.parseerror = `Lexer "${parseOptions.lexer}" isn't available.`; | ||
} | ||
@@ -634,5 +626,5 @@ if (typeof framework.lexer[parseOptions.lexer] === "function") { | ||
// This line parses the code using a lexer file | ||
framework.lexer[parseOptions.lexer](parseOptions.source + " "); | ||
framework.lexer[parseOptions.lexer](`${parseOptions.source} `); | ||
} else { | ||
framework.parseerror = "Specified lexer, " + parseOptions.lexer + ", is not a function."; | ||
framework.parseerror = `Specified lexer, ${parseOptions.lexer}, is not a function.`; | ||
} | ||
@@ -650,4 +642,3 @@ | ||
if (parse.data[keys[a]].length !== parse.data[keys[b]].length) { | ||
framework.parseerror = "'" + keys[a] + "' array is of different length than '" + | ||
keys[b] + "'"; | ||
framework.parseerror = `"${keys[a]}" array is of different length than "${keys[b]}"`; | ||
break; | ||
@@ -675,48 +666,3 @@ } | ||
if (parse.data.begin.length > 0 && (parse.parseOptions.lexerOptions[parseOptions.lexer].objectSort === true || parse.parseOptions.lexerOptions.markup.tagSort === true)) { | ||
let a:number = 0; | ||
const data:data = parse.data, | ||
b:number = data.begin.length, | ||
structure: number[] = [-1]; | ||
do { | ||
if ( | ||
a > 0 && | ||
data.types[a].indexOf("attribute") > -1 && | ||
data.types[a].indexOf("end") < 0 && | ||
data.types[a - 1].indexOf("start") < 0 && | ||
data.types[a - 1].indexOf("attribute") < 0 && | ||
data.lexer[a] === "markup" | ||
) { | ||
structure.push(a - 1); | ||
} | ||
if ( | ||
a > 0 && | ||
data.types[a - 1].indexOf("attribute") > -1 && | ||
data.types[a].indexOf("attribute") < 0 && | ||
data.lexer[structure[structure.length - 1]] === "markup" && | ||
data.types[structure[structure.length - 1]].indexOf("start") < 0 | ||
) { | ||
structure.pop(); | ||
} | ||
if (data.begin[a] !== structure[structure.length - 1]) { | ||
if (structure.length > 0) { | ||
data.begin[a] = structure[structure.length - 1]; | ||
} else { | ||
data.begin[a] = -1; | ||
} | ||
} | ||
if (data.types[a].indexOf("else") > -1) { | ||
if (structure.length > 0) { | ||
structure[structure.length - 1] = a; | ||
} else { | ||
structure.push(a); | ||
} | ||
} | ||
if (data.types[a].indexOf("end") > -1) { | ||
structure.pop(); | ||
} | ||
if (data.types[a].indexOf("start") > -1) { | ||
structure.push(a); | ||
} | ||
a = a + 1; | ||
} while (a < b); | ||
parse.sortCorrection(0, parse.data.begin.length); | ||
} | ||
@@ -748,2 +694,49 @@ }, | ||
}; | ||
parse.sortCorrection = function parse_sortCorrection(start:number, end:number):void { | ||
let a:number = start; | ||
const data:data = parse.data, | ||
structure: number[] = [-1]; | ||
do { | ||
if ( | ||
a > 0 && | ||
data.types[a].indexOf("attribute") > -1 && | ||
data.types[a].indexOf("end") < 0 && | ||
data.types[a - 1].indexOf("start") < 0 && | ||
data.types[a - 1].indexOf("attribute") < 0 && | ||
data.lexer[a] === "markup" | ||
) { | ||
structure.push(a - 1); | ||
} | ||
if ( | ||
a > 0 && | ||
data.types[a - 1].indexOf("attribute") > -1 && | ||
data.types[a].indexOf("attribute") < 0 && | ||
data.lexer[structure[structure.length - 1]] === "markup" && | ||
data.types[structure[structure.length - 1]].indexOf("start") < 0 | ||
) { | ||
structure.pop(); | ||
} | ||
if (data.begin[a] !== structure[structure.length - 1]) { | ||
if (structure.length > 0) { | ||
data.begin[a] = structure[structure.length - 1]; | ||
} else { | ||
data.begin[a] = -1; | ||
} | ||
} | ||
if (data.types[a].indexOf("else") > -1) { | ||
if (structure.length > 0) { | ||
structure[structure.length - 1] = a; | ||
} else { | ||
structure.push(a); | ||
} | ||
} | ||
if (data.types[a].indexOf("end") > -1) { | ||
structure.pop(); | ||
} | ||
if (data.types[a].indexOf("start") > -1) { | ||
structure.push(a); | ||
} | ||
a = a + 1; | ||
} while (a < end); | ||
}; | ||
// parsing block comments and simultaneously applying word wrap | ||
@@ -793,2 +786,5 @@ parse.wrapCommentBlock = function parse_wrapCommentBlock(config: wrapConfig):[string, number] { | ||
build.push(config.chars[a]); | ||
if (config.chars[a] === "\n") { | ||
parse.lineNumber = parse.lineNumber + 1; | ||
} | ||
if (config.chars[a] === term && config.chars.slice(a - terml, a + 1).join("") === config.terminator) { | ||
@@ -795,0 +791,0 @@ break; |
@@ -5,3 +5,3 @@ # Parse Framework | ||
## Version 2.4.18 | ||
## Version 2.5.0 | ||
Play around with this application [in your browser](http://prettydiff.com/parse-framework/runtimes/browsertest.xhtml). | ||
@@ -8,0 +8,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3881343
45875