misc: fix spoiler support
This commit is contained in:
1 parent
98a899c596
commit
687bcde97b
4 files changed
+5
-7
No files matched your search
@@ -80,5 +80,6 @@
|
|||||||
options={{
|
options={{
|
||||||
pedantic: true,
|
pedantic: true,
|
||||||
}}
|
}}
|
||||||
|
isInline={inline}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Disclosure } from 'mono-svelte'
|
import { marked } from 'marked'
|
||||||
|
|
||||||
export let raw: string
|
export let raw: string
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
const spoilerRegex = /^::: spoiler (.+)\n([\s\S]+?)\n:::/gm
|
const spoilerRegex = /^::: spoiler (.+)\n([\s\S]+?)\n:::/gm
|
||||||
|
|
||||||
return text.replace(spoilerRegex, function (match, title, content) {
|
return text.replace(spoilerRegex, function (match, title, content) {
|
||||||
return `<details><summary class="cursor-pointer">${title}</summary>${content}</details>`
|
return `<details><summary class="cursor-pointer">${marked.parseInline(title)}</summary>${marked.parse(content)}</details>`
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let text: string
|
|
||||||
export let raw: string
|
export let raw: string
|
||||||
|
|
||||||
console.log(raw)
|
|
||||||
|
|
||||||
function preprocess(src: string): string {
|
function preprocess(src: string): string {
|
||||||
// superscript, subscript support
|
// superscript, subscript support
|
||||||
src = src
|
src = src
|
||||||
.replace(/~([^~]+)~/g, '<sub>$1</sub>')
|
.replaceAll(/~([^~]+)~/g, '<sub>$1</sub>')
|
||||||
.replace(/\^([^^]+)\^/g, '<sup>$1</sup>')
|
.replaceAll(/\^([^^]+)\^/g, '<sup>$1</sup>')
|
||||||
|
|
||||||
return src
|
return src
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user