shikijs / twoslash

You take some Shiki, add a hint of TypeScript compiler, and 🎉 incredible static code samples
https://shikijs.github.io/twoslash/
MIT License
1.06k stars 51 forks source link

Twoslash will be incorrectly run on certain scenarios #77

Closed frencojobs closed 3 years ago

frencojobs commented 3 years ago

This part is problematic because it will assume ```ts title="twoslash" as twoslash code. Just leaving it up this issue as a reminder, this will be fixed together with the parseCodeFenceInfo refactor.

frencojobs commented 3 years ago

I wrote a much more expressive parser from scratch with properly defined grammar rules plus tests and permutations of tests. Then I felt it was a bit out of scope with twoslash and could be reused in other libraries as well. So I separated it as a different project and published it out as fenceparser. Unlike the current parseCodeFenceInfo, it returns a ~Map~(now returns a Record) so there's a few APIs (not public ones) that needs to be changed. If I have time today, I'll use it and refactor twoslash with it. Or maybe tomorrow.

orta commented 3 years ago

Clever, looks good 👍🏻