Upload folder using huggingface_hub
Browse files
6.3.1/markdown-code/MarkdownCode.svelte
CHANGED
|
@@ -1,26 +1,45 @@
|
|
| 1 |
<script lang="ts">
|
| 2 |
-
import {
|
| 3 |
import { create_marked } from "./utils";
|
| 4 |
import { sanitize } from "@gradio/sanitize";
|
| 5 |
import "./prism.css";
|
| 6 |
import { standardHtmlAndSvgTags } from "./html-tags";
|
| 7 |
import type { ThemeMode } from "@gradio/core";
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
let el: HTMLSpanElement;
|
| 23 |
-
let html: string
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
let katex_loaded = false;
|
| 25 |
|
| 26 |
const marked = create_marked({
|
|
@@ -115,12 +134,6 @@
|
|
| 115 |
return parsedValue;
|
| 116 |
}
|
| 117 |
|
| 118 |
-
$: if (message && message.trim()) {
|
| 119 |
-
html = process_message(message);
|
| 120 |
-
} else {
|
| 121 |
-
html = "";
|
| 122 |
-
}
|
| 123 |
-
|
| 124 |
async function render_html(value: string): Promise<void> {
|
| 125 |
if (latex_delimiters.length > 0 && value && has_math_syntax(value)) {
|
| 126 |
if (!katex_loaded) {
|
|
@@ -163,9 +176,9 @@
|
|
| 163 |
}
|
| 164 |
}
|
| 165 |
|
| 166 |
-
|
| 167 |
if (el && document.body.contains(el)) {
|
| 168 |
-
|
| 169 |
} else {
|
| 170 |
console.error("Element is not in the DOM");
|
| 171 |
}
|
|
|
|
| 1 |
<script lang="ts">
|
| 2 |
+
import { onMount, tick } from "svelte";
|
| 3 |
import { create_marked } from "./utils";
|
| 4 |
import { sanitize } from "@gradio/sanitize";
|
| 5 |
import "./prism.css";
|
| 6 |
import { standardHtmlAndSvgTags } from "./html-tags";
|
| 7 |
import type { ThemeMode } from "@gradio/core";
|
| 8 |
|
| 9 |
+
let {
|
| 10 |
+
chatbot = true,
|
| 11 |
+
message,
|
| 12 |
+
sanitize_html = true,
|
| 13 |
+
latex_delimiters = [],
|
| 14 |
+
render_markdown = true,
|
| 15 |
+
line_breaks = true,
|
| 16 |
+
header_links = false,
|
| 17 |
+
allow_tags = false,
|
| 18 |
+
theme_mode = "system"
|
| 19 |
+
}: {
|
| 20 |
+
chatbot?: boolean;
|
| 21 |
+
message: string;
|
| 22 |
+
sanitize_html?: boolean;
|
| 23 |
+
latex_delimiters?: {
|
| 24 |
+
left: string;
|
| 25 |
+
right: string;
|
| 26 |
+
display: boolean;
|
| 27 |
+
}[];
|
| 28 |
+
render_markdown?: boolean | undefined;
|
| 29 |
+
line_breaks?: boolean;
|
| 30 |
+
header_links?: boolean;
|
| 31 |
+
allow_tags?: string[] | boolean | undefined;
|
| 32 |
+
theme_mode?: ThemeMode;
|
| 33 |
+
} = $props();
|
| 34 |
+
|
| 35 |
let el: HTMLSpanElement;
|
| 36 |
+
let html: string = $derived.by(() => {
|
| 37 |
+
if (message && message.trim()) {
|
| 38 |
+
return process_message(message);
|
| 39 |
+
} else {
|
| 40 |
+
return "";
|
| 41 |
+
}
|
| 42 |
+
});
|
| 43 |
let katex_loaded = false;
|
| 44 |
|
| 45 |
const marked = create_marked({
|
|
|
|
| 134 |
return parsedValue;
|
| 135 |
}
|
| 136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
async function render_html(value: string): Promise<void> {
|
| 138 |
if (latex_delimiters.length > 0 && value && has_math_syntax(value)) {
|
| 139 |
if (!katex_loaded) {
|
|
|
|
| 176 |
}
|
| 177 |
}
|
| 178 |
|
| 179 |
+
$effect(() => {
|
| 180 |
if (el && document.body.contains(el)) {
|
| 181 |
+
render_html(message);
|
| 182 |
} else {
|
| 183 |
console.error("Element is not in the DOM");
|
| 184 |
}
|
6.3.1/markdown-code/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "@gradio/markdown-code",
|
| 3 |
-
"version": "0.6.
|
| 4 |
"description": "Gradio UI packages",
|
| 5 |
"type": "module",
|
| 6 |
"author": "",
|
|
|
|
| 1 |
{
|
| 2 |
"name": "@gradio/markdown-code",
|
| 3 |
+
"version": "0.6.1",
|
| 4 |
"description": "Gradio UI packages",
|
| 5 |
"type": "module",
|
| 6 |
"author": "",
|