diff --git a/server/prisma/dev.db b/server/prisma/dev.db index 3497d5b..e8eff1b 100644 Binary files a/server/prisma/dev.db and b/server/prisma/dev.db differ diff --git a/webapp/src/lib/components/MarkdownRenderer.svelte b/webapp/src/lib/components/MarkdownRenderer.svelte index ccfd325..e882189 100644 --- a/webapp/src/lib/components/MarkdownRenderer.svelte +++ b/webapp/src/lib/components/MarkdownRenderer.svelte @@ -7,6 +7,7 @@ import extensions from '$lib/marked/extensions'; import Link from '$lib/marked/renderers/Link.svelte'; import Tag from '$lib/marked/renderers/Tag.svelte'; + import Highlight from '$lib/marked/renderers/Highlight.svelte'; export let plaintext: string; @@ -28,7 +29,8 @@ prose-blockquote:first:before:content-['']" list: List, link: Link, 'internal-link': InternalLink, - tag: Tag + tag: Tag, + highlight: Highlight }} source={plaintext} {options} diff --git a/webapp/src/lib/marked/extensions.ts b/webapp/src/lib/marked/extensions.ts index 2099c22..5b439c7 100644 --- a/webapp/src/lib/marked/extensions.ts +++ b/webapp/src/lib/marked/extensions.ts @@ -26,7 +26,6 @@ const TagExtension = { tokenizer(src: string) { const match = src.match(/^#([\w/]+)[\W\s]/); if (match) { - console.log(match); return { type: 'tag', raw: match[0].trim(), @@ -37,6 +36,25 @@ const TagExtension = { } }; -export default [InternalLinkExtension, TagExtension]; +const HighlightExtension = { + name: 'highlight', + level: 'inline', + start(src: string) { + return src.match(/==/)?.index; + }, + tokenizer(src: string) { + const match = src.match(/^==(.+)==/); + if (match) { + return { + type: 'highlight', + raw: match[0].trim(), + text: match[1].trim() + }; + } + return false; + } +}; + +export default [InternalLinkExtension, TagExtension, HighlightExtension]; // ^\#([\w\/]+)\W* diff --git a/webapp/src/lib/marked/renderers/Highlight.svelte b/webapp/src/lib/marked/renderers/Highlight.svelte new file mode 100644 index 0000000..9d21975 --- /dev/null +++ b/webapp/src/lib/marked/renderers/Highlight.svelte @@ -0,0 +1,5 @@ + + +{text}