diff --git a/src/components/Solutions/Writing.tsx b/src/components/Solutions/Writing.tsx
index fad9ff5a..9c5f39f9 100644
--- a/src/components/Solutions/Writing.tsx
+++ b/src/components/Solutions/Writing.tsx
@@ -12,19 +12,26 @@ export default function Writing({id, type, prompt, attachment, userSolutions, on
const [isModalOpen, setIsModalOpen] = useState(false);
const formatSolution = (solution: string, errors: {correction: string | null; misspelled: string}[]) => {
- const errorRegex = new RegExp(errors.map((x) => `(${x.misspelled})`).join("|"));
+ const misspelled = errors.map((x) => x.misspelled);
+ console.log({misspelled});
+ const errorRegex = new RegExp(errors.map((x) => `(${x.misspelled})`).join("|"), "g");
+ console.log(errorRegex.global);
return (
<>
- {reactStringReplace(solution, errorRegex, (match) => {
- const correction = errors.find((x) => x.misspelled === match)?.correction;
+ {solution.split(" ").map((word) => {
+ if (!misspelled.includes(word)) return <>{word} >;
+ const correction = errors.find((x) => x.misspelled === word)?.correction;
return (
-
- {match}
-
+ <>
+
+ {word}
+ {" "}
+ >
);
})}
>