@mermanjs/tree-sitter-mermaid 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CMakeLists.txt +44 -0
- package/LICENSE +22 -0
- package/Makefile +80 -0
- package/README.md +201 -0
- package/THIRD_PARTY_LICENSES/mermaid/LICENSE +21 -0
- package/THIRD_PARTY_LICENSES/monaqa-tree-sitter-mermaid/LICENSE +21 -0
- package/THIRD_PARTY_LICENSES/pappasam-tree-sitter-mermaid/LICENSE +21 -0
- package/THIRD_PARTY_LICENSES/singularity-tree-sitter-mermaid/LICENSE +22 -0
- package/THIRD_PARTY_LICENSES/tree-sitter/LICENSE +21 -0
- package/THIRD_PARTY_LICENSES/zenuml-core/LICENSE +21 -0
- package/THIRD_PARTY_NOTICES.md +47 -0
- package/binding.gyp +56 -0
- package/bindings/c/tree-sitter-mermaid.pc.in +10 -0
- package/bindings/c/tree_sitter/tree-sitter-mermaid.h +16 -0
- package/bindings/node/binding.cc +25 -0
- package/bindings/node/index.d.ts +5 -0
- package/bindings/node/index.js +10 -0
- package/grammar/families/architecture.js +361 -0
- package/grammar/families/block.js +370 -0
- package/grammar/families/c4.js +394 -0
- package/grammar/families/class.js +441 -0
- package/grammar/families/cynefin.js +127 -0
- package/grammar/families/entity-relationship.js +408 -0
- package/grammar/families/event-modeling.js +307 -0
- package/grammar/families/flowchart.js +690 -0
- package/grammar/families/gantt.js +445 -0
- package/grammar/families/git-graph.js +326 -0
- package/grammar/families/info.js +77 -0
- package/grammar/families/ishikawa.js +103 -0
- package/grammar/families/journey.js +221 -0
- package/grammar/families/kanban.js +264 -0
- package/grammar/families/mindmap.js +221 -0
- package/grammar/families/packet.js +108 -0
- package/grammar/families/pie.js +118 -0
- package/grammar/families/quadrant-chart.js +385 -0
- package/grammar/families/radar.js +286 -0
- package/grammar/families/railroad-abnf.js +124 -0
- package/grammar/families/railroad-ebnf.js +179 -0
- package/grammar/families/railroad-peg.js +128 -0
- package/grammar/families/railroad-shared.js +114 -0
- package/grammar/families/railroad.js +143 -0
- package/grammar/families/requirement.js +475 -0
- package/grammar/families/sankey.js +139 -0
- package/grammar/families/sequence.js +437 -0
- package/grammar/families/state.js +400 -0
- package/grammar/families/swimlane.js +25 -0
- package/grammar/families/timeline.js +251 -0
- package/grammar/families/tree-view.js +189 -0
- package/grammar/families/treemap.js +146 -0
- package/grammar/families/venn.js +256 -0
- package/grammar/families/wardley.js +530 -0
- package/grammar/families/xy-chart.js +460 -0
- package/grammar/families/zenuml.js +725 -0
- package/grammar/shared/common.js +78 -0
- package/grammar/shared/header.js +16 -0
- package/grammar/shared/indentation.js +22 -0
- package/grammar/shared/langium.js +166 -0
- package/grammar/shared/preamble.js +26 -0
- package/grammar.js +188 -0
- package/metadata/derivations.json +519 -0
- package/metadata/provenance.json +98 -0
- package/package.json +107 -0
- package/prebuilds/darwin-arm64/@mermanjs+tree-sitter-mermaid.node +0 -0
- package/prebuilds/darwin-x64/@mermanjs+tree-sitter-mermaid.node +0 -0
- package/prebuilds/linux-x64/@mermanjs+tree-sitter-mermaid.node +0 -0
- package/prebuilds/win32-x64/@mermanjs+tree-sitter-mermaid.node +0 -0
- package/queries/helix/highlights.scm +960 -0
- package/queries/helix/indents.scm +45 -0
- package/queries/helix/injections.scm +15 -0
- package/queries/helix/locals.scm +134 -0
- package/queries/helix/textobjects.scm +264 -0
- package/queries/neovim/README.md +28 -0
- package/queries/neovim/brackets.scm +65 -0
- package/queries/neovim/folds.scm +53 -0
- package/queries/neovim/highlights.scm +121 -0
- package/queries/neovim/indents.scm +110 -0
- package/queries/neovim/injections.scm +86 -0
- package/queries/neovim/locals.scm +277 -0
- package/queries/neovim/outline.scm +117 -0
- package/queries/neovim/tags.scm +149 -0
- package/queries/neovim/textobjects.scm +97 -0
- package/queries/portable/highlights.scm +961 -0
- package/queries/portable/injections.scm +45 -0
- package/queries/portable/locals.scm +290 -0
- package/queries/portable/tags.scm +182 -0
- package/queries/zed/README.md +48 -0
- package/queries/zed/brackets.scm +111 -0
- package/queries/zed/highlights.scm +961 -0
- package/queries/zed/indents.scm +111 -0
- package/queries/zed/injections.scm +11 -0
- package/queries/zed/outline.scm +167 -0
- package/queries/zed/textobjects.scm +68 -0
- package/src/grammar.json +71138 -0
- package/src/node-types.json +34871 -0
- package/src/parser.c +321353 -0
- package/src/scanner.c +462 -0
- package/src/tree_sitter/alloc.h +54 -0
- package/src/tree_sitter/array.h +336 -0
- package/src/tree_sitter/parser.h +286 -0
- package/tree-sitter-mermaid.wasm +0 -0
- package/tree-sitter.json +40 -0
package/CMakeLists.txt
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.13)
|
|
2
|
+
|
|
3
|
+
project(tree-sitter-mermaid
|
|
4
|
+
VERSION "0.1.0"
|
|
5
|
+
DESCRIPTION "Tolerant Tree-sitter grammar and editor queries for Mermaid"
|
|
6
|
+
HOMEPAGE_URL "https://github.com/Latias94/merman"
|
|
7
|
+
LANGUAGES C)
|
|
8
|
+
|
|
9
|
+
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
|
|
10
|
+
option(TREE_SITTER_REUSE_ALLOCATOR "Reuse the Tree-sitter runtime allocator" OFF)
|
|
11
|
+
|
|
12
|
+
add_library(tree-sitter-mermaid src/parser.c src/scanner.c)
|
|
13
|
+
target_include_directories(tree-sitter-mermaid PRIVATE src)
|
|
14
|
+
target_compile_definitions(
|
|
15
|
+
tree-sitter-mermaid
|
|
16
|
+
PRIVATE
|
|
17
|
+
$<$<BOOL:${TREE_SITTER_REUSE_ALLOCATOR}>:TREE_SITTER_REUSE_ALLOCATOR>
|
|
18
|
+
$<$<CONFIG:Debug>:TREE_SITTER_DEBUG>)
|
|
19
|
+
set_target_properties(
|
|
20
|
+
tree-sitter-mermaid
|
|
21
|
+
PROPERTIES
|
|
22
|
+
C_STANDARD 11
|
|
23
|
+
POSITION_INDEPENDENT_CODE ON
|
|
24
|
+
SOVERSION "15.0"
|
|
25
|
+
VERSION "${PROJECT_VERSION}"
|
|
26
|
+
DEFINE_SYMBOL "")
|
|
27
|
+
|
|
28
|
+
include(GNUInstallDirs)
|
|
29
|
+
configure_file(
|
|
30
|
+
bindings/c/tree-sitter-mermaid.pc.in
|
|
31
|
+
"${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-mermaid.pc"
|
|
32
|
+
@ONLY)
|
|
33
|
+
|
|
34
|
+
install(
|
|
35
|
+
FILES bindings/c/tree_sitter/tree-sitter-mermaid.h
|
|
36
|
+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/tree_sitter")
|
|
37
|
+
install(
|
|
38
|
+
FILES "${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-mermaid.pc"
|
|
39
|
+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
|
40
|
+
install(
|
|
41
|
+
TARGETS tree-sitter-mermaid
|
|
42
|
+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
43
|
+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
44
|
+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Samuel Roeca
|
|
4
|
+
Copyright (c) 2026 Merman contributors
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/Makefile
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
ifeq ($(OS),Windows_NT)
|
|
2
|
+
$(error Use CMake to build tree-sitter-mermaid on Windows)
|
|
3
|
+
endif
|
|
4
|
+
|
|
5
|
+
LANGUAGE_NAME := tree-sitter-mermaid
|
|
6
|
+
DESCRIPTION := Tolerant Tree-sitter grammar and editor queries for Mermaid
|
|
7
|
+
HOMEPAGE_URL := https://github.com/Latias94/merman
|
|
8
|
+
VERSION := 0.1.0
|
|
9
|
+
|
|
10
|
+
SRC_DIR := src
|
|
11
|
+
PARSER := $(SRC_DIR)/parser.c
|
|
12
|
+
EXTRAS := $(filter-out $(PARSER),$(wildcard $(SRC_DIR)/*.c))
|
|
13
|
+
OBJS := $(patsubst %.c,%.o,$(PARSER) $(EXTRAS))
|
|
14
|
+
|
|
15
|
+
PREFIX ?= /usr/local
|
|
16
|
+
INCLUDEDIR ?= $(PREFIX)/include
|
|
17
|
+
LIBDIR ?= $(PREFIX)/lib
|
|
18
|
+
PCLIBDIR ?= $(LIBDIR)/pkgconfig
|
|
19
|
+
ARFLAGS ?= rcs
|
|
20
|
+
override CFLAGS += -I$(SRC_DIR) -std=c11 -fPIC
|
|
21
|
+
|
|
22
|
+
SONAME_MAJOR := $(shell sed -n 's/\#define LANGUAGE_VERSION //p' $(PARSER))
|
|
23
|
+
SONAME_MINOR := $(word 1,$(subst ., ,$(VERSION)))
|
|
24
|
+
|
|
25
|
+
ifeq ($(shell uname),Darwin)
|
|
26
|
+
SOEXT := dylib
|
|
27
|
+
SOEXTVER_MAJOR := $(SONAME_MAJOR).$(SOEXT)
|
|
28
|
+
SOEXTVER := $(SONAME_MAJOR).$(SONAME_MINOR).$(SOEXT)
|
|
29
|
+
LINKSHARED := -dynamiclib -Wl,-install_name,$(LIBDIR)/lib$(LANGUAGE_NAME).$(SOEXTVER)
|
|
30
|
+
else
|
|
31
|
+
SOEXT := so
|
|
32
|
+
SOEXTVER_MAJOR := $(SOEXT).$(SONAME_MAJOR)
|
|
33
|
+
SOEXTVER := $(SOEXT).$(SONAME_MAJOR).$(SONAME_MINOR)
|
|
34
|
+
LINKSHARED := -shared -Wl,-soname,lib$(LANGUAGE_NAME).$(SOEXTVER)
|
|
35
|
+
endif
|
|
36
|
+
|
|
37
|
+
ifneq ($(filter $(shell uname),FreeBSD NetBSD DragonFly),)
|
|
38
|
+
PCLIBDIR := $(PREFIX)/libdata/pkgconfig
|
|
39
|
+
endif
|
|
40
|
+
|
|
41
|
+
all: lib$(LANGUAGE_NAME).a lib$(LANGUAGE_NAME).$(SOEXT) $(LANGUAGE_NAME).pc
|
|
42
|
+
|
|
43
|
+
lib$(LANGUAGE_NAME).a: $(OBJS)
|
|
44
|
+
$(AR) $(ARFLAGS) $@ $^
|
|
45
|
+
|
|
46
|
+
lib$(LANGUAGE_NAME).$(SOEXT): $(OBJS)
|
|
47
|
+
$(CC) $(LDFLAGS) $(LINKSHARED) $^ $(LDLIBS) -o $@
|
|
48
|
+
ifneq ($(STRIP),)
|
|
49
|
+
$(STRIP) $@
|
|
50
|
+
endif
|
|
51
|
+
|
|
52
|
+
$(LANGUAGE_NAME).pc: bindings/c/$(LANGUAGE_NAME).pc.in
|
|
53
|
+
sed -e 's|@PROJECT_VERSION@|$(VERSION)|' \
|
|
54
|
+
-e 's|@CMAKE_INSTALL_LIBDIR@|$(LIBDIR:$(PREFIX)/%=%)|' \
|
|
55
|
+
-e 's|@CMAKE_INSTALL_INCLUDEDIR@|$(INCLUDEDIR:$(PREFIX)/%=%)|' \
|
|
56
|
+
-e 's|@PROJECT_DESCRIPTION@|$(DESCRIPTION)|' \
|
|
57
|
+
-e 's|@PROJECT_HOMEPAGE_URL@|$(HOMEPAGE_URL)|' \
|
|
58
|
+
-e 's|@CMAKE_INSTALL_PREFIX@|$(PREFIX)|' $< > $@
|
|
59
|
+
|
|
60
|
+
install: all
|
|
61
|
+
install -d '$(DESTDIR)$(INCLUDEDIR)/tree_sitter' '$(DESTDIR)$(PCLIBDIR)' '$(DESTDIR)$(LIBDIR)'
|
|
62
|
+
install -m644 bindings/c/tree_sitter/$(LANGUAGE_NAME).h '$(DESTDIR)$(INCLUDEDIR)/tree_sitter/$(LANGUAGE_NAME).h'
|
|
63
|
+
install -m644 $(LANGUAGE_NAME).pc '$(DESTDIR)$(PCLIBDIR)/$(LANGUAGE_NAME).pc'
|
|
64
|
+
install -m644 lib$(LANGUAGE_NAME).a '$(DESTDIR)$(LIBDIR)/lib$(LANGUAGE_NAME).a'
|
|
65
|
+
install -m755 lib$(LANGUAGE_NAME).$(SOEXT) '$(DESTDIR)$(LIBDIR)/lib$(LANGUAGE_NAME).$(SOEXTVER)'
|
|
66
|
+
ln -sf lib$(LANGUAGE_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)/lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR)'
|
|
67
|
+
ln -sf lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR) '$(DESTDIR)$(LIBDIR)/lib$(LANGUAGE_NAME).$(SOEXT)'
|
|
68
|
+
|
|
69
|
+
uninstall:
|
|
70
|
+
$(RM) '$(DESTDIR)$(LIBDIR)/lib$(LANGUAGE_NAME).a' \
|
|
71
|
+
'$(DESTDIR)$(LIBDIR)/lib$(LANGUAGE_NAME).$(SOEXTVER)' \
|
|
72
|
+
'$(DESTDIR)$(LIBDIR)/lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR)' \
|
|
73
|
+
'$(DESTDIR)$(LIBDIR)/lib$(LANGUAGE_NAME).$(SOEXT)' \
|
|
74
|
+
'$(DESTDIR)$(INCLUDEDIR)/tree_sitter/$(LANGUAGE_NAME).h' \
|
|
75
|
+
'$(DESTDIR)$(PCLIBDIR)/$(LANGUAGE_NAME).pc'
|
|
76
|
+
|
|
77
|
+
clean:
|
|
78
|
+
$(RM) $(OBJS) $(LANGUAGE_NAME).pc lib$(LANGUAGE_NAME).a lib$(LANGUAGE_NAME).$(SOEXT)
|
|
79
|
+
|
|
80
|
+
.PHONY: all clean install uninstall
|
package/README.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# tree-sitter-mermaid
|
|
2
|
+
|
|
3
|
+
A tolerant, incremental [Tree-sitter] grammar for Mermaid source. It provides structured concrete
|
|
4
|
+
syntax trees and editor queries for all 35 public diagram families in Mermaid 11.16.1, including
|
|
5
|
+
the ZenUML integration backed by ZenUML Core 3.50.1.
|
|
6
|
+
|
|
7
|
+
Use this package for syntax highlighting, syntax-aware selection, folding, and other editor features
|
|
8
|
+
that must keep working while a document is incomplete. Use [`@mermanjs/web`] or the Merman Rust
|
|
9
|
+
crates when you need strict validation, semantic models, diagnostics, rendering, navigation, or safe
|
|
10
|
+
refactoring. A recovered Tree-sitter tree is useful editor state; it is not proof that Mermaid will
|
|
11
|
+
accept or render the document.
|
|
12
|
+
|
|
13
|
+
## Packages
|
|
14
|
+
|
|
15
|
+
| Consumer | Package or artifact | Provides |
|
|
16
|
+
| --- | --- | --- |
|
|
17
|
+
| Node.js | [`@mermanjs/tree-sitter-mermaid`] | Native Node binding, TypeScript declarations, queries, and language WASM |
|
|
18
|
+
| Browser or Worker | [`@mermanjs/tree-sitter-mermaid`] + [`web-tree-sitter`] | Language WASM and portable queries for the generic browser runtime |
|
|
19
|
+
| Rust | [`tree-sitter-mermaid`] | `LANGUAGE`, `NODE_TYPES`, and the portable queries |
|
|
20
|
+
| C/C++ and editors | [GitHub Release] or repository source | Generated C parser/scanner, public header, Make, CMake, and pkg-config metadata |
|
|
21
|
+
|
|
22
|
+
The grammar has its own version line, independent of Merman. Its npm and Cargo artifacts share that
|
|
23
|
+
grammar version, but their registry names differ: the npm package is scoped under `@mermanjs`, while
|
|
24
|
+
the Rust crate and C library retain the standard `tree-sitter-mermaid` name.
|
|
25
|
+
|
|
26
|
+
## Node.js
|
|
27
|
+
|
|
28
|
+
```console
|
|
29
|
+
npm install tree-sitter @mermanjs/tree-sitter-mermaid
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
const Parser = require('tree-sitter');
|
|
34
|
+
const Mermaid = require('@mermanjs/tree-sitter-mermaid');
|
|
35
|
+
|
|
36
|
+
const parser = new Parser();
|
|
37
|
+
parser.setLanguage(Mermaid);
|
|
38
|
+
|
|
39
|
+
const tree = parser.parse('flowchart TD\nA --> B\n');
|
|
40
|
+
console.log(tree.rootNode.toString());
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The `tree-sitter` peer dependency is optional so a browser-only install does not pull in the native
|
|
44
|
+
Node runtime. Node applications should use the native binding rather than the browser WASM.
|
|
45
|
+
|
|
46
|
+
Node ESM consumers use default imports for the CommonJS native bindings:
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
import Parser from 'tree-sitter';
|
|
50
|
+
import Mermaid from '@mermanjs/tree-sitter-mermaid';
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Browser and Workers
|
|
54
|
+
|
|
55
|
+
```console
|
|
56
|
+
npm install web-tree-sitter @mermanjs/tree-sitter-mermaid
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The package exports `@mermanjs/tree-sitter-mermaid/tree-sitter-mermaid.wasm`. Copy that asset to a
|
|
60
|
+
public URL with your bundler, then load it with the generic `web-tree-sitter` runtime:
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
import { Language, Parser } from 'web-tree-sitter';
|
|
64
|
+
|
|
65
|
+
await Parser.init();
|
|
66
|
+
const language = await Language.load('/assets/tree-sitter-mermaid.wasm');
|
|
67
|
+
|
|
68
|
+
const parser = new Parser();
|
|
69
|
+
parser.setLanguage(language);
|
|
70
|
+
const tree = parser.parse('sequenceDiagram\nAlice->>Bob: Hello\n');
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
A no-build browser prototype can pin the exact grammar version on jsDelivr:
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
const language = await Language.load(
|
|
77
|
+
'https://cdn.jsdelivr.net/npm/@mermanjs/tree-sitter-mermaid@0.1.0/tree-sitter-mermaid.wasm',
|
|
78
|
+
);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The grammar package deliberately does not wrap runtime initialization, Worker lifecycle, or bundler
|
|
82
|
+
URL resolution in another JavaScript SDK. Merman's Playground follows the same boundary: a syntax
|
|
83
|
+
Worker runs this WASM and the portable highlight query, while a separate semantic Worker owns
|
|
84
|
+
diagnostics, completion, navigation, and rename.
|
|
85
|
+
|
|
86
|
+
## Rust
|
|
87
|
+
|
|
88
|
+
```console
|
|
89
|
+
cargo add tree-sitter tree-sitter-mermaid
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
```rust
|
|
93
|
+
let language: tree_sitter::Language = tree_sitter_mermaid::LANGUAGE.into();
|
|
94
|
+
let mut parser = tree_sitter::Parser::new();
|
|
95
|
+
parser.set_language(&language)?;
|
|
96
|
+
|
|
97
|
+
let tree = parser
|
|
98
|
+
.parse("flowchart TD\nA --> B\n", None)
|
|
99
|
+
.expect("Tree-sitter returned no tree");
|
|
100
|
+
assert!(!tree.root_node().has_error());
|
|
101
|
+
# Ok::<(), Box<dyn std::error::Error>>(())
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The crate exports a `tree-sitter-language::LanguageFn` and does not force a Tree-sitter runtime
|
|
105
|
+
version on applications.
|
|
106
|
+
|
|
107
|
+
## C and C++
|
|
108
|
+
|
|
109
|
+
The committed parser and scanner build without the grammar generator:
|
|
110
|
+
|
|
111
|
+
```console
|
|
112
|
+
cmake -S . -B build -DBUILD_SHARED_LIBS=OFF
|
|
113
|
+
cmake --build build
|
|
114
|
+
cmake --install build --prefix /usr/local
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Unix-like consumers may alternatively use `make` and `make install`.
|
|
118
|
+
|
|
119
|
+
```c
|
|
120
|
+
#include <tree_sitter/api.h>
|
|
121
|
+
#include <tree_sitter/tree-sitter-mermaid.h>
|
|
122
|
+
|
|
123
|
+
int main(void) {
|
|
124
|
+
TSParser *parser = ts_parser_new();
|
|
125
|
+
ts_parser_set_language(parser, tree_sitter_mermaid());
|
|
126
|
+
ts_parser_delete(parser);
|
|
127
|
+
return 0;
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Compatibility
|
|
132
|
+
|
|
133
|
+
| Contract | Version |
|
|
134
|
+
| --- | --- |
|
|
135
|
+
| Mermaid syntax baseline | 11.16.1 |
|
|
136
|
+
| ZenUML Core syntax baseline | 3.50.1 |
|
|
137
|
+
| Tree-sitter language ABI | 15 |
|
|
138
|
+
| Tested Rust and Web runtime | 0.26.12 |
|
|
139
|
+
| Native Node runtime contract | 0.25.x |
|
|
140
|
+
|
|
141
|
+
Before 1.0, a minor release may change named nodes, fields, canonical captures, the language ABI, or
|
|
142
|
+
the selected Mermaid baseline. Pin a compatible minor version for application integrations and an
|
|
143
|
+
immutable release commit for editor integrations.
|
|
144
|
+
|
|
145
|
+
## Queries and Editors
|
|
146
|
+
|
|
147
|
+
`tree-sitter.json` selects the canonical portable queries under `queries/portable/`:
|
|
148
|
+
|
|
149
|
+
- `highlights.scm` for base syntax highlighting;
|
|
150
|
+
- `injections.scm` for embedded languages;
|
|
151
|
+
- `locals.scm` for syntax-local scopes; and
|
|
152
|
+
- `tags.scm` for syntax-level symbols.
|
|
153
|
+
|
|
154
|
+
The `queries/neovim`, `queries/helix`, and `queries/zed` directories are pre-1.0 adoption assets.
|
|
155
|
+
Those editors own their final query copies and release cadence, so publishing this package does not
|
|
156
|
+
update an editor automatically. Downstream integrations should pin a released Merman commit and use
|
|
157
|
+
`distribution/tree-sitter-mermaid` as the grammar subdirectory.
|
|
158
|
+
|
|
159
|
+
## Development
|
|
160
|
+
|
|
161
|
+
From the Merman repository root, install the pinned package-local toolchain:
|
|
162
|
+
|
|
163
|
+
```console
|
|
164
|
+
npm ci --ignore-scripts --prefix distribution/tree-sitter-mermaid
|
|
165
|
+
npm rebuild tree-sitter-cli --prefix distribution/tree-sitter-mermaid
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Run the ordinary grammar and binding checks:
|
|
169
|
+
|
|
170
|
+
```console
|
|
171
|
+
npm run check:generated --prefix distribution/tree-sitter-mermaid
|
|
172
|
+
npm run test:corpus --prefix distribution/tree-sitter-mermaid
|
|
173
|
+
cargo nextest run --locked -p tree-sitter-mermaid --no-fail-fast
|
|
174
|
+
npm run test:node --prefix distribution/tree-sitter-mermaid
|
|
175
|
+
npm run test:c --prefix distribution/tree-sitter-mermaid
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Language-WASM freshness and execution are separate, slower checks:
|
|
179
|
+
|
|
180
|
+
```console
|
|
181
|
+
npm run check:wasm --prefix distribution/tree-sitter-mermaid
|
|
182
|
+
npm run test:wasm --prefix distribution/tree-sitter-mermaid
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
See the [development guide] and [release guide] for grammar ownership, generation, testing, and
|
|
186
|
+
publication details.
|
|
187
|
+
|
|
188
|
+
## License and Provenance
|
|
189
|
+
|
|
190
|
+
The package is MIT licensed. Source-derived syntax and template attributions are recorded in
|
|
191
|
+
`metadata/provenance.json`, `metadata/derivations.json`, `THIRD_PARTY_NOTICES.md`, and
|
|
192
|
+
`THIRD_PARTY_LICENSES/`.
|
|
193
|
+
|
|
194
|
+
[Tree-sitter]: https://tree-sitter.github.io/tree-sitter/
|
|
195
|
+
[`@mermanjs/web`]: https://www.npmjs.com/package/@mermanjs/web
|
|
196
|
+
[`@mermanjs/tree-sitter-mermaid`]: https://www.npmjs.com/package/@mermanjs/tree-sitter-mermaid
|
|
197
|
+
[`web-tree-sitter`]: https://www.npmjs.com/package/web-tree-sitter
|
|
198
|
+
[`tree-sitter-mermaid`]: https://crates.io/crates/tree-sitter-mermaid
|
|
199
|
+
[GitHub Release]: https://github.com/Latias94/merman/releases
|
|
200
|
+
[development guide]: https://github.com/Latias94/merman/blob/main/docs/development/TREE_SITTER_MERMAID.md
|
|
201
|
+
[release guide]: https://github.com/Latias94/merman/blob/main/docs/release/TREE_SITTER_MERMAID.md
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 - 2022 Knut Sveidqvist
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Mogami Shinichi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Samuel Roeca
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Mogami Shinichi
|
|
4
|
+
Copyright (c) 2025 Mikael Hugo
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Max Brunsfeld
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Peng Xiao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Third-Party Notices
|
|
2
|
+
|
|
3
|
+
This source distribution derives syntax behavior or compatibility evidence from the following
|
|
4
|
+
MIT-licensed projects. The corresponding license texts are included below
|
|
5
|
+
`THIRD_PARTY_LICENSES/`.
|
|
6
|
+
|
|
7
|
+
## Tree-sitter 0.26.12
|
|
8
|
+
|
|
9
|
+
- Source: https://github.com/tree-sitter/tree-sitter.git
|
|
10
|
+
- Commit: `808e4b1fc06e269a107c4bd8bd936cc6fde18b00`
|
|
11
|
+
- Use: pinned generator, copied generated support headers, and modified C, Rust, and Node binding templates
|
|
12
|
+
- License: `THIRD_PARTY_LICENSES/tree-sitter/LICENSE`
|
|
13
|
+
|
|
14
|
+
## Mermaid 11.16.1
|
|
15
|
+
|
|
16
|
+
- Source: https://github.com/mermaid-js/mermaid.git
|
|
17
|
+
- Commit: `7ecca0cd7f1658ef74f4e7e91f925724ef403bbf`
|
|
18
|
+
- Use: accepted Mermaid syntax, source-backed grammar translation, and representative fixtures
|
|
19
|
+
- License: `THIRD_PARTY_LICENSES/mermaid/LICENSE`
|
|
20
|
+
|
|
21
|
+
## ZenUML Core 3.50.1
|
|
22
|
+
|
|
23
|
+
- Source: https://github.com/mermaid-js/zenuml-core.git
|
|
24
|
+
- Commit: `38404ccc14243ed54ab45b804b2eb6f2ca73af36`
|
|
25
|
+
- Use: ZenUML source syntax, companion behavior, and representative fixture
|
|
26
|
+
- License: `THIRD_PARTY_LICENSES/zenuml-core/LICENSE`
|
|
27
|
+
|
|
28
|
+
## pappasam/tree-sitter-mermaid 0.1.0
|
|
29
|
+
|
|
30
|
+
- Source: https://github.com/pappasam/tree-sitter-mermaid.git
|
|
31
|
+
- Commit: `1a11e2d8cf11afcfdb768f537c1a9bde294c24f9`
|
|
32
|
+
- Use: modified grammar helpers and Flowchart/Mindmap seeds with path-level attribution
|
|
33
|
+
- License: `THIRD_PARTY_LICENSES/pappasam-tree-sitter-mermaid/LICENSE`
|
|
34
|
+
|
|
35
|
+
## monaqa/tree-sitter-mermaid 0.0.2
|
|
36
|
+
|
|
37
|
+
- Source: https://github.com/monaqa/tree-sitter-mermaid.git
|
|
38
|
+
- Commit: `90ae195b31933ceb9d079abfa8a3ad0a36fee4cc`
|
|
39
|
+
- Use: downstream editor compatibility reference
|
|
40
|
+
- License: `THIRD_PARTY_LICENSES/monaqa-tree-sitter-mermaid/LICENSE`
|
|
41
|
+
|
|
42
|
+
## singularity-parser-mermaid 0.9.1
|
|
43
|
+
|
|
44
|
+
- Source: https://github.com/singularity-ng/singularity-parser-mermaid.git
|
|
45
|
+
- Commit: `f5ac2752fbf0f74f9c836014b87e511303d2abae`
|
|
46
|
+
- Use: additional grammar and query behavior reference
|
|
47
|
+
- License: `THIRD_PARTY_LICENSES/singularity-tree-sitter-mermaid/LICENSE`
|
package/binding.gyp
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"targets": [
|
|
3
|
+
{
|
|
4
|
+
"target_name": "tree_sitter_mermaid_binding",
|
|
5
|
+
"dependencies": [
|
|
6
|
+
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except",
|
|
7
|
+
"tree_sitter_mermaid_parser"
|
|
8
|
+
],
|
|
9
|
+
"include_dirs": [
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
12
|
+
"sources": [
|
|
13
|
+
"bindings/node/binding.cc"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"target_name": "tree_sitter_mermaid_parser",
|
|
18
|
+
"type": "static_library",
|
|
19
|
+
"include_dirs": [
|
|
20
|
+
"src"
|
|
21
|
+
],
|
|
22
|
+
"sources": [
|
|
23
|
+
"src/parser.c",
|
|
24
|
+
"src/scanner.c"
|
|
25
|
+
],
|
|
26
|
+
"conditions": [
|
|
27
|
+
["OS!='win'", {
|
|
28
|
+
"cflags_c": [
|
|
29
|
+
"-std=c11"
|
|
30
|
+
]
|
|
31
|
+
}, { # OS == "win"
|
|
32
|
+
"msvs_settings": {
|
|
33
|
+
"VCCLCompilerTool": {
|
|
34
|
+
# Node's common.gypi adds a C++ standard to every MSVC target.
|
|
35
|
+
# Remove it here before selecting C11 for this C-only library.
|
|
36
|
+
"AdditionalOptions!": [
|
|
37
|
+
"-std:c++17",
|
|
38
|
+
"-std:c++20"
|
|
39
|
+
],
|
|
40
|
+
"LanguageStandard_C": "stdc11",
|
|
41
|
+
"AdditionalOptions": [
|
|
42
|
+
"/utf-8"
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}],
|
|
47
|
+
["OS=='mac'", {
|
|
48
|
+
"xcode_settings": {
|
|
49
|
+
"GCC_C_LANGUAGE_STANDARD": "c11",
|
|
50
|
+
"MACOSX_DEPLOYMENT_TARGET": "10.7"
|
|
51
|
+
}
|
|
52
|
+
}]
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
prefix=@CMAKE_INSTALL_PREFIX@
|
|
2
|
+
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
|
|
3
|
+
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
|
4
|
+
|
|
5
|
+
Name: tree-sitter-mermaid
|
|
6
|
+
Description: @PROJECT_DESCRIPTION@
|
|
7
|
+
URL: @PROJECT_HOMEPAGE_URL@
|
|
8
|
+
Version: @PROJECT_VERSION@
|
|
9
|
+
Libs: -L${libdir} -ltree-sitter-mermaid
|
|
10
|
+
Cflags: -I${includedir}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#ifndef TREE_SITTER_MERMAID_H_
|
|
2
|
+
#define TREE_SITTER_MERMAID_H_
|
|
3
|
+
|
|
4
|
+
#ifdef __cplusplus
|
|
5
|
+
extern "C" {
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
typedef struct TSLanguage TSLanguage;
|
|
9
|
+
|
|
10
|
+
const TSLanguage *tree_sitter_mermaid(void);
|
|
11
|
+
|
|
12
|
+
#ifdef __cplusplus
|
|
13
|
+
}
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
#endif
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#include <napi.h>
|
|
2
|
+
|
|
3
|
+
typedef struct TSLanguage TSLanguage;
|
|
4
|
+
|
|
5
|
+
extern "C" const TSLanguage *tree_sitter_mermaid();
|
|
6
|
+
|
|
7
|
+
namespace {
|
|
8
|
+
|
|
9
|
+
const napi_type_tag LANGUAGE_TYPE_TAG = {
|
|
10
|
+
0x8AF2E5212AD58ABF,
|
|
11
|
+
0xD5006CAD83ABBA16,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
Napi::Object Initialize(Napi::Env environment, Napi::Object exports) {
|
|
15
|
+
exports["name"] = Napi::String::New(environment, "mermaid");
|
|
16
|
+
auto language = Napi::External<TSLanguage>::New(
|
|
17
|
+
environment, const_cast<TSLanguage *>(tree_sitter_mermaid()));
|
|
18
|
+
language.TypeTag(&LANGUAGE_TYPE_TAG);
|
|
19
|
+
exports["language"] = language;
|
|
20
|
+
return exports;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
} // namespace
|
|
24
|
+
|
|
25
|
+
NODE_API_MODULE(tree_sitter_mermaid_binding, Initialize)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
|
|
5
|
+
const packageRoot = path.join(__dirname, '..', '..');
|
|
6
|
+
const language = require('node-gyp-build')(packageRoot);
|
|
7
|
+
|
|
8
|
+
language.nodeTypeInfo = require('../../src/node-types.json');
|
|
9
|
+
|
|
10
|
+
module.exports = language;
|