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 "github-markdown-css/github-markdown.css";
|
||||||
import "mathjax-full/es5/tex-mml-svg.js";
|
|
||||||
import "./main.css";
|
import "./main.css";
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
|
|
||||||
let content = `
|
let content = `$E=mc^2$`;
|
||||||
# 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 source = "";
|
let source = "";
|
||||||
|
|
||||||
function updateSource() {
|
function updateSource() {
|
||||||
@ -25,21 +12,24 @@ function updateSource() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderMath() {
|
function renderMath() {
|
||||||
if (window.MathJax && window.MathJax.typesetPromise) {
|
const MathJax = (window as any).MathJax;
|
||||||
window.MathJax.typesetPromise();
|
if (!MathJax) return;
|
||||||
|
if (MathJax.typesetPromise) {
|
||||||
|
MathJax.typesetPromise();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let sizeParam = '1.2em';
|
let sizeParam = '1.2em';
|
||||||
// 获取 URL 的 size 参数
|
onMount(async () => {
|
||||||
onMount(() => {
|
/// @ts-ignore
|
||||||
|
await import("mathjax-full/es5/tex-mml-svg.js");
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
sizeParam = urlParams.get('size');
|
sizeParam = urlParams.get('size') ?? sizeParam;
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</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>
|
<button id="button" on:click={updateSource}>Render Math</button>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<script>
|
<script lang="ts">
|
||||||
import "github-markdown-css/github-markdown.css";
|
import "github-markdown-css/github-markdown.css";
|
||||||
import SvelteMarkdown from "svelte-markdown";
|
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 "./main.css";
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
|
|
||||||
@ -21,27 +21,29 @@ This is a paragraph $E = mc^2$
|
|||||||
let source = "";
|
let source = "";
|
||||||
|
|
||||||
function updateSource() {
|
function updateSource() {
|
||||||
source = ""; // Clear the source to force re-render
|
source = "";
|
||||||
setTimeout(() => { source = content;setTimeout(renderMath, 0);}, 0);
|
setTimeout(() => { source = content;setTimeout(renderMath, 0);}, 0);
|
||||||
// 在内容更新后渲染数学公式
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderMath() {
|
function renderMath() {
|
||||||
if (window.MathJax && window.MathJax.typesetPromise) {
|
const MathJax = (window as any).MathJax;
|
||||||
window.MathJax.typesetPromise();
|
if (!MathJax) return;
|
||||||
|
if (MathJax.typesetPromise) {
|
||||||
|
MathJax.typesetPromise();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let sizeParam = '1.2em';
|
let sizeParam = '1.2em';
|
||||||
// 获取 URL 的 size 参数
|
onMount(async () => {
|
||||||
onMount(() => {
|
/// @ts-ignore
|
||||||
|
await import("mathjax-full/es5/tex-mml-svg.js");
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
sizeParam = urlParams.get('size');
|
sizeParam = urlParams.get('size') ?? sizeParam;
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</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>
|
<button id="button" on:click={updateSource}>Render Math</button>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
|||||||
Reference in New Issue
Block a user