fix: 🐛 fix highlight rendering with mixed formatting

This commit is contained in:
Maxime Cannoodt 2022-08-16 18:07:24 +02:00
parent 91cf1ffdb2
commit 7c9285492c
4 changed files with 11 additions and 4 deletions

2
plugin

@ -1 +1 @@
Subproject commit c727d49dd50eaf0a1acb9c8e4fe08c2a4cfcb9d5 Subproject commit 699b2b93a6c31fb4e2bffebe33af97774e3a5c99

View File

@ -1,5 +1,9 @@
# Changelog # Changelog
## [2022-08-16]
- fix: 🐛 Fix highlights not rendering correctly when mixed with other formatting.
## [2022-08-11] ## [2022-08-11]
- feat: ✨ Users receive a unique error page when opening expired notes vs. wrong URL. - feat: ✨ Users receive a unique error page when opening expired notes vs. wrong URL.

View File

@ -61,13 +61,16 @@ const HighlightExtension = {
start(src: string) { start(src: string) {
return src.match(/==/)?.index; return src.match(/==/)?.index;
}, },
tokenizer(src: string) { tokenizer(src: string): any {
const match = src.match(/^==(.+)==/); const match = src.match(/^==(.+)==/);
const text = match ? match[1].trim() : '';
if (match) { if (match) {
return { return {
type: 'highlight', type: 'highlight',
raw: match[0].trim(), raw: match[0].trim(),
text: match[1].trim() text: text,
// @ts-expect-error - marked types are wrong
tokens: this.lexer.inlineTokens(text, [])
}; };
} }
return false; return false;

View File

@ -2,4 +2,4 @@
export let text: string; export let text: string;
</script> </script>
<span class="bg-[#ffff00]/[0.4]">{text}</span> <span class="bg-[#ffff00]/[0.4]"><slot /></span>