feat: add federation markdown and fix #19
This commit is contained in:
1 parent
5024e9edf1
commit
ad339ef815
2 files changed
+33
-6
No files matched your search
@@ -1,11 +1,32 @@
|
||||
<script lang="ts">
|
||||
import MarkdownIt from 'markdown-it'
|
||||
const md = new MarkdownIt({
|
||||
html: false,
|
||||
linkify: true,
|
||||
})
|
||||
|
||||
import { md } from '$lib/components/markdown/markdown'
|
||||
export let source: string = ''
|
||||
|
||||
md.linkify.add('!', {
|
||||
validate: function (text, pos, self) {
|
||||
var tail = text.slice(pos)
|
||||
|
||||
console.log(tail)
|
||||
|
||||
if (!self.re.community) {
|
||||
self.re.community = new RegExp(
|
||||
/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z]{2,6})/
|
||||
)
|
||||
}
|
||||
if (self.re.community.test(tail)) {
|
||||
// Linkifier allows punctuation chars before prefix,
|
||||
// but we additionally disable `@` ("@@mention" is invalid)
|
||||
if (pos >= 2 && tail[pos - 2] === '!') {
|
||||
return false
|
||||
}
|
||||
return tail.match(self.re.community)![0].length
|
||||
}
|
||||
return 0
|
||||
},
|
||||
normalize: function (match) {
|
||||
match.url = `${location.origin}/c/${match.url.slice(1)}`
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<div class="break-words flex flex-col markdown gap-2">
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import MarkdownIt from 'markdown-it'
|
||||
|
||||
export const md = new MarkdownIt({
|
||||
html: false,
|
||||
linkify: true,
|
||||
})
|
||||
Reference in new issue
Block a user