diff --git a/package.json b/package.json
index 2e65bca..fbe6558 100644
--- a/package.json
+++ b/package.json
@@ -46,6 +46,7 @@
"@sveltejs/adapter-static": "1.0.0-next.13",
"date-fns": "2.23.0",
"js-search": "2.0.0",
+ "marked": "^11.1.1",
"redis": "3.1.2"
}
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 6d639fe..d8e1e6e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -26,6 +26,9 @@ dependencies:
js-search:
specifier: 2.0.0
version: 2.0.0
+ marked:
+ specifier: ^11.1.1
+ version: 11.1.1
redis:
specifier: 3.1.2
version: 3.1.2
@@ -3067,6 +3070,12 @@ packages:
sourcemap-codec: 1.4.8
dev: true
+ /marked@11.1.1:
+ resolution: {integrity: sha512-EgxRjgK9axsQuUa/oKMx5DEY8oXpKJfk61rT5iY3aRlgU6QJtUcxU5OAymdhCvWvhYcd9FKmO5eQoX8m9VGJXg==}
+ engines: {node: '>= 18'}
+ hasBin: true
+ dev: false
+
/marked@2.1.3:
resolution: {integrity: sha512-/Q+7MGzaETqifOMWYEA7HVMaZb4XbcRfaOzcSsHZEith83KGlvaSG33u0SKu89Mj5h+T8V2hM+8O45Qc5XTgwA==}
engines: {node: '>= 10'}
diff --git a/src/lib/components/script-notes/leaf-inner.svelte b/src/lib/components/script-notes/leaf-inner.svelte
index 656e88c..9e738c4 100644
--- a/src/lib/components/script-notes/leaf-inner.svelte
+++ b/src/lib/components/script-notes/leaf-inner.svelte
@@ -1,4 +1,5 @@
@@ -7,5 +8,5 @@
{#if index !== 0}
{/if}
- {part}
+ {@html marked.parseInline(part)}
{/each}
diff --git a/src/lib/components/script-notes/script-notes.svelte b/src/lib/components/script-notes/script-notes.svelte
index 240e1a3..e45fc15 100644
--- a/src/lib/components/script-notes/script-notes.svelte
+++ b/src/lib/components/script-notes/script-notes.svelte
@@ -6,7 +6,12 @@
type Block =
| {
- type: 'p' | 'code'
+ type: 'p'
+ content: string
+ style: string
+ }
+ | {
+ type: 'code'
content: string
}
| {
@@ -17,6 +22,7 @@
type Content = Block[]
let content: Content = []
+
$: {
const lines = notes.split('\n\n')
content = lines.map((line) => {
@@ -42,9 +48,15 @@
}),
}
} else {
+ let classString = ''
+ if (line.startsWith('###')) classString = 'text-lg font-bold'
+ else if (line.startsWith('##')) classString = 'text-xl font-bold'
+ else if (line.startsWith('#')) classString = 'text-2xl font-bold'
+
return {
type: 'p',
- content: line,
+ content: line.replace(/#+\s*/, ''),
+ style: classString,
}
}
})
@@ -54,7 +66,7 @@
+