address PR review: stricter HTML detection and fence label punctuation

This commit is contained in:
Abhinav Raut
2026-07-31 17:02:37 +05:30
parent a5a029d894
commit fa4305d880
3 changed files with 13 additions and 2 deletions
@@ -223,7 +223,8 @@ const runAiGeneration = async (requestFn) => {
if (uuid !== currentConversationUUID.value) return
const out = resp.data.data || ''
// A model can ignore the HTML-output instruction; plain text pasted into the editor loses its line breaks.
htmlContent.value = /<[a-z][\s\S]*>/i.test(out) ? out : convertTextToHtml(out)
// The tag check must not match angle-bracketed plain text like "Contact <user@example.com>".
htmlContent.value = /<\/?[a-z][a-z0-9]*(\s[^>]*)?\/?>/i.test(out) ? out : convertTextToHtml(out)
} catch (error) {
emitter.emit(EMITTER_EVENTS.SHOW_TOAST, {
variant: 'destructive',
+1 -1
View File
@@ -40,7 +40,7 @@ var (
//go:embed queries.sql
efs embed.FS
codeFenceOpenRe = regexp.MustCompile("^```[a-zA-Z0-9]*$")
codeFenceOpenRe = regexp.MustCompile("^```[a-zA-Z0-9+#./_-]*$")
ErrInvalidAPIKey = errors.New("invalid API Key")
ErrApiKeyNotSet = errors.New("api Key not set")
+10
View File
@@ -48,6 +48,16 @@ func TestStripCodeFence(t *testing.T) {
in: "```<p>Hello,</p>\n<p>Thanks.</p>\n```",
want: "```<p>Hello,</p>\n<p>Thanks.</p>\n```",
},
{
name: "c++ fence unwrapped",
in: "```c++\nint main() {}\n```",
want: "int main() {}",
},
{
name: "text/plain fence unwrapped",
in: "```text/plain\nHello there.\n```",
want: "Hello there.",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {