refactor: simplify line filling a bit

pull/3439/head
Divyansh Singh 11 months ago
parent 862549d068
commit 5dab5e3ced

@ -162,24 +162,20 @@ export async function highlight(
}, },
{ {
name: 'vitepress:empty-line', name: 'vitepress:empty-line',
pre(hast) { code(hast) {
hast.children.forEach((code) => { hast.children.forEach((span) => {
if (code.type === 'element' && code.tagName === 'code') { if (
code.children.forEach((span) => { span.type === 'element' &&
if ( span.tagName === 'span' &&
span.type === 'element' && Array.isArray(span.properties.class) &&
span.tagName === 'span' && span.properties.class.includes('line') &&
Array.isArray(span.properties.class) && span.children.length === 0
span.properties.class.includes('line') && ) {
span.children.length === 0 span.children.push({
) { type: 'element',
span.children.push({ tagName: 'wbr',
type: 'element', properties: {},
tagName: 'wbr', children: []
properties: {},
children: []
})
}
}) })
} }
}) })

Loading…
Cancel
Save