-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
52 additions
and
241 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/markdown-remark': minor | ||
--- | ||
|
||
Export remarkShiki and remarkPrism plugins |
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,5 @@ | ||
--- | ||
'@astrojs/mdx': patch | ||
--- | ||
|
||
Use exported remarkShiki and remarkPrism plugins from `@astrojs/markdown-remark` |
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,31 +1,19 @@ | ||
import { runHighlighterWithAstro } from '@astrojs/prism/dist/highlighter'; | ||
import { visit } from 'unist-util-visit'; | ||
import type { RemarkPlugin } from './types.js'; | ||
|
||
type MaybeString = string | null | undefined; | ||
|
||
/** */ | ||
function transformer(className: MaybeString) { | ||
export function remarkPrism(): ReturnType<RemarkPlugin> { | ||
return function (tree: any) { | ||
const visitor = (node: any) => { | ||
visit(tree, 'code', (node) => { | ||
let { lang, value } = node; | ||
node.type = 'html'; | ||
|
||
let { html, classLanguage } = runHighlighterWithAstro(lang, value); | ||
let classes = [classLanguage]; | ||
if (className) { | ||
classes.push(className); | ||
} | ||
node.value = `<pre class="${classes.join( | ||
' ' | ||
)}"><code is:raw class="${classLanguage}">${html}</code></pre>`; | ||
return node; | ||
}; | ||
return visit(tree, 'code', visitor); | ||
}); | ||
}; | ||
} | ||
|
||
function plugin(className: MaybeString) { | ||
return transformer.bind(null, className); | ||
} | ||
|
||
export default plugin; |
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.