tfrere commited on
Commit
0dd9f5a
·
1 Parent(s): 4c8df65
client/src/components/StyledText.jsx CHANGED
@@ -4,13 +4,17 @@ import { useGame } from "../contexts/GameContext";
4
  /**
5
  * A component that renders text with styled words (bold, italic, etc.)
6
  * It automatically handles spacing between words and styled segments
 
7
  */
8
  export function StyledText({ text, ...props }) {
9
  const { heroName } = useGame();
10
 
11
  if (!text || !heroName) return text;
12
 
13
- const parts = text.split(new RegExp(`(${heroName})`, "i"));
 
 
 
14
 
15
  return (
16
  <Box component="span" sx={{ display: "inline", ...props.sx }}>
 
4
  /**
5
  * A component that renders text with styled words (bold, italic, etc.)
6
  * It automatically handles spacing between words and styled segments
7
+ * It also removes any text enclosed in [ ] or ( )
8
  */
9
  export function StyledText({ text, ...props }) {
10
  const { heroName } = useGame();
11
 
12
  if (!text || !heroName) return text;
13
 
14
+ // Remove text enclosed in [ ] or ( )
15
+ const cleanedText = text.replace(/\[.*?\]|\(.*?\)/g, "");
16
+
17
+ const parts = cleanedText.split(new RegExp(`(${heroName})`, "i"));
18
 
19
  return (
20
  <Box component="span" sx={{ display: "inline", ...props.sx }}>