From c9aba8d8a5886ef6456479154a14c69188c20413 Mon Sep 17 00:00:00 2001 From: Dawood Khan Date: Tue, 19 Mar 2024 15:52:03 -0400 Subject: [PATCH] Fixes: gr.Markdown is not updated properly when it has an image tag (#7623) * fix * add changeset --------- Co-authored-by: gradio-pr-bot Co-authored-by: Abubakar Abid --- .changeset/plenty-paths-sing.md | 6 ++++++ js/markdown/shared/MarkdownCode.svelte | 14 ++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 .changeset/plenty-paths-sing.md diff --git a/.changeset/plenty-paths-sing.md b/.changeset/plenty-paths-sing.md new file mode 100644 index 0000000000..cfb7d93e1b --- /dev/null +++ b/.changeset/plenty-paths-sing.md @@ -0,0 +1,6 @@ +--- +"@gradio/markdown": patch +"gradio": patch +--- + +fix:Fixes: gr.Markdown is not updated properly when it has an image tag diff --git a/js/markdown/shared/MarkdownCode.svelte b/js/markdown/shared/MarkdownCode.svelte index 5d5cd63489..69391e1d81 100644 --- a/js/markdown/shared/MarkdownCode.svelte +++ b/js/markdown/shared/MarkdownCode.svelte @@ -61,10 +61,16 @@ } async function render_html(value: string): Promise { if (latex_delimiters.length > 0 && value) { - render_math_in_element(el, { - delimiters: latex_delimiters, - throwOnError: false - }); + const containsDelimiter = latex_delimiters.some( + (delimiter) => + value.includes(delimiter.left) && value.includes(delimiter.right) + ); + if (containsDelimiter) { + render_math_in_element(el, { + delimiters: latex_delimiters, + throwOnError: false + }); + } } } afterUpdate(() => render_html(message));