Skip to content

Commit

Permalink
Fix names with apostrophes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Papel committed Dec 18, 2023
1 parent 53427cb commit 466814c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
23 changes: 17 additions & 6 deletions client/src/components/StyledText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,20 @@ type Token = {
string: string
} & KeywordData[number])

export default function StyledText(props: { children: string[] | string, className?: string, noLinks?: boolean }): ReactElement {
export default function StyledText(props: { children: string[] | string, className?: string, noLinks?: boolean, markdown?: boolean }): ReactElement {
let tokens: Token[] = [{
type: "raw",
string: marked.parse(
typeof props.children === "string"
string: typeof props.children === "string"
? props.children
: props.children.join(""),
MARKDOWN_OPTIONS
)
: props.children.join("")
}];

if (props.markdown) {
tokens[0].string = marked.parse(tokens[0].string, MARKDOWN_OPTIONS);
} else {
tokens[0].string = tokens[0].string.replace('\n', '<br>');
}

tokens = styleKeywords(tokens);

const jsxString = tokens.map(token => {
Expand Down Expand Up @@ -134,6 +137,14 @@ function styleKeywords(tokens: Token[]): Token[] {
if (token.type !== "raw") continue;

// Remove the keyword and split so we can insert the styled text in its place
if (keyword === '1-Jack\'' && token.string.includes('Jack')) {
console.log("Keyword: " + keyword);
console.log("Token: " + token.string);
console.log("Regex: " + find(keyword));
console.log("Regex src: " + find(keyword).source);
console.log("Final regex: " + RegExp('('+find(keyword).source+')', 'gi'));
console.log("Split: " + token.string.split(RegExp('('+find(keyword).source+')', 'gi')));
}
const stringSplit = token.string.split(RegExp('('+find(keyword).source+')', 'gi'));

if (stringSplit.length === 1) continue;
Expand Down
3 changes: 1 addition & 2 deletions client/src/game/messageListener.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import { Role } from "./roleState.d";

export default function messageListener(packet: ToClientPacket){

// console.log(JSON.stringify(packet, null, 2));
console.log(packet.type);
console.log(JSON.stringify(packet, null, 2));


switch(packet.type) {
Expand Down

1 comment on commit 466814c

@vercel
Copy link

@vercel vercel bot commented on 466814c Dec 18, 2023

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:

mafia-game – ./

mafia-game.vercel.app
mafia-game-itssammym.vercel.app
mafia-game-git-00x-main-itssammym.vercel.app

Please sign in to comment.