Skip to content

Commit e2b46f0

Browse files
authored
Patch gatsby-remark-shiki-twoslash to add in tabindex (#3257)
1 parent ad02d26 commit e2b46f0

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
},
4646
"patchedDependencies": {
4747
"[email protected]": "patches/react-server-dom-webpack@0.0.0-experimental-c8b778b7f-20220825.patch",
48-
48+
49+
4950
}
5051
},
5152
"jest": {

patches/[email protected]

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
diff --git a/CHANGELOG.md b/CHANGELOG.md
2+
deleted file mode 100644
3+
index 6036d987fc2889ec9bc230f7774013ae4f736dd9..0000000000000000000000000000000000000000
4+
diff --git a/src/index.js b/src/index.js
5+
index e16676ef50b660d520a0efc0b73b68411db349af..bb21bc500a34ac31063774ba4ba133daed2c4f14 100755
6+
--- a/src/index.js
7+
+++ b/src/index.js
8+
@@ -4,7 +4,15 @@ const { setupForFile, remarkVisitor } = require("remark-shiki-twoslash")
9+
10+
const remarkShiki = async function ({ markdownAST }, userConfig) {
11+
const {settings, highlighters} = await setupForFile(userConfig)
12+
- visit(markdownAST, "code", remarkVisitor(highlighters, settings))
13+
+ const orig = remarkVisitor(highlighters, settings)
14+
+ /** @type {typeof orig} */
15+
+ const visitor = (node) => {
16+
+ orig(node)
17+
+ // Hack to make shiki twoslash code blocks focusable; not needed in modern shiki but we're using an old version
18+
+ node.value = node.value.replace(/(class='code-container')/g, "$1 tabindex='0'")
19+
+ }
20+
+ visit(markdownAST, "code", visitor);
21+
}
22+
23+
module.exports = remarkShiki
24+
+

pnpm-lock.yaml

+5-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)