Commit 236b3e2
fix(core): detect showLineNumbers anywhere in the meta string
`showLineNumbers` was detected with a reversed-string regex:
/srebmuNeniLwohs(?!(.*)(\/))/.test(reverseString(meta))
The negative lookahead was meant to ignore `/showLineNumbers/` used as a
highlight word, but it actually rejected `showLineNumbers` whenever any
`/` appeared before it in the meta. Since highlight tokens such as
`/age/#v` contain slashes, `showLineNumbers` placed after them was
silently ignored — so it only worked at the start of the meta string.
Replace the reverse-string hack with a token-boundary match that is
position-independent and captures the optional start-at number directly:
meta.match(/(?:^|\s)showLineNumbers(?:\{(\d+)\})?(?=\s|$)/)
Bounding on whitespace/string-ends still excludes `/showLineNumbers/`
(slash-delimited), so the highlight-word cases keep working. The
`reverseString` import is now unused in this module and removed.
Added a fixture covering `showLineNumbers` (and `showLineNumbers{N}`)
after highlight tokens; all existing snapshots are unchanged.
Closes #204
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent ad648c5 commit 236b3e2
3 files changed
Lines changed: 111 additions & 12 deletions
File tree
- packages/core
- src
- test
- fixtures
- results
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| |||
427 | 426 | | |
428 | 427 | | |
429 | 428 | | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
430 | 437 | | |
431 | 438 | | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
| 439 | + | |
436 | 440 | | |
437 | 441 | | |
438 | 442 | | |
439 | 443 | | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
| 444 | + | |
444 | 445 | | |
445 | | - | |
446 | | - | |
447 | | - | |
| 446 | + | |
448 | 447 | | |
449 | 448 | | |
450 | 449 | | |
| |||
Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 81 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments