Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chatbot LaTeX Crash Fix #8658

Merged
merged 19 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/puny-dolls-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/markdown": patch
"gradio": patch
---

fix:Chatbot LaTeX Crash Fix
17 changes: 10 additions & 7 deletions js/markdown/shared/MarkdownCode.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { afterUpdate, createEventDispatcher } from "svelte";
import { afterUpdate } from "svelte";
import DOMPurify from "dompurify";
import render_math_in_element from "katex/contrib/auto-render";
import "katex/dist/katex.min.css";
Expand Down Expand Up @@ -73,15 +73,18 @@
}
}
}
afterUpdate(() => render_html(message));

afterUpdate(async () => {
if (el && document.body.contains(el)) {
await render_html(message);
} else {
console.error("Element is not in the DOM");
}
});
</script>

<span class:chatbot bind:this={el} class="md" class:prose={render_markdown}>
{#if render_markdown}
{@html html}
{:else}
{html}
{/if}
dawoodkhan82 marked this conversation as resolved.
Show resolved Hide resolved
{@html html}
</span>

<style>
Expand Down