Skip to content

Build your personal knowledge base with Trilium Notes

fix(code): highlight ASN.1 and MariaDB code notes with their grammars

Elian Doran28656c7b8c68
diff --git a/packages/codemirror/src/syntax_highlighting.spec.ts b/packages/codemirror/src/syntax_highlighting.spec.ts
index 4f2f91aa60..93374f4c1a 100644
--- a/packages/codemirror/src/syntax_highlighting.spec.ts
+++ b/packages/codemirror/src/syntax_highlighting.spec.ts
@@ -53,6 +53,14 @@ describe("byMimeType", () => {
expect(byMimeType["application/x-ejs"]).toBeNull();
});
+ it("highlights ASN.1 and MariaDB with their own grammars", async () => {
+ const asn1 = await byMimeType["text/x-ttcn-asn"]?.();
+ expect(asn1).toMatchObject({ name: "asn1" });
+
+ const { mariaDB } = await import("@codemirror/legacy-modes/mode/sql");
+ expect(await byMimeType["text/x-mariadb"]?.()).toBe(mariaDB);
+ });
+
it("highlights the statements of slow queries in the Trilium log as SQLite", async () => {
const syntax = await byMimeType["text/x-trilium-log"]?.();
expect(Array.isArray(syntax)).toBe(true);
diff --git a/packages/codemirror/src/syntax_highlighting.ts b/packages/codemirror/src/syntax_highlighting.ts
index b562fdecef..de466e0b4c 100644
--- a/packages/codemirror/src/syntax_highlighting.ts
+++ b/packages/codemirror/src/syntax_highlighting.ts
@@ -151,7 +151,7 @@ const byMimeType: Record<SupportedMimeTypes, (() => Promise<StreamParser<unknown
"text/x-literate-haskell": null,
"text/x-livescript": async () => (await import('@codemirror/legacy-modes/mode/livescript')).liveScript,
"text/x-lua": async () => (await import('@codemirror/legacy-modes/mode/lua')).lua,
- "text/x-mariadb": async () => (await import('@codemirror/legacy-modes/mode/sql')).sqlite,
+ "text/x-mariadb": async () => (await import('@codemirror/legacy-modes/mode/sql')).mariaDB,
"text/x-markdown": buildMarkdown,
"text/x-mathematica": async () => (await import('@codemirror/legacy-modes/mode/mathematica')).mathematica,
"text/x-modelica": async () => (await import('@codemirror/legacy-modes/mode/modelica')).modelica,
@@ -214,7 +214,7 @@ const byMimeType: Record<SupportedMimeTypes, (() => Promise<StreamParser<unknown
"text/x-tornado": null,
"text/x-trilium-log": buildTriliumLog,
"text/x-trilium-search": async () => [ (await import('./extensions/trilium_search_highlighter.js')).triliumSearchHighlighter ],
- "text/x-ttcn-asn": async () => (await import('@codemirror/legacy-modes/mode/ttcn')).ttcn,
+ "text/x-ttcn-asn": async () => (await import('@codemirror/legacy-modes/mode/asn1')).asn1({ multiLineStrings: true }),
"text/x-ttcn-cfg": async () => (await import('@codemirror/legacy-modes/mode/ttcn-cfg')).ttcnCfg,
"text/x-ttcn": async () => (await import('@codemirror/legacy-modes/mode/ttcn')).ttcn,
"text/x-twig": async () => ((await import('@ssddanbrown/codemirror-lang-twig')).twig()),