From b2f7c6f20446a0db9d5b083d61bacef48aaa2f52 Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Fri, 29 Sep 2023 07:29:20 -0700 Subject: [PATCH] HTML block: render as HTML, e.g. in case of a full proxy --- src/apps/chat/components/message/blocks.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/apps/chat/components/message/blocks.ts b/src/apps/chat/components/message/blocks.ts index cfdf7617c..ee8f8612b 100644 --- a/src/apps/chat/components/message/blocks.ts +++ b/src/apps/chat/components/message/blocks.ts @@ -10,6 +10,11 @@ export function parseBlocks(forceText: boolean, text: string): Block[] { if (forceText) return [{ type: 'text', content: text }]; + // noinspection HtmlRequiredTitleElement + // special case: this could be generated by a proxy that returns an HTML page instead of the API response + if (text.startsWith('\n')) + return [{ type: 'html', html: text }]; + const regexPatterns = { codeBlock: /`{3,}([\w\\.+-_]+)?\n([\s\S]*?)(`{3,}\n?|$)/g, imageBlock: /(https:\/\/images\.prodia\.xyz\/.*?\.png)/g, // NOTE: only Prodia for now - but this shall be expanded to markdown images ![alt](url) or any png/jpeg