fix: latex markdown rendering

This commit is contained in:
Timothy J. Baek 2023-11-03 18:09:11 -07:00
parent d8d14fbfba
commit 01632775a6

View file

@ -6,8 +6,8 @@
const { saveAs } = fileSaver; const { saveAs } = fileSaver;
import hljs from 'highlight.js'; import hljs from 'highlight.js';
import 'highlight.js/styles/github-dark.min.css'; import 'highlight.js/styles/github-dark.min.css';
import katex from 'katex';
import auto_render from 'katex/dist/contrib/auto-render.mjs'; import auto_render from 'katex/dist/contrib/auto-render.mjs';
import 'katex/dist/katex.min.css';
import toast from 'svelte-french-toast'; import toast from 'svelte-french-toast';
import { API_BASE_URL as BUILD_TIME_API_BASE_URL } from '$lib/constants'; import { API_BASE_URL as BUILD_TIME_API_BASE_URL } from '$lib/constants';
@ -144,13 +144,12 @@
// • auto-render specific keys, e.g.: // • auto-render specific keys, e.g.:
delimiters: [ delimiters: [
{ left: '$$', right: '$$', display: true }, { left: '$$', right: '$$', display: true },
{ left: '$', right: '$', display: false }, { left: '$', right: '$', display: true },
{ left: '\\(', right: '\\)', display: false }, { left: '\\(', right: '\\)', display: true },
{ left: '\\[', right: '\\]', display: true } { left: '\\[', right: '\\]', display: true }
], ],
// • rendering keys, e.g.: // • rendering keys, e.g.:
throwOnError: false, throwOnError: false
output: 'mathml'
}); });
} }
}; };
@ -223,9 +222,10 @@
settings.temperature = chat.temperature ?? settings.temperature; settings.temperature = chat.temperature ?? settings.temperature;
await tick(); await tick();
renderLatex();
hljs.highlightAll(); hljs.highlightAll();
createCopyCodeBlockButton(); createCopyCodeBlockButton();
renderLatex();
} }
}; };
@ -893,7 +893,7 @@
{message.content} {message.content}
{/if} {/if}
{:else} {:else}
{@html marked.parse(message.content)} {@html marked(message.content.replace('\\\\', '\\\\\\'))}
{#if message.done} {#if message.done}
<div class=" flex justify-end space-x-1 text-gray-400"> <div class=" flex justify-end space-x-1 text-gray-400">
@ -1122,12 +1122,6 @@
</div> </div>
</div> </div>
</div> </div>
<div class=" hidden katex" />
<!-- <main class="w-full flex justify-center">
<div class="max-w-lg w-screen p-5" />
</main> -->
</div> </div>
</div> </div>