Skip to content

Build your personal knowledge base with Trilium Notes

init

misch33439d10124ab41
diff --git a/packages/trilium-core/src/services/backend_script_api.ts b/packages/trilium-core/src/services/backend_script_api.ts
index d764a32890..f41e99c5b9 100644
--- a/packages/trilium-core/src/services/backend_script_api.ts
+++ b/packages/trilium-core/src/services/backend_script_api.ts
@@ -36,6 +36,7 @@ import { getSql } from "./sql/index";
import treeService from "./tree.js";
import { escapeHtml, randomString, unescapeHtml } from "./utils/index";
import ws from "./ws.js";
+import markdown from "./export/markdown.js";
/**
* A whole number
@@ -59,7 +60,10 @@ interface NoteAndBranch {
branch: BBranch;
}
+
export interface Api {
+ htmlToMarkdown(html: string): string
+
/**
* Note where the script execution started — the entry point of the current script bundle
* (in C terms, the file containing `main()`). When a script is spread across multiple code
@@ -508,6 +512,8 @@ function BackendScriptApi(this: Api, currentNote: BNote, apiParams: ApiParams) {
this.getOptions = () => optionsService.getOptions();
this.getAttribute = (attributeId) => becca.getAttribute(attributeId);
+ this.htmlToMarkdown = (html) => markdown.toMarkdown(html);
+
this.searchForNotes = (query, searchParams = {}) => {
if (searchParams.includeArchivedNotes === undefined) {
searchParams.includeArchivedNotes = true;