mermaid2term 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/README.md ADDED
@@ -0,0 +1,229 @@
1
+ # mermaid2term
2
+
3
+ Render [Mermaid](https://mermaid.js.org/) diagrams as ASCII/Unicode art in the terminal.
4
+
5
+ ```
6
+ ┌───────┐
7
+ │ │
8
+ │ Start │
9
+ │ │
10
+ └───────┘
11
+
12
+
13
+
14
+ ┌───▼────┐
15
+ │ │
16
+ │ Process│
17
+ │ │
18
+ └────────┘
19
+
20
+ │ Yes
21
+ ├────────────┐No
22
+ │ │
23
+ ┌───▼───┐ ┌────▼───┐
24
+ │ │ │ │
25
+ │ Done │ │ Skip │
26
+ │ │ │ │
27
+ └───────┘ └────────┘
28
+ ```
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ npm install -g mermaid2term
34
+ ```
35
+
36
+ Or use directly with npx:
37
+
38
+ ```bash
39
+ npx mermaid2term diagram.mmd
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ ### CLI
45
+
46
+ ```bash
47
+ # From a file
48
+ mermaid2term diagram.mmd
49
+
50
+ # From stdin
51
+ echo 'graph LR; A-->B; B-->C' | mermaid2term
52
+
53
+ # With options
54
+ mermaid2term --charset ascii diagram.mmd
55
+ ```
56
+
57
+ ### Options
58
+
59
+ | Option | Description | Default |
60
+ |--------|-------------|---------|
61
+ | `-c, --charset <type>` | Character set: `unicode` or `ascii` | `unicode` |
62
+ | `-h, --help` | Show help | |
63
+ | `-V, --version` | Show version | |
64
+
65
+ ### Programmatic API
66
+
67
+ ```typescript
68
+ import { render } from 'mermaid2term';
69
+
70
+ const diagram = `
71
+ graph TD
72
+ A[Start] --> B{Decision}
73
+ B -->|Yes| C[Do Something]
74
+ B -->|No| D[Skip]
75
+ C --> E[End]
76
+ D --> E
77
+ `;
78
+
79
+ const output = render(diagram);
80
+ console.log(output);
81
+ ```
82
+
83
+ #### API Reference
84
+
85
+ ##### `render(input: string, options?: RenderOptions): string`
86
+
87
+ Renders a Mermaid diagram to ASCII/Unicode art.
88
+
89
+ **Parameters:**
90
+ - `input` - Mermaid diagram source
91
+ - `options` - Optional configuration object
92
+
93
+ **Options:**
94
+ ```typescript
95
+ interface RenderOptions {
96
+ charset?: 'unicode' | 'ascii'; // Default: 'unicode'
97
+ paddingX?: number; // Horizontal padding between nodes (default: 4)
98
+ paddingY?: number; // Vertical padding between nodes (default: 2)
99
+ borderPadding?: number; // Padding inside node borders (default: 1)
100
+ }
101
+ ```
102
+
103
+ ## Supported Diagram Types
104
+
105
+ ### Flowcharts
106
+
107
+ Full support for flowchart/graph diagrams:
108
+
109
+ ```mermaid
110
+ graph TD
111
+ A[Rectangle] --> B(Rounded)
112
+ B --> C{Diamond}
113
+ C -->|Yes| D[Result 1]
114
+ C -->|No| E[Result 2]
115
+ ```
116
+
117
+ **Supported features:**
118
+ - Directions: `TD`/`TB` (top-down), `LR` (left-right), `RL` (right-left), `BT` (bottom-top)
119
+ - Node shapes: rectangles `[]`, rounded `()`, diamonds `{}`
120
+ - Edge types: solid `-->`, dotted `-..->`, thick `==>`
121
+ - Edge labels: `-->|label|`
122
+ - Cycles/back-edges (rendered with proper routing)
123
+ - Semicolon syntax for single-line diagrams
124
+
125
+ **Example:**
126
+
127
+ ```bash
128
+ echo 'graph LR; A-->B; B-->C; C-->A' | mermaid2term
129
+ ```
130
+
131
+ Output:
132
+ ```
133
+ ┌───┐ ┌───┐ ┌───┐
134
+ │ │ │ │ │ │
135
+ │ A │─────► B │─────► C │
136
+ │ │ │ │ │ │
137
+ └─▲─┘ └───┘ └───┘
138
+ │ │
139
+ └───────────────────┘
140
+ ```
141
+
142
+ ### Sequence Diagrams
143
+
144
+ Basic support for sequence diagrams:
145
+
146
+ ```mermaid
147
+ sequenceDiagram
148
+ Alice->>Bob: Hello Bob
149
+ Bob-->>Alice: Hi Alice
150
+ ```
151
+
152
+ ## Character Sets
153
+
154
+ ### Unicode (default)
155
+
156
+ Uses Unicode box-drawing characters for crisp rendering:
157
+ ```
158
+ ┌───────┐
159
+ │ Node │
160
+ └───────┘
161
+
162
+
163
+ ```
164
+
165
+ ### ASCII
166
+
167
+ For terminals without Unicode support:
168
+ ```
169
+ +-------+
170
+ | Node |
171
+ +-------+
172
+ |
173
+ v
174
+ ```
175
+
176
+ ## Examples
177
+
178
+ ### Decision Flow
179
+
180
+ ```bash
181
+ echo 'graph TD
182
+ Start --> Process
183
+ Process --> Decision{Valid?}
184
+ Decision -->|Yes| Success
185
+ Decision -->|No| Error
186
+ Error --> Process
187
+ Success --> End' | mermaid2term
188
+ ```
189
+
190
+ ### Horizontal Flow
191
+
192
+ ```bash
193
+ echo 'graph LR
194
+ Input --> Process
195
+ Process --> Output' | mermaid2term
196
+ ```
197
+
198
+ ### With Labels
199
+
200
+ ```bash
201
+ echo 'graph TD
202
+ A -->|step 1| B
203
+ B -->|step 2| C
204
+ C -->|step 3| D' | mermaid2term
205
+ ```
206
+
207
+ ## Development
208
+
209
+ ```bash
210
+ # Clone the repository
211
+ git clone https://github.com/watzon/mermaid2term.git
212
+ cd mermaid2term
213
+
214
+ # Install dependencies
215
+ npm install
216
+
217
+ # Build
218
+ npm run build
219
+
220
+ # Run tests
221
+ npm test
222
+
223
+ # Development mode (watch)
224
+ npm run dev
225
+ ```
226
+
227
+ ## License
228
+
229
+ MIT
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import('../dist/cli.js');