diff --git a/src/parse.js b/src/parse.js index 8caaf64..d8ea651 100644 --- a/src/parse.js +++ b/src/parse.js @@ -24,7 +24,23 @@ export default function parse(html, options) { }) } - html.replace(tagRE, function (tag, index) { + const matches = Array.from(html.matchAll(tagRE)) + matches.forEach(function (match, i) { + const tag = match[0] + if (!tag) return console.log({ html, matches }) + const amountOfLts = tag.split('<').length + const amountOfGts = tag.split('>').length + if (amountOfLts > 0 && amountOfLts > amountOfGts) { + const firstPart = tag.substring(0, tag.indexOf('<', tag.indexOf('<') + 1)) + const secondPart = tag.substring(firstPart.length) + matches[i][0] = secondPart + matches[i].index += firstPart.length + } + }) + matches.forEach(function (match, i) { + const tag = match[0] + if (!tag) return + const index = match.index if (inComponent) { if (tag !== '') { return @@ -36,6 +52,13 @@ export default function parse(html, options) { const isComment = tag.startsWith('