misc: re-add markdown to posts
This commit is contained in:
1 parent
715c8f878b
commit
b4bcadf40d
3 files changed
+31
-12
No files matched your search
@@ -8,6 +8,7 @@
|
||||
import PostLink from '$lib/components/lemmy/post/PostLink.svelte'
|
||||
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
|
||||
import { ToastType, toast } from '$lib/components/ui/toasts/toasts.js'
|
||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||
|
||||
export let post: PostView
|
||||
export let actions: boolean = true
|
||||
@@ -102,14 +103,17 @@
|
||||
/>
|
||||
{/if}
|
||||
{#if post.post.body && !post.post.nsfw}
|
||||
<p
|
||||
<div
|
||||
class="text-sm bg-slate-100 dark:bg-zinc-800
|
||||
border border-slate-200 dark:border-zinc-700 rounded-md p-2"
|
||||
>
|
||||
{post.post.body.length > 350
|
||||
? `${post.post.body.slice(0, 350)}...`
|
||||
: post.post.body}
|
||||
</p>
|
||||
<Markdown
|
||||
inline
|
||||
source={post.post.body.length > 350
|
||||
? `${post.post.body.slice(0, 350)}...`
|
||||
: post.post.body}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
{#if actions}
|
||||
|
||||
@@ -22,12 +22,25 @@ export const md = new MarkdownIt({
|
||||
},
|
||||
})
|
||||
|
||||
export const mdInline: MarkdownIt = new MarkdownIt('zero').enable([
|
||||
'emphasis',
|
||||
'backticks',
|
||||
'strikethrough',
|
||||
'link',
|
||||
])
|
||||
export const mdInline: MarkdownIt = new MarkdownIt('zero')
|
||||
.enable(['emphasis', 'backticks', 'strikethrough', 'link'])
|
||||
.use(markdown_it_container, 'spoiler', {
|
||||
validate: (params: string) => {
|
||||
return params.trim().match(/^spoiler+(.*)/)
|
||||
},
|
||||
|
||||
render: (tokens: any, idx: any) => {
|
||||
var m = tokens[idx].info.trim().match(/^spoiler+(.*)/)
|
||||
|
||||
if (tokens[idx].nesting === 1) {
|
||||
// opening tag
|
||||
return `<details><summary> ${md.utils.escapeHtml(m[1])} </summary>\n`
|
||||
} else {
|
||||
// closing tag
|
||||
return '</details>\n'
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
md.linkify.add('!', {
|
||||
validate: function (text, pos, self) {
|
||||
|
||||
Reference in new issue
Block a user