Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
docs(codemirror): credit Mermaid's parsers for the Mermaid grammars
Elian Doranbce032461991
diff --git a/.claude/skills/developing-mermaid-highlighting/SKILL.md b/.claude/skills/developing-mermaid-highlighting/SKILL.mdindex 60351a641a..2242acb009 100644--- a/.claude/skills/developing-mermaid-highlighting/SKILL.md+++ b/.claude/skills/developing-mermaid-highlighting/SKILL.md@@ -31,7 +31,8 @@ languages/mermaid/parsers/line_text.ts lineText(): the "rest of the line after a keyword" tokenizer (titles, styles)test/<diagram>.txt Lezer fixtures, one file per parsers/ directory, same namemermaid.spec.ts runs every fixture file, checks generated parsers are current- LICENSE upstream MIT licence — keep it+ LICENSE MIT notices of codemirror-lang-mermaid, @mermaid-js/parser and Mermaid+ — keep them```How a document parses: `mermaid.grammar` first takes the front matter, the way Mermaid does: a `---`@@ -125,7 +126,9 @@ extension (Mermaid-Chart/vscode-mermaid-chart, `syntaxes/`) only lists keywords.case per construct. Add a detection case to `test/mermaid.txt`.7. **Map Mermaid's id** to the node in `HIGHLIGHTED_AS` (`mermaid_highlighting.spec.ts`), and runit: `cd apps/client && pnpm exec vitest run src/widgets/type_widgets/mermaid`.-8. Regenerate, run the suite, measure coverage.+8. **Credit the source** in `LICENSE`: add the diagram to the section of the parser it follows+ (`@mermaid-js/parser` for Langium, Mermaid for Jison and Chevrotain).+9. Regenerate, run the suite, measure coverage.## Lezer traps already hitdiff --git a/README.md b/README.mdindex 944f979209..e686e04e62 100644--- a/README.md+++ b/README.md@@ -241,6 +241,8 @@ Trilium would not be possible without the technologies behind it:* [CKEditor 5](https://github.com/ckeditor/ckeditor5) - the visual editor behind text notes.* [CodeMirror](https://github.com/codemirror/CodeMirror) - code editor with support for huge amount of languages.+* [Mermaid](https://github.com/mermaid-js/mermaid) - renders the diagrams of Mermaid notes; its parsers are the model for their syntax highlighting.+* [codemirror-lang-mermaid](https://github.com/inspirnathan/codemirror-lang-mermaid) - the base of the Mermaid syntax highlighting.* [Excalidraw](https://github.com/excalidraw/excalidraw) - the infinite whiteboard used in Canvas notes.* [Mind Elixir](https://github.com/SSShooter/mind-elixir-core) - providing the mind map functionality.* [Leaflet](https://github.com/Leaflet/Leaflet) - for rendering geographical maps.diff --git a/docs/README.md b/docs/README.mdindex 2b66afc430..f3eae2b76f 100644--- a/docs/README.md+++ b/docs/README.md@@ -241,6 +241,8 @@ Trilium would not be possible without the technologies behind it:* [CKEditor 5](https://github.com/ckeditor/ckeditor5) - the visual editor behind text notes.* [CodeMirror](https://github.com/codemirror/CodeMirror) - code editor with support for huge amount of languages.+* [Mermaid](https://github.com/mermaid-js/mermaid) - renders the diagrams of Mermaid notes; its parsers are the model for their syntax highlighting.+* [codemirror-lang-mermaid](https://github.com/inspirnathan/codemirror-lang-mermaid) - the base of the Mermaid syntax highlighting.* [Excalidraw](https://github.com/excalidraw/excalidraw) - the infinite whiteboard used in Canvas notes.* [Mind Elixir](https://github.com/SSShooter/mind-elixir-core) - providing the mind map functionality.* [Leaflet](https://github.com/Leaflet/Leaflet) - for rendering geographical maps.diff --git a/packages/codemirror/src/languages/mermaid/LICENSE b/packages/codemirror/src/languages/mermaid/LICENSEindex 4c1d7ef13f..fe15c00e13 100644--- a/packages/codemirror/src/languages/mermaid/LICENSE+++ b/packages/codemirror/src/languages/mermaid/LICENSE@@ -1,3 +1,13 @@+The Mermaid language in this directory contains code from the MIT-licensed+projects below.++================================================================================+codemirror-lang-mermaid+https://github.com/inspirnathan/codemirror-lang-mermaid, vendored from the fork+at https://github.com/Edge-Tools/codemirror-lang-mermaid. The dispatcher and the+grammars that the sections below do not name come from it, changed since.+================================================================================+MIT LicenseCopyright (C) 2023 by Nathan Vaughn <[email protected]>@@ -19,3 +29,60 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.++================================================================================+@mermaid-js/parser+https://github.com/mermaid-js/mermaid/tree/develop/packages/parser. The radar,+treemap, tree view, Wardley, Cynefin, event modeling and railroad grammars+follow its Langium grammars.+================================================================================++The MIT License (MIT)++Copyright (c) 2023 Yokozuna59++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.++================================================================================+Mermaid+https://github.com/mermaid-js/mermaid. The Ishikawa and Venn grammars follow its+Jison grammars, and the use case grammar follows its Chevrotain lexer.+================================================================================++The MIT License (MIT)++Copyright (c) 2014 - 2022 Knut Sveidqvist++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.diff --git a/packages/codemirror/src/languages/mermaid/index.ts b/packages/codemirror/src/languages/mermaid/index.tsindex 89ed410dcf..eda307184d 100644--- a/packages/codemirror/src/languages/mermaid/index.ts+++ b/packages/codemirror/src/languages/mermaid/index.ts@@ -1,5 +1,6 @@// Mermaid language support, vendored from https://github.com/Edge-Tools/codemirror-lang-mermaid-// (itself a fork of https://github.com/inspirnathan/codemirror-lang-mermaid); MIT, see LICENSE.+// (itself a fork of https://github.com/inspirnathan/codemirror-lang-mermaid). Newer grammars follow+// Mermaid's own parsers. MIT, see LICENSE.// After editing a `.grammar` file, regenerate its parser with// `pnpm --filter @triliumnext/codemirror build:mermaid-grammars`.import { yamlLanguage } from "@codemirror/lang-yaml";