Fixes: gr.Markdown is not updated properly when it has an image tag (#7623)

* fix

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
Dawood Khan 2024-03-19 15:52:03 -04:00 committed by GitHub
parent 41385f402b
commit c9aba8d8a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 4 deletions

View File

@ -0,0 +1,6 @@
---
"@gradio/markdown": patch
"gradio": patch
---
fix:Fixes: gr.Markdown is not updated properly when it has an image tag

View File

@ -61,10 +61,16 @@
}
async function render_html(value: string): Promise<void> {
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));