import { Text } from "@pikku/mantine/core" import { asI18n } from "@pikku/react" import React from "react" interface EmphasizeProps { text: string; primary?: boolean renderInlineStyles?: boolean [key: string]: any } function stripInlineTags(text: string) { return text .replace(/<\/?(strong|i|em)>/g, '') .replace(//g, '\n') .replace(/<\/br>/g, '') } export function Emphasize({ text, primary = true, renderInlineStyles = true, ...textProps }: EmphasizeProps) { if (!renderInlineStyles) { return {asI18n(stripInlineTags(text))} } // Split text by and tags while preserving the tags const parts = text.split(/(.*?<\/strong>|.*?<\/i>|.*?<\/em>|
.*?<\/br>)/g); return ( {parts.map((part, i) => { if ((part.startsWith('') && part.endsWith('')) || (part.startsWith('') && part.endsWith(''))){ // Extract content between tags const content = part.replace(/<\/?strong>/g, '').replace(/<\/?em>/g, ''); return ( {asI18n(content)} ); } else if (part.startsWith('') && part.endsWith('')) { // Extract content between tags const content = part.replace(/<\/?i>/g, ''); return ( {asI18n(content)} ); } else if (part.startsWith('
') && part.endsWith('
')) { return (
); } else { // Regular text return {asI18n(part)}; } })}
); }