|
1 | 1 | import { createJavaScriptRegexEngine } from 'shiki' |
2 | 2 | import { describe, expect, it } from 'vitest' |
3 | | -import { codeToHtml, codeToTokens, codeToTokensBase, createShikiPrimitiveAsync } from '../src' |
| 3 | +import { codeToHtml, codeToTokens, codeToTokensBase, createShikiPrimitiveAsync, splitTokens } from '../src' |
| 4 | + |
| 5 | +describe('splitTokens', () => { |
| 6 | + it('splits at contained breakpoints while preserving token order and fields', () => { |
| 7 | + const tokens = [[ |
| 8 | + { content: 'wxyz', marker: 'later', offset: 10 }, |
| 9 | + { content: 'abcd', marker: 'earlier', offset: 0 }, |
| 10 | + ]] |
| 11 | + |
| 12 | + expect(splitTokens(tokens, [14, 2, 13, 11, 10, 4, 0, 2])).toEqual([[ |
| 13 | + { content: 'w', marker: 'later', offset: 10 }, |
| 14 | + { content: 'xy', marker: 'later', offset: 11 }, |
| 15 | + { content: 'z', marker: 'later', offset: 13 }, |
| 16 | + { content: 'ab', marker: 'earlier', offset: 0 }, |
| 17 | + { content: 'cd', marker: 'earlier', offset: 2 }, |
| 18 | + ]]) |
| 19 | + }) |
| 20 | +}) |
4 | 21 |
|
5 | 22 | it('includeExplanation', async () => { |
6 | 23 | using engine = await createShikiPrimitiveAsync({ |
|
0 commit comments