diff --git a/docs/Release Notes/Release Notes/v0.94.0.md b/docs/Release Notes/Release Notes/v0.94.0.md index a1770bf4e..3b2c8e54a 100644 --- a/docs/Release Notes/Release Notes/v0.94.0.md +++ b/docs/Release Notes/Release Notes/v0.94.0.md @@ -36,6 +36,8 @@ * Added the Nix language (and also in code blocks for text notes). * Added an indentation marker. * Note: syntax highlighting for some languages (mostly HTML-template languages such as EJS, JSP) is no longer supported due to lack of upstream support. If this is a problem, feel free to report an issue and we can see what can be done about it. +* Syntax highlighting in code blocks for text notes: + * Added support for Cypher. * Mermaid diagrams: basic syntax highlight (not all diagram types are supported) and code folding. * Slight organization in Appearance settings: code block themes are now in "Text Notes", added a "Related settings" section in Appearance. * [Added support for opening and activating a note in a new tab using Ctrl+Shift+click on notes in the launcher pane, note tree, or note images](https://github.com/TriliumNext/Notes/pull/1854) by @SiriusXT diff --git a/packages/highlightjs/package.json b/packages/highlightjs/package.json index e5b0a3c07..d49889360 100644 --- a/packages/highlightjs/package.json +++ b/packages/highlightjs/package.json @@ -21,6 +21,7 @@ "dependencies": { "@exercism/highlightjs-gdscript": "0.0.1", "@triliumnext/commons": "workspace:*", - "highlight.js": "11.11.1" + "highlight.js": "11.11.1", + "highlightjs-cypher": "1.2.0" } } diff --git a/packages/highlightjs/src/syntax_highlighting.ts b/packages/highlightjs/src/syntax_highlighting.ts index 0c3875877..f5d4abf86 100644 --- a/packages/highlightjs/src/syntax_highlighting.ts +++ b/packages/highlightjs/src/syntax_highlighting.ts @@ -6,7 +6,7 @@ type MimeRecord = Record Promise<{ default: LanguageFn}>) | null> const byMimeType: MimeRecord = { "text/plain": () => import("highlight.js/lib/languages/plaintext"), "application/dart": () => import("highlight.js/lib/languages/dart"), - "application/edn": null, + "application/edn": () => import("highlight.js/lib/languages/clojure"), "application/javascript;env=backend": () => import("highlight.js/lib/languages/javascript"), "application/javascript;env=frontend": () => import("highlight.js/lib/languages/javascript"), "application/json": () => import("highlight.js/lib/languages/json"), @@ -19,7 +19,7 @@ const byMimeType: MimeRecord = { "application/typescript": () => import("highlight.js/lib/languages/typescript"), "application/x-aspx": null, "application/x-bat": () => import("highlight.js/lib/languages/dos"), - "application/x-cypher-query": null, + "application/x-cypher-query": () => import("highlightjs-cypher"), "application/x-ejs": null, "application/x-erb": () => import("highlight.js/lib/languages/erb"), "application/x-jsp": () => import("highlight.js/lib/languages/java"), diff --git a/packages/highlightjs/src/types.d.ts b/packages/highlightjs/src/types.d.ts index ae56ed768..e2921a2d0 100644 --- a/packages/highlightjs/src/types.d.ts +++ b/packages/highlightjs/src/types.d.ts @@ -3,3 +3,9 @@ declare module '@exercism/highlightjs-gdscript' { const defineLanguage: LanguageFn; export default defineLanguage; } + +declare module 'highlightjs-cypher' { + import { LanguageFn } from "highlight.js"; + const defineLanguage: LanguageFn; + export default defineLanguage; +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index be2e6135d..24f52aea7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1292,6 +1292,9 @@ importers: highlight.js: specifier: 11.11.1 version: 11.11.1 + highlightjs-cypher: + specifier: 1.2.0 + version: 1.2.0 packages/turndown-plugin-gfm: dependencies: @@ -8755,6 +8758,9 @@ packages: resolution: {integrity: sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w==} engines: {node: '>=12.0.0'} + highlightjs-cypher@1.2.0: + resolution: {integrity: sha512-mOY/g6R1MgXiYx07icl8nwtXCRDSy4Y9EAlDZKia8Thqe766v6cjnrD6/xWak9UXoLQfWqbHhmRmYuw0SiO+CA==} + history@4.10.1: resolution: {integrity: sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew==} @@ -24007,6 +24013,11 @@ snapshots: highlight.js@11.11.1: {} + highlightjs-cypher@1.2.0: + dependencies: + minimist: 1.2.8 + mkdirp: 1.0.4 + history@4.10.1: dependencies: '@babel/runtime': 7.27.0