-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch gatsby-remark-shiki-twoslash to add in tabindex (#3257)
- Loading branch information
1 parent
ad02d26
commit e2b46f0
Showing
3 changed files
with
31 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,8 @@ | |
}, | ||
"patchedDependencies": { | ||
"[email protected]": "patches/react-server-dom-webpack@0.0.0-experimental-c8b778b7f-20220825.patch", | ||
"[email protected]": "patches/[email protected]" | ||
"[email protected]": "patches/[email protected]", | ||
"[email protected]": "patches/[email protected]" | ||
} | ||
}, | ||
"jest": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
diff --git a/CHANGELOG.md b/CHANGELOG.md | ||
deleted file mode 100644 | ||
index 6036d987fc2889ec9bc230f7774013ae4f736dd9..0000000000000000000000000000000000000000 | ||
diff --git a/src/index.js b/src/index.js | ||
index e16676ef50b660d520a0efc0b73b68411db349af..bb21bc500a34ac31063774ba4ba133daed2c4f14 100755 | ||
--- a/src/index.js | ||
+++ b/src/index.js | ||
@@ -4,7 +4,15 @@ const { setupForFile, remarkVisitor } = require("remark-shiki-twoslash") | ||
|
||
const remarkShiki = async function ({ markdownAST }, userConfig) { | ||
const {settings, highlighters} = await setupForFile(userConfig) | ||
- visit(markdownAST, "code", remarkVisitor(highlighters, settings)) | ||
+ const orig = remarkVisitor(highlighters, settings) | ||
+ /** @type {typeof orig} */ | ||
+ const visitor = (node) => { | ||
+ orig(node) | ||
+ // Hack to make shiki twoslash code blocks focusable; not needed in modern shiki but we're using an old version | ||
+ node.value = node.value.replace(/(class='code-container')/g, "$1 tabindex='0'") | ||
+ } | ||
+ visit(markdownAST, "code", visitor); | ||
} | ||
|
||
module.exports = remarkShiki | ||
+ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.