mermaid-simple-validator 1.0.0 → 1.0.1
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/README.md +66 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# mermaid-simple-validator
|
|
2
|
+
|
|
3
|
+
Validate mermaid diagram syntax in Markdown files — no browser required.
|
|
4
|
+
|
|
5
|
+
Uses [JSDOM](https://github.com/jsdom/jsdom) to create a fake DOM so [mermaid](https://mermaid.js.org/) can parse and validate diagrams purely in Node.js.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install mermaid-simple-validator
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx mermaid-simple-validate <file.md>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Example
|
|
20
|
+
|
|
21
|
+
Given `diagrams.md`:
|
|
22
|
+
|
|
23
|
+
````markdown
|
|
24
|
+
## Flowchart
|
|
25
|
+
|
|
26
|
+
```mermaid
|
|
27
|
+
flowchart TD
|
|
28
|
+
A --> B
|
|
29
|
+
B --> C
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Broken diagram
|
|
33
|
+
|
|
34
|
+
```mermaid
|
|
35
|
+
flowchart LR
|
|
36
|
+
X -> Y %% `->` is invalid
|
|
37
|
+
```
|
|
38
|
+
````
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx mermaid-simple-validate diagrams.md
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Output:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
block 1 (line 4): valid (flowchart)
|
|
48
|
+
block 2 (line 12): INVALID
|
|
49
|
+
Parse error on line 2
|
|
50
|
+
...
|
|
51
|
+
|
|
52
|
+
1 error(s) found.
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Exit code is `1` when any block fails validation, `0` otherwise.
|
|
56
|
+
|
|
57
|
+
## How it works
|
|
58
|
+
|
|
59
|
+
1. Scans a Markdown file for ```` ```mermaid ```` fenced code blocks
|
|
60
|
+
2. Creates a lightweight JSDOM window/document
|
|
61
|
+
3. Calls `mermaid.parse()` on each block
|
|
62
|
+
4. Reports success (with detected diagram type) or the parse error
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
MIT
|