From 2bdfa8e77b5f2ba26ffbfef3d3b1c789516986c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Sat, 29 Jun 2024 19:57:56 -0400 Subject: [PATCH] nits --- src/api/script-cache.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/api/script-cache.ts b/src/api/script-cache.ts index bab10612..fbf708f7 100644 --- a/src/api/script-cache.ts +++ b/src/api/script-cache.ts @@ -52,6 +52,7 @@ export class ScriptCache { /** Attempts to resolve the source to load given a path or link to a markdown section. */ private async resolveSource(path: string | Link, sourcePath?: string): Promise> { const object = this.store.resolveLink(path); + const prefixRegex = /datacore\s?/i; if (!object) return Result.failure("Could not find a script at the given path: " + path.toString()); const tfile = this.store.vault.getFileByPath(object.$file!); @@ -66,14 +67,14 @@ export class ScriptCache { // Load the script. } else if (object instanceof MarkdownCodeblock) { - if (object.$languages.some((x) => ScriptCache.SCRIPT_TAGS.includes(x.replace(/datacore\s?/i, "")))) + if (object.$languages.some((x) => ScriptCache.SCRIPT_TAGS.includes(x.replace(prefixRegex, "")))) codeBlock = object; } if (!codeBlock) return Result.failure("Could not find a script in the given markdown section: " + path.toString()); - let lang = codeBlock.$languages.find((a) => ScriptCache.SCRIPT_TAGS.includes(a)); + let lang = codeBlock.$languages.find((a) => ScriptCache.SCRIPT_TAGS.includes(a.replace(prefixRegex, "")))!.replace(prefixRegex, ""); if (lang?.toLocaleLowerCase() === "typescript") lang = "ts"; else if (lang?.toLocaleLowerCase() === "javascript") lang = "js";