diff --git a/src/app/club/Components/Admin/AddQuestions.tsx b/src/app/club/Components/Admin/AddQuestions.tsx index 433272e..efc57a5 100644 --- a/src/app/club/Components/Admin/AddQuestions.tsx +++ b/src/app/club/Components/Admin/AddQuestions.tsx @@ -1,8 +1,15 @@ -import { useEffect, useState } from "react"; +import { useEffect, useMemo, useState } from "react"; import { FaPlus } from "react-icons/fa6"; import { RiDeleteBin6Line } from "react-icons/ri"; import { RxGear } from "react-icons/rx"; +import Markdown from "react-markdown"; import { toast } from "react-toastify"; +import rehypeHighlight from "rehype-highlight"; +import rehypeKatex from "rehype-katex"; +import remarkGfm from "remark-gfm"; +import remarkMath from "remark-math"; +import "highlight.js/styles/atom-one-light.css"; +import "katex/dist/katex.min.css"; interface questionInterface { mcq: boolean; @@ -189,6 +196,24 @@ const AddQuestions = ({ console.log("-------------"); }, [questions, answers]); + const modifiedText = useMemo(() => { + const lines = (question || "").split("\n"); + + return lines + .map((line, index) => { + // Check if the line is part of a list + const isListItem = /^\s*[*\-+]\s+|^\s*\d+\.\s+/.test(line); + const isNextLineListItem = + index < lines.length - 1 && + /^\s*[*\-+]\s+|^\s*\d+\.\s+/.test(lines[index + 1]); + + if (isListItem || isNextLineListItem) return line; + + return line + "\n"; + }) + .join("\n"); + }, [question]); + return (
@@ -238,7 +263,18 @@ const AddQuestions = ({ rows={7} />
- +
+ +
+ + {modifiedText} + +
+