@chromamark/renderer 0.2.2 → 0.3.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 +19 -0
- package/dist/chromamark.min.js +11 -11
- package/package.json +1 -1
- package/src/ansi.js +302 -0
- package/src/index.js +3 -0
- package/src/lint.js +157 -0
package/README.md
CHANGED
|
@@ -24,6 +24,25 @@ import chromamark, { render, createRenderer } from '@chromamark/renderer';
|
|
|
24
24
|
| `default` (`chromamark`) | markdown-it plugin: `new MarkdownIt().use(chromamark, options?)`. |
|
|
25
25
|
| `render(src, options?)` | Convenience: ChromaMark string → HTML fragment. |
|
|
26
26
|
| `createRenderer(options?)`| A `markdown-it` instance preconfigured with ChromaMark. |
|
|
27
|
+
| `renderAnsi(src, opts?)` | ChromaMark string → ANSI-styled text for a terminal. |
|
|
28
|
+
| `lint(src, opts?)` | Check for common mistakes → array of `{ line, column, rule, … }`. |
|
|
29
|
+
|
|
30
|
+
### Terminal rendering
|
|
31
|
+
|
|
32
|
+
`renderAnsi` walks the same parse into a TTY: tones become ANSI colors, pills
|
|
33
|
+
become bracketed icon chips (`[✓ PASS]`), blocks get a colored left bar, and
|
|
34
|
+
meters draw a unicode bar. It degrades to plain, icon-annotated text when color
|
|
35
|
+
is off.
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
import { renderAnsi } from '@chromamark/renderer';
|
|
39
|
+
|
|
40
|
+
process.stdout.write(renderAnsi('::: success\nAll good [!ok healthy]\n:::'));
|
|
41
|
+
// options: { color: 'auto' | 'always' | 'never', width?: number }
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Color defaults to `'auto'` — on when stdout is a TTY and [`NO_COLOR`](https://no-color.org)
|
|
45
|
+
is unset. The `colorEnabled(option, env?, isTTY?)` helper is exported too.
|
|
27
46
|
|
|
28
47
|
### Options
|
|
29
48
|
|