Spaces:
Running
Running
feat: better markdown rendering
Browse files
src/lib/components/chat/MarkdownRenderer.svelte
CHANGED
@@ -48,7 +48,20 @@
|
|
48 |
renderer,
|
49 |
};
|
50 |
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
function processLatex(parsed: string) {
|
54 |
const delimiters = [
|
|
|
48 |
renderer,
|
49 |
};
|
50 |
|
51 |
+
function escapeHTML(content: string) {
|
52 |
+
return content.replace(
|
53 |
+
/[<>&\n]/g,
|
54 |
+
(x) =>
|
55 |
+
({
|
56 |
+
"<": "<",
|
57 |
+
">": ">",
|
58 |
+
"&": "&",
|
59 |
+
"\n": "<br />",
|
60 |
+
}[x] || x)
|
61 |
+
);
|
62 |
+
}
|
63 |
+
|
64 |
+
$: tokens = marked.lexer(addInlineCitations(escapeHTML(content), sources));
|
65 |
|
66 |
function processLatex(parsed: string) {
|
67 |
const delimiters = [
|