Comparing version 3.2.1 to 4.0.1
363
dist/main.js
@@ -1,5 +0,5 @@ | ||
var $gyQpm$htmlentities = require("html-entities"); | ||
var $gyQpm$hyntaxlibconstructtree = require("hyntax/lib/construct-tree"); | ||
var $gyQpm$hyntaxlibtokenize = require("hyntax/lib/tokenize"); | ||
var $gyQpm$vuecompilerdom = require("@vue/compiler-dom"); | ||
var $8wP6K$htmlentities = require("html-entities"); | ||
var $8wP6K$hyntaxlibconstructtree = require("hyntax/lib/construct-tree"); | ||
var $8wP6K$hyntaxlibtokenize = require("hyntax/lib/tokenize"); | ||
var $8wP6K$vuecompilerdom = require("@vue/compiler-dom"); | ||
@@ -13,4 +13,4 @@ function $parcel$export(e, n, v, s) { | ||
$parcel$export(module.exports, "convert", () => $0ca9772bb4919d41$export$9c68d69a4c5bbcf9, (v) => $0ca9772bb4919d41$export$9c68d69a4c5bbcf9 = v); | ||
var $a92eca0b06868bbf$export$85c928794f8d04d4 = { | ||
$parcel$export(module.exports, "convert", () => $86b6b968d2dbe88f$export$9c68d69a4c5bbcf9, (v) => $86b6b968d2dbe88f$export$9c68d69a4c5bbcf9 = v); | ||
var $0e6b16fffa0a9bc6$export$85c928794f8d04d4 = { | ||
Doctype: 0, | ||
@@ -25,12 +25,12 @@ Tag: 1, | ||
var $19bc831d3f29a2ee$var$findTag = function(nodes, tagName) { | ||
var $4ef8b8fe7daf140b$var$findTag = function(nodes, tagName) { | ||
return nodes.find(function(node) { | ||
if (node.node === $a92eca0b06868bbf$export$85c928794f8d04d4.Tag && node.name === tagName) return node; | ||
if (node.node === $a92eca0b06868bbf$export$85c928794f8d04d4.Tag && node.children) return $19bc831d3f29a2ee$var$findTag(node.children, tagName); | ||
if (node.node === (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Tag && node.name === tagName) return node; | ||
if (node.node === (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Tag && node.children) return $4ef8b8fe7daf140b$var$findTag(node.children, tagName); | ||
return undefined; | ||
}); | ||
}; | ||
var $19bc831d3f29a2ee$var$createTag = function(name, children) { | ||
var $4ef8b8fe7daf140b$var$createTag = function(name, children) { | ||
return { | ||
node: $a92eca0b06868bbf$export$85c928794f8d04d4.Tag, | ||
node: (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Tag, | ||
name: name, | ||
@@ -41,9 +41,9 @@ children: children, | ||
}; | ||
var $19bc831d3f29a2ee$export$15f1e0b2d8c15007 = function(nodes) { | ||
var html = $19bc831d3f29a2ee$var$findTag(nodes, "html"); | ||
var body = $19bc831d3f29a2ee$var$findTag(nodes, "body"); | ||
var head = $19bc831d3f29a2ee$var$findTag(nodes, "head"); | ||
var $4ef8b8fe7daf140b$export$15f1e0b2d8c15007 = function(nodes) { | ||
var html = $4ef8b8fe7daf140b$var$findTag(nodes, "html"); | ||
var body = $4ef8b8fe7daf140b$var$findTag(nodes, "body"); | ||
var head = $4ef8b8fe7daf140b$var$findTag(nodes, "head"); | ||
if (html) return nodes; | ||
if (!body && head) return [ | ||
$19bc831d3f29a2ee$var$createTag("html", [ | ||
$4ef8b8fe7daf140b$var$createTag("html", [ | ||
head | ||
@@ -53,3 +53,3 @@ ]) | ||
if (body && !head) return [ | ||
$19bc831d3f29a2ee$var$createTag("html", [ | ||
$4ef8b8fe7daf140b$var$createTag("html", [ | ||
body | ||
@@ -59,3 +59,3 @@ ]) | ||
if (!html && body && head) return [ | ||
$19bc831d3f29a2ee$var$createTag("html", [ | ||
$4ef8b8fe7daf140b$var$createTag("html", [ | ||
head, | ||
@@ -66,4 +66,4 @@ body | ||
return [ | ||
$19bc831d3f29a2ee$var$createTag("html", [ | ||
$19bc831d3f29a2ee$var$createTag("body", nodes) | ||
$4ef8b8fe7daf140b$var$createTag("html", [ | ||
$4ef8b8fe7daf140b$var$createTag("body", nodes) | ||
]) | ||
@@ -74,13 +74,13 @@ ]; | ||
var $d915837238100320$exports = {}; | ||
var $58b850e81b24fb0a$exports = {}; | ||
$parcel$export($d915837238100320$exports, "compileAst", () => $d915837238100320$export$85f0a661b59e6ae5, (v) => $d915837238100320$export$85f0a661b59e6ae5 = v); | ||
$parcel$export($58b850e81b24fb0a$exports, "compileAst", () => $58b850e81b24fb0a$export$85f0a661b59e6ae5, (v) => $58b850e81b24fb0a$export$85f0a661b59e6ae5 = v); | ||
var $c307bfe9f4e9329c$exports = {}; | ||
var $456c9667291840f7$exports = {}; | ||
$parcel$export($c307bfe9f4e9329c$exports, "wrapAttrs", () => $c307bfe9f4e9329c$export$fc18073465ce7ae5, (v) => $c307bfe9f4e9329c$export$fc18073465ce7ae5 = v); | ||
$parcel$export($c307bfe9f4e9329c$exports, "formatAttrsForTag", () => $c307bfe9f4e9329c$export$25212e79da653bac, (v) => $c307bfe9f4e9329c$export$25212e79da653bac = v); | ||
$parcel$export($c307bfe9f4e9329c$exports, "compileAttrs", () => $c307bfe9f4e9329c$export$ec87509295a42e9b, (v) => $c307bfe9f4e9329c$export$ec87509295a42e9b = v); | ||
var $c307bfe9f4e9329c$var$__assign = undefined && undefined.__assign || function() { | ||
$c307bfe9f4e9329c$var$__assign = Object.assign || function(t) { | ||
$parcel$export($456c9667291840f7$exports, "wrapAttrs", () => $456c9667291840f7$export$fc18073465ce7ae5, (v) => $456c9667291840f7$export$fc18073465ce7ae5 = v); | ||
$parcel$export($456c9667291840f7$exports, "formatAttrsForTag", () => $456c9667291840f7$export$25212e79da653bac, (v) => $456c9667291840f7$export$25212e79da653bac = v); | ||
$parcel$export($456c9667291840f7$exports, "compileAttrs", () => $456c9667291840f7$export$ec87509295a42e9b, (v) => $456c9667291840f7$export$ec87509295a42e9b = v); | ||
var $456c9667291840f7$var$__assign = undefined && undefined.__assign || function() { | ||
$456c9667291840f7$var$__assign = Object.assign || function(t) { | ||
for(var s, i = 1, n = arguments.length; i < n; i++){ | ||
@@ -92,23 +92,20 @@ s = arguments[i]; | ||
}; | ||
return $c307bfe9f4e9329c$var$__assign.apply(this, arguments); | ||
return $456c9667291840f7$var$__assign.apply(this, arguments); | ||
}; | ||
var $c307bfe9f4e9329c$export$fc18073465ce7ae5 = function(str) { | ||
var $456c9667291840f7$export$fc18073465ce7ae5 = function(str) { | ||
return str ? "(".concat(str, ")") : ""; | ||
}; | ||
var $c307bfe9f4e9329c$var$allowValue = function(str) { | ||
var $456c9667291840f7$var$allowValue = function(str) { | ||
return !/[{}_]/.test(str); | ||
}; | ||
var $c307bfe9f4e9329c$export$25212e79da653bac = function(attrs, options) { | ||
var $456c9667291840f7$export$25212e79da653bac = function(attrs, options) { | ||
return attrs.reduce(function(acc, _a) { | ||
var key = _a.key, value = _a.value; | ||
if (key === "id" && value && $c307bfe9f4e9329c$var$allowValue(value)) return $c307bfe9f4e9329c$var$__assign($c307bfe9f4e9329c$var$__assign({ | ||
}, acc), { | ||
if (key === "id" && value && $456c9667291840f7$var$allowValue(value)) return $456c9667291840f7$var$__assign($456c9667291840f7$var$__assign({}, acc), { | ||
id: value | ||
}); | ||
if (key === "class" && value && $c307bfe9f4e9329c$var$allowValue(value) && !options.inlineCSS) return $c307bfe9f4e9329c$var$__assign($c307bfe9f4e9329c$var$__assign({ | ||
}, acc), { | ||
if (key === "class" && value && $456c9667291840f7$var$allowValue(value) && !options.inlineCSS) return $456c9667291840f7$var$__assign($456c9667291840f7$var$__assign({}, acc), { | ||
className: value | ||
}); | ||
return $c307bfe9f4e9329c$var$__assign($c307bfe9f4e9329c$var$__assign({ | ||
}, acc), { | ||
return $456c9667291840f7$var$__assign($456c9667291840f7$var$__assign({}, acc), { | ||
attrs: acc.attrs.concat({ | ||
@@ -125,12 +122,10 @@ key: key, | ||
}; | ||
var $c307bfe9f4e9329c$var$wrapInQuotes = function(str, options) { | ||
var $456c9667291840f7$var$wrapInQuotes = function(str, options) { | ||
if (str === undefined) return null; | ||
if (options.doubleQuotes && str.includes("\"")) return "'".concat(str, "'"); | ||
if (options.doubleQuotes && !str.includes("\"")) return "\"".concat(str, "\""); | ||
if (/\n/.test(str)) return "`".concat(str, "`"); | ||
if (options.doubleQuotes && str.includes('"')) return "'".concat(str, "'"); | ||
if (options.doubleQuotes && !str.includes('"')) return '"'.concat(str, '"'); | ||
return "'".concat(str, "'"); | ||
}; | ||
var $c307bfe9f4e9329c$var$keepMultilineAttrValue = function(str) { | ||
return str === null || str === void 0 ? void 0 : str.replace(/\n/g, "\\\n"); | ||
}; | ||
var $c307bfe9f4e9329c$export$ec87509295a42e9b = function(attrs, options) { | ||
var $456c9667291840f7$export$ec87509295a42e9b = function(attrs, options) { | ||
return attrs.map(function(_a) { | ||
@@ -140,3 +135,3 @@ var key = _a.key, value = _a.value; | ||
key, | ||
value && $c307bfe9f4e9329c$var$keepMultilineAttrValue($c307bfe9f4e9329c$var$wrapInQuotes(value, options)) | ||
value && $456c9667291840f7$var$wrapInQuotes(value, options) | ||
].filter(function(str) { | ||
@@ -150,4 +145,4 @@ return str != null; | ||
var $d915837238100320$var$__assign = undefined && undefined.__assign || function() { | ||
$d915837238100320$var$__assign = Object.assign || function(t) { | ||
var $58b850e81b24fb0a$var$__assign = undefined && undefined.__assign || function() { | ||
$58b850e81b24fb0a$var$__assign = Object.assign || function(t) { | ||
for(var s, i = 1, n = arguments.length; i < n; i++){ | ||
@@ -159,5 +154,5 @@ s = arguments[i]; | ||
}; | ||
return $d915837238100320$var$__assign.apply(this, arguments); | ||
return $58b850e81b24fb0a$var$__assign.apply(this, arguments); | ||
}; | ||
var $d915837238100320$var$__spreadArray = undefined && undefined.__spreadArray || function(to, from, pack) { | ||
var $58b850e81b24fb0a$var$__spreadArray = undefined && undefined.__spreadArray || function(to, from, pack) { | ||
if (pack || arguments.length === 2) { | ||
@@ -171,40 +166,39 @@ for(var i = 0, l = from.length, ar; i < l; i++)if (ar || !(i in from)) { | ||
}; | ||
var $d915837238100320$var$getFirstText = function(nodes) { | ||
var $58b850e81b24fb0a$var$getFirstText = function(nodes) { | ||
var textNode = nodes[0]; | ||
if (textNode && textNode.node === $a92eca0b06868bbf$export$85c928794f8d04d4.Text) return textNode; | ||
if (textNode && textNode.node === (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Text) return textNode; | ||
return null; | ||
}; | ||
var $d915837238100320$var$getNodesWithoutText = function(nodes) { | ||
var $58b850e81b24fb0a$var$getNodesWithoutText = function(nodes) { | ||
var textNode = nodes[0], other = nodes.slice(1); | ||
if (textNode && textNode.node === $a92eca0b06868bbf$export$85c928794f8d04d4.Text) return other; | ||
if (textNode && textNode.node === (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Text) return other; | ||
return nodes; | ||
}; | ||
var $d915837238100320$var$getIndent = function(_a) { | ||
var $58b850e81b24fb0a$var$getIndent = function(_a) { | ||
var level = _a.level, symbol = _a.symbol; | ||
return symbol.repeat(level); | ||
}; | ||
var $d915837238100320$var$wrapPreformattedText = function(str1, options) { | ||
var $58b850e81b24fb0a$var$wrapPreformattedText = function(str1, options) { | ||
return str1 ? ".\n" + str1.trim().split("\n").map(function(str) { | ||
return $d915837238100320$var$getIndent(options) + str.trimStart(); | ||
return $58b850e81b24fb0a$var$getIndent(options) + str.trimStart(); | ||
}).join("\n") : ""; | ||
}; | ||
var $d915837238100320$var$compileDoctype = function(_, options) { | ||
return "".concat($d915837238100320$var$getIndent(options), "doctype html"); | ||
var $58b850e81b24fb0a$var$compileDoctype = function(_, options) { | ||
return "".concat($58b850e81b24fb0a$var$getIndent(options), "doctype html"); | ||
}; | ||
var $d915837238100320$var$compileText = function(node, options) { | ||
var $58b850e81b24fb0a$var$compileText = function(node, options) { | ||
var resultText = node.value.trimEnd().split("\n").filter(Boolean).map(function(str) { | ||
return "".concat($d915837238100320$var$getIndent(options), "| ").concat(str.trimStart()); | ||
return "".concat($58b850e81b24fb0a$var$getIndent(options), "| ").concat(str.trimStart()); | ||
}).join("\n"); | ||
return options.encode ? $gyQpm$htmlentities.encode(resultText) : resultText; | ||
return options.encode ? (0, $8wP6K$htmlentities.encode)(resultText) : resultText; | ||
}; | ||
var $d915837238100320$var$compileSingleLineText = function(node, options) { | ||
return options.encode ? $gyQpm$htmlentities.encode(node.value) : node.value; | ||
var $58b850e81b24fb0a$var$compileSingleLineText = function(node, options) { | ||
return options.encode ? (0, $8wP6K$htmlentities.encode)(node.value) : node.value; | ||
}; | ||
var $d915837238100320$var$compileComment = function(node, options) { | ||
var start = $d915837238100320$var$getIndent(options) + "//"; | ||
var $58b850e81b24fb0a$var$compileComment = function(node, options) { | ||
var start = $58b850e81b24fb0a$var$getIndent(options) + "//"; | ||
var clearedValue = node.value.trim(); | ||
if (!clearedValue.includes("\n")) return start + " " + clearedValue; | ||
return start + "\n" + clearedValue.split("\n").map(function(str) { | ||
return "".concat($d915837238100320$var$getIndent($d915837238100320$var$__assign($d915837238100320$var$__assign({ | ||
}, options), { | ||
return "".concat($58b850e81b24fb0a$var$getIndent($58b850e81b24fb0a$var$__assign($58b850e81b24fb0a$var$__assign({}, options), { | ||
level: options.level + 1 | ||
@@ -214,61 +208,58 @@ }))).concat(str.trim()); | ||
}; | ||
var $d915837238100320$var$compileScript = function(node, options) { | ||
return "".concat($d915837238100320$var$getIndent(options), "script").concat($c307bfe9f4e9329c$exports.wrapAttrs($c307bfe9f4e9329c$exports.compileAttrs(node.attrs, options))).concat($d915837238100320$var$wrapPreformattedText(node.value, $d915837238100320$var$__assign($d915837238100320$var$__assign({ | ||
}, options), { | ||
var $58b850e81b24fb0a$var$compileScript = function(node, options) { | ||
return "".concat($58b850e81b24fb0a$var$getIndent(options), "script").concat((0, $456c9667291840f7$exports.wrapAttrs)((0, $456c9667291840f7$exports.compileAttrs)(node.attrs, options))).concat($58b850e81b24fb0a$var$wrapPreformattedText(node.value, $58b850e81b24fb0a$var$__assign($58b850e81b24fb0a$var$__assign({}, options), { | ||
level: options.level + 1 | ||
}))); | ||
}; | ||
var $d915837238100320$var$compileStyle = function(node, options) { | ||
return "".concat($d915837238100320$var$getIndent(options), "style").concat($c307bfe9f4e9329c$exports.wrapAttrs($c307bfe9f4e9329c$exports.compileAttrs(node.attrs, options))).concat($d915837238100320$var$wrapPreformattedText(node.value, $d915837238100320$var$__assign($d915837238100320$var$__assign({ | ||
}, options), { | ||
var $58b850e81b24fb0a$var$compileStyle = function(node, options) { | ||
return "".concat($58b850e81b24fb0a$var$getIndent(options), "style").concat((0, $456c9667291840f7$exports.wrapAttrs)((0, $456c9667291840f7$exports.compileAttrs)(node.attrs, options))).concat($58b850e81b24fb0a$var$wrapPreformattedText(node.value, $58b850e81b24fb0a$var$__assign($58b850e81b24fb0a$var$__assign({}, options), { | ||
level: options.level + 1 | ||
}))); | ||
}; | ||
var $d915837238100320$var$compileTag = function(node, options) { | ||
var _a = $c307bfe9f4e9329c$exports.formatAttrsForTag(node.attrs, options), attrs = _a.attrs, className = _a.className, id = _a.id; | ||
var $58b850e81b24fb0a$var$compileTag = function(node, options) { | ||
var _a = (0, $456c9667291840f7$exports.formatAttrsForTag)(node.attrs, options), attrs = _a.attrs, className = _a.className, id = _a.id; | ||
var tag = ""; | ||
if (options.classesAtEnd) tag = [ | ||
$d915837238100320$var$getIndent(options), | ||
$58b850e81b24fb0a$var$getIndent(options), | ||
node.name, | ||
id ? "#".concat(id) : "", | ||
$c307bfe9f4e9329c$exports.wrapAttrs($c307bfe9f4e9329c$exports.compileAttrs(attrs, options)), | ||
(0, $456c9667291840f7$exports.wrapAttrs)((0, $456c9667291840f7$exports.compileAttrs)(attrs, options)), | ||
className ? "." + className.split(" ").join(".") : "", | ||
].filter(Boolean).join(""); | ||
else tag = [ | ||
$d915837238100320$var$getIndent(options), | ||
$58b850e81b24fb0a$var$getIndent(options), | ||
(id || className) && node.name === "div" ? "" : node.name, | ||
id ? "#".concat(id) : "", | ||
className ? "." + className.split(" ").join(".") : "", | ||
$c307bfe9f4e9329c$exports.wrapAttrs($c307bfe9f4e9329c$exports.compileAttrs(attrs, options)), | ||
(0, $456c9667291840f7$exports.wrapAttrs)((0, $456c9667291840f7$exports.compileAttrs)(attrs, options)), | ||
].filter(Boolean).join(""); | ||
var textNode = $d915837238100320$var$getFirstText(node.children); | ||
var textNode = $58b850e81b24fb0a$var$getFirstText(node.children); | ||
if (!textNode) return tag; | ||
var resultText = textNode.value.includes("\n") ? "\n" + $d915837238100320$var$compileText(textNode, $d915837238100320$var$__assign($d915837238100320$var$__assign({ | ||
}, options), { | ||
var resultText = textNode.value.includes("\n") ? "\n" + $58b850e81b24fb0a$var$compileText(textNode, $58b850e81b24fb0a$var$__assign($58b850e81b24fb0a$var$__assign({}, options), { | ||
level: options.level + 1 | ||
})) : " " + $d915837238100320$var$compileSingleLineText(textNode, options); | ||
})) : " " + $58b850e81b24fb0a$var$compileSingleLineText(textNode, options); | ||
return "".concat(tag).concat(resultText); | ||
}; | ||
function $d915837238100320$export$85f0a661b59e6ae5(ast1, options) { | ||
function $58b850e81b24fb0a$export$85f0a661b59e6ae5(ast1, options) { | ||
var deepCompile = function(ast, level) { | ||
if (level === void 0) level = 0; | ||
return ast.reduce(function(acc, node) { | ||
var newOptions = $d915837238100320$var$__assign({ | ||
var newOptions = $58b850e81b24fb0a$var$__assign({ | ||
level: level | ||
}, options); | ||
switch(node.node){ | ||
case $a92eca0b06868bbf$export$85c928794f8d04d4.Doctype: | ||
return acc.concat($d915837238100320$var$compileDoctype(node, newOptions)); | ||
case $a92eca0b06868bbf$export$85c928794f8d04d4.Script: | ||
return acc.concat($d915837238100320$var$compileScript(node, newOptions)); | ||
case $a92eca0b06868bbf$export$85c928794f8d04d4.Style: | ||
return acc.concat($d915837238100320$var$compileStyle(node, newOptions)); | ||
case $a92eca0b06868bbf$export$85c928794f8d04d4.Text: | ||
return acc.concat($d915837238100320$var$compileText(node, newOptions)); | ||
case $a92eca0b06868bbf$export$85c928794f8d04d4.Comment: | ||
return acc.concat($d915837238100320$var$compileComment(node, newOptions)); | ||
case $a92eca0b06868bbf$export$85c928794f8d04d4.Tag: | ||
return acc.concat.apply(acc, $d915837238100320$var$__spreadArray([ | ||
$d915837238100320$var$compileTag(node, newOptions) | ||
], deepCompile($d915837238100320$var$getNodesWithoutText(node.children), level + 1), false)); | ||
case (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Doctype: | ||
return acc.concat($58b850e81b24fb0a$var$compileDoctype(node, newOptions)); | ||
case (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Script: | ||
return acc.concat($58b850e81b24fb0a$var$compileScript(node, newOptions)); | ||
case (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Style: | ||
return acc.concat($58b850e81b24fb0a$var$compileStyle(node, newOptions)); | ||
case (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Text: | ||
return acc.concat($58b850e81b24fb0a$var$compileText(node, newOptions)); | ||
case (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Comment: | ||
return acc.concat($58b850e81b24fb0a$var$compileComment(node, newOptions)); | ||
case (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Tag: | ||
return acc.concat.apply(acc, $58b850e81b24fb0a$var$__spreadArray([ | ||
$58b850e81b24fb0a$var$compileTag(node, newOptions) | ||
], deepCompile($58b850e81b24fb0a$var$getNodesWithoutText(node.children), level + 1), false)); | ||
default: | ||
@@ -286,21 +277,21 @@ return acc; | ||
var $4aee57f987bf4a68$var$isTag = function(child) { | ||
var $55670f3adf398d0d$var$isTag = function(child) { | ||
return child.nodeType === "tag"; | ||
}; | ||
var $4aee57f987bf4a68$var$isDoctype = function(child) { | ||
var $55670f3adf398d0d$var$isDoctype = function(child) { | ||
return child.nodeType === "doctype"; | ||
}; | ||
var $4aee57f987bf4a68$var$isText = function(child) { | ||
var $55670f3adf398d0d$var$isText = function(child) { | ||
return child.nodeType === "text"; | ||
}; | ||
var $4aee57f987bf4a68$var$isComment = function(child) { | ||
var $55670f3adf398d0d$var$isComment = function(child) { | ||
return child.nodeType === "comment"; | ||
}; | ||
var $4aee57f987bf4a68$var$isScript = function(child) { | ||
var $55670f3adf398d0d$var$isScript = function(child) { | ||
return child.nodeType === "script"; | ||
}; | ||
var $4aee57f987bf4a68$var$isStyle = function(child) { | ||
var $55670f3adf398d0d$var$isStyle = function(child) { | ||
return child.nodeType === "style"; | ||
}; | ||
var $4aee57f987bf4a68$var$parseAttrs = function(attrs) { | ||
var $55670f3adf398d0d$var$parseAttrs = function(attrs) { | ||
if (attrs === void 0) attrs = []; | ||
@@ -318,40 +309,40 @@ return attrs.map(function(attr) { | ||
}; | ||
var $4aee57f987bf4a68$var$parseText = function(child) { | ||
var $55670f3adf398d0d$var$parseText = function(child) { | ||
return child.content.value.content.trim() ? { | ||
node: $a92eca0b06868bbf$export$85c928794f8d04d4.Text, | ||
node: (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Text, | ||
value: child.content.value.content | ||
} : null; | ||
}; | ||
var $4aee57f987bf4a68$var$parseComment = function(child) { | ||
var $55670f3adf398d0d$var$parseComment = function(child) { | ||
return { | ||
node: $a92eca0b06868bbf$export$85c928794f8d04d4.Comment, | ||
node: (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Comment, | ||
value: child.content.value.content | ||
}; | ||
}; | ||
var $4aee57f987bf4a68$var$parseDoctype = function(child) { | ||
var $55670f3adf398d0d$var$parseDoctype = function(child) { | ||
return { | ||
node: $a92eca0b06868bbf$export$85c928794f8d04d4.Doctype, | ||
attrs: $4aee57f987bf4a68$var$parseAttrs(child.content.attributes) | ||
node: (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Doctype, | ||
attrs: $55670f3adf398d0d$var$parseAttrs(child.content.attributes) | ||
}; | ||
}; | ||
var $4aee57f987bf4a68$var$parseScript = function(child) { | ||
var $55670f3adf398d0d$var$parseScript = function(child) { | ||
var _a, _b; | ||
return { | ||
node: $a92eca0b06868bbf$export$85c928794f8d04d4.Script, | ||
attrs: $4aee57f987bf4a68$var$parseAttrs(child.content.attributes), | ||
node: (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Script, | ||
attrs: $55670f3adf398d0d$var$parseAttrs(child.content.attributes), | ||
value: (_b = (_a = child.content.value) === null || _a === void 0 ? void 0 : _a.content) !== null && _b !== void 0 ? _b : "" | ||
}; | ||
}; | ||
var $4aee57f987bf4a68$var$parseStyle = function(child) { | ||
var $55670f3adf398d0d$var$parseStyle = function(child) { | ||
var _a, _b; | ||
return { | ||
node: $a92eca0b06868bbf$export$85c928794f8d04d4.Style, | ||
attrs: $4aee57f987bf4a68$var$parseAttrs(child.content.attributes), | ||
node: (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Style, | ||
attrs: $55670f3adf398d0d$var$parseAttrs(child.content.attributes), | ||
value: (_b = (_a = child.content.value) === null || _a === void 0 ? void 0 : _a.content) !== null && _b !== void 0 ? _b : "" | ||
}; | ||
}; | ||
var $4aee57f987bf4a68$var$parseTag = function(child, children) { | ||
var $55670f3adf398d0d$var$parseTag = function(child, children) { | ||
return { | ||
node: $a92eca0b06868bbf$export$85c928794f8d04d4.Tag, | ||
attrs: $4aee57f987bf4a68$var$parseAttrs(child.content.attributes), | ||
node: (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Tag, | ||
attrs: $55670f3adf398d0d$var$parseAttrs(child.content.attributes), | ||
name: child.content.name, | ||
@@ -361,17 +352,17 @@ children: children | ||
}; | ||
function $4aee57f987bf4a68$export$538fc22499890e84(ast) { | ||
function $55670f3adf398d0d$export$538fc22499890e84(ast) { | ||
var deepConvert = function(children) { | ||
return children.reduce(function(acc, child) { | ||
var _a; | ||
if ($4aee57f987bf4a68$var$isText(child)) { | ||
var textNode = $4aee57f987bf4a68$var$parseText(child); | ||
if ($55670f3adf398d0d$var$isText(child)) { | ||
var textNode = $55670f3adf398d0d$var$parseText(child); | ||
return textNode ? acc.concat(textNode) : acc; | ||
} | ||
if ($4aee57f987bf4a68$var$isComment(child)) return acc.concat($4aee57f987bf4a68$var$parseComment(child)); | ||
if ($4aee57f987bf4a68$var$isDoctype(child)) return acc.concat($4aee57f987bf4a68$var$parseDoctype(child)); | ||
if ($4aee57f987bf4a68$var$isScript(child)) return acc.concat($4aee57f987bf4a68$var$parseScript(child)); | ||
if ($4aee57f987bf4a68$var$isStyle(child)) return acc.concat($4aee57f987bf4a68$var$parseStyle(child)); | ||
/* istanbul ignore else */ if ($4aee57f987bf4a68$var$isTag(child)) { | ||
if ($55670f3adf398d0d$var$isComment(child)) return acc.concat($55670f3adf398d0d$var$parseComment(child)); | ||
if ($55670f3adf398d0d$var$isDoctype(child)) return acc.concat($55670f3adf398d0d$var$parseDoctype(child)); | ||
if ($55670f3adf398d0d$var$isScript(child)) return acc.concat($55670f3adf398d0d$var$parseScript(child)); | ||
if ($55670f3adf398d0d$var$isStyle(child)) return acc.concat($55670f3adf398d0d$var$parseStyle(child)); | ||
/* istanbul ignore else */ if ($55670f3adf398d0d$var$isTag(child)) { | ||
var children_1 = deepConvert((_a = child.content.children) !== null && _a !== void 0 ? _a : []); | ||
return acc.concat($4aee57f987bf4a68$var$parseTag(child, children_1)); | ||
return acc.concat($55670f3adf398d0d$var$parseTag(child, children_1)); | ||
} | ||
@@ -384,4 +375,4 @@ /* istanbul ignore next */ return acc; | ||
} | ||
function $4aee57f987bf4a68$export$16f39c815cb63b03(html) { | ||
return $4aee57f987bf4a68$export$538fc22499890e84(($parcel$interopDefault($gyQpm$hyntaxlibconstructtree))(($parcel$interopDefault($gyQpm$hyntaxlibtokenize))(html).tokens).ast); | ||
function $55670f3adf398d0d$export$16f39c815cb63b03(html) { | ||
return $55670f3adf398d0d$export$538fc22499890e84((0, ($parcel$interopDefault($8wP6K$hyntaxlibconstructtree)))((0, ($parcel$interopDefault($8wP6K$hyntaxlibtokenize)))(html).tokens).ast); | ||
} | ||
@@ -392,3 +383,3 @@ | ||
var $eda749154f7aea64$var$NodeTypes = { | ||
var $a7a9f151104f4a45$var$NodeTypes = { | ||
ELEMENT: 1, | ||
@@ -400,21 +391,21 @@ TEXT: 2, | ||
}; | ||
var $eda749154f7aea64$var$isElement = function(child) { | ||
return child.type === $eda749154f7aea64$var$NodeTypes.ELEMENT; | ||
var $a7a9f151104f4a45$var$isElement = function(child) { | ||
return child.type === $a7a9f151104f4a45$var$NodeTypes.ELEMENT; | ||
}; | ||
var $eda749154f7aea64$var$isText = function(child) { | ||
return child.type === $eda749154f7aea64$var$NodeTypes.TEXT; | ||
var $a7a9f151104f4a45$var$isText = function(child) { | ||
return child.type === $a7a9f151104f4a45$var$NodeTypes.TEXT; | ||
}; | ||
var $eda749154f7aea64$var$isComment = function(child) { | ||
return child.type === $eda749154f7aea64$var$NodeTypes.COMMENT; | ||
var $a7a9f151104f4a45$var$isComment = function(child) { | ||
return child.type === $a7a9f151104f4a45$var$NodeTypes.COMMENT; | ||
}; | ||
var $eda749154f7aea64$var$isAttr = function(attr) { | ||
return attr.type === $eda749154f7aea64$var$NodeTypes.ATTRIBUTE; | ||
var $a7a9f151104f4a45$var$isAttr = function(attr) { | ||
return attr.type === $a7a9f151104f4a45$var$NodeTypes.ATTRIBUTE; | ||
}; | ||
var $eda749154f7aea64$var$isInterpolation = function(child) { | ||
return child.type === $eda749154f7aea64$var$NodeTypes.INTERPOLATION; | ||
var $a7a9f151104f4a45$var$isInterpolation = function(child) { | ||
return child.type === $a7a9f151104f4a45$var$NodeTypes.INTERPOLATION; | ||
}; | ||
var $eda749154f7aea64$export$e1a9355cfd8f6c64 = function(attrs) { | ||
var $a7a9f151104f4a45$export$e1a9355cfd8f6c64 = function(attrs) { | ||
return attrs.map(function(attr) { | ||
var _a; | ||
if ($eda749154f7aea64$var$isAttr(attr)) return { | ||
if ($a7a9f151104f4a45$var$isAttr(attr)) return { | ||
key: attr.name, | ||
@@ -428,26 +419,26 @@ value: (_a = attr.value) === null || _a === void 0 ? void 0 : _a.content | ||
}; | ||
var $eda749154f7aea64$export$ec3f164301cf7795 = function(child) { | ||
var $a7a9f151104f4a45$export$ec3f164301cf7795 = function(child) { | ||
return { | ||
node: $a92eca0b06868bbf$export$85c928794f8d04d4.Text, | ||
node: (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Text, | ||
value: child.content.trim() | ||
}; | ||
}; | ||
var $eda749154f7aea64$export$c25837ef67955388 = function(child) { | ||
var $a7a9f151104f4a45$export$c25837ef67955388 = function(child) { | ||
return { | ||
node: $a92eca0b06868bbf$export$85c928794f8d04d4.Comment, | ||
node: (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Comment, | ||
value: child.content.trim() | ||
}; | ||
}; | ||
var $eda749154f7aea64$export$99bca2eadc127ad2 = function(child, children) { | ||
var $a7a9f151104f4a45$export$99bca2eadc127ad2 = function(child, children) { | ||
return { | ||
node: $a92eca0b06868bbf$export$85c928794f8d04d4.Tag, | ||
node: (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Tag, | ||
name: child.tag, | ||
attrs: $eda749154f7aea64$export$e1a9355cfd8f6c64(child.props), | ||
attrs: $a7a9f151104f4a45$export$e1a9355cfd8f6c64(child.props), | ||
children: children | ||
}; | ||
}; | ||
var $eda749154f7aea64$var$parseScript = function(child) { | ||
var $a7a9f151104f4a45$var$parseScript = function(child) { | ||
return { | ||
node: $a92eca0b06868bbf$export$85c928794f8d04d4.Script, | ||
attrs: $eda749154f7aea64$export$e1a9355cfd8f6c64(child.props), | ||
node: (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Script, | ||
attrs: $a7a9f151104f4a45$export$e1a9355cfd8f6c64(child.props), | ||
value: child.children.map(function(el) { | ||
@@ -458,6 +449,6 @@ return el.content; | ||
}; | ||
var $eda749154f7aea64$var$parseStyle = function(child) { | ||
var $a7a9f151104f4a45$var$parseStyle = function(child) { | ||
return { | ||
node: $a92eca0b06868bbf$export$85c928794f8d04d4.Style, | ||
attrs: $eda749154f7aea64$export$e1a9355cfd8f6c64(child.props), | ||
node: (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Style, | ||
attrs: $a7a9f151104f4a45$export$e1a9355cfd8f6c64(child.props), | ||
value: child.children.map(function(el) { | ||
@@ -468,19 +459,19 @@ return el.content; | ||
}; | ||
var $eda749154f7aea64$var$parseInterpolation = function(child) { | ||
var $a7a9f151104f4a45$var$parseInterpolation = function(child) { | ||
return { | ||
node: $a92eca0b06868bbf$export$85c928794f8d04d4.Text, | ||
node: (0, $0e6b16fffa0a9bc6$export$85c928794f8d04d4).Text, | ||
value: child.loc.source | ||
}; | ||
}; | ||
function $eda749154f7aea64$export$9f888db2af58a9f1(ast) { | ||
function $a7a9f151104f4a45$export$9f888db2af58a9f1(ast) { | ||
var deepConvert = function(children) { | ||
return children.reduce(function(acc, child) { | ||
if ($eda749154f7aea64$var$isText(child)) return acc.concat($eda749154f7aea64$export$ec3f164301cf7795(child)); | ||
if ($eda749154f7aea64$var$isInterpolation(child)) return acc.concat($eda749154f7aea64$var$parseInterpolation(child)); | ||
if ($eda749154f7aea64$var$isComment(child)) return acc.concat($eda749154f7aea64$export$c25837ef67955388(child)); | ||
if ($eda749154f7aea64$var$isElement(child) && child.tag === "script") return acc.concat($eda749154f7aea64$var$parseScript(child)); | ||
if ($eda749154f7aea64$var$isElement(child) && child.tag === "style") return acc.concat($eda749154f7aea64$var$parseStyle(child)); | ||
/* istanbul ignore else */ if ($eda749154f7aea64$var$isElement(child)) { | ||
if ($a7a9f151104f4a45$var$isText(child)) return acc.concat($a7a9f151104f4a45$export$ec3f164301cf7795(child)); | ||
if ($a7a9f151104f4a45$var$isInterpolation(child)) return acc.concat($a7a9f151104f4a45$var$parseInterpolation(child)); | ||
if ($a7a9f151104f4a45$var$isComment(child)) return acc.concat($a7a9f151104f4a45$export$c25837ef67955388(child)); | ||
if ($a7a9f151104f4a45$var$isElement(child) && child.tag === "script") return acc.concat($a7a9f151104f4a45$var$parseScript(child)); | ||
if ($a7a9f151104f4a45$var$isElement(child) && child.tag === "style") return acc.concat($a7a9f151104f4a45$var$parseStyle(child)); | ||
/* istanbul ignore else */ if ($a7a9f151104f4a45$var$isElement(child)) { | ||
var children_1 = deepConvert(child.children); | ||
return acc.concat($eda749154f7aea64$export$99bca2eadc127ad2(child, children_1)); | ||
return acc.concat($a7a9f151104f4a45$export$99bca2eadc127ad2(child, children_1)); | ||
} | ||
@@ -493,9 +484,9 @@ console.error(child); | ||
} | ||
function $eda749154f7aea64$export$6803692198d357dd(html) { | ||
return $eda749154f7aea64$export$9f888db2af58a9f1($gyQpm$vuecompilerdom.parse(html)); | ||
function $a7a9f151104f4a45$export$6803692198d357dd(html) { | ||
return $a7a9f151104f4a45$export$9f888db2af58a9f1((0, $8wP6K$vuecompilerdom.parse)(html)); | ||
} | ||
var $0ca9772bb4919d41$var$__assign = undefined && undefined.__assign || function() { | ||
$0ca9772bb4919d41$var$__assign = Object.assign || function(t) { | ||
var $86b6b968d2dbe88f$var$__assign = undefined && undefined.__assign || function() { | ||
$86b6b968d2dbe88f$var$__assign = Object.assign || function(t) { | ||
for(var s, i = 1, n = arguments.length; i < n; i++){ | ||
@@ -507,7 +498,6 @@ s = arguments[i]; | ||
}; | ||
return $0ca9772bb4919d41$var$__assign.apply(this, arguments); | ||
return $86b6b968d2dbe88f$var$__assign.apply(this, arguments); | ||
}; | ||
var $0ca9772bb4919d41$var$__rest = undefined && undefined.__rest || function(s, e) { | ||
var t = { | ||
}; | ||
var $86b6b968d2dbe88f$var$__rest = undefined && undefined.__rest || function(s, e) { | ||
var t = {}; | ||
for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; | ||
@@ -519,7 +509,7 @@ if (s != null && typeof Object.getOwnPropertySymbols === "function") { | ||
}; | ||
var $0ca9772bb4919d41$var$setupDefaultOptions = function(_a) { | ||
var _b = _a.attrComma, attrComma = _b === void 0 ? true : _b, options = $0ca9772bb4919d41$var$__rest(_a, [ | ||
var $86b6b968d2dbe88f$var$setupDefaultOptions = function(_a) { | ||
var _b = _a.attrComma, attrComma = _b === void 0 ? true : _b, options = $86b6b968d2dbe88f$var$__rest(_a, [ | ||
"attrComma" | ||
]); | ||
return $0ca9772bb4919d41$var$__assign({ | ||
return $86b6b968d2dbe88f$var$__assign({ | ||
attrSep: attrComma ? ", " : " ", | ||
@@ -535,8 +525,7 @@ bodyLess: false, | ||
}; | ||
function $0ca9772bb4919d41$export$9c68d69a4c5bbcf9(html, options) { | ||
if (options === void 0) options = { | ||
}; | ||
var definedOptions = $0ca9772bb4919d41$var$setupDefaultOptions(options); | ||
var convertedAst = definedOptions.parser === "html" ? $4aee57f987bf4a68$export$16f39c815cb63b03(html) : $eda749154f7aea64$export$6803692198d357dd(html); | ||
return $d915837238100320$exports.compileAst(options.bodyLess ? convertedAst : $19bc831d3f29a2ee$export$15f1e0b2d8c15007(convertedAst), definedOptions); | ||
function $86b6b968d2dbe88f$export$9c68d69a4c5bbcf9(html, options) { | ||
if (options === void 0) options = {}; | ||
var definedOptions = $86b6b968d2dbe88f$var$setupDefaultOptions(options); | ||
var convertedAst = definedOptions.parser === "html" ? (0, $55670f3adf398d0d$export$16f39c815cb63b03)(html) : (0, $a7a9f151104f4a45$export$6803692198d357dd)(html); | ||
return (0, $58b850e81b24fb0a$exports.compileAst)(options.bodyLess ? convertedAst : (0, $4ef8b8fe7daf140b$export$15f1e0b2d8c15007)(convertedAst), definedOptions); | ||
} | ||
@@ -543,0 +532,0 @@ |
@@ -1,5 +0,5 @@ | ||
import {encode as $blZUa$encode} from "html-entities"; | ||
import $blZUa$hyntaxlibconstructtree from "hyntax/lib/construct-tree"; | ||
import $blZUa$hyntaxlibtokenize from "hyntax/lib/tokenize"; | ||
import {parse as $blZUa$parse} from "@vue/compiler-dom"; | ||
import {encode as $kbbYs$encode} from "html-entities"; | ||
import $kbbYs$hyntaxlibconstructtree from "hyntax/lib/construct-tree"; | ||
import $kbbYs$hyntaxlibtokenize from "hyntax/lib/tokenize"; | ||
import {parse as $kbbYs$parse} from "@vue/compiler-dom"; | ||
@@ -9,6 +9,6 @@ function $parcel$export(e, n, v, s) { | ||
} | ||
var $f586152863514d65$exports = {}; | ||
var $09a65d7ba376d391$exports = {}; | ||
$parcel$export($f586152863514d65$exports, "convert", () => $f586152863514d65$export$9c68d69a4c5bbcf9, (v) => $f586152863514d65$export$9c68d69a4c5bbcf9 = v); | ||
var $820b09e697cfbfeb$export$85c928794f8d04d4 = { | ||
$parcel$export($09a65d7ba376d391$exports, "convert", () => $09a65d7ba376d391$export$9c68d69a4c5bbcf9, (v) => $09a65d7ba376d391$export$9c68d69a4c5bbcf9 = v); | ||
var $00a4bd21c189f400$export$85c928794f8d04d4 = { | ||
Doctype: 0, | ||
@@ -23,12 +23,12 @@ Tag: 1, | ||
var $c1d9d56b4477109d$var$findTag = function(nodes, tagName) { | ||
var $8094157b9d54973a$var$findTag = function(nodes, tagName) { | ||
return nodes.find(function(node) { | ||
if (node.node === $820b09e697cfbfeb$export$85c928794f8d04d4.Tag && node.name === tagName) return node; | ||
if (node.node === $820b09e697cfbfeb$export$85c928794f8d04d4.Tag && node.children) return $c1d9d56b4477109d$var$findTag(node.children, tagName); | ||
if (node.node === (0, $00a4bd21c189f400$export$85c928794f8d04d4).Tag && node.name === tagName) return node; | ||
if (node.node === (0, $00a4bd21c189f400$export$85c928794f8d04d4).Tag && node.children) return $8094157b9d54973a$var$findTag(node.children, tagName); | ||
return undefined; | ||
}); | ||
}; | ||
var $c1d9d56b4477109d$var$createTag = function(name, children) { | ||
var $8094157b9d54973a$var$createTag = function(name, children) { | ||
return { | ||
node: $820b09e697cfbfeb$export$85c928794f8d04d4.Tag, | ||
node: (0, $00a4bd21c189f400$export$85c928794f8d04d4).Tag, | ||
name: name, | ||
@@ -39,9 +39,9 @@ children: children, | ||
}; | ||
var $c1d9d56b4477109d$export$15f1e0b2d8c15007 = function(nodes) { | ||
var html = $c1d9d56b4477109d$var$findTag(nodes, "html"); | ||
var body = $c1d9d56b4477109d$var$findTag(nodes, "body"); | ||
var head = $c1d9d56b4477109d$var$findTag(nodes, "head"); | ||
var $8094157b9d54973a$export$15f1e0b2d8c15007 = function(nodes) { | ||
var html = $8094157b9d54973a$var$findTag(nodes, "html"); | ||
var body = $8094157b9d54973a$var$findTag(nodes, "body"); | ||
var head = $8094157b9d54973a$var$findTag(nodes, "head"); | ||
if (html) return nodes; | ||
if (!body && head) return [ | ||
$c1d9d56b4477109d$var$createTag("html", [ | ||
$8094157b9d54973a$var$createTag("html", [ | ||
head | ||
@@ -51,3 +51,3 @@ ]) | ||
if (body && !head) return [ | ||
$c1d9d56b4477109d$var$createTag("html", [ | ||
$8094157b9d54973a$var$createTag("html", [ | ||
body | ||
@@ -57,3 +57,3 @@ ]) | ||
if (!html && body && head) return [ | ||
$c1d9d56b4477109d$var$createTag("html", [ | ||
$8094157b9d54973a$var$createTag("html", [ | ||
head, | ||
@@ -64,4 +64,4 @@ body | ||
return [ | ||
$c1d9d56b4477109d$var$createTag("html", [ | ||
$c1d9d56b4477109d$var$createTag("body", nodes) | ||
$8094157b9d54973a$var$createTag("html", [ | ||
$8094157b9d54973a$var$createTag("body", nodes) | ||
]) | ||
@@ -72,13 +72,13 @@ ]; | ||
var $af5a31028cc763e0$exports = {}; | ||
var $d0384cb133070227$exports = {}; | ||
$parcel$export($af5a31028cc763e0$exports, "compileAst", () => $af5a31028cc763e0$export$85f0a661b59e6ae5, (v) => $af5a31028cc763e0$export$85f0a661b59e6ae5 = v); | ||
$parcel$export($d0384cb133070227$exports, "compileAst", () => $d0384cb133070227$export$85f0a661b59e6ae5, (v) => $d0384cb133070227$export$85f0a661b59e6ae5 = v); | ||
var $eea8bcf3ac89b5b4$exports = {}; | ||
var $58ca0532e5af11ea$exports = {}; | ||
$parcel$export($eea8bcf3ac89b5b4$exports, "wrapAttrs", () => $eea8bcf3ac89b5b4$export$fc18073465ce7ae5, (v) => $eea8bcf3ac89b5b4$export$fc18073465ce7ae5 = v); | ||
$parcel$export($eea8bcf3ac89b5b4$exports, "formatAttrsForTag", () => $eea8bcf3ac89b5b4$export$25212e79da653bac, (v) => $eea8bcf3ac89b5b4$export$25212e79da653bac = v); | ||
$parcel$export($eea8bcf3ac89b5b4$exports, "compileAttrs", () => $eea8bcf3ac89b5b4$export$ec87509295a42e9b, (v) => $eea8bcf3ac89b5b4$export$ec87509295a42e9b = v); | ||
var $eea8bcf3ac89b5b4$var$__assign = undefined && undefined.__assign || function() { | ||
$eea8bcf3ac89b5b4$var$__assign = Object.assign || function(t) { | ||
$parcel$export($58ca0532e5af11ea$exports, "wrapAttrs", () => $58ca0532e5af11ea$export$fc18073465ce7ae5, (v) => $58ca0532e5af11ea$export$fc18073465ce7ae5 = v); | ||
$parcel$export($58ca0532e5af11ea$exports, "formatAttrsForTag", () => $58ca0532e5af11ea$export$25212e79da653bac, (v) => $58ca0532e5af11ea$export$25212e79da653bac = v); | ||
$parcel$export($58ca0532e5af11ea$exports, "compileAttrs", () => $58ca0532e5af11ea$export$ec87509295a42e9b, (v) => $58ca0532e5af11ea$export$ec87509295a42e9b = v); | ||
var $58ca0532e5af11ea$var$__assign = undefined && undefined.__assign || function() { | ||
$58ca0532e5af11ea$var$__assign = Object.assign || function(t) { | ||
for(var s, i = 1, n = arguments.length; i < n; i++){ | ||
@@ -90,23 +90,20 @@ s = arguments[i]; | ||
}; | ||
return $eea8bcf3ac89b5b4$var$__assign.apply(this, arguments); | ||
return $58ca0532e5af11ea$var$__assign.apply(this, arguments); | ||
}; | ||
var $eea8bcf3ac89b5b4$export$fc18073465ce7ae5 = function(str) { | ||
var $58ca0532e5af11ea$export$fc18073465ce7ae5 = function(str) { | ||
return str ? "(".concat(str, ")") : ""; | ||
}; | ||
var $eea8bcf3ac89b5b4$var$allowValue = function(str) { | ||
var $58ca0532e5af11ea$var$allowValue = function(str) { | ||
return !/[{}_]/.test(str); | ||
}; | ||
var $eea8bcf3ac89b5b4$export$25212e79da653bac = function(attrs, options) { | ||
var $58ca0532e5af11ea$export$25212e79da653bac = function(attrs, options) { | ||
return attrs.reduce(function(acc, _a) { | ||
var key = _a.key, value = _a.value; | ||
if (key === "id" && value && $eea8bcf3ac89b5b4$var$allowValue(value)) return $eea8bcf3ac89b5b4$var$__assign($eea8bcf3ac89b5b4$var$__assign({ | ||
}, acc), { | ||
if (key === "id" && value && $58ca0532e5af11ea$var$allowValue(value)) return $58ca0532e5af11ea$var$__assign($58ca0532e5af11ea$var$__assign({}, acc), { | ||
id: value | ||
}); | ||
if (key === "class" && value && $eea8bcf3ac89b5b4$var$allowValue(value) && !options.inlineCSS) return $eea8bcf3ac89b5b4$var$__assign($eea8bcf3ac89b5b4$var$__assign({ | ||
}, acc), { | ||
if (key === "class" && value && $58ca0532e5af11ea$var$allowValue(value) && !options.inlineCSS) return $58ca0532e5af11ea$var$__assign($58ca0532e5af11ea$var$__assign({}, acc), { | ||
className: value | ||
}); | ||
return $eea8bcf3ac89b5b4$var$__assign($eea8bcf3ac89b5b4$var$__assign({ | ||
}, acc), { | ||
return $58ca0532e5af11ea$var$__assign($58ca0532e5af11ea$var$__assign({}, acc), { | ||
attrs: acc.attrs.concat({ | ||
@@ -123,12 +120,10 @@ key: key, | ||
}; | ||
var $eea8bcf3ac89b5b4$var$wrapInQuotes = function(str, options) { | ||
var $58ca0532e5af11ea$var$wrapInQuotes = function(str, options) { | ||
if (str === undefined) return null; | ||
if (options.doubleQuotes && str.includes("\"")) return "'".concat(str, "'"); | ||
if (options.doubleQuotes && !str.includes("\"")) return "\"".concat(str, "\""); | ||
if (/\n/.test(str)) return "`".concat(str, "`"); | ||
if (options.doubleQuotes && str.includes('"')) return "'".concat(str, "'"); | ||
if (options.doubleQuotes && !str.includes('"')) return '"'.concat(str, '"'); | ||
return "'".concat(str, "'"); | ||
}; | ||
var $eea8bcf3ac89b5b4$var$keepMultilineAttrValue = function(str) { | ||
return str === null || str === void 0 ? void 0 : str.replace(/\n/g, "\\\n"); | ||
}; | ||
var $eea8bcf3ac89b5b4$export$ec87509295a42e9b = function(attrs, options) { | ||
var $58ca0532e5af11ea$export$ec87509295a42e9b = function(attrs, options) { | ||
return attrs.map(function(_a) { | ||
@@ -138,3 +133,3 @@ var key = _a.key, value = _a.value; | ||
key, | ||
value && $eea8bcf3ac89b5b4$var$keepMultilineAttrValue($eea8bcf3ac89b5b4$var$wrapInQuotes(value, options)) | ||
value && $58ca0532e5af11ea$var$wrapInQuotes(value, options) | ||
].filter(function(str) { | ||
@@ -148,4 +143,4 @@ return str != null; | ||
var $af5a31028cc763e0$var$__assign = undefined && undefined.__assign || function() { | ||
$af5a31028cc763e0$var$__assign = Object.assign || function(t) { | ||
var $d0384cb133070227$var$__assign = undefined && undefined.__assign || function() { | ||
$d0384cb133070227$var$__assign = Object.assign || function(t) { | ||
for(var s, i = 1, n = arguments.length; i < n; i++){ | ||
@@ -157,5 +152,5 @@ s = arguments[i]; | ||
}; | ||
return $af5a31028cc763e0$var$__assign.apply(this, arguments); | ||
return $d0384cb133070227$var$__assign.apply(this, arguments); | ||
}; | ||
var $af5a31028cc763e0$var$__spreadArray = undefined && undefined.__spreadArray || function(to, from, pack) { | ||
var $d0384cb133070227$var$__spreadArray = undefined && undefined.__spreadArray || function(to, from, pack) { | ||
if (pack || arguments.length === 2) { | ||
@@ -169,40 +164,39 @@ for(var i = 0, l = from.length, ar; i < l; i++)if (ar || !(i in from)) { | ||
}; | ||
var $af5a31028cc763e0$var$getFirstText = function(nodes) { | ||
var $d0384cb133070227$var$getFirstText = function(nodes) { | ||
var textNode = nodes[0]; | ||
if (textNode && textNode.node === $820b09e697cfbfeb$export$85c928794f8d04d4.Text) return textNode; | ||
if (textNode && textNode.node === (0, $00a4bd21c189f400$export$85c928794f8d04d4).Text) return textNode; | ||
return null; | ||
}; | ||
var $af5a31028cc763e0$var$getNodesWithoutText = function(nodes) { | ||
var $d0384cb133070227$var$getNodesWithoutText = function(nodes) { | ||
var textNode = nodes[0], other = nodes.slice(1); | ||
if (textNode && textNode.node === $820b09e697cfbfeb$export$85c928794f8d04d4.Text) return other; | ||
if (textNode && textNode.node === (0, $00a4bd21c189f400$export$85c928794f8d04d4).Text) return other; | ||
return nodes; | ||
}; | ||
var $af5a31028cc763e0$var$getIndent = function(_a) { | ||
var $d0384cb133070227$var$getIndent = function(_a) { | ||
var level = _a.level, symbol = _a.symbol; | ||
return symbol.repeat(level); | ||
}; | ||
var $af5a31028cc763e0$var$wrapPreformattedText = function(str1, options) { | ||
var $d0384cb133070227$var$wrapPreformattedText = function(str1, options) { | ||
return str1 ? ".\n" + str1.trim().split("\n").map(function(str) { | ||
return $af5a31028cc763e0$var$getIndent(options) + str.trimStart(); | ||
return $d0384cb133070227$var$getIndent(options) + str.trimStart(); | ||
}).join("\n") : ""; | ||
}; | ||
var $af5a31028cc763e0$var$compileDoctype = function(_, options) { | ||
return "".concat($af5a31028cc763e0$var$getIndent(options), "doctype html"); | ||
var $d0384cb133070227$var$compileDoctype = function(_, options) { | ||
return "".concat($d0384cb133070227$var$getIndent(options), "doctype html"); | ||
}; | ||
var $af5a31028cc763e0$var$compileText = function(node, options) { | ||
var $d0384cb133070227$var$compileText = function(node, options) { | ||
var resultText = node.value.trimEnd().split("\n").filter(Boolean).map(function(str) { | ||
return "".concat($af5a31028cc763e0$var$getIndent(options), "| ").concat(str.trimStart()); | ||
return "".concat($d0384cb133070227$var$getIndent(options), "| ").concat(str.trimStart()); | ||
}).join("\n"); | ||
return options.encode ? $blZUa$encode(resultText) : resultText; | ||
return options.encode ? (0, $kbbYs$encode)(resultText) : resultText; | ||
}; | ||
var $af5a31028cc763e0$var$compileSingleLineText = function(node, options) { | ||
return options.encode ? $blZUa$encode(node.value) : node.value; | ||
var $d0384cb133070227$var$compileSingleLineText = function(node, options) { | ||
return options.encode ? (0, $kbbYs$encode)(node.value) : node.value; | ||
}; | ||
var $af5a31028cc763e0$var$compileComment = function(node, options) { | ||
var start = $af5a31028cc763e0$var$getIndent(options) + "//"; | ||
var $d0384cb133070227$var$compileComment = function(node, options) { | ||
var start = $d0384cb133070227$var$getIndent(options) + "//"; | ||
var clearedValue = node.value.trim(); | ||
if (!clearedValue.includes("\n")) return start + " " + clearedValue; | ||
return start + "\n" + clearedValue.split("\n").map(function(str) { | ||
return "".concat($af5a31028cc763e0$var$getIndent($af5a31028cc763e0$var$__assign($af5a31028cc763e0$var$__assign({ | ||
}, options), { | ||
return "".concat($d0384cb133070227$var$getIndent($d0384cb133070227$var$__assign($d0384cb133070227$var$__assign({}, options), { | ||
level: options.level + 1 | ||
@@ -212,61 +206,58 @@ }))).concat(str.trim()); | ||
}; | ||
var $af5a31028cc763e0$var$compileScript = function(node, options) { | ||
return "".concat($af5a31028cc763e0$var$getIndent(options), "script").concat($eea8bcf3ac89b5b4$exports.wrapAttrs($eea8bcf3ac89b5b4$exports.compileAttrs(node.attrs, options))).concat($af5a31028cc763e0$var$wrapPreformattedText(node.value, $af5a31028cc763e0$var$__assign($af5a31028cc763e0$var$__assign({ | ||
}, options), { | ||
var $d0384cb133070227$var$compileScript = function(node, options) { | ||
return "".concat($d0384cb133070227$var$getIndent(options), "script").concat((0, $58ca0532e5af11ea$exports.wrapAttrs)((0, $58ca0532e5af11ea$exports.compileAttrs)(node.attrs, options))).concat($d0384cb133070227$var$wrapPreformattedText(node.value, $d0384cb133070227$var$__assign($d0384cb133070227$var$__assign({}, options), { | ||
level: options.level + 1 | ||
}))); | ||
}; | ||
var $af5a31028cc763e0$var$compileStyle = function(node, options) { | ||
return "".concat($af5a31028cc763e0$var$getIndent(options), "style").concat($eea8bcf3ac89b5b4$exports.wrapAttrs($eea8bcf3ac89b5b4$exports.compileAttrs(node.attrs, options))).concat($af5a31028cc763e0$var$wrapPreformattedText(node.value, $af5a31028cc763e0$var$__assign($af5a31028cc763e0$var$__assign({ | ||
}, options), { | ||
var $d0384cb133070227$var$compileStyle = function(node, options) { | ||
return "".concat($d0384cb133070227$var$getIndent(options), "style").concat((0, $58ca0532e5af11ea$exports.wrapAttrs)((0, $58ca0532e5af11ea$exports.compileAttrs)(node.attrs, options))).concat($d0384cb133070227$var$wrapPreformattedText(node.value, $d0384cb133070227$var$__assign($d0384cb133070227$var$__assign({}, options), { | ||
level: options.level + 1 | ||
}))); | ||
}; | ||
var $af5a31028cc763e0$var$compileTag = function(node, options) { | ||
var _a = $eea8bcf3ac89b5b4$exports.formatAttrsForTag(node.attrs, options), attrs = _a.attrs, className = _a.className, id = _a.id; | ||
var $d0384cb133070227$var$compileTag = function(node, options) { | ||
var _a = (0, $58ca0532e5af11ea$exports.formatAttrsForTag)(node.attrs, options), attrs = _a.attrs, className = _a.className, id = _a.id; | ||
var tag = ""; | ||
if (options.classesAtEnd) tag = [ | ||
$af5a31028cc763e0$var$getIndent(options), | ||
$d0384cb133070227$var$getIndent(options), | ||
node.name, | ||
id ? "#".concat(id) : "", | ||
$eea8bcf3ac89b5b4$exports.wrapAttrs($eea8bcf3ac89b5b4$exports.compileAttrs(attrs, options)), | ||
(0, $58ca0532e5af11ea$exports.wrapAttrs)((0, $58ca0532e5af11ea$exports.compileAttrs)(attrs, options)), | ||
className ? "." + className.split(" ").join(".") : "", | ||
].filter(Boolean).join(""); | ||
else tag = [ | ||
$af5a31028cc763e0$var$getIndent(options), | ||
$d0384cb133070227$var$getIndent(options), | ||
(id || className) && node.name === "div" ? "" : node.name, | ||
id ? "#".concat(id) : "", | ||
className ? "." + className.split(" ").join(".") : "", | ||
$eea8bcf3ac89b5b4$exports.wrapAttrs($eea8bcf3ac89b5b4$exports.compileAttrs(attrs, options)), | ||
(0, $58ca0532e5af11ea$exports.wrapAttrs)((0, $58ca0532e5af11ea$exports.compileAttrs)(attrs, options)), | ||
].filter(Boolean).join(""); | ||
var textNode = $af5a31028cc763e0$var$getFirstText(node.children); | ||
var textNode = $d0384cb133070227$var$getFirstText(node.children); | ||
if (!textNode) return tag; | ||
var resultText = textNode.value.includes("\n") ? "\n" + $af5a31028cc763e0$var$compileText(textNode, $af5a31028cc763e0$var$__assign($af5a31028cc763e0$var$__assign({ | ||
}, options), { | ||
var resultText = textNode.value.includes("\n") ? "\n" + $d0384cb133070227$var$compileText(textNode, $d0384cb133070227$var$__assign($d0384cb133070227$var$__assign({}, options), { | ||
level: options.level + 1 | ||
})) : " " + $af5a31028cc763e0$var$compileSingleLineText(textNode, options); | ||
})) : " " + $d0384cb133070227$var$compileSingleLineText(textNode, options); | ||
return "".concat(tag).concat(resultText); | ||
}; | ||
function $af5a31028cc763e0$export$85f0a661b59e6ae5(ast1, options) { | ||
function $d0384cb133070227$export$85f0a661b59e6ae5(ast1, options) { | ||
var deepCompile = function(ast, level) { | ||
if (level === void 0) level = 0; | ||
return ast.reduce(function(acc, node) { | ||
var newOptions = $af5a31028cc763e0$var$__assign({ | ||
var newOptions = $d0384cb133070227$var$__assign({ | ||
level: level | ||
}, options); | ||
switch(node.node){ | ||
case $820b09e697cfbfeb$export$85c928794f8d04d4.Doctype: | ||
return acc.concat($af5a31028cc763e0$var$compileDoctype(node, newOptions)); | ||
case $820b09e697cfbfeb$export$85c928794f8d04d4.Script: | ||
return acc.concat($af5a31028cc763e0$var$compileScript(node, newOptions)); | ||
case $820b09e697cfbfeb$export$85c928794f8d04d4.Style: | ||
return acc.concat($af5a31028cc763e0$var$compileStyle(node, newOptions)); | ||
case $820b09e697cfbfeb$export$85c928794f8d04d4.Text: | ||
return acc.concat($af5a31028cc763e0$var$compileText(node, newOptions)); | ||
case $820b09e697cfbfeb$export$85c928794f8d04d4.Comment: | ||
return acc.concat($af5a31028cc763e0$var$compileComment(node, newOptions)); | ||
case $820b09e697cfbfeb$export$85c928794f8d04d4.Tag: | ||
return acc.concat.apply(acc, $af5a31028cc763e0$var$__spreadArray([ | ||
$af5a31028cc763e0$var$compileTag(node, newOptions) | ||
], deepCompile($af5a31028cc763e0$var$getNodesWithoutText(node.children), level + 1), false)); | ||
case (0, $00a4bd21c189f400$export$85c928794f8d04d4).Doctype: | ||
return acc.concat($d0384cb133070227$var$compileDoctype(node, newOptions)); | ||
case (0, $00a4bd21c189f400$export$85c928794f8d04d4).Script: | ||
return acc.concat($d0384cb133070227$var$compileScript(node, newOptions)); | ||
case (0, $00a4bd21c189f400$export$85c928794f8d04d4).Style: | ||
return acc.concat($d0384cb133070227$var$compileStyle(node, newOptions)); | ||
case (0, $00a4bd21c189f400$export$85c928794f8d04d4).Text: | ||
return acc.concat($d0384cb133070227$var$compileText(node, newOptions)); | ||
case (0, $00a4bd21c189f400$export$85c928794f8d04d4).Comment: | ||
return acc.concat($d0384cb133070227$var$compileComment(node, newOptions)); | ||
case (0, $00a4bd21c189f400$export$85c928794f8d04d4).Tag: | ||
return acc.concat.apply(acc, $d0384cb133070227$var$__spreadArray([ | ||
$d0384cb133070227$var$compileTag(node, newOptions) | ||
], deepCompile($d0384cb133070227$var$getNodesWithoutText(node.children), level + 1), false)); | ||
default: | ||
@@ -284,21 +275,21 @@ return acc; | ||
var $32eb091b68757c9a$var$isTag = function(child) { | ||
var $d10d982ddf2a6e42$var$isTag = function(child) { | ||
return child.nodeType === "tag"; | ||
}; | ||
var $32eb091b68757c9a$var$isDoctype = function(child) { | ||
var $d10d982ddf2a6e42$var$isDoctype = function(child) { | ||
return child.nodeType === "doctype"; | ||
}; | ||
var $32eb091b68757c9a$var$isText = function(child) { | ||
var $d10d982ddf2a6e42$var$isText = function(child) { | ||
return child.nodeType === "text"; | ||
}; | ||
var $32eb091b68757c9a$var$isComment = function(child) { | ||
var $d10d982ddf2a6e42$var$isComment = function(child) { | ||
return child.nodeType === "comment"; | ||
}; | ||
var $32eb091b68757c9a$var$isScript = function(child) { | ||
var $d10d982ddf2a6e42$var$isScript = function(child) { | ||
return child.nodeType === "script"; | ||
}; | ||
var $32eb091b68757c9a$var$isStyle = function(child) { | ||
var $d10d982ddf2a6e42$var$isStyle = function(child) { | ||
return child.nodeType === "style"; | ||
}; | ||
var $32eb091b68757c9a$var$parseAttrs = function(attrs) { | ||
var $d10d982ddf2a6e42$var$parseAttrs = function(attrs) { | ||
if (attrs === void 0) attrs = []; | ||
@@ -316,40 +307,40 @@ return attrs.map(function(attr) { | ||
}; | ||
var $32eb091b68757c9a$var$parseText = function(child) { | ||
var $d10d982ddf2a6e42$var$parseText = function(child) { | ||
return child.content.value.content.trim() ? { | ||
node: $820b09e697cfbfeb$export$85c928794f8d04d4.Text, | ||
node: (0, $00a4bd21c189f400$export$85c928794f8d04d4).Text, | ||
value: child.content.value.content | ||
} : null; | ||
}; | ||
var $32eb091b68757c9a$var$parseComment = function(child) { | ||
var $d10d982ddf2a6e42$var$parseComment = function(child) { | ||
return { | ||
node: $820b09e697cfbfeb$export$85c928794f8d04d4.Comment, | ||
node: (0, $00a4bd21c189f400$export$85c928794f8d04d4).Comment, | ||
value: child.content.value.content | ||
}; | ||
}; | ||
var $32eb091b68757c9a$var$parseDoctype = function(child) { | ||
var $d10d982ddf2a6e42$var$parseDoctype = function(child) { | ||
return { | ||
node: $820b09e697cfbfeb$export$85c928794f8d04d4.Doctype, | ||
attrs: $32eb091b68757c9a$var$parseAttrs(child.content.attributes) | ||
node: (0, $00a4bd21c189f400$export$85c928794f8d04d4).Doctype, | ||
attrs: $d10d982ddf2a6e42$var$parseAttrs(child.content.attributes) | ||
}; | ||
}; | ||
var $32eb091b68757c9a$var$parseScript = function(child) { | ||
var $d10d982ddf2a6e42$var$parseScript = function(child) { | ||
var _a, _b; | ||
return { | ||
node: $820b09e697cfbfeb$export$85c928794f8d04d4.Script, | ||
attrs: $32eb091b68757c9a$var$parseAttrs(child.content.attributes), | ||
node: (0, $00a4bd21c189f400$export$85c928794f8d04d4).Script, | ||
attrs: $d10d982ddf2a6e42$var$parseAttrs(child.content.attributes), | ||
value: (_b = (_a = child.content.value) === null || _a === void 0 ? void 0 : _a.content) !== null && _b !== void 0 ? _b : "" | ||
}; | ||
}; | ||
var $32eb091b68757c9a$var$parseStyle = function(child) { | ||
var $d10d982ddf2a6e42$var$parseStyle = function(child) { | ||
var _a, _b; | ||
return { | ||
node: $820b09e697cfbfeb$export$85c928794f8d04d4.Style, | ||
attrs: $32eb091b68757c9a$var$parseAttrs(child.content.attributes), | ||
node: (0, $00a4bd21c189f400$export$85c928794f8d04d4).Style, | ||
attrs: $d10d982ddf2a6e42$var$parseAttrs(child.content.attributes), | ||
value: (_b = (_a = child.content.value) === null || _a === void 0 ? void 0 : _a.content) !== null && _b !== void 0 ? _b : "" | ||
}; | ||
}; | ||
var $32eb091b68757c9a$var$parseTag = function(child, children) { | ||
var $d10d982ddf2a6e42$var$parseTag = function(child, children) { | ||
return { | ||
node: $820b09e697cfbfeb$export$85c928794f8d04d4.Tag, | ||
attrs: $32eb091b68757c9a$var$parseAttrs(child.content.attributes), | ||
node: (0, $00a4bd21c189f400$export$85c928794f8d04d4).Tag, | ||
attrs: $d10d982ddf2a6e42$var$parseAttrs(child.content.attributes), | ||
name: child.content.name, | ||
@@ -359,17 +350,17 @@ children: children | ||
}; | ||
function $32eb091b68757c9a$export$538fc22499890e84(ast) { | ||
function $d10d982ddf2a6e42$export$538fc22499890e84(ast) { | ||
var deepConvert = function(children) { | ||
return children.reduce(function(acc, child) { | ||
var _a; | ||
if ($32eb091b68757c9a$var$isText(child)) { | ||
var textNode = $32eb091b68757c9a$var$parseText(child); | ||
if ($d10d982ddf2a6e42$var$isText(child)) { | ||
var textNode = $d10d982ddf2a6e42$var$parseText(child); | ||
return textNode ? acc.concat(textNode) : acc; | ||
} | ||
if ($32eb091b68757c9a$var$isComment(child)) return acc.concat($32eb091b68757c9a$var$parseComment(child)); | ||
if ($32eb091b68757c9a$var$isDoctype(child)) return acc.concat($32eb091b68757c9a$var$parseDoctype(child)); | ||
if ($32eb091b68757c9a$var$isScript(child)) return acc.concat($32eb091b68757c9a$var$parseScript(child)); | ||
if ($32eb091b68757c9a$var$isStyle(child)) return acc.concat($32eb091b68757c9a$var$parseStyle(child)); | ||
/* istanbul ignore else */ if ($32eb091b68757c9a$var$isTag(child)) { | ||
if ($d10d982ddf2a6e42$var$isComment(child)) return acc.concat($d10d982ddf2a6e42$var$parseComment(child)); | ||
if ($d10d982ddf2a6e42$var$isDoctype(child)) return acc.concat($d10d982ddf2a6e42$var$parseDoctype(child)); | ||
if ($d10d982ddf2a6e42$var$isScript(child)) return acc.concat($d10d982ddf2a6e42$var$parseScript(child)); | ||
if ($d10d982ddf2a6e42$var$isStyle(child)) return acc.concat($d10d982ddf2a6e42$var$parseStyle(child)); | ||
/* istanbul ignore else */ if ($d10d982ddf2a6e42$var$isTag(child)) { | ||
var children_1 = deepConvert((_a = child.content.children) !== null && _a !== void 0 ? _a : []); | ||
return acc.concat($32eb091b68757c9a$var$parseTag(child, children_1)); | ||
return acc.concat($d10d982ddf2a6e42$var$parseTag(child, children_1)); | ||
} | ||
@@ -382,4 +373,4 @@ /* istanbul ignore next */ return acc; | ||
} | ||
function $32eb091b68757c9a$export$16f39c815cb63b03(html) { | ||
return $32eb091b68757c9a$export$538fc22499890e84($blZUa$hyntaxlibconstructtree($blZUa$hyntaxlibtokenize(html).tokens).ast); | ||
function $d10d982ddf2a6e42$export$16f39c815cb63b03(html) { | ||
return $d10d982ddf2a6e42$export$538fc22499890e84((0, $kbbYs$hyntaxlibconstructtree)((0, $kbbYs$hyntaxlibtokenize)(html).tokens).ast); | ||
} | ||
@@ -390,3 +381,3 @@ | ||
var $ca7607610484658e$var$NodeTypes = { | ||
var $0bdb9fe31cc037ca$var$NodeTypes = { | ||
ELEMENT: 1, | ||
@@ -398,21 +389,21 @@ TEXT: 2, | ||
}; | ||
var $ca7607610484658e$var$isElement = function(child) { | ||
return child.type === $ca7607610484658e$var$NodeTypes.ELEMENT; | ||
var $0bdb9fe31cc037ca$var$isElement = function(child) { | ||
return child.type === $0bdb9fe31cc037ca$var$NodeTypes.ELEMENT; | ||
}; | ||
var $ca7607610484658e$var$isText = function(child) { | ||
return child.type === $ca7607610484658e$var$NodeTypes.TEXT; | ||
var $0bdb9fe31cc037ca$var$isText = function(child) { | ||
return child.type === $0bdb9fe31cc037ca$var$NodeTypes.TEXT; | ||
}; | ||
var $ca7607610484658e$var$isComment = function(child) { | ||
return child.type === $ca7607610484658e$var$NodeTypes.COMMENT; | ||
var $0bdb9fe31cc037ca$var$isComment = function(child) { | ||
return child.type === $0bdb9fe31cc037ca$var$NodeTypes.COMMENT; | ||
}; | ||
var $ca7607610484658e$var$isAttr = function(attr) { | ||
return attr.type === $ca7607610484658e$var$NodeTypes.ATTRIBUTE; | ||
var $0bdb9fe31cc037ca$var$isAttr = function(attr) { | ||
return attr.type === $0bdb9fe31cc037ca$var$NodeTypes.ATTRIBUTE; | ||
}; | ||
var $ca7607610484658e$var$isInterpolation = function(child) { | ||
return child.type === $ca7607610484658e$var$NodeTypes.INTERPOLATION; | ||
var $0bdb9fe31cc037ca$var$isInterpolation = function(child) { | ||
return child.type === $0bdb9fe31cc037ca$var$NodeTypes.INTERPOLATION; | ||
}; | ||
var $ca7607610484658e$export$e1a9355cfd8f6c64 = function(attrs) { | ||
var $0bdb9fe31cc037ca$export$e1a9355cfd8f6c64 = function(attrs) { | ||
return attrs.map(function(attr) { | ||
var _a; | ||
if ($ca7607610484658e$var$isAttr(attr)) return { | ||
if ($0bdb9fe31cc037ca$var$isAttr(attr)) return { | ||
key: attr.name, | ||
@@ -426,26 +417,26 @@ value: (_a = attr.value) === null || _a === void 0 ? void 0 : _a.content | ||
}; | ||
var $ca7607610484658e$export$ec3f164301cf7795 = function(child) { | ||
var $0bdb9fe31cc037ca$export$ec3f164301cf7795 = function(child) { | ||
return { | ||
node: $820b09e697cfbfeb$export$85c928794f8d04d4.Text, | ||
node: (0, $00a4bd21c189f400$export$85c928794f8d04d4).Text, | ||
value: child.content.trim() | ||
}; | ||
}; | ||
var $ca7607610484658e$export$c25837ef67955388 = function(child) { | ||
var $0bdb9fe31cc037ca$export$c25837ef67955388 = function(child) { | ||
return { | ||
node: $820b09e697cfbfeb$export$85c928794f8d04d4.Comment, | ||
node: (0, $00a4bd21c189f400$export$85c928794f8d04d4).Comment, | ||
value: child.content.trim() | ||
}; | ||
}; | ||
var $ca7607610484658e$export$99bca2eadc127ad2 = function(child, children) { | ||
var $0bdb9fe31cc037ca$export$99bca2eadc127ad2 = function(child, children) { | ||
return { | ||
node: $820b09e697cfbfeb$export$85c928794f8d04d4.Tag, | ||
node: (0, $00a4bd21c189f400$export$85c928794f8d04d4).Tag, | ||
name: child.tag, | ||
attrs: $ca7607610484658e$export$e1a9355cfd8f6c64(child.props), | ||
attrs: $0bdb9fe31cc037ca$export$e1a9355cfd8f6c64(child.props), | ||
children: children | ||
}; | ||
}; | ||
var $ca7607610484658e$var$parseScript = function(child) { | ||
var $0bdb9fe31cc037ca$var$parseScript = function(child) { | ||
return { | ||
node: $820b09e697cfbfeb$export$85c928794f8d04d4.Script, | ||
attrs: $ca7607610484658e$export$e1a9355cfd8f6c64(child.props), | ||
node: (0, $00a4bd21c189f400$export$85c928794f8d04d4).Script, | ||
attrs: $0bdb9fe31cc037ca$export$e1a9355cfd8f6c64(child.props), | ||
value: child.children.map(function(el) { | ||
@@ -456,6 +447,6 @@ return el.content; | ||
}; | ||
var $ca7607610484658e$var$parseStyle = function(child) { | ||
var $0bdb9fe31cc037ca$var$parseStyle = function(child) { | ||
return { | ||
node: $820b09e697cfbfeb$export$85c928794f8d04d4.Style, | ||
attrs: $ca7607610484658e$export$e1a9355cfd8f6c64(child.props), | ||
node: (0, $00a4bd21c189f400$export$85c928794f8d04d4).Style, | ||
attrs: $0bdb9fe31cc037ca$export$e1a9355cfd8f6c64(child.props), | ||
value: child.children.map(function(el) { | ||
@@ -466,19 +457,19 @@ return el.content; | ||
}; | ||
var $ca7607610484658e$var$parseInterpolation = function(child) { | ||
var $0bdb9fe31cc037ca$var$parseInterpolation = function(child) { | ||
return { | ||
node: $820b09e697cfbfeb$export$85c928794f8d04d4.Text, | ||
node: (0, $00a4bd21c189f400$export$85c928794f8d04d4).Text, | ||
value: child.loc.source | ||
}; | ||
}; | ||
function $ca7607610484658e$export$9f888db2af58a9f1(ast) { | ||
function $0bdb9fe31cc037ca$export$9f888db2af58a9f1(ast) { | ||
var deepConvert = function(children) { | ||
return children.reduce(function(acc, child) { | ||
if ($ca7607610484658e$var$isText(child)) return acc.concat($ca7607610484658e$export$ec3f164301cf7795(child)); | ||
if ($ca7607610484658e$var$isInterpolation(child)) return acc.concat($ca7607610484658e$var$parseInterpolation(child)); | ||
if ($ca7607610484658e$var$isComment(child)) return acc.concat($ca7607610484658e$export$c25837ef67955388(child)); | ||
if ($ca7607610484658e$var$isElement(child) && child.tag === "script") return acc.concat($ca7607610484658e$var$parseScript(child)); | ||
if ($ca7607610484658e$var$isElement(child) && child.tag === "style") return acc.concat($ca7607610484658e$var$parseStyle(child)); | ||
/* istanbul ignore else */ if ($ca7607610484658e$var$isElement(child)) { | ||
if ($0bdb9fe31cc037ca$var$isText(child)) return acc.concat($0bdb9fe31cc037ca$export$ec3f164301cf7795(child)); | ||
if ($0bdb9fe31cc037ca$var$isInterpolation(child)) return acc.concat($0bdb9fe31cc037ca$var$parseInterpolation(child)); | ||
if ($0bdb9fe31cc037ca$var$isComment(child)) return acc.concat($0bdb9fe31cc037ca$export$c25837ef67955388(child)); | ||
if ($0bdb9fe31cc037ca$var$isElement(child) && child.tag === "script") return acc.concat($0bdb9fe31cc037ca$var$parseScript(child)); | ||
if ($0bdb9fe31cc037ca$var$isElement(child) && child.tag === "style") return acc.concat($0bdb9fe31cc037ca$var$parseStyle(child)); | ||
/* istanbul ignore else */ if ($0bdb9fe31cc037ca$var$isElement(child)) { | ||
var children_1 = deepConvert(child.children); | ||
return acc.concat($ca7607610484658e$export$99bca2eadc127ad2(child, children_1)); | ||
return acc.concat($0bdb9fe31cc037ca$export$99bca2eadc127ad2(child, children_1)); | ||
} | ||
@@ -491,9 +482,9 @@ console.error(child); | ||
} | ||
function $ca7607610484658e$export$6803692198d357dd(html) { | ||
return $ca7607610484658e$export$9f888db2af58a9f1($blZUa$parse(html)); | ||
function $0bdb9fe31cc037ca$export$6803692198d357dd(html) { | ||
return $0bdb9fe31cc037ca$export$9f888db2af58a9f1((0, $kbbYs$parse)(html)); | ||
} | ||
var $f586152863514d65$var$__assign = undefined && undefined.__assign || function() { | ||
$f586152863514d65$var$__assign = Object.assign || function(t) { | ||
var $09a65d7ba376d391$var$__assign = undefined && undefined.__assign || function() { | ||
$09a65d7ba376d391$var$__assign = Object.assign || function(t) { | ||
for(var s, i = 1, n = arguments.length; i < n; i++){ | ||
@@ -505,7 +496,6 @@ s = arguments[i]; | ||
}; | ||
return $f586152863514d65$var$__assign.apply(this, arguments); | ||
return $09a65d7ba376d391$var$__assign.apply(this, arguments); | ||
}; | ||
var $f586152863514d65$var$__rest = undefined && undefined.__rest || function(s, e) { | ||
var t = { | ||
}; | ||
var $09a65d7ba376d391$var$__rest = undefined && undefined.__rest || function(s, e) { | ||
var t = {}; | ||
for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; | ||
@@ -517,7 +507,7 @@ if (s != null && typeof Object.getOwnPropertySymbols === "function") { | ||
}; | ||
var $f586152863514d65$var$setupDefaultOptions = function(_a) { | ||
var _b = _a.attrComma, attrComma = _b === void 0 ? true : _b, options = $f586152863514d65$var$__rest(_a, [ | ||
var $09a65d7ba376d391$var$setupDefaultOptions = function(_a) { | ||
var _b = _a.attrComma, attrComma = _b === void 0 ? true : _b, options = $09a65d7ba376d391$var$__rest(_a, [ | ||
"attrComma" | ||
]); | ||
return $f586152863514d65$var$__assign({ | ||
return $09a65d7ba376d391$var$__assign({ | ||
attrSep: attrComma ? ", " : " ", | ||
@@ -533,12 +523,11 @@ bodyLess: false, | ||
}; | ||
function $f586152863514d65$export$9c68d69a4c5bbcf9(html, options) { | ||
if (options === void 0) options = { | ||
}; | ||
var definedOptions = $f586152863514d65$var$setupDefaultOptions(options); | ||
var convertedAst = definedOptions.parser === "html" ? $32eb091b68757c9a$export$16f39c815cb63b03(html) : $ca7607610484658e$export$6803692198d357dd(html); | ||
return $af5a31028cc763e0$exports.compileAst(options.bodyLess ? convertedAst : $c1d9d56b4477109d$export$15f1e0b2d8c15007(convertedAst), definedOptions); | ||
function $09a65d7ba376d391$export$9c68d69a4c5bbcf9(html, options) { | ||
if (options === void 0) options = {}; | ||
var definedOptions = $09a65d7ba376d391$var$setupDefaultOptions(options); | ||
var convertedAst = definedOptions.parser === "html" ? (0, $d10d982ddf2a6e42$export$16f39c815cb63b03)(html) : (0, $0bdb9fe31cc037ca$export$6803692198d357dd)(html); | ||
return (0, $d0384cb133070227$exports.compileAst)(options.bodyLess ? convertedAst : (0, $8094157b9d54973a$export$15f1e0b2d8c15007)(convertedAst), definedOptions); | ||
} | ||
export {$f586152863514d65$export$9c68d69a4c5bbcf9 as convert, $f586152863514d65$exports as default}; | ||
export {$09a65d7ba376d391$export$9c68d69a4c5bbcf9 as convert, $09a65d7ba376d391$exports as default}; | ||
//# sourceMappingURL=module.js.map |
interface PublicOptions { | ||
/** Don't wrap into html > body */ | ||
bodyLess: boolean; | ||
/** Commas in attributes */ | ||
attrComma: boolean; | ||
/** Encode html characters */ | ||
encode: boolean; | ||
/** Use double quotes for attributes */ | ||
doubleQuotes: boolean; | ||
/** Place all classes in class attribute */ | ||
inlineCSS: boolean; | ||
/** Symbol for indents, can be anything */ | ||
symbol: string; | ||
/** Html for any standard html, vue for any vue-like html */ | ||
parser: "html" | "vue"; | ||
/** Place all classes after attributes */ | ||
classesAtEnd: boolean; | ||
@@ -10,0 +18,0 @@ } |
{ | ||
"name": "xhtml2pug", | ||
"version": "3.2.1", | ||
"version": "4.0.1", | ||
"description": "library for convert html2pug", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -70,3 +70,3 @@ # xhtml2pug | ||
const html = '<header><h1 class="title">Hello World!</h1></header>'; | ||
const pug = html2pug(html, { tabs: true }); | ||
const pug = convert(html, { symbol: '\t' }); | ||
``` | ||
@@ -78,6 +78,6 @@ | ||
-b, --bodyLess Don't wrap into html > body | ||
[boolean] [required] [default: false] | ||
[boolean] [default: false] | ||
-t, --tabs Use tabs as indent [boolean] [default: false] | ||
-s, --spaces Number of spaces for indent [number] [default: 2] | ||
-a, --attrComma Commas in attributes [boolean] [required] [default: false] | ||
-a, --attrComma Commas in attributes [boolean] [default: false] | ||
-e, --encode Encode html characters [boolean] [default: true] | ||
@@ -84,0 +84,0 @@ -q, --doubleQuotes Use double quotes for attributes[boolean] [default: false] |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
125019
987