Skip to content

Commit

Permalink
Fix apostrophe after mention
Browse files Browse the repository at this point in the history
  • Loading branch information
moysa committed Oct 9, 2023
1 parent 7953f03 commit b42ee44
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/components/ParsedNote/ParsedNote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import NoteImage from '../NoteImage/NoteImage';
import { createStore } from 'solid-js/store';
import { linebreakRegex } from '../../constants';

const specialChars = [",", "?", ";", "!", "'"];

const ParsedNote: Component<{
note: PrimalNote,
Expand Down Expand Up @@ -351,12 +352,18 @@ const ParsedNote: Component<{
return token;
}

let end = id[id.length - 1];
let end = '';

if ([',', '?', ';', '!'].some(x => end === x)) {
id = id.slice(0, -1);
} else {
end = '';
for (let i=0; i<specialChars.length; i++) {
const char = specialChars[i];

const index = id.indexOf(char);

if (index >= 0) {
end = id.slice(index);
id = id.slice(0, index);
break;
}
}

try {
Expand Down

0 comments on commit b42ee44

Please sign in to comment.