feat(test): add jump to question functionality
This commit is contained in:
19
src/components/RenderQuestionText.tsx
Normal file
19
src/components/RenderQuestionText.tsx
Normal file
@ -0,0 +1,19 @@
|
||||
import { BlockMath, InlineMath } from "react-katex";
|
||||
|
||||
export const renderQuestionText = (text: string) => {
|
||||
const parts = text.split(/(\$\$.*?\$\$|\$.*?\$)/g);
|
||||
|
||||
return (
|
||||
<>
|
||||
{parts.map((part, index) => {
|
||||
if (part.startsWith("$$")) {
|
||||
return <BlockMath key={index}>{part.slice(2, -2)}</BlockMath>;
|
||||
}
|
||||
if (part.startsWith("$")) {
|
||||
return <InlineMath key={index}>{part.slice(1, -1)}</InlineMath>;
|
||||
}
|
||||
return <span key={index}>{part}</span>;
|
||||
})}
|
||||
</>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user