Workaround for Markdown rendering
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -1,22 +1,9 @@
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import "github-markdown-css/github-markdown.css";
|
||||
import "mathjax-full/es5/tex-mml-svg.js";
|
||||
import "./main.css";
|
||||
import { onMount } from "svelte";
|
||||
|
||||
let content = `
|
||||
# This is a header
|
||||
This is a paragraph $E = mc^2$
|
||||
* This is a list
|
||||
* With two items
|
||||
1. And a sublist
|
||||
2. That is ordered
|
||||
* With another
|
||||
* Sublist inside
|
||||
| And this is | A table |
|
||||
|-------------|---------|
|
||||
| With two | columns |
|
||||
`;
|
||||
let content = `$E=mc^2$`;
|
||||
let source = "";
|
||||
|
||||
function updateSource() {
|
||||
@ -25,21 +12,24 @@ function updateSource() {
|
||||
}
|
||||
|
||||
function renderMath() {
|
||||
if (window.MathJax && window.MathJax.typesetPromise) {
|
||||
window.MathJax.typesetPromise();
|
||||
const MathJax = (window as any).MathJax;
|
||||
if (!MathJax) return;
|
||||
if (MathJax.typesetPromise) {
|
||||
MathJax.typesetPromise();
|
||||
}
|
||||
}
|
||||
|
||||
let sizeParam = '1.2em';
|
||||
// 获取 URL 的 size 参数
|
||||
onMount(() => {
|
||||
onMount(async () => {
|
||||
/// @ts-ignore
|
||||
await import("mathjax-full/es5/tex-mml-svg.js");
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
sizeParam = urlParams.get('size');
|
||||
sizeParam = urlParams.get('size') ?? sizeParam;
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<textarea name="content" id="content" type="text" bind:value={content}></textarea>
|
||||
<textarea name="content" id="content" bind:value={content}></textarea>
|
||||
<button id="button" on:click={updateSource}>Render Math</button>
|
||||
|
||||
<svelte:head>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import "github-markdown-css/github-markdown.css";
|
||||
import SvelteMarkdown from "svelte-markdown";
|
||||
import "mathjax-full/es5/tex-mml-svg.js";
|
||||
// import "mathjax-full/es5/tex-mml-svg.js";
|
||||
import "./main.css";
|
||||
import { onMount } from "svelte";
|
||||
|
||||
@ -21,27 +21,29 @@ This is a paragraph $E = mc^2$
|
||||
let source = "";
|
||||
|
||||
function updateSource() {
|
||||
source = ""; // Clear the source to force re-render
|
||||
source = "";
|
||||
setTimeout(() => { source = content;setTimeout(renderMath, 0);}, 0);
|
||||
// 在内容更新后渲染数学公式
|
||||
}
|
||||
|
||||
function renderMath() {
|
||||
if (window.MathJax && window.MathJax.typesetPromise) {
|
||||
window.MathJax.typesetPromise();
|
||||
const MathJax = (window as any).MathJax;
|
||||
if (!MathJax) return;
|
||||
if (MathJax.typesetPromise) {
|
||||
MathJax.typesetPromise();
|
||||
}
|
||||
}
|
||||
|
||||
let sizeParam = '1.2em';
|
||||
// 获取 URL 的 size 参数
|
||||
onMount(() => {
|
||||
onMount(async () => {
|
||||
/// @ts-ignore
|
||||
await import("mathjax-full/es5/tex-mml-svg.js");
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
sizeParam = urlParams.get('size');
|
||||
sizeParam = urlParams.get('size') ?? sizeParam;
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<textarea name="content" id="content" type="text" bind:value={content}></textarea>
|
||||
<textarea name="content" id="content" bind:value={content}></textarea>
|
||||
<button id="button" on:click={updateSource}>Render Math</button>
|
||||
|
||||
<svelte:head>
|
||||
|
||||
Reference in New Issue
Block a user