Skip to content

Commit

Permalink
Abandon the Shikiji patch approach
Browse files Browse the repository at this point in the history
`npm` does not support the `patch` protocol, so we lost the ability to
`npm install -g neogrok`. Just do the aforementioned janky integration
with the shikiji APIs as they exist today.
  • Loading branch information
isker committed Jan 15, 2024
1 parent 7792271 commit 05cdf97
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 84 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-bulldogs-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"neogrok": patch
---

Fix ability to `npm install -g neogrok`
49 changes: 0 additions & 49 deletions .yarn/patches/shikiji-core-npm-0.9.18-826293a3df.patch

This file was deleted.

13 changes: 0 additions & 13 deletions .yarn/patches/shikiji-npm-0.9.18-945ea5efcb.patch

This file was deleted.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"lucide-svelte": "0.303.0",
"pretty-bytes": "6.1.1",
"prom-client": "15.0.0",
"shikiji": "patch:shikiji@npm%3A0.9.18#~/.yarn/patches/shikiji-npm-0.9.18-945ea5efcb.patch"
"shikiji": "0.9.18"
},
"engines": {
"node": ">=20"
Expand Down Expand Up @@ -107,7 +107,6 @@
"typed-array-length": "npm:@nolyfill/typed-array-length@latest",
"unbox-primitive": "npm:@nolyfill/unbox-primitive@latest",
"which-boxed-primitive": "npm:@nolyfill/which-boxed-primitive@latest",
"which-typed-array": "npm:@nolyfill/which-typed-array@latest",
"shikiji-core@npm:0.9.18": "patch:shikiji-core@npm%3A0.9.18#~/.yarn/patches/shikiji-core-npm-0.9.18-826293a3df.patch"
"which-typed-array": "npm:@nolyfill/which-typed-array@latest"
}
}
4 changes: 3 additions & 1 deletion src/routes/(search-page)/line-group.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@
if (!canceled) {
highlights.set(
await codeToThemedTokens(
lines.map(({ line: { text } }) => text),
// Shikiji only accepts a single string even though it goes right
// ahead and splits it :(.
lines.map(({ line: { text } }) => text).join("\n"),
{
theme: "github-light",
lang,
Expand Down
7 changes: 6 additions & 1 deletion src/routes/(search-page)/rendered-content.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@
const matchRangeIterator = content.matchRanges[Symbol.iterator]();
let currentMatchRange: Range | undefined =
matchRangeIterator.next().value;
for (const { start, end, fontStyle, color } of highlights) {
let start = 0;
for (const { content: highlightText, fontStyle, color } of highlights) {
const end = start + highlightText.length;
const fontClass = toFontClass(fontStyle);
let base = start;
Expand Down Expand Up @@ -94,6 +97,8 @@
color,
});
}
start = end;
}
} else {
let base = 0;
Expand Down
18 changes: 1 addition & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3580,7 +3580,7 @@ __metadata:
prettier-plugin-svelte: "npm:3.0.3"
pretty-bytes: "npm:6.1.1"
prom-client: "npm:15.0.0"
shikiji: "patch:shikiji@npm%3A0.9.18#~/.yarn/patches/shikiji-npm-0.9.18-945ea5efcb.patch"
shikiji: "npm:0.9.18"
svelte: "npm:4.2.1"
svelte-check: "npm:3.5.2"
tailwindcss: "npm:3.3.3"
Expand Down Expand Up @@ -4510,13 +4510,6 @@ __metadata:
languageName: node
linkType: hard

"shikiji-core@patch:shikiji-core@npm%3A0.9.18#~/.yarn/patches/shikiji-core-npm-0.9.18-826293a3df.patch":
version: 0.9.18
resolution: "shikiji-core@patch:shikiji-core@npm%3A0.9.18#~/.yarn/patches/shikiji-core-npm-0.9.18-826293a3df.patch::version=0.9.18&hash=6968ed"
checksum: ace21e92feb3bfe58d126d95fd876b729184dbf57bf1e0cf3f96f7c71840754ed227649328e2301bcb47730e6875c4915e109599db5ed5d7f28557a3bd82b4c5
languageName: node
linkType: hard

"shikiji@npm:0.9.18":
version: 0.9.18
resolution: "shikiji@npm:0.9.18"
Expand All @@ -4526,15 +4519,6 @@ __metadata:
languageName: node
linkType: hard

"shikiji@patch:shikiji@npm%3A0.9.18#~/.yarn/patches/shikiji-npm-0.9.18-945ea5efcb.patch":
version: 0.9.18
resolution: "shikiji@patch:shikiji@npm%3A0.9.18#~/.yarn/patches/shikiji-npm-0.9.18-945ea5efcb.patch::version=0.9.18&hash=43ddf9"
dependencies:
shikiji-core: "npm:0.9.18"
checksum: b397c3bef535e66c64c73785143e4ce9e6faca083966b0ade618063e88fa27ed025531e78aaa7712ad5c776a97130a0e6603c77fadeeebde5ba078dfb7d9cfc3
languageName: node
linkType: hard

"siginfo@npm:^2.0.0":
version: 2.0.0
resolution: "siginfo@npm:2.0.0"
Expand Down

0 comments on commit 05cdf97

Please sign in to comment.