@markii/ansi 0.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/dist/ansi.d.ts +79 -0
- package/dist/ansi.js +136 -0
- package/dist/box.d.ts +47 -0
- package/dist/box.js +209 -0
- package/dist/components/badge.d.ts +10 -0
- package/dist/components/badge.js +44 -0
- package/dist/components/callout.d.ts +20 -0
- package/dist/components/callout.js +71 -0
- package/dist/components/card.d.ts +12 -0
- package/dist/components/card.js +44 -0
- package/dist/components/cell.d.ts +18 -0
- package/dist/components/cell.js +31 -0
- package/dist/components/chart.d.ts +15 -0
- package/dist/components/chart.js +129 -0
- package/dist/components/details.d.ts +12 -0
- package/dist/components/details.js +25 -0
- package/dist/components/divider.d.ts +4 -0
- package/dist/components/divider.js +80 -0
- package/dist/components/figure.d.ts +20 -0
- package/dist/components/figure.js +53 -0
- package/dist/components/index.d.ts +34 -0
- package/dist/components/index.js +109 -0
- package/dist/components/kbd.d.ts +7 -0
- package/dist/components/kbd.js +8 -0
- package/dist/components/layout-wrapper.d.ts +35 -0
- package/dist/components/layout-wrapper.js +62 -0
- package/dist/components/progress.d.ts +15 -0
- package/dist/components/progress.js +78 -0
- package/dist/components/rating.d.ts +9 -0
- package/dist/components/rating.js +28 -0
- package/dist/components/row.d.ts +26 -0
- package/dist/components/row.js +67 -0
- package/dist/components/stat.d.ts +13 -0
- package/dist/components/stat.js +79 -0
- package/dist/components/tab.d.ts +13 -0
- package/dist/components/tab.js +17 -0
- package/dist/components/table-grid.d.ts +34 -0
- package/dist/components/table-grid.js +124 -0
- package/dist/components/table.d.ts +16 -0
- package/dist/components/table.js +101 -0
- package/dist/components/tabs.d.ts +18 -0
- package/dist/components/tabs.js +30 -0
- package/dist/failure-presentation.d.ts +58 -0
- package/dist/failure-presentation.js +124 -0
- package/dist/href-resolve.d.ts +21 -0
- package/dist/href-resolve.js +25 -0
- package/dist/image-resolve.d.ts +41 -0
- package/dist/image-resolve.js +28 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +17 -0
- package/dist/layout.d.ts +73 -0
- package/dist/layout.js +144 -0
- package/dist/measure.d.ts +25 -0
- package/dist/measure.js +108 -0
- package/dist/registry.d.ts +227 -0
- package/dist/registry.js +121 -0
- package/dist/render.d.ts +69 -0
- package/dist/render.js +889 -0
- package/dist/resolve.d.ts +60 -0
- package/dist/resolve.js +152 -0
- package/dist/sanitize.d.ts +51 -0
- package/dist/sanitize.js +101 -0
- package/dist/style.d.ts +9 -0
- package/dist/style.js +13 -0
- package/dist/theme.d.ts +36 -0
- package/dist/theme.js +79 -0
- package/dist/url-resolve.d.ts +54 -0
- package/dist/url-resolve.js +82 -0
- package/dist/value-format.d.ts +13 -0
- package/dist/value-format.js +16 -0
- package/dist/value-types.d.ts +37 -0
- package/dist/value-types.js +17 -0
- package/package.json +61 -0
package/dist/render.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { parse } from '@markii/core';
|
|
2
|
+
import type { MarkNode } from '@markii/core';
|
|
3
|
+
import { type ColorOption } from './ansi.js';
|
|
4
|
+
import { type AnsiTheme } from './theme.js';
|
|
5
|
+
import type { AnsiRegistry } from './registry.js';
|
|
6
|
+
import { type OnDiagnostic } from '@markii/stdlib';
|
|
7
|
+
import { type ResolveImageSrc } from './image-resolve.js';
|
|
8
|
+
import { type ResolveHref } from './href-resolve.js';
|
|
9
|
+
import type { AnsiValueStore, AnsiVaultStore } from './value-types.js';
|
|
10
|
+
type MarkRoot = ReturnType<typeof parse>;
|
|
11
|
+
/**
|
|
12
|
+
* Options for `renderMarkToAnsi`/`renderMarkNodeToAnsi`/`renderMarkInlineToAnsi`.
|
|
13
|
+
* `store`/`vault` are offered both here and as positional parameters; when
|
|
14
|
+
* both are given, the option wins (matching `@markii/html`'s
|
|
15
|
+
* `RenderMarkOptions`).
|
|
16
|
+
*/
|
|
17
|
+
export interface RenderMarkOptions {
|
|
18
|
+
readonly width?: number;
|
|
19
|
+
readonly color?: ColorOption;
|
|
20
|
+
readonly theme?: AnsiTheme;
|
|
21
|
+
readonly resolveImageSrc?: ResolveImageSrc;
|
|
22
|
+
readonly resolveHref?: ResolveHref;
|
|
23
|
+
readonly onDiagnostic?: OnDiagnostic;
|
|
24
|
+
readonly store?: AnsiValueStore;
|
|
25
|
+
readonly vault?: AnsiVaultStore;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Renders Markii text to a plain string (optionally carrying ANSI SGR/OSC 8
|
|
29
|
+
* escapes) using `registry` to resolve directive names. `registry` is
|
|
30
|
+
* OPTIONAL here, unlike the other two engines' required parameter, and
|
|
31
|
+
* defaults to `defaultAnsiRegistry` (empty in this phase; every directive
|
|
32
|
+
* therefore renders the unknown-component fallback).
|
|
33
|
+
*
|
|
34
|
+
* Pipeline: `@markii/core`'s `toHast` (parse -> tag directive nodes ->
|
|
35
|
+
* remark-rehype -> sanitize URLs) -> a width-aware hast walk that swaps
|
|
36
|
+
* directive elements for registry components (or the unknown-directive
|
|
37
|
+
* fallback), folds script fences into a one-line marker, and wraps every
|
|
38
|
+
* paragraph, heading, and list item to `options.width` (default 80). Pure
|
|
39
|
+
* and never-throwing: parsing is tolerant, unknown names always render a
|
|
40
|
+
* fallback, and any unexpected internal error degrades to the "failed to
|
|
41
|
+
* render document" line.
|
|
42
|
+
*
|
|
43
|
+
* `options.color` resolves via `./ansi.js`'s `resolveColorOption`: `'auto'`
|
|
44
|
+
* and `undefined` both mean "no escapes" here, since this engine has no
|
|
45
|
+
* environment knowledge of its own — a caller that wants automatic
|
|
46
|
+
* detection calls `detectColorLevel` itself and passes the result as
|
|
47
|
+
* `'16'`/`'256'`/`'truecolor'`.
|
|
48
|
+
*
|
|
49
|
+
* `store`/`vault` and `resolveImageSrc`/`resolveHref`/`onDiagnostic` carry
|
|
50
|
+
* the same meaning as `@markii/html`'s identical options.
|
|
51
|
+
*/
|
|
52
|
+
export declare function renderMarkToAnsi(text: string, registry?: AnsiRegistry, store?: AnsiValueStore, vault?: AnsiVaultStore, options?: RenderMarkOptions): string;
|
|
53
|
+
/**
|
|
54
|
+
* The block-level twin of `renderMarkToAnsi`: renders one already-parsed
|
|
55
|
+
* mdast node OR a whole already-parsed mdast document (`@markii/core`'s
|
|
56
|
+
* `MarkNode`, or the `Root` `parse` itself returns) instead of raw document
|
|
57
|
+
* text. Same registry resolution, same fallbacks, same purity and
|
|
58
|
+
* never-throw guarantees, same options.
|
|
59
|
+
*/
|
|
60
|
+
export declare function renderMarkNodeToAnsi(node: MarkNode | MarkRoot, registry?: AnsiRegistry, store?: AnsiValueStore, vault?: AnsiVaultStore, options?: RenderMarkOptions): string;
|
|
61
|
+
/**
|
|
62
|
+
* Renders `text` as a single, standalone inline directive when that is all
|
|
63
|
+
* it is, mirroring `@markii/html`'s identical `renderMarkInlineToHtml`: a
|
|
64
|
+
* source whose only parsed block is a paragraph holding exactly one text
|
|
65
|
+
* directive renders that directive alone. Any other source falls back to
|
|
66
|
+
* the exact same rendering `renderMarkToAnsi` would produce.
|
|
67
|
+
*/
|
|
68
|
+
export declare function renderMarkInlineToAnsi(text: string, registry?: AnsiRegistry, store?: AnsiValueStore, vault?: AnsiVaultStore, options?: RenderMarkOptions): string;
|
|
69
|
+
export {};
|