diff --git a/src/CmpResultInFile.svelte b/src/CmpResultInFile.svelte index 4b37567..ac4afe9 100644 --- a/src/CmpResultInFile.svelte +++ b/src/CmpResultInFile.svelte @@ -1,7 +1,7 @@
dispatch("click")} >
- {@html cleanContent(note?.content ?? "").replace(reg, highlighter)} + {@html makeExcerpt(note?.content ?? "", offset).replace(reg, highlighter)}
diff --git a/src/CmpResultNote.svelte b/src/CmpResultNote.svelte index abf9da1..08ddba4 100644 --- a/src/CmpResultNote.svelte +++ b/src/CmpResultNote.svelte @@ -1,8 +1,8 @@
-1) { + const from = Math.max(0, pos - excerptBefore) + const to = Math.min(content.length - 1, pos + excerptAfter) + content = + (from > 0 ? '…' : '') + + content.slice(from, to).trim() + + (to < content.length - 1 ? '…' : '') + } + return escapeHTML(content) +}