Simplify formatXml

This commit is contained in:
HelderSepu
2017-11-01 21:48:18 -04:00
parent 4eae9b681b
commit f600fe8dbb
2 changed files with 24 additions and 19 deletions

View File

@@ -186,24 +186,17 @@ export function formatXml (xml) {
"other->other": 0
}
fn = function(ln) {
var fromTo, key, padding, type, types, value
types = {
single: Boolean(ln.match(/<.+\/>/)),
closing: Boolean(ln.match(/<\/.+>/)),
opening: Boolean(ln.match(/<[^!?].*>/))
}
type = ((function() {
var results
results = []
for (key in types) {
value = types[key]
if (value) {
results.push(key)
}
}
return results
})())[0]
type = type === void 0 ? "other" : type
var fromTo, padding, type
if (Boolean(ln.match(/<.+\/>/))) {
type = "single"
} else if (Boolean(ln.match(/<\/.+>/))) {
type = "closing"
} else if (Boolean(ln.match(/<[^!?].*>/))) {
type = "opening"
} else {
type = "other"
}
fromTo = lastType + "->" + type
lastType = type
padding = ""