ansimax 1.3.7 → 1.4.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/CHANGELOG.md +217 -0
- package/README.es.md +58 -2
- package/README.md +58 -2
- package/dist/index.d.mts +189 -1
- package/dist/index.d.ts +189 -1
- package/dist/index.js +401 -41
- package/dist/index.mjs +397 -41
- package/examples/all-in-one.cjs +1 -1
- package/examples/all-in-one.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,223 @@
|
|
|
3
3
|
All notable changes to **ansimax** are documented in this file.
|
|
4
4
|
This project follows [Semantic Versioning](https://semver.org/).
|
|
5
5
|
|
|
6
|
+
## [1.4.1] — Grid v2 + markdown internal refactor
|
|
7
|
+
|
|
8
|
+
Patch release with two improvements: **grid** gains CSS Grid-style
|
|
9
|
+
column spans + uniform row heights + flow direction control, and the
|
|
10
|
+
**markdown** module is internally refactored from a 522-line monolith
|
|
11
|
+
into 4 focused files (no API changes).
|
|
12
|
+
|
|
13
|
+
### Added — `panels.grid` v2
|
|
14
|
+
|
|
15
|
+
**`colSpan: number[]`** — per-block column span (CSS Grid-style):
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import { panels, ascii } from 'ansimax';
|
|
19
|
+
|
|
20
|
+
const header = ascii.box('Dashboard', { borderStyle: 'rounded' });
|
|
21
|
+
const sidebar = ascii.box('Sidebar', { borderStyle: 'rounded' });
|
|
22
|
+
const content = ascii.box('Main content area', { borderStyle: 'rounded' });
|
|
23
|
+
const footer = ascii.box('Footer', { borderStyle: 'rounded' });
|
|
24
|
+
|
|
25
|
+
// 2 columns, header + footer span the full width
|
|
26
|
+
console.log(panels.grid([header, sidebar, content, footer], {
|
|
27
|
+
columns: 2,
|
|
28
|
+
colSpan: [2, 1, 1, 2],
|
|
29
|
+
}));
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Auto-flow: each block consumes its `span` columns. If a row's remaining
|
|
33
|
+
capacity can't fit the next block, the layout wraps to a new row.
|
|
34
|
+
Invalid spans (NaN, negative, > columns) are normalized to safe values.
|
|
35
|
+
|
|
36
|
+
**`cellHeight: number | null`** — uniform vertical sizing per row:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
// All rows exactly 5 lines tall — short blocks padded, tall blocks truncated
|
|
40
|
+
panels.grid(blocks, { columns: 3, cellHeight: 5 });
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Complements the existing `cellWidth` option for fully uniform grids.
|
|
44
|
+
|
|
45
|
+
**`flow: 'row' | 'column'`** — auto-flow direction:
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
// Default: row flow (left-to-right, then wrap down)
|
|
49
|
+
panels.grid([1, 2, 3, 4, 5, 6], { columns: 3, flow: 'row' });
|
|
50
|
+
// 1 2 3
|
|
51
|
+
// 4 5 6
|
|
52
|
+
|
|
53
|
+
// Column flow (top-to-bottom, then wrap right)
|
|
54
|
+
panels.grid([1, 2, 3, 4, 5, 6], { columns: 3, flow: 'column' });
|
|
55
|
+
// 1 3 5
|
|
56
|
+
// 2 4 6
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
When `colSpan` contains values > 1, flow is forced to `'row'` (the
|
|
60
|
+
column-flow + spans combination requires a full packing algorithm,
|
|
61
|
+
deferred to a later release).
|
|
62
|
+
|
|
63
|
+
### Improved — `markdown` module refactored
|
|
64
|
+
|
|
65
|
+
The single-file `src/markdown/index.ts` (522 lines) split into 5 files
|
|
66
|
+
of focused responsibility — **zero API changes, fully backward compatible**:
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
src/markdown/
|
|
70
|
+
├── types.ts — Public types (MarkdownTheme, Block, …)
|
|
71
|
+
├── theme.ts — Color palettes (THEMES record, private)
|
|
72
|
+
├── block-parser.ts — parseBlocks + line regexes
|
|
73
|
+
├── inline-parser.ts — parseInline + protected-code placeholders
|
|
74
|
+
├── renderer.ts — render (dispatches blocks → ansimax primitives)
|
|
75
|
+
└── index.ts — Re-exports + `markdown` namespace
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
External imports keep working unchanged:
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
import { markdown, parseMarkdownBlocks, parseMarkdownInline, renderMarkdown }
|
|
82
|
+
from 'ansimax';
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Submodule imports now also work (advanced use):
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
import { parseBlocks } from 'ansimax/markdown/block-parser'; // tree-shake friendly
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Improved — Tests
|
|
92
|
+
|
|
93
|
+
- `+18` tests for `colSpan` (defaults, clamping, wrapping, invalid input)
|
|
94
|
+
- `+4` tests for `cellHeight` (pad, truncate, null, zero clamp)
|
|
95
|
+
- `+5` tests for `flow` (row, column, non-multiples, fallback with colSpan)
|
|
96
|
+
- `+1` integration test (colSpan + cellHeight together)
|
|
97
|
+
- `+4` tests verifying submodule imports work after refactor
|
|
98
|
+
|
|
99
|
+
Total: **+32 tests** in `panels.test.ts` and `markdown.test.ts`.
|
|
100
|
+
|
|
101
|
+
### Notes
|
|
102
|
+
|
|
103
|
+
- **Zero behavior changes** for v1.4.0 users — `panels.grid` without the
|
|
104
|
+
new options produces byte-identical output
|
|
105
|
+
- **Zero breaking changes** — `markdown` API surface unchanged
|
|
106
|
+
- Submodule imports enabled (`ansimax/markdown/block-parser`) for
|
|
107
|
+
tree-shaking-friendly bundling
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## [1.4.0] — Phase 4 closure: Markdown rendering
|
|
112
|
+
|
|
113
|
+
**Minor release** introducing the long-planned `markdown` module — the
|
|
114
|
+
final piece of Phase 4 (after `panels` v1.3.0 and `json` v1.3.0).
|
|
115
|
+
|
|
116
|
+
Renders standard Markdown to ANSI-styled terminal output using the
|
|
117
|
+
existing ansimax primitives (`color`, `gradient`, `ascii.box`,
|
|
118
|
+
`components.table`, `hyperlink`). **Zero new runtime dependencies.**
|
|
119
|
+
|
|
120
|
+
### Added — `markdown` module
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
import { markdown } from 'ansimax';
|
|
124
|
+
|
|
125
|
+
console.log(markdown.render(`
|
|
126
|
+
# Welcome
|
|
127
|
+
|
|
128
|
+
This is **bold** and *italic* with \`code\` and [a link](https://example.com).
|
|
129
|
+
|
|
130
|
+
- Item 1
|
|
131
|
+
- Item 2
|
|
132
|
+
|
|
133
|
+
\`\`\`js
|
|
134
|
+
const x = 42;
|
|
135
|
+
\`\`\`
|
|
136
|
+
|
|
137
|
+
> Quoted wisdom
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
| Name | Value |
|
|
142
|
+
|---|---|
|
|
143
|
+
| foo | 1 |
|
|
144
|
+
| bar | 2 |
|
|
145
|
+
`));
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Supported markdown
|
|
149
|
+
|
|
150
|
+
| Markdown | Rendered using |
|
|
151
|
+
|---|---|
|
|
152
|
+
| `#` to `######` headings | `gradient` (h1) + `color.hex` (h2–h6) |
|
|
153
|
+
| **Bold** (`**` or `__`) | `color.bold` |
|
|
154
|
+
| *Italic* (`*` or `_`) | `color.italic` |
|
|
155
|
+
| ~~Strikethrough~~ (`~~`) | `color.strikethrough` |
|
|
156
|
+
| `Inline code` (``` ` ```) | dim + tinted background |
|
|
157
|
+
| ```` ```code blocks``` ```` | `ascii.box` with language label as title |
|
|
158
|
+
| `- item` / `* item` / `1.` lists | indented bullets |
|
|
159
|
+
| `> blockquote` | `│` prefix + dim |
|
|
160
|
+
| `--- / *** / ___` HRs | `ascii.divider` |
|
|
161
|
+
| `[label](url)` | `hyperlink` (OSC 8) |
|
|
162
|
+
| `\| a \| b \|` tables | `components.table` |
|
|
163
|
+
|
|
164
|
+
### API
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
// Main entry — high-level render
|
|
168
|
+
markdown.render(source: string, opts?: MarkdownOptions): string
|
|
169
|
+
|
|
170
|
+
// Lower-level helpers (advanced use)
|
|
171
|
+
markdown.parseBlocks(source: string): Block[]
|
|
172
|
+
markdown.parseInline(text: string, opts?): string
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Options
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
interface MarkdownOptions {
|
|
179
|
+
width?: number; // default: terminal width or 80
|
|
180
|
+
theme?: 'dark' | 'light'; // default 'dark'
|
|
181
|
+
headingGradient?: string[]; // override h1 gradient colors
|
|
182
|
+
boxCodeBlocks?: boolean; // default true; false = indented dim
|
|
183
|
+
inlineCodeBackground?: boolean; // default true
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Design notes
|
|
188
|
+
|
|
189
|
+
- **Pure functions** — `parseBlocks` and `parseInline` are deterministic
|
|
190
|
+
- **No regex backtracking** — all patterns are anchored, single-pass
|
|
191
|
+
- **Code blocks protect contents** — `**bold**` inside `` ` `` stays literal
|
|
192
|
+
- **Inline parser precedence**: code > links > strikethrough > bold > italic
|
|
193
|
+
- **Graceful degradation** — malformed markdown renders as plain text
|
|
194
|
+
rather than throwing
|
|
195
|
+
|
|
196
|
+
### Tests
|
|
197
|
+
|
|
198
|
+
- `+18` tests for `parseBlocks` (headings, lists, code, tables, blockquotes, HRs, edge cases)
|
|
199
|
+
- `+13` tests for `parseInline` (bold/italic/code/links/strikethrough, precedence, protection)
|
|
200
|
+
- `+19` tests for `render` (full pipeline, integration, options, theming)
|
|
201
|
+
- `+2` tests for namespace + `+2` for barrel re-exports
|
|
202
|
+
|
|
203
|
+
Total: **+54 tests** in a new `markdown.test.ts` file.
|
|
204
|
+
|
|
205
|
+
### Roadmap note
|
|
206
|
+
|
|
207
|
+
Phase 4 of the project is now closed. Future v1.4.x patches will refine
|
|
208
|
+
the markdown module:
|
|
209
|
+
- v1.4.1+ — CommonMark spec strict mode (escapes, reference links, setext headings)
|
|
210
|
+
- v1.4.2+ — Optional syntax highlighting for code blocks (basic JS/TS/JSON/Bash)
|
|
211
|
+
- v1.4.3+ — Nested lists (currently flat)
|
|
212
|
+
- v1.4.4+ — Custom themes / theme registry
|
|
213
|
+
|
|
214
|
+
### Notes
|
|
215
|
+
|
|
216
|
+
- **No breaking changes** — new module, all existing APIs unchanged
|
|
217
|
+
- **Drop-in replacement** for `1.3.7`
|
|
218
|
+
- Zero runtime dependencies maintained
|
|
219
|
+
- All markdown features implemented in ~450 lines of source
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
6
223
|
## [1.3.7] — Internal consolidation + new clamp helpers
|
|
7
224
|
|
|
8
225
|
Maintenance release focused on code cleanup. Zero behavior changes —
|
package/README.es.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
_Colores • Gradientes • Animaciones • ASCII Art • Pixel Art • Árboles • Componentes • Temas_
|
|
8
8
|
|
|
9
9
|
[](LICENSE)
|
|
10
|
-
[](https://www.npmjs.com/package/ansimax)
|
|
11
11
|
[](tsconfig.json)
|
|
12
12
|
[](#testing)
|
|
13
13
|
[](#testing)
|
|
@@ -478,7 +478,7 @@ console.log(components.table([
|
|
|
478
478
|
['loaders', color.green('● listo'), '100%'],
|
|
479
479
|
], { borderStyle: 'rounded' }));
|
|
480
480
|
|
|
481
|
-
console.log(components.badge('VERSION', 'v1.
|
|
481
|
+
console.log(components.badge('VERSION', 'v1.4.1'));
|
|
482
482
|
console.log(components.badge('BUILD', 'passing'));
|
|
483
483
|
```
|
|
484
484
|
|
|
@@ -1065,6 +1065,62 @@ ansimax/
|
|
|
1065
1065
|
|
|
1066
1066
|
## 📝 Changelog
|
|
1067
1067
|
|
|
1068
|
+
### v1.4.1 — Grid v2 + refactor markdown
|
|
1069
|
+
|
|
1070
|
+
Release patch. Cero breaking changes:
|
|
1071
|
+
|
|
1072
|
+
- 🎯 **`panels.grid` — colSpan**: span de columnas por bloque (auto-flow estilo CSS Grid)
|
|
1073
|
+
- 📏 **`panels.grid` — cellHeight**: alturas de fila uniformes (complementa `cellWidth`)
|
|
1074
|
+
- 🔀 **`panels.grid` — flow**: dirección de auto-flow `'row'` (default) o `'column'`
|
|
1075
|
+
- 📁 **`markdown` refactorizado** de monolito de 522 líneas → 5 submódulos enfocados (API sin cambios)
|
|
1076
|
+
- 🌳 Imports de submódulo habilitados: `import { parseBlocks } from 'ansimax/markdown/block-parser'`
|
|
1077
|
+
- 🧪 **+32 tests**
|
|
1078
|
+
|
|
1079
|
+
```js
|
|
1080
|
+
import { panels, ascii } from 'ansimax';
|
|
1081
|
+
|
|
1082
|
+
// Header span ambas columnas, luego sidebar + content lado a lado
|
|
1083
|
+
panels.grid([header, sidebar, content], {
|
|
1084
|
+
columns: 2,
|
|
1085
|
+
colSpan: [2, 1, 1],
|
|
1086
|
+
cellHeight: 10, // altura de fila uniforme
|
|
1087
|
+
});
|
|
1088
|
+
```
|
|
1089
|
+
|
|
1090
|
+
Drop-in replacement para `1.4.0`.
|
|
1091
|
+
|
|
1092
|
+
### v1.4.0 — Cierre de Fase 4: Renderizado Markdown 🎉
|
|
1093
|
+
|
|
1094
|
+
**Release minor** completando la Fase 4 con el nuevo módulo `markdown`:
|
|
1095
|
+
|
|
1096
|
+
- 📝 **`markdown.render(source, opts?)`** — pipeline completo markdown → terminal
|
|
1097
|
+
- 🧩 **`markdown.parseBlocks` + `markdown.parseInline`** — helpers de bajo nivel
|
|
1098
|
+
- 🎨 **Temas**: `'dark'` (default) y `'light'`
|
|
1099
|
+
- 📐 Renderiza headings (h1–h6), bold/italic/strikethrough/code, listas, tablas, blockquotes, HRs, links
|
|
1100
|
+
- 🔗 Links usan hyperlinks OSC 8 (clickables en terminales modernos)
|
|
1101
|
+
- 📦 Bloques de código renderizados en `ascii.box` con label de lenguaje
|
|
1102
|
+
- 🚀 **Cero dependencias nuevas** — reusa `color`, `gradient`, `ascii`, `components`, `hyperlink`
|
|
1103
|
+
- 🧪 **+54 tests** para parser + renderer
|
|
1104
|
+
|
|
1105
|
+
```js
|
|
1106
|
+
import { markdown } from 'ansimax';
|
|
1107
|
+
|
|
1108
|
+
console.log(markdown.render(`
|
|
1109
|
+
# Bienvenido
|
|
1110
|
+
|
|
1111
|
+
Esto es **bold** con \`code\` y [un link](https://example.com).
|
|
1112
|
+
|
|
1113
|
+
- Feature uno
|
|
1114
|
+
- Feature dos
|
|
1115
|
+
|
|
1116
|
+
\`\`\`js
|
|
1117
|
+
const x = 42;
|
|
1118
|
+
\`\`\`
|
|
1119
|
+
`));
|
|
1120
|
+
```
|
|
1121
|
+
|
|
1122
|
+
La Fase 4 está completa. v1.4.x refinará markdown (CommonMark estricto, syntax highlighting, listas anidadas).
|
|
1123
|
+
|
|
1068
1124
|
### v1.3.7 — Consolidación interna + helpers clamp
|
|
1069
1125
|
|
|
1070
1126
|
Release de mantenimiento enfocado en limpieza de código. Cero cambios de comportamiento:
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
_Colors • Gradients • Animations • ASCII Art • Pixel Art • Trees • Components • Themes_
|
|
8
8
|
|
|
9
9
|
[](LICENSE)
|
|
10
|
-
[](https://www.npmjs.com/package/ansimax)
|
|
11
11
|
[](tsconfig.json)
|
|
12
12
|
[](#testing)
|
|
13
13
|
[](#testing)
|
|
@@ -478,7 +478,7 @@ console.log(components.table([
|
|
|
478
478
|
['loaders', color.green('● ready'), '100%'],
|
|
479
479
|
], { borderStyle: 'rounded' }));
|
|
480
480
|
|
|
481
|
-
console.log(components.badge('VERSION', 'v1.
|
|
481
|
+
console.log(components.badge('VERSION', 'v1.4.1'));
|
|
482
482
|
console.log(components.badge('BUILD', 'passing'));
|
|
483
483
|
```
|
|
484
484
|
|
|
@@ -1065,6 +1065,62 @@ ansimax/
|
|
|
1065
1065
|
|
|
1066
1066
|
## 📝 Changelog
|
|
1067
1067
|
|
|
1068
|
+
### v1.4.1 — Grid v2 + markdown refactor
|
|
1069
|
+
|
|
1070
|
+
Patch release. Zero breaking changes:
|
|
1071
|
+
|
|
1072
|
+
- 🎯 **`panels.grid` — colSpan**: per-block column span (CSS Grid-style auto-flow)
|
|
1073
|
+
- 📏 **`panels.grid` — cellHeight**: uniform row heights (complements `cellWidth`)
|
|
1074
|
+
- 🔀 **`panels.grid` — flow**: `'row'` (default) or `'column'` auto-flow direction
|
|
1075
|
+
- 📁 **`markdown` refactored** from 522-line monolith → 5 focused submodules (API unchanged)
|
|
1076
|
+
- 🌳 Submodule imports enabled: `import { parseBlocks } from 'ansimax/markdown/block-parser'`
|
|
1077
|
+
- 🧪 **+32 tests**
|
|
1078
|
+
|
|
1079
|
+
```js
|
|
1080
|
+
import { panels, ascii } from 'ansimax';
|
|
1081
|
+
|
|
1082
|
+
// Header spans both columns, then sidebar + content side by side
|
|
1083
|
+
panels.grid([header, sidebar, content], {
|
|
1084
|
+
columns: 2,
|
|
1085
|
+
colSpan: [2, 1, 1],
|
|
1086
|
+
cellHeight: 10, // uniform row height
|
|
1087
|
+
});
|
|
1088
|
+
```
|
|
1089
|
+
|
|
1090
|
+
Drop-in replacement for `1.4.0`.
|
|
1091
|
+
|
|
1092
|
+
### v1.4.0 — Phase 4 closure: Markdown rendering 🎉
|
|
1093
|
+
|
|
1094
|
+
**Minor release** completing Phase 4 with the new `markdown` module:
|
|
1095
|
+
|
|
1096
|
+
- 📝 **`markdown.render(source, opts?)`** — full markdown → terminal pipeline
|
|
1097
|
+
- 🧩 **`markdown.parseBlocks` + `markdown.parseInline`** — low-level helpers
|
|
1098
|
+
- 🎨 **Themes**: `'dark'` (default) and `'light'`
|
|
1099
|
+
- 📐 Renders headings (h1–h6), bold/italic/strikethrough/code, lists, tables, blockquotes, HRs, links
|
|
1100
|
+
- 🔗 Links use OSC 8 hyperlinks (clickable in modern terminals)
|
|
1101
|
+
- 📦 Code blocks rendered in `ascii.box` with language label
|
|
1102
|
+
- 🚀 **Zero new dependencies** — reuses existing `color`, `gradient`, `ascii`, `components`, `hyperlink`
|
|
1103
|
+
- 🧪 **+54 tests** for parser + renderer
|
|
1104
|
+
|
|
1105
|
+
```js
|
|
1106
|
+
import { markdown } from 'ansimax';
|
|
1107
|
+
|
|
1108
|
+
console.log(markdown.render(`
|
|
1109
|
+
# Welcome
|
|
1110
|
+
|
|
1111
|
+
This is **bold** with \`code\` and [a link](https://example.com).
|
|
1112
|
+
|
|
1113
|
+
- Feature one
|
|
1114
|
+
- Feature two
|
|
1115
|
+
|
|
1116
|
+
\`\`\`js
|
|
1117
|
+
const x = 42;
|
|
1118
|
+
\`\`\`
|
|
1119
|
+
`));
|
|
1120
|
+
```
|
|
1121
|
+
|
|
1122
|
+
Phase 4 is now complete. v1.4.x will refine markdown (CommonMark strict, syntax highlighting, nested lists).
|
|
1123
|
+
|
|
1068
1124
|
### v1.3.7 — Internal consolidation + clamp helpers
|
|
1069
1125
|
|
|
1070
1126
|
Maintenance release focused on code cleanup. Zero behavior changes:
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,76 @@
|
|
|
1
|
+
/** Visual theme for rendered output. */
|
|
2
|
+
type MarkdownTheme = 'dark' | 'light';
|
|
3
|
+
interface MarkdownOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Maximum width in columns. Long lines wrap. Default: terminal width
|
|
6
|
+
* or 80 if unavailable.
|
|
7
|
+
*/
|
|
8
|
+
width?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Color theme. `'dark'` (default) uses bright colors for dark backgrounds.
|
|
11
|
+
* `'light'` uses dimmer/contrast colors for light backgrounds.
|
|
12
|
+
*/
|
|
13
|
+
theme?: MarkdownTheme;
|
|
14
|
+
/**
|
|
15
|
+
* Override the gradient used for top-level (`# H1`) headings. Receives
|
|
16
|
+
* a list of hex colors. Default uses the dracula palette.
|
|
17
|
+
*/
|
|
18
|
+
headingGradient?: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Render code blocks inside an ASCII box. Default `true`. If `false`,
|
|
21
|
+
* code blocks render as indented dim text.
|
|
22
|
+
*/
|
|
23
|
+
boxCodeBlocks?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Inline code background tint. Default `true`. If `false`, inline code
|
|
26
|
+
* shows only as dim text (cleaner in some terminals).
|
|
27
|
+
*/
|
|
28
|
+
inlineCodeBackground?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Internal options shape passed to `parseInline`. Exposed for advanced
|
|
32
|
+
* use cases that bypass `render` (custom block handlers, etc.).
|
|
33
|
+
*
|
|
34
|
+
* @since 1.4.0
|
|
35
|
+
*/
|
|
36
|
+
interface InlineOptions {
|
|
37
|
+
theme: MarkdownTheme;
|
|
38
|
+
inlineCodeBackground: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Block-level token after parsing the markdown into structural pieces.
|
|
42
|
+
* Tokens contain raw inline text — inline parsing happens at render time.
|
|
43
|
+
*
|
|
44
|
+
* @since 1.4.0
|
|
45
|
+
*/
|
|
46
|
+
type Block = {
|
|
47
|
+
type: 'heading';
|
|
48
|
+
level: number;
|
|
49
|
+
text: string;
|
|
50
|
+
} | {
|
|
51
|
+
type: 'paragraph';
|
|
52
|
+
text: string;
|
|
53
|
+
} | {
|
|
54
|
+
type: 'codeblock';
|
|
55
|
+
lang: string;
|
|
56
|
+
code: string;
|
|
57
|
+
} | {
|
|
58
|
+
type: 'list';
|
|
59
|
+
ordered: boolean;
|
|
60
|
+
items: string[];
|
|
61
|
+
} | {
|
|
62
|
+
type: 'blockquote';
|
|
63
|
+
text: string;
|
|
64
|
+
} | {
|
|
65
|
+
type: 'table';
|
|
66
|
+
headers: string[];
|
|
67
|
+
rows: string[][];
|
|
68
|
+
} | {
|
|
69
|
+
type: 'hr';
|
|
70
|
+
} | {
|
|
71
|
+
type: 'blank';
|
|
72
|
+
};
|
|
73
|
+
|
|
1
74
|
/** Color rendering capability. 'none' suppresses all color output. */
|
|
2
75
|
type ColorMode = 'none' | 'basic' | '256' | 'truecolor' | 'auto';
|
|
3
76
|
/** Animation pacing multiplier preset. */
|
|
@@ -2713,6 +2786,46 @@ interface GridOptions {
|
|
|
2713
2786
|
* use the max width of the widest block in their column.
|
|
2714
2787
|
*/
|
|
2715
2788
|
cellWidth?: number | null;
|
|
2789
|
+
/**
|
|
2790
|
+
* **v1.4.1+** Fix each row to this height (in lines). When the block has
|
|
2791
|
+
* fewer lines, it is padded (using `alignY`). When it has more lines, it
|
|
2792
|
+
* is truncated. If omitted (default), rows take the natural height of
|
|
2793
|
+
* their tallest block.
|
|
2794
|
+
*
|
|
2795
|
+
* @since 1.4.1
|
|
2796
|
+
*/
|
|
2797
|
+
cellHeight?: number | null;
|
|
2798
|
+
/**
|
|
2799
|
+
* **v1.4.1+** Per-block column span. `colSpan[i]` is the number of
|
|
2800
|
+
* columns block `i` occupies. Defaults to `1` for every block when
|
|
2801
|
+
* omitted or shorter than `blocks`.
|
|
2802
|
+
*
|
|
2803
|
+
* The auto-flow algorithm wraps to the next row when the current row's
|
|
2804
|
+
* remaining capacity is less than the next block's span. Spans that
|
|
2805
|
+
* exceed `columns` are clamped to `columns`.
|
|
2806
|
+
*
|
|
2807
|
+
* @example
|
|
2808
|
+
* ```js
|
|
2809
|
+
* // Header spans full width, then 2 cells in a row
|
|
2810
|
+
* panels.grid([header, left, right], {
|
|
2811
|
+
* columns: 2,
|
|
2812
|
+
* colSpan: [2, 1, 1],
|
|
2813
|
+
* });
|
|
2814
|
+
* ```
|
|
2815
|
+
*
|
|
2816
|
+
* @since 1.4.1
|
|
2817
|
+
*/
|
|
2818
|
+
colSpan?: number[];
|
|
2819
|
+
/**
|
|
2820
|
+
* **v1.4.1+** Auto-flow direction. `'row'` (default) fills cells
|
|
2821
|
+
* left-to-right then wraps to the next row — matches CSS Grid's
|
|
2822
|
+
* `grid-auto-flow: row`. `'column'` fills top-to-bottom then wraps to
|
|
2823
|
+
* the next column. Not applicable when `colSpan` is set with any
|
|
2824
|
+
* span > 1 (forces 'row' mode).
|
|
2825
|
+
*
|
|
2826
|
+
* @since 1.4.1
|
|
2827
|
+
*/
|
|
2828
|
+
flow?: 'row' | 'column';
|
|
2716
2829
|
}
|
|
2717
2830
|
/**
|
|
2718
2831
|
* Arrange blocks in a grid of N columns, flowing left-to-right then
|
|
@@ -2887,6 +3000,66 @@ declare const json: {
|
|
|
2887
3000
|
pretty: (value: unknown, opts?: PrettyOptions) => string;
|
|
2888
3001
|
};
|
|
2889
3002
|
|
|
3003
|
+
/**
|
|
3004
|
+
* Parse markdown source into a flat sequence of block tokens.
|
|
3005
|
+
* Tokens contain raw inline text — inline parsing happens at render time.
|
|
3006
|
+
*
|
|
3007
|
+
* @since 1.4.0
|
|
3008
|
+
*/
|
|
3009
|
+
declare const parseBlocks: (source: string) => Block[];
|
|
3010
|
+
|
|
3011
|
+
/**
|
|
3012
|
+
* Apply inline markdown markup (bold/italic/code/links/etc.) to a string.
|
|
3013
|
+
*
|
|
3014
|
+
* @since 1.4.0
|
|
3015
|
+
*/
|
|
3016
|
+
declare const parseInline: (text: string, opts?: InlineOptions) => string;
|
|
3017
|
+
|
|
3018
|
+
/**
|
|
3019
|
+
* Render a markdown source string to a terminal-ready string with ANSI
|
|
3020
|
+
* styling. Handles headings, paragraphs, code blocks, lists, blockquotes,
|
|
3021
|
+
* tables, inline emphasis, links, and horizontal rules.
|
|
3022
|
+
*
|
|
3023
|
+
* @example
|
|
3024
|
+
* ```ts
|
|
3025
|
+
* import { markdown } from 'ansimax';
|
|
3026
|
+
*
|
|
3027
|
+
* const out = markdown.render(`
|
|
3028
|
+
* # Welcome
|
|
3029
|
+
*
|
|
3030
|
+
* This is **bold** with \`inline code\` and [a link](https://example.com).
|
|
3031
|
+
*
|
|
3032
|
+
* - First item
|
|
3033
|
+
* - Second item
|
|
3034
|
+
*
|
|
3035
|
+
* \`\`\`js
|
|
3036
|
+
* const x = 42;
|
|
3037
|
+
* \`\`\`
|
|
3038
|
+
* `);
|
|
3039
|
+
*
|
|
3040
|
+
* console.log(out);
|
|
3041
|
+
* ```
|
|
3042
|
+
*
|
|
3043
|
+
* @since 1.4.0
|
|
3044
|
+
*/
|
|
3045
|
+
declare const render: (source: string, opts?: MarkdownOptions) => string;
|
|
3046
|
+
|
|
3047
|
+
/**
|
|
3048
|
+
* Markdown → terminal renderer. Use `markdown.render(source, opts?)` to
|
|
3049
|
+
* convert a markdown string to an ANSI-styled string ready for
|
|
3050
|
+
* `console.log` or `process.stdout.write`.
|
|
3051
|
+
*
|
|
3052
|
+
* Lower-level helpers `parseBlocks` and `parseInline` are also exposed
|
|
3053
|
+
* for advanced use cases (custom block handlers, partial rendering).
|
|
3054
|
+
*
|
|
3055
|
+
* @since 1.4.0
|
|
3056
|
+
*/
|
|
3057
|
+
declare const markdown: {
|
|
3058
|
+
render: (source: string, opts?: MarkdownOptions) => string;
|
|
3059
|
+
parseBlocks: (source: string) => Block[];
|
|
3060
|
+
parseInline: (text: string, opts?: InlineOptions) => string;
|
|
3061
|
+
};
|
|
3062
|
+
|
|
2890
3063
|
type EasingFunction = (t: number) => number;
|
|
2891
3064
|
/**
|
|
2892
3065
|
* Union of all built-in easing names in the comprehensive Robert Penner
|
|
@@ -3088,6 +3261,21 @@ declare const ansimax: {
|
|
|
3088
3261
|
clearAnsiCache: () => void;
|
|
3089
3262
|
};
|
|
3090
3263
|
configure: (opts?: AnsimaxConfig, meta?: ConfigureOptions) => void;
|
|
3264
|
+
panels: {
|
|
3265
|
+
vsplit: (blocks: string[], opts?: VsplitOptions) => string;
|
|
3266
|
+
hsplit: (blocks: string[], opts?: HsplitOptions) => string;
|
|
3267
|
+
center: (block: string, opts: CenterOptions) => string;
|
|
3268
|
+
frame: (block: string, opts?: FrameOptions) => string;
|
|
3269
|
+
grid: (blocks: string[], opts: GridOptions) => string;
|
|
3270
|
+
};
|
|
3271
|
+
json: {
|
|
3272
|
+
pretty: (value: unknown, opts?: PrettyOptions) => string;
|
|
3273
|
+
};
|
|
3274
|
+
markdown: {
|
|
3275
|
+
render: (source: string, opts?: MarkdownOptions) => string;
|
|
3276
|
+
parseBlocks: (source: string) => Block[];
|
|
3277
|
+
parseInline: (text: string, opts?: InlineOptions) => string;
|
|
3278
|
+
};
|
|
3091
3279
|
};
|
|
3092
3280
|
|
|
3093
|
-
export { ASCII_RAMPS, type Alignment, type AnimateGradientController, type AnimateGradientOptions, type AnimationHooks, type AnimationSpeed, type AnsiCode, type AnsimaxConfig, type AsciiRamp, BEL, BG, type BadgeOptions, type BallOptions, type BannerOptions, type BoxOptions, type BoxStyle, type BreatheOptions, DEFAULTS as CONFIG_DEFAULTS, CSI, type Canvas, type CanvasRenderOptions, type CenterOptions, type ColorChain, type ColorFn, type ColorLevel, type ColorMode, type ColorSpace, type ColorSupport, type ColumnsOptions, type ConfigChangeListener, type ConfigKey, type ConfigKeyListener, type ConfigureOptions, type CountdownOptions, type CustomOptions, DEFAULT_TERM_COLS, DEFAULT_TERM_ROWS, type DebounceOptions, type DiffType, type Dimensions, type DividerOptions, type DotsOptions, ESC, type EasingFn, type EasingFunction, type EasingLibraryName, type EasingName, type EraseMode, FG, FRAME_MS, type FadeOptions, type FigletFont, type FigletOptions, type FontMap, type FontName, type FrameCallback, type FrameHandle, type FrameOptions, type FromImageOptions, type GlitchOptions, type Glyph, type GradientOptions, type GradientRectOptions, type GridOptions, type HSL, type HsplitOptions, type PrettyOptions as JsonPrettyOptions, type LineDiff, type LiveController, type LiveOptions, type LoadingBarOptions, type LogoOptions, MENU_CANCELLED, type MemoizeOptions, type MenuInput, type MenuOptions, type MenuOutput, type MenuResult, type MultiLoader, type MultiLoaderItem, OSC, type Oklab, type OnResizeOptions, type OutputBuffer, type ParallelOptions, type ParallelStep, type Pixel, type PixelGrid, type PlayController, type PlayOptions, type PresetName, type ProgressAnimateOptions, type ProgressBarOptions, type ProgressOptions, type PulseOptions, type RGB, type RGBA, type RegisterFontOptions, type RenderOptions$1 as RenderOptions, type ResizeListener, type ReusableGradient, type RevealOptions, SPINNERS, SPRITES, ST, STYLE, type SectionOptions, type SleepOptions, type SlideOptions, type SpinOptions, type SpinnerType, type StatusOptions, type StatusType, type StopFn, type StreamOptions, type TableBorderStyle, type TableOptions, type Task, type TaskResult, type TasksOptions, type Theme, type BannerOpts as ThemeBannerOpts, type ThemeChangeListener, type ThemeInstance, type ThemeStyleName, type TimelineEvent, type TimelineOptions, type TreeData, type TreeDimensions, type TreeNode, type RenderOptions as TreeRenderOptions, type TreeStyle, type TypeDeleteOptions, type TypewriterOptions, type VsplitOptions, type WalkVisitor, type WaveOptions, type WriteAsyncOptions, animate, animateGradient, ascii, bell, bg256, bgRgb, box, canAnimate, cancelTerminalFrame, center$1 as center, center as centerBlock, chain, charWidth, clamp, clampByte, clampInt, clampPercent, clearAnsiCache, clearColorCache, clearLine, clearRenderCache, clearThemeColorCache, color, colorLevel, presets as colorPresets, components, compose, configure, countNodes, createCanvas, createGradient, createOutputBuffer, createTheme, cursor, debounce, ansimax as default, diffLines, easings, escapeForRegex, escapeRegex, fg256, fgRgb, figletText, filterTree, findInTree, flipHorizontal, flipVertical, frame, frames, fromImage, getConfig, getConfigValue, getRenderCacheSize, getSpeedMultiplier, getTerminalHeight, getTerminalWidth, gradient, gradientColor, gradientRect, gradientStops, graphemes, grid, hasFont, hexToRgb, hideCursor, hslToRgb, hsplit, hyperlink, images, isFiniteNumber, isHexColor, isNoColor, json, pretty as jsonPretty, lerp, lerpColor, link, listFonts, listPresets, loader, mapTree, measureBlock, measureTree, memoize, mixColors, nextTick, oklabToRgb, onConfigChange, onConfigKeyChange, onResize, once, padBoth, padEnd, padStart, panels, parseFiglet, pauseListeners, presetNames, presets, quantizeColor, rainbow, registerFont, registerPreset, renderPixelArt, renderTree, renderTreeStream, repeatVisible, requestTerminalFrame, reset, resetColorSupportCache, resetConfig, resetCursorRefCount, resetFramesCursorCount, resetLoaderCursorCount, resetNoColor, resolveEasingByName, resumeListeners, reverseGradient, rgbTo256, rgbToHex, rgbToHsl, rgbToOklab, rotate90, safeInt, safeJson, screen, setConfigValue, setNoColor, setTitle, sgr, showCursor, sleep, sleepFrame, sliceAnsi, stripAnsi$2 as stripAnsi, stripAnsi$1 as stripAnsiCodes, stripAnsi as stripAnsiColors, subscribeConfig, supportsColor, supportsColorLevel, termSize, themes, throttle, tree, trees, truncateAnsi, visibleLen, vsplit, walkTree, withConfig, wordWrap, wrapAnsi, write, writeAsync, writeErr, writeln, writelnErr };
|
|
3281
|
+
export { ASCII_RAMPS, type Alignment, type AnimateGradientController, type AnimateGradientOptions, type AnimationHooks, type AnimationSpeed, type AnsiCode, type AnsimaxConfig, type AsciiRamp, BEL, BG, type BadgeOptions, type BallOptions, type BannerOptions, type BoxOptions, type BoxStyle, type BreatheOptions, DEFAULTS as CONFIG_DEFAULTS, CSI, type Canvas, type CanvasRenderOptions, type CenterOptions, type ColorChain, type ColorFn, type ColorLevel, type ColorMode, type ColorSpace, type ColorSupport, type ColumnsOptions, type ConfigChangeListener, type ConfigKey, type ConfigKeyListener, type ConfigureOptions, type CountdownOptions, type CustomOptions, DEFAULT_TERM_COLS, DEFAULT_TERM_ROWS, type DebounceOptions, type DiffType, type Dimensions, type DividerOptions, type DotsOptions, ESC, type EasingFn, type EasingFunction, type EasingLibraryName, type EasingName, type EraseMode, FG, FRAME_MS, type FadeOptions, type FigletFont, type FigletOptions, type FontMap, type FontName, type FrameCallback, type FrameHandle, type FrameOptions, type FromImageOptions, type GlitchOptions, type Glyph, type GradientOptions, type GradientRectOptions, type GridOptions, type HSL, type HsplitOptions, type PrettyOptions as JsonPrettyOptions, type LineDiff, type LiveController, type LiveOptions, type LoadingBarOptions, type LogoOptions, MENU_CANCELLED, type MarkdownOptions, type MarkdownTheme, type MemoizeOptions, type MenuInput, type MenuOptions, type MenuOutput, type MenuResult, type MultiLoader, type MultiLoaderItem, OSC, type Oklab, type OnResizeOptions, type OutputBuffer, type ParallelOptions, type ParallelStep, type Pixel, type PixelGrid, type PlayController, type PlayOptions, type PresetName, type ProgressAnimateOptions, type ProgressBarOptions, type ProgressOptions, type PulseOptions, type RGB, type RGBA, type RegisterFontOptions, type RenderOptions$1 as RenderOptions, type ResizeListener, type ReusableGradient, type RevealOptions, SPINNERS, SPRITES, ST, STYLE, type SectionOptions, type SleepOptions, type SlideOptions, type SpinOptions, type SpinnerType, type StatusOptions, type StatusType, type StopFn, type StreamOptions, type TableBorderStyle, type TableOptions, type Task, type TaskResult, type TasksOptions, type Theme, type BannerOpts as ThemeBannerOpts, type ThemeChangeListener, type ThemeInstance, type ThemeStyleName, type TimelineEvent, type TimelineOptions, type TreeData, type TreeDimensions, type TreeNode, type RenderOptions as TreeRenderOptions, type TreeStyle, type TypeDeleteOptions, type TypewriterOptions, type VsplitOptions, type WalkVisitor, type WaveOptions, type WriteAsyncOptions, animate, animateGradient, ascii, bell, bg256, bgRgb, box, canAnimate, cancelTerminalFrame, center$1 as center, center as centerBlock, chain, charWidth, clamp, clampByte, clampInt, clampPercent, clearAnsiCache, clearColorCache, clearLine, clearRenderCache, clearThemeColorCache, color, colorLevel, presets as colorPresets, components, compose, configure, countNodes, createCanvas, createGradient, createOutputBuffer, createTheme, cursor, debounce, ansimax as default, diffLines, easings, escapeForRegex, escapeRegex, fg256, fgRgb, figletText, filterTree, findInTree, flipHorizontal, flipVertical, frame, frames, fromImage, getConfig, getConfigValue, getRenderCacheSize, getSpeedMultiplier, getTerminalHeight, getTerminalWidth, gradient, gradientColor, gradientRect, gradientStops, graphemes, grid, hasFont, hexToRgb, hideCursor, hslToRgb, hsplit, hyperlink, images, isFiniteNumber, isHexColor, isNoColor, json, pretty as jsonPretty, lerp, lerpColor, link, listFonts, listPresets, loader, mapTree, markdown, measureBlock, measureTree, memoize, mixColors, nextTick, oklabToRgb, onConfigChange, onConfigKeyChange, onResize, once, padBoth, padEnd, padStart, panels, parseFiglet, parseBlocks as parseMarkdownBlocks, parseInline as parseMarkdownInline, pauseListeners, presetNames, presets, quantizeColor, rainbow, registerFont, registerPreset, render as renderMarkdown, renderPixelArt, renderTree, renderTreeStream, repeatVisible, requestTerminalFrame, reset, resetColorSupportCache, resetConfig, resetCursorRefCount, resetFramesCursorCount, resetLoaderCursorCount, resetNoColor, resolveEasingByName, resumeListeners, reverseGradient, rgbTo256, rgbToHex, rgbToHsl, rgbToOklab, rotate90, safeInt, safeJson, screen, setConfigValue, setNoColor, setTitle, sgr, showCursor, sleep, sleepFrame, sliceAnsi, stripAnsi$2 as stripAnsi, stripAnsi$1 as stripAnsiCodes, stripAnsi as stripAnsiColors, subscribeConfig, supportsColor, supportsColorLevel, termSize, themes, throttle, tree, trees, truncateAnsi, visibleLen, vsplit, walkTree, withConfig, wordWrap, wrapAnsi, write, writeAsync, writeErr, writeln, writelnErr };
|