-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: replace prism with starry night #67
Conversation
@kt3k PTAL. One small note, this PR currently uses the |
I'm not convinced starry-night is stable/reliable enough. It's very new (1 year old) and it has very much smaller number of downloads in npm compared to prismjs. https://npmtrends.com/@wooorm/starry-night-vs-prismjs Also it doesn't seem solving any specific problem currently we have. I feel we don't have enough motivation to switch to starry-night at this point |
@kt3k it does solve a few problems we currently have (but one could argue that they aren't big enough to worry about):
Additionally, as @kidonng correctly points out, it's by the same author as remark (which is the library we will hopefully be moving over to). Unless we want to hack prism support into remark, we will be switching to starry night in the future regardless of our decision on this PR. I'm not married to the idea of using starry night, and I would be more than willing to accept that Prism is all that is in the scope of the project, but that's more of a discussion of #57. |
The same author also maintains 2 other syntax highlighters: refractor and lowlight The author says starry-night is slower than other 2 (wooorm/starry-night#20 (comment)). That sounds concerning to me because we highlight source code on the fly |
Would you prefer if we switched to one of the other two? I'd have no qualms with it. |
I think we should have performance benchmarks anyways, I'll bench this over the current implementation in main. We should not merge regardless until we see what that looks like. |
Fair benchmark is being blocked by: esm-dev/esm.sh#627 but from my initial testing it seems to be ~10x slower than Prism which is slower but also not unreasonably slow. We have a few options here:
I think any of these are reasonable and can be argued. Any specific opinions? |
I created this benchmark to test highlighting a large file. import {
all,
createStarryNight,
} from "https://esm.sh/@wooorm/[email protected]";
import { default as Prism } from "https://esm.sh/[email protected]";
import "https://esm.sh/[email protected]/components/prism-typescript";
Deno.bench("no-op", ()=>{})
const code = await (await fetch("https://esm.sh/v127/[email protected]/es2022/vscode-textmate.mjs")).text()
const starryNight = await createStarryNight(all);
Deno.bench("starry-night", () => {
const scope = starryNight.flagToScope("ts")!;
starryNight.highlight(code, scope);
})
Deno.bench("prism", () => {
Prism.highlight(code, Prism.languages["ts"], "ts");
}) |
Thanks for measuring! this kind of information is very helpful |
Closes #60 and #56.