Spaces:
Runtime error
Runtime error
matthoffner
commited on
Commit
·
4af5a43
1
Parent(s):
e8ed8bb
render html
Browse files- components/Chat/ChatMessage.tsx +17 -16
components/Chat/ChatMessage.tsx
CHANGED
@@ -216,26 +216,27 @@ export const ChatMessage: FC<Props> = memo(({ message, messageIndex, onEdit }) =
|
|
216 |
components={{
|
217 |
code({ node, inline, className, children, ...props }) {
|
218 |
if (children.length) {
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
children[0] = (children[0] as string).replace("`▍`", "▍")
|
224 |
}
|
225 |
-
|
226 |
const match = /language-(\w+)/.exec(className || '');
|
227 |
-
|
228 |
return !inline ? (
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
|
|
|
|
|
|
|
|
235 |
) : (
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
);
|
240 |
},
|
241 |
table({ children }) {
|
|
|
216 |
components={{
|
217 |
code({ node, inline, className, children, ...props }) {
|
218 |
if (children.length) {
|
219 |
+
if (children[0] == '▍') {
|
220 |
+
return <span className="animate-pulse cursor-default mt-1">▍</span>
|
221 |
+
}
|
222 |
+
children[0] = (children[0] as string).replace("`▍`", "▍")
|
|
|
223 |
}
|
|
|
224 |
const match = /language-(\w+)/.exec(className || '');
|
|
|
225 |
return !inline ? (
|
226 |
+
match && match[1] === 'html' ? (
|
227 |
+
<div className={className} dangerouslySetInnerHTML={{ __html: String(children).replace(/\n$/, '') }} />
|
228 |
+
) : (
|
229 |
+
<CodeBlock
|
230 |
+
key={Math.random()}
|
231 |
+
language={(match && match[1]) || ''}
|
232 |
+
value={String(children).replace(/\n$/, '')}
|
233 |
+
{...props}
|
234 |
+
/>
|
235 |
+
)
|
236 |
) : (
|
237 |
+
<code className={className} {...props}>
|
238 |
+
{children}
|
239 |
+
</code>
|
240 |
);
|
241 |
},
|
242 |
table({ children }) {
|