ansimax 1.3.6 → 1.4.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/CHANGELOG.md +182 -0
- package/README.es.md +56 -2
- package/README.md +56 -2
- package/dist/index.d.mts +201 -1
- package/dist/index.d.ts +201 -1
- package/dist/index.js +360 -76
- package/dist/index.mjs +354 -76
- 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,188 @@
|
|
|
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.0] — Phase 4 closure: Markdown rendering
|
|
7
|
+
|
|
8
|
+
**Minor release** introducing the long-planned `markdown` module — the
|
|
9
|
+
final piece of Phase 4 (after `panels` v1.3.0 and `json` v1.3.0).
|
|
10
|
+
|
|
11
|
+
Renders standard Markdown to ANSI-styled terminal output using the
|
|
12
|
+
existing ansimax primitives (`color`, `gradient`, `ascii.box`,
|
|
13
|
+
`components.table`, `hyperlink`). **Zero new runtime dependencies.**
|
|
14
|
+
|
|
15
|
+
### Added — `markdown` module
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import { markdown } from 'ansimax';
|
|
19
|
+
|
|
20
|
+
console.log(markdown.render(`
|
|
21
|
+
# Welcome
|
|
22
|
+
|
|
23
|
+
This is **bold** and *italic* with \`code\` and [a link](https://example.com).
|
|
24
|
+
|
|
25
|
+
- Item 1
|
|
26
|
+
- Item 2
|
|
27
|
+
|
|
28
|
+
\`\`\`js
|
|
29
|
+
const x = 42;
|
|
30
|
+
\`\`\`
|
|
31
|
+
|
|
32
|
+
> Quoted wisdom
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
| Name | Value |
|
|
37
|
+
|---|---|
|
|
38
|
+
| foo | 1 |
|
|
39
|
+
| bar | 2 |
|
|
40
|
+
`));
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Supported markdown
|
|
44
|
+
|
|
45
|
+
| Markdown | Rendered using |
|
|
46
|
+
|---|---|
|
|
47
|
+
| `#` to `######` headings | `gradient` (h1) + `color.hex` (h2–h6) |
|
|
48
|
+
| **Bold** (`**` or `__`) | `color.bold` |
|
|
49
|
+
| *Italic* (`*` or `_`) | `color.italic` |
|
|
50
|
+
| ~~Strikethrough~~ (`~~`) | `color.strikethrough` |
|
|
51
|
+
| `Inline code` (``` ` ```) | dim + tinted background |
|
|
52
|
+
| ```` ```code blocks``` ```` | `ascii.box` with language label as title |
|
|
53
|
+
| `- item` / `* item` / `1.` lists | indented bullets |
|
|
54
|
+
| `> blockquote` | `│` prefix + dim |
|
|
55
|
+
| `--- / *** / ___` HRs | `ascii.divider` |
|
|
56
|
+
| `[label](url)` | `hyperlink` (OSC 8) |
|
|
57
|
+
| `\| a \| b \|` tables | `components.table` |
|
|
58
|
+
|
|
59
|
+
### API
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
// Main entry — high-level render
|
|
63
|
+
markdown.render(source: string, opts?: MarkdownOptions): string
|
|
64
|
+
|
|
65
|
+
// Lower-level helpers (advanced use)
|
|
66
|
+
markdown.parseBlocks(source: string): Block[]
|
|
67
|
+
markdown.parseInline(text: string, opts?): string
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Options
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
interface MarkdownOptions {
|
|
74
|
+
width?: number; // default: terminal width or 80
|
|
75
|
+
theme?: 'dark' | 'light'; // default 'dark'
|
|
76
|
+
headingGradient?: string[]; // override h1 gradient colors
|
|
77
|
+
boxCodeBlocks?: boolean; // default true; false = indented dim
|
|
78
|
+
inlineCodeBackground?: boolean; // default true
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Design notes
|
|
83
|
+
|
|
84
|
+
- **Pure functions** — `parseBlocks` and `parseInline` are deterministic
|
|
85
|
+
- **No regex backtracking** — all patterns are anchored, single-pass
|
|
86
|
+
- **Code blocks protect contents** — `**bold**` inside `` ` `` stays literal
|
|
87
|
+
- **Inline parser precedence**: code > links > strikethrough > bold > italic
|
|
88
|
+
- **Graceful degradation** — malformed markdown renders as plain text
|
|
89
|
+
rather than throwing
|
|
90
|
+
|
|
91
|
+
### Tests
|
|
92
|
+
|
|
93
|
+
- `+18` tests for `parseBlocks` (headings, lists, code, tables, blockquotes, HRs, edge cases)
|
|
94
|
+
- `+13` tests for `parseInline` (bold/italic/code/links/strikethrough, precedence, protection)
|
|
95
|
+
- `+19` tests for `render` (full pipeline, integration, options, theming)
|
|
96
|
+
- `+2` tests for namespace + `+2` for barrel re-exports
|
|
97
|
+
|
|
98
|
+
Total: **+54 tests** in a new `markdown.test.ts` file.
|
|
99
|
+
|
|
100
|
+
### Roadmap note
|
|
101
|
+
|
|
102
|
+
Phase 4 of the project is now closed. Future v1.4.x patches will refine
|
|
103
|
+
the markdown module:
|
|
104
|
+
- v1.4.1+ — CommonMark spec strict mode (escapes, reference links, setext headings)
|
|
105
|
+
- v1.4.2+ — Optional syntax highlighting for code blocks (basic JS/TS/JSON/Bash)
|
|
106
|
+
- v1.4.3+ — Nested lists (currently flat)
|
|
107
|
+
- v1.4.4+ — Custom themes / theme registry
|
|
108
|
+
|
|
109
|
+
### Notes
|
|
110
|
+
|
|
111
|
+
- **No breaking changes** — new module, all existing APIs unchanged
|
|
112
|
+
- **Drop-in replacement** for `1.3.7`
|
|
113
|
+
- Zero runtime dependencies maintained
|
|
114
|
+
- All markdown features implemented in ~450 lines of source
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## [1.3.7] — Internal consolidation + new clamp helpers
|
|
119
|
+
|
|
120
|
+
Maintenance release focused on code cleanup. Zero behavior changes —
|
|
121
|
+
internal duplications consolidated into the existing `utils/helpers`
|
|
122
|
+
module, plus two new exported helpers that codify the most common
|
|
123
|
+
defensive patterns.
|
|
124
|
+
|
|
125
|
+
### Added — New exported helpers
|
|
126
|
+
|
|
127
|
+
**`clampPercent(value)`** — clamp + coerce to 0–100 range, with 0 fallback
|
|
128
|
+
for non-finite input. Previously duplicated as a private function in
|
|
129
|
+
`components/index.ts` and `loaders/index.ts`:
|
|
130
|
+
|
|
131
|
+
```js
|
|
132
|
+
import { clampPercent } from 'ansimax';
|
|
133
|
+
|
|
134
|
+
clampPercent(50) // → 50
|
|
135
|
+
clampPercent(150) // → 100
|
|
136
|
+
clampPercent(-5) // → 0
|
|
137
|
+
clampPercent(NaN) // → 0
|
|
138
|
+
clampPercent('abc') // → 0
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**`clampInt(value, min, max, fallback?)`** — coerce to integer clamped
|
|
142
|
+
between `[min, max]`. Falls back (and clamps) when input is non-finite:
|
|
143
|
+
|
|
144
|
+
```js
|
|
145
|
+
import { clampInt } from 'ansimax';
|
|
146
|
+
|
|
147
|
+
clampInt(50.7, 0, 100) // → 50 (floored)
|
|
148
|
+
clampInt(150, 0, 100) // → 100 (clamped)
|
|
149
|
+
clampInt(NaN, 0, 100, 25) // → 25 (fallback, also clamped)
|
|
150
|
+
clampInt(NaN, 10, 20, 999) // → 20 (fallback clamped to range)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Improved — Internal consolidation (DRY)
|
|
154
|
+
|
|
155
|
+
Removed 5 copies of the inline `isFiniteNumber` definition that were
|
|
156
|
+
duplicated across modules. They now all import the canonical version
|
|
157
|
+
from `utils/helpers` (exported since v1.3.5):
|
|
158
|
+
|
|
159
|
+
- `components/index.ts` — was 1 inline copy + 1 inline `clampPercent`
|
|
160
|
+
- `frames/index.ts` — was 1 inline copy
|
|
161
|
+
- `images/index.ts` — was 1 inline copy + 1 inline `clampInt`
|
|
162
|
+
- `loaders/index.ts` — was 1 inline copy + 1 inline `clampPercent`
|
|
163
|
+
- `trees/index.ts` — was 1 inline copy
|
|
164
|
+
|
|
165
|
+
`utils/ansi.ts` intentionally keeps its private copy to avoid creating a
|
|
166
|
+
dependency on `utils/helpers` (the two modules are deliberately
|
|
167
|
+
independent at the bottom of the dependency graph).
|
|
168
|
+
|
|
169
|
+
### Improved — Tests
|
|
170
|
+
|
|
171
|
+
- `+6` tests for `clampPercent` (range, fallback, fractional values, non-numeric input)
|
|
172
|
+
- `+6` tests for `clampInt` (clamping, fallback behavior, edge cases)
|
|
173
|
+
- `+1` test for barrel re-exports
|
|
174
|
+
|
|
175
|
+
Total: **+13 tests**.
|
|
176
|
+
|
|
177
|
+
### Notes
|
|
178
|
+
|
|
179
|
+
- **No behavior changes** — the consolidated helpers are byte-identical
|
|
180
|
+
to the inline copies they replaced
|
|
181
|
+
- **No API changes** — only additions (`clampPercent`, `clampInt`)
|
|
182
|
+
- **No breaking changes** — drop-in replacement for `1.3.6`
|
|
183
|
+
- Smaller bundle output expected as TypeScript can dedupe the
|
|
184
|
+
consolidated implementations
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
6
188
|
## [1.3.6] — Branch coverage improvements
|
|
7
189
|
|
|
8
190
|
Maintenance release. Zero behavior changes — only adds tests covering
|
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.0'));
|
|
482
482
|
console.log(components.badge('BUILD', 'passing'));
|
|
483
483
|
```
|
|
484
484
|
|
|
@@ -1065,6 +1065,60 @@ ansimax/
|
|
|
1065
1065
|
|
|
1066
1066
|
## 📝 Changelog
|
|
1067
1067
|
|
|
1068
|
+
### v1.4.0 — Cierre de Fase 4: Renderizado Markdown 🎉
|
|
1069
|
+
|
|
1070
|
+
**Release minor** completando la Fase 4 con el nuevo módulo `markdown`:
|
|
1071
|
+
|
|
1072
|
+
- 📝 **`markdown.render(source, opts?)`** — pipeline completo markdown → terminal
|
|
1073
|
+
- 🧩 **`markdown.parseBlocks` + `markdown.parseInline`** — helpers de bajo nivel
|
|
1074
|
+
- 🎨 **Temas**: `'dark'` (default) y `'light'`
|
|
1075
|
+
- 📐 Renderiza headings (h1–h6), bold/italic/strikethrough/code, listas, tablas, blockquotes, HRs, links
|
|
1076
|
+
- 🔗 Links usan hyperlinks OSC 8 (clickables en terminales modernos)
|
|
1077
|
+
- 📦 Bloques de código renderizados en `ascii.box` con label de lenguaje
|
|
1078
|
+
- 🚀 **Cero dependencias nuevas** — reusa `color`, `gradient`, `ascii`, `components`, `hyperlink`
|
|
1079
|
+
- 🧪 **+54 tests** para parser + renderer
|
|
1080
|
+
|
|
1081
|
+
```js
|
|
1082
|
+
import { markdown } from 'ansimax';
|
|
1083
|
+
|
|
1084
|
+
console.log(markdown.render(`
|
|
1085
|
+
# Bienvenido
|
|
1086
|
+
|
|
1087
|
+
Esto es **bold** con \`code\` y [un link](https://example.com).
|
|
1088
|
+
|
|
1089
|
+
- Feature uno
|
|
1090
|
+
- Feature dos
|
|
1091
|
+
|
|
1092
|
+
\`\`\`js
|
|
1093
|
+
const x = 42;
|
|
1094
|
+
\`\`\`
|
|
1095
|
+
`));
|
|
1096
|
+
```
|
|
1097
|
+
|
|
1098
|
+
La Fase 4 está completa. v1.4.x refinará markdown (CommonMark estricto, syntax highlighting, listas anidadas).
|
|
1099
|
+
|
|
1100
|
+
### v1.3.7 — Consolidación interna + helpers clamp
|
|
1101
|
+
|
|
1102
|
+
Release de mantenimiento enfocado en limpieza de código. Cero cambios de comportamiento:
|
|
1103
|
+
|
|
1104
|
+
- ➕ **`clampPercent(value)`** — clamp + coerce a rango 0–100 (NaN/no-numérico → 0)
|
|
1105
|
+
- ➕ **`clampInt(value, min, max, fallback?)`** — clamp de enteros con fallback seguro
|
|
1106
|
+
- 🧹 Removidas 5 copias duplicadas de `isFiniteNumber` entre módulos (ahora importadas desde `utils/helpers`)
|
|
1107
|
+
- 🧹 Removidas 2 copias duplicadas de `clampPercent` (components + loaders)
|
|
1108
|
+
- 🧹 Removida 1 copia duplicada de `clampInt` en images
|
|
1109
|
+
- 🧪 **+13 tests** para los helpers consolidados
|
|
1110
|
+
|
|
1111
|
+
```js
|
|
1112
|
+
import { clampPercent, clampInt } from 'ansimax';
|
|
1113
|
+
|
|
1114
|
+
clampPercent(150) // → 100 (clamped)
|
|
1115
|
+
clampPercent(NaN) // → 0 (fallback seguro)
|
|
1116
|
+
clampInt(50.7, 0, 100) // → 50 (floored + clamped)
|
|
1117
|
+
clampInt(NaN, 0, 100, 25) // → 25 (fallback con inválidos)
|
|
1118
|
+
```
|
|
1119
|
+
|
|
1120
|
+
Drop-in replacement para `1.3.6`.
|
|
1121
|
+
|
|
1068
1122
|
### v1.3.6 — Mejoras de branch coverage
|
|
1069
1123
|
|
|
1070
1124
|
Release de mantenimiento. 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.0'));
|
|
482
482
|
console.log(components.badge('BUILD', 'passing'));
|
|
483
483
|
```
|
|
484
484
|
|
|
@@ -1065,6 +1065,60 @@ ansimax/
|
|
|
1065
1065
|
|
|
1066
1066
|
## 📝 Changelog
|
|
1067
1067
|
|
|
1068
|
+
### v1.4.0 — Phase 4 closure: Markdown rendering 🎉
|
|
1069
|
+
|
|
1070
|
+
**Minor release** completing Phase 4 with the new `markdown` module:
|
|
1071
|
+
|
|
1072
|
+
- 📝 **`markdown.render(source, opts?)`** — full markdown → terminal pipeline
|
|
1073
|
+
- 🧩 **`markdown.parseBlocks` + `markdown.parseInline`** — low-level helpers
|
|
1074
|
+
- 🎨 **Themes**: `'dark'` (default) and `'light'`
|
|
1075
|
+
- 📐 Renders headings (h1–h6), bold/italic/strikethrough/code, lists, tables, blockquotes, HRs, links
|
|
1076
|
+
- 🔗 Links use OSC 8 hyperlinks (clickable in modern terminals)
|
|
1077
|
+
- 📦 Code blocks rendered in `ascii.box` with language label
|
|
1078
|
+
- 🚀 **Zero new dependencies** — reuses existing `color`, `gradient`, `ascii`, `components`, `hyperlink`
|
|
1079
|
+
- 🧪 **+54 tests** for parser + renderer
|
|
1080
|
+
|
|
1081
|
+
```js
|
|
1082
|
+
import { markdown } from 'ansimax';
|
|
1083
|
+
|
|
1084
|
+
console.log(markdown.render(`
|
|
1085
|
+
# Welcome
|
|
1086
|
+
|
|
1087
|
+
This is **bold** with \`code\` and [a link](https://example.com).
|
|
1088
|
+
|
|
1089
|
+
- Feature one
|
|
1090
|
+
- Feature two
|
|
1091
|
+
|
|
1092
|
+
\`\`\`js
|
|
1093
|
+
const x = 42;
|
|
1094
|
+
\`\`\`
|
|
1095
|
+
`));
|
|
1096
|
+
```
|
|
1097
|
+
|
|
1098
|
+
Phase 4 is now complete. v1.4.x will refine markdown (CommonMark strict, syntax highlighting, nested lists).
|
|
1099
|
+
|
|
1100
|
+
### v1.3.7 — Internal consolidation + clamp helpers
|
|
1101
|
+
|
|
1102
|
+
Maintenance release focused on code cleanup. Zero behavior changes:
|
|
1103
|
+
|
|
1104
|
+
- ➕ **`clampPercent(value)`** — clamp + coerce to 0–100 range (NaN/non-numeric → 0)
|
|
1105
|
+
- ➕ **`clampInt(value, min, max, fallback?)`** — integer clamp with safe fallback
|
|
1106
|
+
- 🧹 Removed 5 duplicate copies of `isFiniteNumber` across modules (now imported from `utils/helpers`)
|
|
1107
|
+
- 🧹 Removed 2 duplicate copies of `clampPercent` (components + loaders)
|
|
1108
|
+
- 🧹 Removed 1 duplicate `clampInt` from images
|
|
1109
|
+
- 🧪 **+13 tests** for the consolidated helpers
|
|
1110
|
+
|
|
1111
|
+
```js
|
|
1112
|
+
import { clampPercent, clampInt } from 'ansimax';
|
|
1113
|
+
|
|
1114
|
+
clampPercent(150) // → 100 (clamped)
|
|
1115
|
+
clampPercent(NaN) // → 0 (safe fallback)
|
|
1116
|
+
clampInt(50.7, 0, 100) // → 50 (floored + clamped)
|
|
1117
|
+
clampInt(NaN, 0, 100, 25) // → 25 (fallback when invalid)
|
|
1118
|
+
```
|
|
1119
|
+
|
|
1120
|
+
Drop-in replacement for `1.3.6`.
|
|
1121
|
+
|
|
1068
1122
|
### v1.3.6 — Branch coverage improvements
|
|
1069
1123
|
|
|
1070
1124
|
Maintenance release. Zero behavior changes:
|
package/dist/index.d.mts
CHANGED
|
@@ -168,6 +168,42 @@ declare const lerp: (a: number, b: number, t: number) => number;
|
|
|
168
168
|
* @since 1.3.5
|
|
169
169
|
*/
|
|
170
170
|
declare const clampByte: (v: number) => number;
|
|
171
|
+
/**
|
|
172
|
+
* Clamp + coerce a number to the 0–100 percentage range. Returns `0` for
|
|
173
|
+
* non-finite input. Consolidates duplicate `clampPercent` definitions
|
|
174
|
+
* previously living in `components/index.ts` and `loaders/index.ts`.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```ts
|
|
178
|
+
* clampPercent(50) // → 50
|
|
179
|
+
* clampPercent(150) // → 100
|
|
180
|
+
* clampPercent(-5) // → 0
|
|
181
|
+
* clampPercent(NaN) // → 0
|
|
182
|
+
* clampPercent('abc') // → 0
|
|
183
|
+
* ```
|
|
184
|
+
*
|
|
185
|
+
* @since 1.3.7
|
|
186
|
+
*/
|
|
187
|
+
declare const clampPercent: (p: unknown) => number;
|
|
188
|
+
/**
|
|
189
|
+
* Coerce any value to an integer clamped between `[min, max]`. Returns
|
|
190
|
+
* `fallback` (which is also clamped) when input is non-finite.
|
|
191
|
+
*
|
|
192
|
+
* More flexible than `safeInt` for the common pattern
|
|
193
|
+
* `Math.max(min, Math.min(max, Math.floor(n)))` that appears 30+ times
|
|
194
|
+
* across the codebase.
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```ts
|
|
198
|
+
* clampInt(50, 0, 100) // → 50
|
|
199
|
+
* clampInt(150, 0, 100) // → 100
|
|
200
|
+
* clampInt(NaN, 0, 100, 25) // → 25 (fallback)
|
|
201
|
+
* clampInt('abc', 0, 100, 25) // → 25 (fallback)
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
* @since 1.3.7
|
|
205
|
+
*/
|
|
206
|
+
declare const clampInt: (value: unknown, min: number, max: number, fallback?: number) => number;
|
|
171
207
|
/** Returns true when a string is a valid 3- or 6-digit hex color. */
|
|
172
208
|
declare const isHexColor: (hex: string) => boolean;
|
|
173
209
|
/**
|
|
@@ -2851,6 +2887,126 @@ declare const json: {
|
|
|
2851
2887
|
pretty: (value: unknown, opts?: PrettyOptions) => string;
|
|
2852
2888
|
};
|
|
2853
2889
|
|
|
2890
|
+
/** Visual theme for rendered output. */
|
|
2891
|
+
type MarkdownTheme = 'dark' | 'light';
|
|
2892
|
+
interface MarkdownOptions {
|
|
2893
|
+
/**
|
|
2894
|
+
* Maximum width in columns. Long lines wrap. Default: terminal width
|
|
2895
|
+
* or 80 if unavailable.
|
|
2896
|
+
*/
|
|
2897
|
+
width?: number;
|
|
2898
|
+
/**
|
|
2899
|
+
* Color theme. `'dark'` (default) uses bright colors for dark backgrounds.
|
|
2900
|
+
* `'light'` uses dimmer/contrast colors for light backgrounds.
|
|
2901
|
+
*/
|
|
2902
|
+
theme?: MarkdownTheme;
|
|
2903
|
+
/**
|
|
2904
|
+
* Override the gradient used for top-level (`# H1`) headings. Receives
|
|
2905
|
+
* a list of hex colors. Default uses the dracula palette.
|
|
2906
|
+
*/
|
|
2907
|
+
headingGradient?: string[];
|
|
2908
|
+
/**
|
|
2909
|
+
* Render code blocks inside an ASCII box. Default `true`. If `false`,
|
|
2910
|
+
* code blocks render as indented dim text.
|
|
2911
|
+
*/
|
|
2912
|
+
boxCodeBlocks?: boolean;
|
|
2913
|
+
/**
|
|
2914
|
+
* Inline code background tint. Default `true`. If `false`, inline code
|
|
2915
|
+
* shows only as dim text (cleaner in some terminals).
|
|
2916
|
+
*/
|
|
2917
|
+
inlineCodeBackground?: boolean;
|
|
2918
|
+
}
|
|
2919
|
+
/** Block-level token after parsing the markdown into structural pieces. */
|
|
2920
|
+
type Block = {
|
|
2921
|
+
type: 'heading';
|
|
2922
|
+
level: number;
|
|
2923
|
+
text: string;
|
|
2924
|
+
} | {
|
|
2925
|
+
type: 'paragraph';
|
|
2926
|
+
text: string;
|
|
2927
|
+
} | {
|
|
2928
|
+
type: 'codeblock';
|
|
2929
|
+
lang: string;
|
|
2930
|
+
code: string;
|
|
2931
|
+
} | {
|
|
2932
|
+
type: 'list';
|
|
2933
|
+
ordered: boolean;
|
|
2934
|
+
items: string[];
|
|
2935
|
+
} | {
|
|
2936
|
+
type: 'blockquote';
|
|
2937
|
+
text: string;
|
|
2938
|
+
} | {
|
|
2939
|
+
type: 'table';
|
|
2940
|
+
headers: string[];
|
|
2941
|
+
rows: string[][];
|
|
2942
|
+
} | {
|
|
2943
|
+
type: 'hr';
|
|
2944
|
+
} | {
|
|
2945
|
+
type: 'blank';
|
|
2946
|
+
};
|
|
2947
|
+
/**
|
|
2948
|
+
* Parse markdown source into a flat sequence of block tokens.
|
|
2949
|
+
* Tokens contain raw inline text — inline parsing happens at render time.
|
|
2950
|
+
*
|
|
2951
|
+
* @since 1.4.0
|
|
2952
|
+
*/
|
|
2953
|
+
declare const parseBlocks: (source: string) => Block[];
|
|
2954
|
+
/**
|
|
2955
|
+
* Apply inline markdown markup (bold/italic/code/links/etc.) to a string.
|
|
2956
|
+
*
|
|
2957
|
+
* @since 1.4.0
|
|
2958
|
+
*/
|
|
2959
|
+
declare const parseInline: (text: string, opts?: {
|
|
2960
|
+
theme: MarkdownTheme;
|
|
2961
|
+
inlineCodeBackground: boolean;
|
|
2962
|
+
}) => string;
|
|
2963
|
+
/**
|
|
2964
|
+
* Render a markdown source string to a terminal-ready string with ANSI
|
|
2965
|
+
* styling. Handles headings, paragraphs, code blocks, lists, blockquotes,
|
|
2966
|
+
* tables, inline emphasis, links, and horizontal rules.
|
|
2967
|
+
*
|
|
2968
|
+
* @example
|
|
2969
|
+
* ```ts
|
|
2970
|
+
* import { markdown } from 'ansimax';
|
|
2971
|
+
*
|
|
2972
|
+
* const out = markdown.render(`
|
|
2973
|
+
* # Welcome
|
|
2974
|
+
*
|
|
2975
|
+
* This is **bold** with \`inline code\` and [a link](https://example.com).
|
|
2976
|
+
*
|
|
2977
|
+
* - First item
|
|
2978
|
+
* - Second item
|
|
2979
|
+
*
|
|
2980
|
+
* \`\`\`js
|
|
2981
|
+
* const x = 42;
|
|
2982
|
+
* \`\`\`
|
|
2983
|
+
* `);
|
|
2984
|
+
*
|
|
2985
|
+
* console.log(out);
|
|
2986
|
+
* ```
|
|
2987
|
+
*
|
|
2988
|
+
* @since 1.4.0
|
|
2989
|
+
*/
|
|
2990
|
+
declare const render: (source: string, opts?: MarkdownOptions) => string;
|
|
2991
|
+
/**
|
|
2992
|
+
* Markdown → terminal renderer. Use `markdown.render(source, opts?)` to
|
|
2993
|
+
* convert a markdown string to an ANSI-styled string ready for
|
|
2994
|
+
* `console.log` or `process.stdout.write`.
|
|
2995
|
+
*
|
|
2996
|
+
* Lower-level helpers `parseBlocks` and `parseInline` are also exposed
|
|
2997
|
+
* for advanced use cases (custom block handlers, partial rendering).
|
|
2998
|
+
*
|
|
2999
|
+
* @since 1.4.0
|
|
3000
|
+
*/
|
|
3001
|
+
declare const markdown: {
|
|
3002
|
+
render: (source: string, opts?: MarkdownOptions) => string;
|
|
3003
|
+
parseBlocks: (source: string) => Block[];
|
|
3004
|
+
parseInline: (text: string, opts?: {
|
|
3005
|
+
theme: MarkdownTheme;
|
|
3006
|
+
inlineCodeBackground: boolean;
|
|
3007
|
+
}) => string;
|
|
3008
|
+
};
|
|
3009
|
+
|
|
2854
3010
|
type EasingFunction = (t: number) => number;
|
|
2855
3011
|
/**
|
|
2856
3012
|
* Union of all built-in easing names in the comprehensive Robert Penner
|
|
@@ -3052,6 +3208,50 @@ declare const ansimax: {
|
|
|
3052
3208
|
clearAnsiCache: () => void;
|
|
3053
3209
|
};
|
|
3054
3210
|
configure: (opts?: AnsimaxConfig, meta?: ConfigureOptions) => void;
|
|
3211
|
+
panels: {
|
|
3212
|
+
vsplit: (blocks: string[], opts?: VsplitOptions) => string;
|
|
3213
|
+
hsplit: (blocks: string[], opts?: HsplitOptions) => string;
|
|
3214
|
+
center: (block: string, opts: CenterOptions) => string;
|
|
3215
|
+
frame: (block: string, opts?: FrameOptions) => string;
|
|
3216
|
+
grid: (blocks: string[], opts: GridOptions) => string;
|
|
3217
|
+
};
|
|
3218
|
+
json: {
|
|
3219
|
+
pretty: (value: unknown, opts?: PrettyOptions) => string;
|
|
3220
|
+
};
|
|
3221
|
+
markdown: {
|
|
3222
|
+
render: (source: string, opts?: MarkdownOptions) => string;
|
|
3223
|
+
parseBlocks: (source: string) => ({
|
|
3224
|
+
type: "heading";
|
|
3225
|
+
level: number;
|
|
3226
|
+
text: string;
|
|
3227
|
+
} | {
|
|
3228
|
+
type: "paragraph";
|
|
3229
|
+
text: string;
|
|
3230
|
+
} | {
|
|
3231
|
+
type: "codeblock";
|
|
3232
|
+
lang: string;
|
|
3233
|
+
code: string;
|
|
3234
|
+
} | {
|
|
3235
|
+
type: "list";
|
|
3236
|
+
ordered: boolean;
|
|
3237
|
+
items: string[];
|
|
3238
|
+
} | {
|
|
3239
|
+
type: "blockquote";
|
|
3240
|
+
text: string;
|
|
3241
|
+
} | {
|
|
3242
|
+
type: "table";
|
|
3243
|
+
headers: string[];
|
|
3244
|
+
rows: string[][];
|
|
3245
|
+
} | {
|
|
3246
|
+
type: "hr";
|
|
3247
|
+
} | {
|
|
3248
|
+
type: "blank";
|
|
3249
|
+
})[];
|
|
3250
|
+
parseInline: (text: string, opts?: {
|
|
3251
|
+
theme: MarkdownTheme;
|
|
3252
|
+
inlineCodeBackground: boolean;
|
|
3253
|
+
}) => string;
|
|
3254
|
+
};
|
|
3055
3255
|
};
|
|
3056
3256
|
|
|
3057
|
-
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, 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 };
|
|
3257
|
+
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 };
|