Skip to content

Commit 5dab5e3

Browse files
committed
refactor: simplify line filling a bit
1 parent 862549d commit 5dab5e3

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

Diff for: src/node/markdown/plugins/highlight.ts

+14-18
Original file line numberDiff line numberDiff line change
@@ -162,24 +162,20 @@ export async function highlight(
162162
},
163163
{
164164
name: 'vitepress:empty-line',
165-
pre(hast) {
166-
hast.children.forEach((code) => {
167-
if (code.type === 'element' && code.tagName === 'code') {
168-
code.children.forEach((span) => {
169-
if (
170-
span.type === 'element' &&
171-
span.tagName === 'span' &&
172-
Array.isArray(span.properties.class) &&
173-
span.properties.class.includes('line') &&
174-
span.children.length === 0
175-
) {
176-
span.children.push({
177-
type: 'element',
178-
tagName: 'wbr',
179-
properties: {},
180-
children: []
181-
})
182-
}
165+
code(hast) {
166+
hast.children.forEach((span) => {
167+
if (
168+
span.type === 'element' &&
169+
span.tagName === 'span' &&
170+
Array.isArray(span.properties.class) &&
171+
span.properties.class.includes('line') &&
172+
span.children.length === 0
173+
) {
174+
span.children.push({
175+
type: 'element',
176+
tagName: 'wbr',
177+
properties: {},
178+
children: []
183179
})
184180
}
185181
})

0 commit comments

Comments
 (0)