@@ -20,6 +20,7 @@ export type UseRemarkOptions = {
2020
2121export const useRemark = ( {
2222 onError = ( ) => { } ,
23+ // rehypePlugins = [[rehypeMermaid, { strategy: "inline-svg" }]],
2324 rehypePlugins = [ ] ,
2425 rehypeReactOptions,
2526 remarkParseOptions,
@@ -31,7 +32,7 @@ export const useRemark = ({
3132 reactContent : ReactElement | null ,
3233 metadata : SlideMetadata | null ,
3334 } > ,
34- setMarkdown : ( source : string , customPlugins ?: PluggableList ) => void ,
35+ setMarkdown : ( source : string , customPlugins ?: PluggableList , isDark ?: boolean ) => void ,
3536 getMarkdown : ( contents : string ) => string ,
3637 getFrontMatter : ( contents : string ) => string ,
3738 matter : null | SlideMetadata ,
@@ -44,27 +45,28 @@ export const useRemark = ({
4445 *
4546 * @param source - The Markdown source string to process.
4647 * @param customPlugins - An optional list of custom plugins to extend the processing pipeline.
48+ * @param isDark - A boolean indicating if the dark mode is enabled.
4749 * @returns An object containing:
4850 * - `reactContent`: The processed React element representation of the Markdown content.
4951 * - `metadata`: Extracted frontmatter metadata from the Markdown file, if available.
5052 *
5153 * @throws Will call the `onError` handler if an error occurs during processing.
5254 */
53- const processMarkdown = async ( source : string , customPlugins ?: PluggableList ) : Promise < {
55+ const processMarkdown = async ( source : string , customPlugins ?: PluggableList , isDark ?: boolean ) : Promise < {
5456 reactContent : ReactElement | null ,
5557 metadata : SlideMetadata | null ,
5658 } > => {
5759 try {
58- const vfile = await transformMarkdown ( source , remarkParseOptions , remarRehypeOptions , remarkPlugins , [ ...rehypePlugins , ...( customPlugins || [ ] ) ] , rehypeReactOptions ) ;
60+ const vfile = await transformMarkdown ( source , remarkParseOptions , remarRehypeOptions , remarkPlugins , [ ...rehypePlugins , ...( customPlugins || [ ] ) ] , rehypeReactOptions , { isWebComponent : true , isDark } ) ;
5961 return vfile ;
6062 } catch ( err ) {
6163 onError ( err as Error ) ;
6264 return { reactContent : null , metadata : null } ;
6365 }
6466 } ;
6567
66- const setMarkdownSource = useCallback ( ( source : string , customPlugins ?: PluggableList ) => {
67- processMarkdown ( source , customPlugins ) . then ( ( { reactContent, metadata } ) => {
68+ const setMarkdownSource = useCallback ( ( source : string , customPlugins ?: PluggableList , isDark ?: boolean ) => {
69+ processMarkdown ( source , customPlugins , isDark ) . then ( ( { reactContent, metadata } ) => {
6870 setReactContent ( reactContent ) ;
6971 setMetadata ( metadata ) ;
7072 } ) ;
0 commit comments