Escape HTML
Instead of trying to do some smart (and unsecure) stuff, just display the raw note contents as is
This commit is contained in:
22
src/main.ts
22
src/main.ts
@@ -1,10 +1,6 @@
|
||||
import { Notice, Plugin, TAbstractFile, TFile } from 'obsidian'
|
||||
import MiniSearch from 'minisearch'
|
||||
import {
|
||||
clearContent,
|
||||
extractHeadingsFromCache,
|
||||
wait,
|
||||
} from './utils'
|
||||
import { escapeHTML, extractHeadingsFromCache, wait } from './utils'
|
||||
import { IndexedNote } from './globals'
|
||||
import { OmnisearchModal } from './modal'
|
||||
|
||||
@@ -97,7 +93,7 @@ export default class OmnisearchPlugin extends Plugin {
|
||||
}
|
||||
// Fetch content from the cache,
|
||||
// trim the markdown, remove embeds and clear wikilinks
|
||||
const content = clearContent(await this.app.vault.cachedRead(file))
|
||||
const content = escapeHTML(await this.app.vault.cachedRead(file))
|
||||
|
||||
// Purge HTML before indexing
|
||||
const tmp = document.createElement('div')
|
||||
@@ -106,11 +102,17 @@ export default class OmnisearchPlugin extends Plugin {
|
||||
// Make the document and index it
|
||||
const note: IndexedNote = {
|
||||
basename: file.basename,
|
||||
content: tmp.innerText,
|
||||
content: tmp.innerText, // content,
|
||||
path: file.path,
|
||||
headings1: fileCache ? extractHeadingsFromCache(fileCache, 1).join(' ') : '',
|
||||
headings2: fileCache ? extractHeadingsFromCache(fileCache, 2).join(' ') : '',
|
||||
headings3: fileCache ? extractHeadingsFromCache(fileCache, 3).join(' ') : '',
|
||||
headings1: fileCache
|
||||
? extractHeadingsFromCache(fileCache, 1).join(' ')
|
||||
: '',
|
||||
headings2: fileCache
|
||||
? extractHeadingsFromCache(fileCache, 2).join(' ')
|
||||
: '',
|
||||
headings3: fileCache
|
||||
? extractHeadingsFromCache(fileCache, 3).join(' ')
|
||||
: '',
|
||||
}
|
||||
this.minisearch.add(note)
|
||||
this.indexedNotes[file.path] = note
|
||||
|
||||
Reference in New Issue
Block a user