pl-fe: fix nyaize

Signed-off-by: Nicole Mikołajczyk <git@mkljczk.pl>
This commit is contained in:
Nicole Mikołajczyk
2025-04-02 12:13:40 +02:00
parent b68fc4e7d8
commit 2059afb11e

View File

@ -101,17 +101,13 @@ function parseContent({
const options: HTMLReactParserOptions = {
replace(domNode) {
if (!(domNode instanceof Element)) {
const data = speakAsCat ? nyaize(domNode.data) : domNode.data;
// @ts-ignore
if (greentext && (data.startsWith('>') || domNode.prev?.greentext)) {
if (greentext && (domNode.data.startsWith('>') || domNode.prev?.greentext)) {
// @ts-ignore
domNode.greentext = true;
return <span className='dark:text-accent-green text-lime-600'>{data}</span>;
return <span className='dark:text-accent-green text-lime-600'>{domNode.data}</span>;
}
if (speakAsCat) return data;
return;
}
@ -220,7 +216,9 @@ function parseContent({
transform(reactNode, _domNode, index) {
if (typeof reactNode === 'string') {
return <Emojify key={index} text={reactNode} emojis={emojiMap} />;
const text = speakAsCat ? nyaize(reactNode) : reactNode;
return <Emojify key={index} text={text} emojis={emojiMap} />;
}
return reactNode as JSX.Element;