-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from malikpiara/latex
Implemented Latex rendering with Katex
- Loading branch information
Showing
6 changed files
with
371 additions
and
314 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,24 @@ | ||
'use client'; | ||
import renderMathInElement from 'katex/dist/contrib/auto-render'; | ||
import 'katex/dist/katex.min.css'; | ||
import { useEffect, useRef } from 'react'; | ||
|
||
export default function KatexSpan({ text, ...delegated }) { | ||
const katexTextRef = useRef(); | ||
useEffect(() => { | ||
if (katexTextRef.current) { | ||
renderMathInElement(katexTextRef.current, { | ||
delimiters: [ | ||
{ left: '$$', right: '$$', display: true }, | ||
{ left: '$', right: '$', display: false }, | ||
], | ||
}); | ||
} | ||
}, [text]); | ||
|
||
return ( | ||
<div ref={katexTextRef} {...delegated}> | ||
{text} | ||
</div> | ||
); | ||
} |
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.
47cce3f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
logicola – ./
logicola-malik-piaras-projects.vercel.app
logicola.org
logicola-git-main-malik-piaras-projects.vercel.app
www.logicola.org