diff options
Diffstat (limited to 'util/processOrg.tsx')
-rw-r--r-- | util/processOrg.tsx | 75 |
1 files changed, 42 insertions, 33 deletions
diff --git a/util/processOrg.tsx b/util/processOrg.tsx index 26d9377..ef75acf 100644 --- a/util/processOrg.tsx +++ b/util/processOrg.tsx @@ -119,41 +119,50 @@ export const ProcessedOrg = (props: ProcessedOrgProps) => { const processor = useMemo( () => - baseProcessor.use(katex).use(rehype2react, { - createElement: React.createElement, - // eslint-disable-next-line react/display-name - components: { - a: ({ children, href }) => { - return ( - <PreviewLink - nodeByCite={nodeByCite} - setSidebarHighlightedNode={setSidebarHighlightedNode} - href={`${href as string}`} - nodeById={nodeById} - linksByNodeId={linksByNodeId} - setPreviewNode={setPreviewNode} - openContextMenu={openContextMenu} - outline={outline} - previewNode={previewNode} - isWiki={isMarkdown} - > - {children} - </PreviewLink> - ) - }, - img: ({ src }) => { - return <OrgImage src={src as string} file={previewNode?.file} /> + baseProcessor + .use(katex, { + trust: (context) => ['\\htmlId', '\\href'].includes(context.command), + macros: { + '\\eqref': '\\href{###1}{(\\text{#1})}', + '\\ref': '\\href{###1}{\\text{#1}}', + '\\label': '\\htmlId{#1}{}', }, - section: ({ children, className }) => ( - <Section {...{ outline, collapse }} className={className as string}> - {children} - </Section> - ), - p: ({ children }) => { - return <p lang="en">{children as ReactNode}</p> + }) + .use(rehype2react, { + createElement: React.createElement, + // eslint-disable-next-line react/display-name + components: { + a: ({ children, href }) => { + return ( + <PreviewLink + nodeByCite={nodeByCite} + setSidebarHighlightedNode={setSidebarHighlightedNode} + href={`${href as string}`} + nodeById={nodeById} + linksByNodeId={linksByNodeId} + setPreviewNode={setPreviewNode} + openContextMenu={openContextMenu} + outline={outline} + previewNode={previewNode} + isWiki={isMarkdown} + > + {children} + </PreviewLink> + ) + }, + img: ({ src }) => { + return <OrgImage src={src as string} file={previewNode?.file} /> + }, + section: ({ children, className }) => ( + <Section {...{ outline, collapse }} className={className as string}> + {children} + </Section> + ), + p: ({ children }) => { + return <p lang="en">{children as ReactNode}</p> + }, }, - }, - }), + }), [previewNode?.id], ) |