wip: pre tag handling

This commit is contained in:
Evan You 2023-11-15 23:55:50 +08:00
parent 5762288bdf
commit 1a1f680536
1 changed files with 9 additions and 3 deletions

View File

@ -274,10 +274,13 @@ function emitOpenTag(name: string, start: number) {
function endOpenTag(end: number) {
addNode(currentElement!)
const name = currentElement!.tag
if (!currentOptions.isVoidTag(name)) {
stack.unshift(currentElement!)
} else {
if (currentOptions.isPreTag(name)) {
inPre++
}
if (currentOptions.isVoidTag(name)) {
onCloseTag(currentElement!, end)
} else {
stack.unshift(currentElement!)
}
currentElement = null
}
@ -319,6 +322,9 @@ function onCloseTag(el: ElementNode, end: number) {
el.loc.end = tokenizer.getPos(end + offset + 1)
// whitepsace management
el.children = condenseWhitespace(el.children)
if (currentOptions.isPreTag(el.tag)) {
inPre--
}
}
const windowsNewlineRE = /\r\n/g