chore: clean up

pull/3237/head
Anthony Fu 2 years ago
parent f833849fa6
commit 364fba02a4

@ -163,19 +163,19 @@ describe('Line Numbers', () => {
describe('Import Code Snippets', () => { describe('Import Code Snippets', () => {
test('basic', async () => { test('basic', async () => {
const lines = page.locator('#basic-code-snippet + div code > span') const lines = page.locator('#basic-code-snippet + div code > span')
expect(await lines.count()).toBe(22) expect(await lines.count()).toBe(11)
}) })
test('specify region', async () => { test('specify region', async () => {
const lines = page.locator('#specify-region + div code > span') const lines = page.locator('#specify-region + div code > span')
expect(await lines.count()).toBe(6) expect(await lines.count()).toBe(3)
}) })
test('with other features', async () => { test('with other features', async () => {
const div = page.locator('#with-other-features + div') const div = page.locator('#with-other-features + div')
expect(await getClassList(div)).toContain('line-numbers-mode') expect(await getClassList(div)).toContain('line-numbers-mode')
const lines = div.locator('code > span') const lines = div.locator('code > span')
expect(await lines.count()).toBe(6) expect(await lines.count()).toBe(3)
expect(await getClassList(lines.nth(0))).toContain('highlighted') expect(await getClassList(lines.nth(0))).toContain('highlighted')
}) })
}) })
@ -216,10 +216,10 @@ describe('Code Groups', () => {
// blocks // blocks
const blocks = div.locator('.blocks > div') const blocks = div.locator('.blocks > div')
expect(await blocks.nth(0).locator('code > span').count()).toBe(22) expect(await blocks.nth(0).locator('code > span').count()).toBe(11)
expect(await getClassList(blocks.nth(1))).toContain('line-numbers-mode') expect(await getClassList(blocks.nth(1))).toContain('line-numbers-mode')
expect(await getClassList(blocks.nth(1))).toContain('language-ts') expect(await getClassList(blocks.nth(1))).toContain('language-ts')
expect(await blocks.nth(1).locator('code > span').count()).toBe(6) expect(await blocks.nth(1).locator('code > span').count()).toBe(1)
expect( expect(
await getClassList(blocks.nth(1).locator('code > span').nth(0)) await getClassList(blocks.nth(1).locator('code > span').nth(0))
).toContain('highlighted') ).toContain('highlighted')

@ -66,14 +66,19 @@ export async function highlight(
langs: languages?.length ? languages : Object.keys(bundledLanguages) langs: languages?.length ? languages : Object.keys(bundledLanguages)
}) })
const transformers = [ const transformers: ShikijiTransformer[] = [
transformerNotationDiff(), transformerNotationDiff(),
transformerNotationFocus({ transformerNotationFocus({
classFocused: 'has-focus', classFocused: 'has-focus',
classRootActive: 'has-focused-lines' classRootActive: 'has-focused-lines'
}), }),
transformerNotationHighlight(), transformerNotationHighlight(),
transformerNotationErrorLevel() transformerNotationErrorLevel(),
{
pre(node) {
node.properties.class = 'vp-code shiki'
}
},
] ]
const styleRE = /<pre[^>]*(style=".*?")/ const styleRE = /<pre[^>]*(style=".*?")/
@ -152,11 +157,6 @@ export async function highlight(
transformers: [ transformers: [
...transformers, ...transformers,
transformerCompactLineOptions(lineOptions), transformerCompactLineOptions(lineOptions),
{
pre(node) {
node.properties.class = 'vp-code'
}
},
...userTransformers ...userTransformers
], ],
...(typeof theme === 'string' || 'name' in theme ...(typeof theme === 'string' || 'name' in theme

Loading…
Cancel
Save