Skip to content

Build your personal knowledge base with Trilium Notes

feat(codemirror): enable nested syntax highlighting for MD (closes #9150)

Elian Doran438442345e38
diff --git a/packages/codemirror/package.json b/packages/codemirror/package.json
index 837ea1db6f..6d947aa4c3 100644
--- a/packages/codemirror/package.json
+++ b/packages/codemirror/package.json
@@ -12,6 +12,7 @@
"@codemirror/lang-javascript": "6.2.5",
"@codemirror/lang-json": "6.0.2",
"@codemirror/lang-markdown": "6.5.0",
+ "@codemirror/language-data": "6.5.1",
"@codemirror/lang-php": "6.0.2",
"@codemirror/lang-vue": "0.1.3",
"@codemirror/lang-xml": "6.1.0",
diff --git a/packages/codemirror/src/syntax_highlighting.ts b/packages/codemirror/src/syntax_highlighting.ts
index 518c84732b..d5c862f254 100644
--- a/packages/codemirror/src/syntax_highlighting.ts
+++ b/packages/codemirror/src/syntax_highlighting.ts
@@ -101,8 +101,10 @@ const byMimeType: Record<SupportedMimeTypes, (() => Promise<StreamParser<unknown
"text/x-gdscript": async () => (await import('./languages/gdscript.js')).gdscript,
"text/x-gfm": async () => {
const { markdown, markdownLanguage } = (await import('@codemirror/lang-markdown'));
+ const { languages } = (await import('@codemirror/language-data'));
return markdown({
- base: markdownLanguage
+ base: markdownLanguage,
+ codeLanguages: languages
});
},
"text/x-go": async () => (await import('@codemirror/legacy-modes/mode/go')).go,
@@ -124,7 +126,11 @@ const byMimeType: Record<SupportedMimeTypes, (() => Promise<StreamParser<unknown
"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-markdown": async () => ((await import('@codemirror/lang-markdown')).markdown()),
+ "text/x-markdown": async () => {
+ const { markdown } = (await import('@codemirror/lang-markdown'));
+ const { languages } = (await import('@codemirror/language-data'));
+ return markdown({ codeLanguages: languages });
+ },
"text/x-mathematica": async () => (await import('@codemirror/legacy-modes/mode/mathematica')).mathematica,
"text/x-modelica": async () => (await import('@codemirror/legacy-modes/mode/modelica')).modelica,
"text/x-mscgen": async () => (await import('@codemirror/legacy-modes/mode/mscgen')).mscgen,
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index d7d06a0e18..cdb5c47c72 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1226,6 +1226,9 @@ importers:
'@codemirror/lang-xml':
specifier: 6.1.0
version: 6.1.0
+ '@codemirror/language-data':
+ specifier: 6.5.1
+ version: 6.5.1
'@codemirror/legacy-modes':
specifier: 6.5.2
version: 6.5.2
@@ -2008,18 +2011,36 @@ packages:
'@codemirror/[email protected]':
resolution: {integrity: sha512-KlGVYufHMQzxbdQONiLyGQDUW0itrLZwq3CcY7xpv9ZLRHqzkBSoteocBHtMCoY7/Ci4xhzSrToIeLg7FxHuaw==}
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-oap+gsltb/fzdlTQWD6BFF4bSLKcDnlxDsLdePiJpCVNKWXSTAbiiQeYI3UmES+BLAdkmIC1WjyztC1pi/bX4g==}
+
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-URM26M3vunFFn9/sm6rzqrBzDgfWuDixp85uTY49wKudToc2jTHUrKIGGKs+QWND+YLofNNZpxcNGRynFJfvgA==}
+
'@codemirror/[email protected]':
resolution: {integrity: sha512-kr5fwBGiGtmz6l0LSJIbno9QrifNMUusivHbnA1H6Dmqy4HZFte3UAICix1VuKo0lMPKQr2rqB+0BkKi/S3Ejg==}
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-7fNvbyNylvqCphW9HD6WFnRpcDjr+KXX/FgqXy5H5ZS0eC5edDljukm/yNgYkwTsgp2busdod50AOTIy6Jikfg==}
+
'@codemirror/[email protected]':
resolution: {integrity: sha512-9NsXp7Nwp891pQchI7gPdTwBuSuT3K65NGTHWHNJ55HjYcHLllr0rbIZNdOzas9ztc1EUVBlHou85FFZS4BNnw==}
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-m5Nt1mQ/cznJY7tMfQTJchmrjdjQ71IDs+55d1GAa8DGaB8JXWsVCkVT284C3RTASaY43YknrK2X3hPO/J3MOQ==}
+
'@codemirror/[email protected]':
resolution: {integrity: sha512-zD4e5mS+50htS7F+TYjBPsiIFGanfVqg4HyUz6WNFikgOPf2BgKlx+TQedI1w6n/IqRBVBbBWmGFdLB/7uxO4A==}
'@codemirror/[email protected]':
resolution: {integrity: sha512-x2OtO+AvwEHrEwR0FyyPtfDUiloG3rnVTSZV1W8UteaLL8/MajQd8DpvUb2YVzC+/T18aSDv0H9mu+xw0EStoQ==}
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-EYdQTG22V+KUUk8Qq582g7FMnCZeEHsyuOJisHRft/mQ+ZSZ2w51NupvDUHiqtsOy7It5cHLPGfHQLpMh9bqpQ==}
+
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-6PDVU3ZnfeYyz1at1E/ttorErZvZFXXt1OPhtfe1EZJ2V2iDFa0CwPqPgG5F7NXN0yONGoBogKmFAafKTqlwIw==}
+
'@codemirror/[email protected]':
resolution: {integrity: sha512-c/5MYinGbFxYl4itE9q/rgN/sMTjOr8XL5OWnC+EaRMLfCbVUmmubTJfdgpfcSS2SCaT7b+Q+xi3l6CgoE+BsA==}
@@ -2029,12 +2050,33 @@ packages:
'@codemirror/[email protected]':
resolution: {integrity: sha512-ZKy2v1n8Fc8oEXj0Th0PUMXzQJ0AIR6TaZU+PbDHExFwdu+guzOA4jmCHS1Nz4vbFezwD7LyBdDnddSJeScMCA==}
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-IRjC8RUBhn9mGR9ywecNhB51yePWCGgvHfY1lWN/Mrp3cKuHr0isDKia+9HnvhiWNnMpbGhWrkhuWOc09exRyw==}
+
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-EZaGjCUegtiU7kSMvOfEZpaCReowEf3yNidYu7+vfuGTm9ow4mthAparY5hisJqOHmJowVH3Upu+eJlUji6qqA==}
+
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-l/bdzIABvnTo1nzdY6U+kPAC51czYQcOErfzQ9zSm9D8GmNPD0WTW8st/CJwBTPLO8jlrbyvlSEcN20dc4iL0Q==}
+
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-6ayPkEd/yRw0XKBx5uAiToSgGECo/GY2NoJIHXIIQh1EVwLuKoU8BP/qK0qH5NLXAbtJRLuT73hx7P9X34iO4w==}
+
'@codemirror/[email protected]':
resolution: {integrity: sha512-QSKdtYTDRhEHCfo5zOShzxCmqKJvgGrZwDQSdbvCRJ5pRLWBS7pD/8e/tH44aVQT6FKm0t6RVNoSUWHOI5vNug==}
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-Imi2KTpVGm7TKuUkqyJ5NRmeFWF7aMpNiwHnLQe0x9kmrxElndyH0K6H/gXtWwY6UshMRAhpENsgfpSwsgmC6Q==}
+
'@codemirror/[email protected]':
resolution: {integrity: sha512-3z0blhicHLfwi2UgkZYRPioSgVTo9PV5GP5ducFH6FaHy0IAJRg+ixj5gTR1gnT/glAIC8xv4w2VL1LoZfs+Jg==}
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-AZ8DJBuXGVHybpBQhmZtgew5//4hv3tdkXnr3vDmOUMJRuB6vn/uuwtmTOTlqEaQFg3hQSVeA90NmvIQyUV6FQ==}
+
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-0sWxeUSNlBr6OmkqybUTImADFUP0M3P0IiSde4nc24bz/6jIYzqYSgkOSLS+CBIoW1vU8Q9KUWXscBXeoMVC9w==}
+
'@codemirror/[email protected]':
resolution: {integrity: sha512-QwCZW6Tt1siP37Jet9Tb02Zs81TQt6qQrZR2H+eGMcFsL1zMrk2/b9CLC7/9ieP1fjIUMgviLWMmgiHoJrj+ZA==}
@@ -3627,15 +3669,24 @@ packages:
resolution: {integrity: sha512-sxQE460fPZyU3sdc8lafxiPwJHBzZRy/udNFynGQky1SePYBdhkBl1kOagA9uT3pxR8K09bOrmTUqA9wb/PjSQ==}
+ '@lezer/[email protected]':
+ resolution: {integrity: sha512-DIhSXmYtJKLehrjzDFN+2cPt547ySQ41nA8yqcDf/GxMc+YM736xqltFkvADL2M0VebU5I+3+4ks2Vv+Kyq3Aw==}
+
resolution: {integrity: sha512-FuAnusbLBl1SEAtfN8NdShxYJiESKw9LAFysfea1T96jD3ydBn12oYjaSG1a04BQRIUd93/0D8e5CV1cUMkmQg==}
+ '@lezer/[email protected]':
+ resolution: {integrity: sha512-xToRsYxwsgJNHTgNdStpcvmbVuKxTapV0dM0wey1geMMRc9aggoVyKgzYp41D2/vVOx+Ii4hmE206kvxIXBVXQ==}
+
resolution: {integrity: sha512-qXdH7UqTvGfdVBINrgKhDsVTJTxactNNxLk7+UMwZhU13lMHaOBlJe9Vqp907ya56Y3+ed2tlqzys7jDkTmW0g==}
resolution: {integrity: sha512-RJ7eRWdaJe3bsiiLLHjCFT1JMk8m1YP9kaUbvu2rMLEoOnke9mcTVDyfOslsln0LtujdWespjJ39w6zo+RsQYw==}
+ '@lezer/[email protected]':
+ resolution: {integrity: sha512-yHquUfujwg6Yu4Fd1GNHCvidIvJwi/1Xu2DaKl/pfWIA2c1oXkVvawH3NyXhCaFx4OdlYBVX5wvz2f7Aoa/4Xw==}
+
resolution: {integrity: sha512-ATOImjeVJuvgm3JQ/bpo2Tmv55HSScE2MTPnKRMRIPx2cLhHGyX2VnqpHhtIV1tVzIjZDbcWQm+NCTF40ggZVw==}
@@ -3651,9 +3702,21 @@ packages:
resolution: {integrity: sha512-GN7BnqtGRpFyeoKSEqxvGvhJQiI4zkgmYnDk/JIyc7H7Ifc1tkPnUn/R2R8meH3h/aBf5rzjvU8ZQoyiNDtDrA==}
+ '@lezer/[email protected]':
+ resolution: {integrity: sha512-31FiUrU7z9+d/ElGQLJFXl+dKOdx0jALlP3KEOsGTex8mvj+SoE1FgItcHWK/axkxCHGUSpqIHt6JAWfWu9Rhg==}
+
+ '@lezer/[email protected]':
+ resolution: {integrity: sha512-Lz5sIPBdF2FUXcWeCu1//ojFAZqzTQNRga0aYv6dYXqJqPfMdCAI0NzajWUd4Xijj1IKJLtjoXRPMvTKWBcqKg==}
+
+ '@lezer/[email protected]':
+ resolution: {integrity: sha512-3mMGdCTUZ/84ArHOuXWQr37pnf7f+Nw9ycPUeKX+wu19b7pSMcZGLbaXwvD2APMBDOGxPmpK/O6S1v1EvLoqgQ==}
+
resolution: {integrity: sha512-CdDwirL0OEaStFue/66ZmFSeppuL6Dwjlk8qk153mSQwiSH/Dlri4GNymrNWnUmPl2Um7QfV1FO9KFUyX3Twww==}
+ '@lezer/[email protected]':
+ resolution: {integrity: sha512-2lrrHqxalACEbxIbsjhqGpSW8kWpUKuY6RHgnSAFZa6qK62wvnPxA8hGOwOoDbwHcOFs5M4o27mjGu+P7TvBmw==}
+
'@listr2/[email protected]':
resolution: {integrity: sha512-hV36ZoY+xKL6pYOt1nPNnkciFkn89KZwqLhAFzJvYysAvL5uBQdiADZx/8bIDXIukzzwG0QlPYolgMzQUtKgpQ==}
engines: {node: '>=18.0.0'}
@@ -15453,6 +15516,20 @@ snapshots:
'@codemirror/view': 6.41.0
'@lezer/common': 1.5.2
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/lang-html': 6.4.11
+ '@codemirror/lang-javascript': 6.2.5
+ '@codemirror/language': 6.12.3
+ '@lezer/common': 1.5.2
+ '@lezer/highlight': 1.2.3
+ '@lezer/lr': 1.4.2
+
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/language': 6.12.3
+ '@lezer/cpp': 1.1.5
+
'@codemirror/[email protected]':
dependencies:
'@codemirror/autocomplete': 6.18.6
@@ -15461,6 +15538,14 @@ snapshots:
'@lezer/common': 1.5.2
'@lezer/css': 1.1.11
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/autocomplete': 6.18.6
+ '@codemirror/language': 6.12.3
+ '@codemirror/state': 6.6.0
+ '@lezer/common': 1.5.2
+ '@lezer/go': 1.0.1
+
'@codemirror/[email protected]':
dependencies:
'@codemirror/autocomplete': 6.18.6
@@ -15473,6 +15558,11 @@ snapshots:
'@lezer/css': 1.1.11
'@lezer/html': 1.3.12
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/language': 6.12.3
+ '@lezer/java': 1.1.3
+
'@codemirror/[email protected]':
dependencies:
'@codemirror/autocomplete': 6.18.6
@@ -15488,6 +15578,25 @@ snapshots:
'@codemirror/language': 6.12.3
'@lezer/json': 1.0.3
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/lang-css': 6.3.1
+ '@codemirror/language': 6.12.3
+ '@lezer/common': 1.5.2
+ '@lezer/highlight': 1.2.3
+ '@lezer/lr': 1.4.2
+
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/autocomplete': 6.18.6
+ '@codemirror/lang-html': 6.4.11
+ '@codemirror/language': 6.12.3
+ '@codemirror/state': 6.6.0
+ '@codemirror/view': 6.41.0
+ '@lezer/common': 1.5.2
+ '@lezer/highlight': 1.2.3
+ '@lezer/lr': 1.4.2
+
'@codemirror/[email protected]':
dependencies:
'@codemirror/autocomplete': 6.18.6
@@ -15516,6 +15625,36 @@ snapshots:
'@lezer/common': 1.5.2
'@lezer/php': 1.0.2
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/autocomplete': 6.18.6
+ '@codemirror/language': 6.12.3
+ '@codemirror/state': 6.6.0
+ '@lezer/common': 1.5.2
+ '@lezer/python': 1.1.18
+
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/language': 6.12.3
+ '@lezer/rust': 1.0.2
+
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/lang-css': 6.3.1
+ '@codemirror/language': 6.12.3
+ '@codemirror/state': 6.6.0
+ '@lezer/common': 1.5.2
+ '@lezer/sass': 1.1.0
+
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/autocomplete': 6.18.6
+ '@codemirror/language': 6.12.3
+ '@codemirror/state': 6.6.0
+ '@lezer/common': 1.5.2
+ '@lezer/highlight': 1.2.3
+ '@lezer/lr': 1.4.2
+
'@codemirror/[email protected]':
dependencies:
'@codemirror/lang-html': 6.4.11
@@ -15525,6 +15664,13 @@ snapshots:
'@lezer/highlight': 1.2.3
'@lezer/lr': 1.4.2
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/language': 6.12.3
+ '@lezer/common': 1.5.2
+ '@lezer/highlight': 1.2.3
+ '@lezer/lr': 1.4.2
+
'@codemirror/[email protected]':
dependencies:
'@codemirror/autocomplete': 6.18.6
@@ -15534,6 +15680,41 @@ snapshots:
'@lezer/common': 1.5.2
'@lezer/xml': 1.0.6
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/autocomplete': 6.18.6
+ '@codemirror/language': 6.12.3
+ '@codemirror/state': 6.6.0
+ '@lezer/common': 1.5.2
+ '@lezer/highlight': 1.2.3
+ '@lezer/lr': 1.4.2
+ '@lezer/yaml': 1.0.4
+
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/lang-angular': 0.1.4
+ '@codemirror/lang-cpp': 6.0.3
+ '@codemirror/lang-css': 6.3.1
+ '@codemirror/lang-go': 6.0.1
+ '@codemirror/lang-html': 6.4.11
+ '@codemirror/lang-java': 6.0.2
+ '@codemirror/lang-javascript': 6.2.5
+ '@codemirror/lang-json': 6.0.2
+ '@codemirror/lang-less': 6.0.2
+ '@codemirror/lang-liquid': 6.3.2
+ '@codemirror/lang-markdown': 6.5.0
+ '@codemirror/lang-php': 6.0.2
+ '@codemirror/lang-python': 6.2.1
+ '@codemirror/lang-rust': 6.0.2
+ '@codemirror/lang-sass': 6.0.2
+ '@codemirror/lang-sql': 6.10.0
+ '@codemirror/lang-vue': 0.1.3
+ '@codemirror/lang-wast': 6.0.2
+ '@codemirror/lang-xml': 6.1.0
+ '@codemirror/lang-yaml': 6.1.3
+ '@codemirror/language': 6.12.3
+ '@codemirror/legacy-modes': 6.5.2
+
'@codemirror/[email protected]':
dependencies:
'@codemirror/state': 6.6.0
@@ -17280,12 +17461,24 @@ snapshots:
'@lezer/[email protected]': {}
+ '@lezer/[email protected]':
+ dependencies:
+ '@lezer/common': 1.5.2
+ '@lezer/highlight': 1.2.3
+ '@lezer/lr': 1.4.2
+
dependencies:
'@lezer/common': 1.5.2
'@lezer/highlight': 1.2.3
'@lezer/lr': 1.4.2
+ '@lezer/[email protected]':
+ dependencies:
+ '@lezer/common': 1.5.2
+ '@lezer/highlight': 1.2.3
+ '@lezer/lr': 1.4.2
+
dependencies:
'@lezer/common': 1.5.2
@@ -17296,6 +17489,12 @@ snapshots:
'@lezer/highlight': 1.2.3
'@lezer/lr': 1.4.2
+ '@lezer/[email protected]':
+ dependencies:
+ '@lezer/common': 1.5.2
+ '@lezer/highlight': 1.2.3
+ '@lezer/lr': 1.4.2
+
dependencies:
'@lezer/common': 1.5.2
@@ -17323,12 +17522,36 @@ snapshots:
'@lezer/highlight': 1.2.3
'@lezer/lr': 1.4.2
+ '@lezer/[email protected]':
+ dependencies:
+ '@lezer/common': 1.5.2
+ '@lezer/highlight': 1.2.3
+ '@lezer/lr': 1.4.2
+
+ '@lezer/[email protected]':
+ dependencies:
+ '@lezer/common': 1.5.2
+ '@lezer/highlight': 1.2.3
+ '@lezer/lr': 1.4.2
+
+ '@lezer/[email protected]':
+ dependencies:
+ '@lezer/common': 1.5.2
+ '@lezer/highlight': 1.2.3
+ '@lezer/lr': 1.4.2
+
dependencies:
'@lezer/common': 1.5.2
'@lezer/highlight': 1.2.3
'@lezer/lr': 1.4.2
+ '@lezer/[email protected]':
+ dependencies:
+ '@lezer/common': 1.5.2
+ '@lezer/highlight': 1.2.3
+ '@lezer/lr': 1.4.2
+
'@listr2/[email protected](@inquirer/[email protected])':
dependencies:
'@inquirer/prompts': 6.0.1