@flighthq/text-markup 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.
@@ -0,0 +1,5 @@
1
+ export * from './markupClassStyles';
2
+ export * from './markupNamedColors';
3
+ export * from './markupTagRegistry';
4
+ export * from './textMarkup';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './markupClassStyles';
2
+ export * from './markupNamedColors';
3
+ export * from './markupTagRegistry';
4
+ export * from './textMarkup';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { MarkupTagRegistry, TextFormat } from '@flighthq/types';
2
+ /**
3
+ * Opts a registry's `<span class>` styling into a caller-provided class → format map — the Tier-1
4
+ * class-styling path over the standard dialect. `registerStandardMarkupTags` leaves the `classResolver`
5
+ * seam unset, so a bare `<span class="warn">…</span>` contributes nothing; calling this installs a
6
+ * resolver that looks each class name up in `styles` (returning null for unknown names), so the span
7
+ * then contributes `styles.warn`. A `class` naming several space-separated classes merges their formats
8
+ * left to right. Class names match exactly — CSS classes are case-sensitive.
9
+ *
10
+ * The map is the caller's own, so this carries no built-in style table: its weight is only ever what the
11
+ * caller registers, and a bundle that never calls this keeps `<span>` a no-op grouping element. It is a
12
+ * distinct export rather than a flag on `registerStandardMarkupTags` for the same reason as
13
+ * `registerMarkupNamedColors` — the opt-in boundary is what keeps the feature off a bundle that does not
14
+ * use it. Last-write-wins over any previously installed class resolver.
15
+ */
16
+ export declare function registerMarkupClassStyles(registry: MarkupTagRegistry, styles: Readonly<Record<string, Readonly<Partial<TextFormat>>>>): void;
17
+ //# sourceMappingURL=markupClassStyles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markupClassStyles.d.ts","sourceRoot":"","sources":["../src/markupClassStyles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAuB,iBAAiB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE1F;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAC9D,IAAI,CAGN"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Opts a registry's `<span class>` styling into a caller-provided class → format map — the Tier-1
3
+ * class-styling path over the standard dialect. `registerStandardMarkupTags` leaves the `classResolver`
4
+ * seam unset, so a bare `<span class="warn">…</span>` contributes nothing; calling this installs a
5
+ * resolver that looks each class name up in `styles` (returning null for unknown names), so the span
6
+ * then contributes `styles.warn`. A `class` naming several space-separated classes merges their formats
7
+ * left to right. Class names match exactly — CSS classes are case-sensitive.
8
+ *
9
+ * The map is the caller's own, so this carries no built-in style table: its weight is only ever what the
10
+ * caller registers, and a bundle that never calls this keeps `<span>` a no-op grouping element. It is a
11
+ * distinct export rather than a flag on `registerStandardMarkupTags` for the same reason as
12
+ * `registerMarkupNamedColors` — the opt-in boundary is what keeps the feature off a bundle that does not
13
+ * use it. Last-write-wins over any previously installed class resolver.
14
+ */
15
+ export function registerMarkupClassStyles(registry, styles) {
16
+ const resolver = (className) => styles[className] ?? null;
17
+ registry.classResolver = resolver;
18
+ }
19
+ //# sourceMappingURL=markupClassStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markupClassStyles.js","sourceRoot":"","sources":["../src/markupClassStyles.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAA2B,EAC3B,MAA+D;IAE/D,MAAM,QAAQ,GAAwB,CAAC,SAAiB,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC;IACvF,QAAQ,CAAC,aAAa,GAAG,QAAQ,CAAC;AACpC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { MarkupTagRegistry } from '@flighthq/types';
2
+ /**
3
+ * Opts a registry's `<font color>` into the CSS named-color keywords — the separately-importable half
4
+ * of the standard dialect. `registerStandardMarkupTags` installs a hex-only color seam; calling this
5
+ * afterward swaps in a resolver that first tries hex (`#rgb`/`#rrggbb`/`0x`) then the ~148-entry CSS
6
+ * named-color table, so `<font color="red">` resolves to `#ff0000`. It augments the seam in place and
7
+ * leaves the `<font>` handler registration untouched, so a custom `<font>` handler that also consults
8
+ * `registry.colorResolver` keeps its behavior.
9
+ *
10
+ * This function is the ONLY importer of the named-color table, which is why the table is tree-shakable:
11
+ * a bundle that registers the standard tags but never calls `registerMarkupNamedColors` never pulls the
12
+ * ~148-entry table into its import graph. It is a distinct export rather than a flag on
13
+ * `registerStandardMarkupTags` on purpose — a flag would import the table unconditionally and defeat
14
+ * the tree-shaking.
15
+ */
16
+ export declare function registerMarkupNamedColors(registry: MarkupTagRegistry): void;
17
+ //# sourceMappingURL=markupNamedColors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markupNamedColors.d.ts","sourceRoot":"","sources":["../src/markupNamedColors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIzD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAE3E"}
@@ -0,0 +1,180 @@
1
+ import { resolveMarkupHexColor } from './markupTagRegistry';
2
+ /**
3
+ * Opts a registry's `<font color>` into the CSS named-color keywords — the separately-importable half
4
+ * of the standard dialect. `registerStandardMarkupTags` installs a hex-only color seam; calling this
5
+ * afterward swaps in a resolver that first tries hex (`#rgb`/`#rrggbb`/`0x`) then the ~148-entry CSS
6
+ * named-color table, so `<font color="red">` resolves to `#ff0000`. It augments the seam in place and
7
+ * leaves the `<font>` handler registration untouched, so a custom `<font>` handler that also consults
8
+ * `registry.colorResolver` keeps its behavior.
9
+ *
10
+ * This function is the ONLY importer of the named-color table, which is why the table is tree-shakable:
11
+ * a bundle that registers the standard tags but never calls `registerMarkupNamedColors` never pulls the
12
+ * ~148-entry table into its import graph. It is a distinct export rather than a flag on
13
+ * `registerStandardMarkupTags` on purpose — a flag would import the table unconditionally and defeat
14
+ * the tree-shaking.
15
+ */
16
+ export function registerMarkupNamedColors(registry) {
17
+ registry.colorResolver = resolveMarkupNamedColor;
18
+ }
19
+ // The hex-or-named color resolver installed by `registerMarkupNamedColors`. Hex is tried first (reusing
20
+ // `resolveMarkupHexColor`), then the named-color table — so a `#`/`0x` value never pays a table lookup.
21
+ function resolveMarkupNamedColor(value) {
22
+ const hex = resolveMarkupHexColor(value);
23
+ if (hex !== null)
24
+ return hex;
25
+ const named = markupNamedColors[value.trim().toLowerCase()];
26
+ return named === undefined ? null : named;
27
+ }
28
+ // The CSS Color Module Level 4 named-color keywords, packed as 24-bit RGB. Reachable only through
29
+ // `registerMarkupNamedColors`; a bundle that never opts in tree-shakes it out.
30
+ const markupNamedColors = {
31
+ aliceblue: 0xf0f8ff,
32
+ antiquewhite: 0xfaebd7,
33
+ aqua: 0x00ffff,
34
+ aquamarine: 0x7fffd4,
35
+ azure: 0xf0ffff,
36
+ beige: 0xf5f5dc,
37
+ bisque: 0xffe4c4,
38
+ black: 0x000000,
39
+ blanchedalmond: 0xffebcd,
40
+ blue: 0x0000ff,
41
+ blueviolet: 0x8a2be2,
42
+ brown: 0xa52a2a,
43
+ burlywood: 0xdeb887,
44
+ cadetblue: 0x5f9ea0,
45
+ chartreuse: 0x7fff00,
46
+ chocolate: 0xd2691e,
47
+ coral: 0xff7f50,
48
+ cornflowerblue: 0x6495ed,
49
+ cornsilk: 0xfff8dc,
50
+ crimson: 0xdc143c,
51
+ cyan: 0x00ffff,
52
+ darkblue: 0x00008b,
53
+ darkcyan: 0x008b8b,
54
+ darkgoldenrod: 0xb8860b,
55
+ darkgray: 0xa9a9a9,
56
+ darkgreen: 0x006400,
57
+ darkgrey: 0xa9a9a9,
58
+ darkkhaki: 0xbdb76b,
59
+ darkmagenta: 0x8b008b,
60
+ darkolivegreen: 0x556b2f,
61
+ darkorange: 0xff8c00,
62
+ darkorchid: 0x9932cc,
63
+ darkred: 0x8b0000,
64
+ darksalmon: 0xe9967a,
65
+ darkseagreen: 0x8fbc8f,
66
+ darkslateblue: 0x483d8b,
67
+ darkslategray: 0x2f4f4f,
68
+ darkslategrey: 0x2f4f4f,
69
+ darkturquoise: 0x00ced1,
70
+ darkviolet: 0x9400d3,
71
+ deeppink: 0xff1493,
72
+ deepskyblue: 0x00bfff,
73
+ dimgray: 0x696969,
74
+ dimgrey: 0x696969,
75
+ dodgerblue: 0x1e90ff,
76
+ firebrick: 0xb22222,
77
+ floralwhite: 0xfffaf0,
78
+ forestgreen: 0x228b22,
79
+ fuchsia: 0xff00ff,
80
+ gainsboro: 0xdcdcdc,
81
+ ghostwhite: 0xf8f8ff,
82
+ gold: 0xffd700,
83
+ goldenrod: 0xdaa520,
84
+ gray: 0x808080,
85
+ green: 0x008000,
86
+ greenyellow: 0xadff2f,
87
+ grey: 0x808080,
88
+ honeydew: 0xf0fff0,
89
+ hotpink: 0xff69b4,
90
+ indianred: 0xcd5c5c,
91
+ indigo: 0x4b0082,
92
+ ivory: 0xfffff0,
93
+ khaki: 0xf0e68c,
94
+ lavender: 0xe6e6fa,
95
+ lavenderblush: 0xfff0f5,
96
+ lawngreen: 0x7cfc00,
97
+ lemonchiffon: 0xfffacd,
98
+ lightblue: 0xadd8e6,
99
+ lightcoral: 0xf08080,
100
+ lightcyan: 0xe0ffff,
101
+ lightgoldenrodyellow: 0xfafad2,
102
+ lightgray: 0xd3d3d3,
103
+ lightgreen: 0x90ee90,
104
+ lightgrey: 0xd3d3d3,
105
+ lightpink: 0xffb6c1,
106
+ lightsalmon: 0xffa07a,
107
+ lightseagreen: 0x20b2aa,
108
+ lightskyblue: 0x87cefa,
109
+ lightslategray: 0x778899,
110
+ lightslategrey: 0x778899,
111
+ lightsteelblue: 0xb0c4de,
112
+ lightyellow: 0xffffe0,
113
+ lime: 0x00ff00,
114
+ limegreen: 0x32cd32,
115
+ linen: 0xfaf0e6,
116
+ magenta: 0xff00ff,
117
+ maroon: 0x800000,
118
+ mediumaquamarine: 0x66cdaa,
119
+ mediumblue: 0x0000cd,
120
+ mediumorchid: 0xba55d3,
121
+ mediumpurple: 0x9370db,
122
+ mediumseagreen: 0x3cb371,
123
+ mediumslateblue: 0x7b68ee,
124
+ mediumspringgreen: 0x00fa9a,
125
+ mediumturquoise: 0x48d1cc,
126
+ mediumvioletred: 0xc71585,
127
+ midnightblue: 0x191970,
128
+ mintcream: 0xf5fffa,
129
+ mistyrose: 0xffe4e1,
130
+ moccasin: 0xffe4b5,
131
+ navajowhite: 0xffdead,
132
+ navy: 0x000080,
133
+ oldlace: 0xfdf5e6,
134
+ olive: 0x808000,
135
+ olivedrab: 0x6b8e23,
136
+ orange: 0xffa500,
137
+ orangered: 0xff4500,
138
+ orchid: 0xda70d6,
139
+ palegoldenrod: 0xeee8aa,
140
+ palegreen: 0x98fb98,
141
+ paleturquoise: 0xafeeee,
142
+ palevioletred: 0xdb7093,
143
+ papayawhip: 0xffefd5,
144
+ peachpuff: 0xffdab9,
145
+ peru: 0xcd853f,
146
+ pink: 0xffc0cb,
147
+ plum: 0xdda0dd,
148
+ powderblue: 0xb0e0e6,
149
+ purple: 0x800080,
150
+ rebeccapurple: 0x663399,
151
+ red: 0xff0000,
152
+ rosybrown: 0xbc8f8f,
153
+ royalblue: 0x4169e1,
154
+ saddlebrown: 0x8b4513,
155
+ salmon: 0xfa8072,
156
+ sandybrown: 0xf4a460,
157
+ seagreen: 0x2e8b57,
158
+ seashell: 0xfff5ee,
159
+ sienna: 0xa0522d,
160
+ silver: 0xc0c0c0,
161
+ skyblue: 0x87ceeb,
162
+ slateblue: 0x6a5acd,
163
+ slategray: 0x708090,
164
+ slategrey: 0x708090,
165
+ snow: 0xfffafa,
166
+ springgreen: 0x00ff7f,
167
+ steelblue: 0x4682b4,
168
+ tan: 0xd2b48c,
169
+ teal: 0x008080,
170
+ thistle: 0xd8bfd8,
171
+ tomato: 0xff6347,
172
+ turquoise: 0x40e0d0,
173
+ violet: 0xee82ee,
174
+ wheat: 0xf5deb3,
175
+ white: 0xffffff,
176
+ whitesmoke: 0xf5f5f5,
177
+ yellow: 0xffff00,
178
+ yellowgreen: 0x9acd32,
179
+ };
180
+ //# sourceMappingURL=markupNamedColors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markupNamedColors.js","sourceRoot":"","sources":["../src/markupNamedColors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAA2B;IACnE,QAAQ,CAAC,aAAa,GAAG,uBAAuB,CAAC;AACnD,CAAC;AAED,wGAAwG;AACxG,wGAAwG;AACxG,SAAS,uBAAuB,CAAC,KAAa;IAC5C,MAAM,GAAG,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACzC,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,GAAG,CAAC;IAC7B,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;IAC5D,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI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EAAE,QAAQ;IAChB,KAAK,EAAE,QAAQ;IACf,KAAK,EAAE,QAAQ;IACf,UAAU,EAAE,QAAQ;IACpB,MAAM,EAAE,QAAQ;IAChB,WAAW,EAAE,QAAQ;CACtB,CAAC"}
@@ -0,0 +1,41 @@
1
+ import type { MarkupTagHandler, MarkupTagRegistry } from '@flighthq/types';
2
+ /**
3
+ * Creates an empty markup tag registry — the meaning layer `parseTextMarkup` composes over the parse
4
+ * layer. Register handlers with `registerMarkupTag`, or populate the standard `htmlText` dialect with
5
+ * `registerStandardMarkupTags`. The registered set of tag names is the supported dialect; a custom
6
+ * registry that omits the standard tags lets them tree-shake out.
7
+ */
8
+ export declare function createMarkupTagRegistry(): MarkupTagRegistry;
9
+ /**
10
+ * Binds a tag name to its handler. The registry is open and last-write-wins: a user registers their
11
+ * own (vendor-prefixed) tags or overrides a standard one. The name is matched case-insensitively, so
12
+ * it is stored lowercased. Handlers are pure — they map this tag's attributes to its contribution and
13
+ * never see spans, ranges, or surrounding text; the parser owns composition and the format stack.
14
+ */
15
+ export declare function registerMarkupTag(registry: Readonly<MarkupTagRegistry>, name: string, handler: MarkupTagHandler): void;
16
+ /**
17
+ * Registers the standard `htmlText` dialect into `registry` — the default bundle `parseTextMarkup`
18
+ * uses when no registry is passed. Covers `<b>`/`<strong>`, `<i>`/`<em>`, `<u>`, `<s>`/`<strike>`,
19
+ * `<font color size face>` (color is `#rgb`/`#rrggbb`/`0x` only by default), `<a href target>`,
20
+ * `<p align>` (implicit line break), `<li type>` (break + bullet), `<br>` (a `\n`), `<span class>`
21
+ * (a transparent grouping element, styled only once class styles are registered), and `<textformat
22
+ * leftmargin blockindent indent rightmargin leading tabstops>`. Each handler returns a fresh result,
23
+ * so registrations share no mutable state.
24
+ *
25
+ * The `<font>` handler resolves color through the registry's `colorResolver` seam, which this installs
26
+ * as the hex-only `resolveMarkupHexColor`. A named color like `red` therefore resolves to no color by
27
+ * default (graceful, not an error). Call `registerMarkupNamedColors` afterward to opt the ~148-entry
28
+ * CSS named-color table in; a bundle that never does keeps the table tree-shaken out. The `<span>`
29
+ * handler consults the registry's `classResolver` seam, left unset here so a bare `<span class>` is
30
+ * inert; call `registerMarkupClassStyles` to bind a class → format map — the same tree-shakable opt-in
31
+ * shape as named colors.
32
+ */
33
+ export declare function registerStandardMarkupTags(registry: MarkupTagRegistry): void;
34
+ /**
35
+ * Resolves a hex `<font color>` value — `#rgb`, `#rrggbb`, or `0xRRGGBB` — to a packed 24-bit RGB
36
+ * integer, or null when unrecognized. This is the default color seam `registerStandardMarkupTags`
37
+ * installs; it imports no named-color table, so the standard dialect stays hex-only until a caller
38
+ * opts into `registerMarkupNamedColors`. Alpha is not modeled — `TextFormat.color` is opaque RGB.
39
+ */
40
+ export declare function resolveMarkupHexColor(value: string): number | null;
41
+ //# sourceMappingURL=markupTagRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markupTagRegistry.d.ts","sourceRoot":"","sources":["../src/markupTagRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,gBAAgB,EAChB,iBAAiB,EAIlB,MAAM,iBAAiB,CAAC;AAEzB;;;;;GAKG;AACH,wBAAgB,uBAAuB,IAAI,iBAAiB,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,QAAQ,CAAC,iBAAiB,CAAC,EACrC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,GACxB,IAAI,CAEN;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAgB5E;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAgBlE"}
@@ -0,0 +1,228 @@
1
+ /**
2
+ * Creates an empty markup tag registry — the meaning layer `parseTextMarkup` composes over the parse
3
+ * layer. Register handlers with `registerMarkupTag`, or populate the standard `htmlText` dialect with
4
+ * `registerStandardMarkupTags`. The registered set of tag names is the supported dialect; a custom
5
+ * registry that omits the standard tags lets them tree-shake out.
6
+ */
7
+ export function createMarkupTagRegistry() {
8
+ return { handlers: new Map() };
9
+ }
10
+ /**
11
+ * Binds a tag name to its handler. The registry is open and last-write-wins: a user registers their
12
+ * own (vendor-prefixed) tags or overrides a standard one. The name is matched case-insensitively, so
13
+ * it is stored lowercased. Handlers are pure — they map this tag's attributes to its contribution and
14
+ * never see spans, ranges, or surrounding text; the parser owns composition and the format stack.
15
+ */
16
+ export function registerMarkupTag(registry, name, handler) {
17
+ registry.handlers.set(name.toLowerCase(), handler);
18
+ }
19
+ /**
20
+ * Registers the standard `htmlText` dialect into `registry` — the default bundle `parseTextMarkup`
21
+ * uses when no registry is passed. Covers `<b>`/`<strong>`, `<i>`/`<em>`, `<u>`, `<s>`/`<strike>`,
22
+ * `<font color size face>` (color is `#rgb`/`#rrggbb`/`0x` only by default), `<a href target>`,
23
+ * `<p align>` (implicit line break), `<li type>` (break + bullet), `<br>` (a `\n`), `<span class>`
24
+ * (a transparent grouping element, styled only once class styles are registered), and `<textformat
25
+ * leftmargin blockindent indent rightmargin leading tabstops>`. Each handler returns a fresh result,
26
+ * so registrations share no mutable state.
27
+ *
28
+ * The `<font>` handler resolves color through the registry's `colorResolver` seam, which this installs
29
+ * as the hex-only `resolveMarkupHexColor`. A named color like `red` therefore resolves to no color by
30
+ * default (graceful, not an error). Call `registerMarkupNamedColors` afterward to opt the ~148-entry
31
+ * CSS named-color table in; a bundle that never does keeps the table tree-shaken out. The `<span>`
32
+ * handler consults the registry's `classResolver` seam, left unset here so a bare `<span class>` is
33
+ * inert; call `registerMarkupClassStyles` to bind a class → format map — the same tree-shakable opt-in
34
+ * shape as named colors.
35
+ */
36
+ export function registerStandardMarkupTags(registry) {
37
+ registry.colorResolver = resolveMarkupHexColor;
38
+ registerMarkupTag(registry, 'a', markupAnchorTagHandler);
39
+ registerMarkupTag(registry, 'b', markupBoldTagHandler);
40
+ registerMarkupTag(registry, 'br', markupBreakTagHandler);
41
+ registerMarkupTag(registry, 'em', markupItalicTagHandler);
42
+ registerMarkupTag(registry, 'font', createMarkupFontTagHandler(registry));
43
+ registerMarkupTag(registry, 'i', markupItalicTagHandler);
44
+ registerMarkupTag(registry, 'li', markupListItemTagHandler);
45
+ registerMarkupTag(registry, 'p', markupParagraphTagHandler);
46
+ registerMarkupTag(registry, 's', markupStrikethroughTagHandler);
47
+ registerMarkupTag(registry, 'span', createMarkupSpanTagHandler(registry));
48
+ registerMarkupTag(registry, 'strike', markupStrikethroughTagHandler);
49
+ registerMarkupTag(registry, 'strong', markupBoldTagHandler);
50
+ registerMarkupTag(registry, 'textformat', markupTextformatTagHandler);
51
+ registerMarkupTag(registry, 'u', markupUnderlineTagHandler);
52
+ }
53
+ /**
54
+ * Resolves a hex `<font color>` value — `#rgb`, `#rrggbb`, or `0xRRGGBB` — to a packed 24-bit RGB
55
+ * integer, or null when unrecognized. This is the default color seam `registerStandardMarkupTags`
56
+ * installs; it imports no named-color table, so the standard dialect stays hex-only until a caller
57
+ * opts into `registerMarkupNamedColors`. Alpha is not modeled — `TextFormat.color` is opaque RGB.
58
+ */
59
+ export function resolveMarkupHexColor(value) {
60
+ const color = value.trim().toLowerCase();
61
+ if (color.startsWith('#')) {
62
+ const hex = color.slice(1);
63
+ if (hex.length === 3) {
64
+ const parsed = Number.parseInt(`${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`, 16);
65
+ return Number.isNaN(parsed) ? null : parsed;
66
+ }
67
+ const parsed = Number.parseInt(hex, 16);
68
+ return Number.isNaN(parsed) ? null : parsed;
69
+ }
70
+ if (color.startsWith('0x')) {
71
+ const parsed = Number.parseInt(color.slice(2), 16);
72
+ return Number.isNaN(parsed) ? null : parsed;
73
+ }
74
+ return null;
75
+ }
76
+ // Builds the `<span>` handler bound to `registry`, so it consults the live `classResolver` seam at
77
+ // parse time — letting `registerMarkupClassStyles` add class styling after registration without
78
+ // re-registering the handler. With no resolver set, or a `class` naming only unknown classes, the span
79
+ // contributes nothing (a transparent grouping element). Space-separated class names in one `class`
80
+ // attribute merge left to right, so a later class overrides an earlier one on a shared field.
81
+ function createMarkupSpanTagHandler(registry) {
82
+ return (attributes) => {
83
+ const resolve = registry.classResolver;
84
+ const classes = attributes.class;
85
+ if (resolve === undefined || classes === undefined)
86
+ return {};
87
+ const format = {};
88
+ for (const name of classes.split(/\s+/)) {
89
+ if (name.length === 0)
90
+ continue;
91
+ const contribution = resolve(name);
92
+ if (contribution !== null)
93
+ Object.assign(format, contribution);
94
+ }
95
+ return format;
96
+ };
97
+ }
98
+ // Builds the `<font>` handler bound to `registry`, so it can consult the live `colorResolver` seam at
99
+ // parse time — letting `registerMarkupNamedColors` widen color support after registration without
100
+ // re-registering the handler. Color parsing goes through the seam only (`resolveMarkupHexColor` when
101
+ // unset), which is what keeps the named-color table off this handler's import graph.
102
+ function createMarkupFontTagHandler(registry) {
103
+ return (attributes) => {
104
+ const format = {};
105
+ const color = attributes.color;
106
+ if (color !== undefined) {
107
+ const resolve = registry.colorResolver ?? resolveMarkupHexColor;
108
+ const parsed = resolve(color);
109
+ if (parsed !== null)
110
+ format.color = parsed;
111
+ }
112
+ const size = attributes.size;
113
+ if (size !== undefined) {
114
+ const parsed = parseMarkupNumber(size);
115
+ if (parsed !== null)
116
+ format.size = parsed;
117
+ }
118
+ const face = attributes.face ?? attributes.font;
119
+ if (face !== undefined && face.length > 0)
120
+ format.font = face;
121
+ return format;
122
+ };
123
+ }
124
+ function isMarkupAlign(value) {
125
+ switch (value.toLowerCase()) {
126
+ case 'center':
127
+ case 'end':
128
+ case 'justify':
129
+ case 'left':
130
+ case 'right':
131
+ case 'start':
132
+ return true;
133
+ default:
134
+ return false;
135
+ }
136
+ }
137
+ function isMarkupListMarker(value) {
138
+ switch (value.toLowerCase()) {
139
+ case 'circle':
140
+ case 'decimal':
141
+ case 'disc':
142
+ case 'none':
143
+ case 'square':
144
+ return true;
145
+ default:
146
+ return false;
147
+ }
148
+ }
149
+ function markupAnchorTagHandler(attributes) {
150
+ const format = {};
151
+ if (attributes.href !== undefined)
152
+ format.url = attributes.href;
153
+ if (attributes.target !== undefined)
154
+ format.target = attributes.target;
155
+ return format;
156
+ }
157
+ function markupBoldTagHandler() {
158
+ return { bold: true };
159
+ }
160
+ function markupBreakTagHandler() {
161
+ return { text: '\n' };
162
+ }
163
+ function markupItalicTagHandler() {
164
+ return { italic: true };
165
+ }
166
+ function markupListItemTagHandler(attributes) {
167
+ const format = { bullet: true };
168
+ const marker = attributes.type;
169
+ if (marker !== undefined && isMarkupListMarker(marker))
170
+ format.listMarker = marker.toLowerCase();
171
+ return { breakBefore: true, format };
172
+ }
173
+ function markupParagraphTagHandler(attributes) {
174
+ const format = {};
175
+ const align = attributes.align;
176
+ if (align !== undefined && isMarkupAlign(align))
177
+ format.align = align.toLowerCase();
178
+ return { breakBefore: true, format };
179
+ }
180
+ function markupStrikethroughTagHandler() {
181
+ return { strikethrough: true };
182
+ }
183
+ function markupTextformatTagHandler(attributes) {
184
+ const format = {};
185
+ const blockIndent = readMarkupNumberAttribute(attributes, 'blockindent');
186
+ if (blockIndent !== null)
187
+ format.blockIndent = blockIndent;
188
+ const indent = readMarkupNumberAttribute(attributes, 'indent');
189
+ if (indent !== null)
190
+ format.indent = indent;
191
+ const leading = readMarkupNumberAttribute(attributes, 'leading');
192
+ if (leading !== null)
193
+ format.leading = leading;
194
+ const leftMargin = readMarkupNumberAttribute(attributes, 'leftmargin');
195
+ if (leftMargin !== null)
196
+ format.leftMargin = leftMargin;
197
+ const rightMargin = readMarkupNumberAttribute(attributes, 'rightmargin');
198
+ if (rightMargin !== null)
199
+ format.rightMargin = rightMargin;
200
+ const tabStops = readMarkupTabStopsAttribute(attributes, 'tabstops');
201
+ if (tabStops !== null)
202
+ format.tabStops = tabStops;
203
+ return format;
204
+ }
205
+ function markupUnderlineTagHandler() {
206
+ return { underline: true };
207
+ }
208
+ function parseMarkupNumber(value) {
209
+ const parsed = Number.parseFloat(value);
210
+ return Number.isFinite(parsed) ? parsed : null;
211
+ }
212
+ function readMarkupNumberAttribute(attributes, name) {
213
+ const raw = attributes[name];
214
+ return raw === undefined ? null : parseMarkupNumber(raw);
215
+ }
216
+ function readMarkupTabStopsAttribute(attributes, name) {
217
+ const raw = attributes[name];
218
+ if (raw === undefined)
219
+ return null;
220
+ const stops = [];
221
+ for (const part of raw.split(',')) {
222
+ const parsed = parseMarkupNumber(part.trim());
223
+ if (parsed !== null)
224
+ stops.push(parsed);
225
+ }
226
+ return stops;
227
+ }
228
+ //# sourceMappingURL=markupTagRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markupTagRegistry.js","sourceRoot":"","sources":["../src/markupTagRegistry.ts"],"names":[],"mappings":"AAUA;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;AACjC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAqC,EACrC,IAAY,EACZ,OAAyB;IAEzB,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,0BAA0B,CAAC,QAA2B;IACpE,QAAQ,CAAC,aAAa,GAAG,qBAAqB,CAAC;IAC/C,iBAAiB,CAAC,QAAQ,EAAE,GAAG,EAAE,sBAAsB,CAAC,CAAC;IACzD,iBAAiB,CAAC,QAAQ,EAAE,GAAG,EAAE,oBAAoB,CAAC,CAAC;IACvD,iBAAiB,CAAC,QAAQ,EAAE,IAAI,EAAE,qBAAqB,CAAC,CAAC;IACzD,iBAAiB,CAAC,QAAQ,EAAE,IAAI,EAAE,sBAAsB,CAAC,CAAC;IAC1D,iBAAiB,CAAC,QAAQ,EAAE,MAAM,E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` back into `htmlText`-subset markup — the inverse of
4
+ * `parseTextMarkup` for everything the rich-text model can express. The emitted tag set is the fixed
5
+ * standard dialect that reproduces the `formatRanges`: `<b>`/`<i>`/`<u>`/`<s>` for the style booleans,
6
+ * `<font color size face>` for color/size/font, `<a href target>` for links, `<p align>` for
7
+ * alignment, `<li>` for bullets, and `<textformat …>` for the block metrics. Colors always emit as
8
+ * `#rrggbb` (a named-color source like `red` normalizes to `#ff0000`). Text is escaped (`&` `<` `>`);
9
+ * attribute values additionally escape `"`.
10
+ *
11
+ * The round-trip guarantee is `parseTextMarkup(formatTextMarkup(parseTextMarkup(x)))` equals
12
+ * `parseTextMarkup(x)` — a fixed point over the modeled tags. `<p>`/`<li>` imply a collapsing line
13
+ * break before their content; the resulting `\n` carries no block format and re-parses as a plain
14
+ * newline that the block tag's own collapse rule does not double, so the fixed point holds. Format
15
+ * fields with no `htmlText` representation (`kerning`, `letterSpacing`) cannot be expressed and are
16
+ * omitted; `parseTextMarkup` never produces them, so the fixed point is unaffected.
17
+ */
18
+ export declare function formatTextMarkup(content: Readonly<RichTextContent>): string;
19
+ /**
20
+ * Parses `htmlText`-style markup into Flight's rich-text model — a plain `text` string plus the
21
+ * `TextFormatRange[]` a `RichText`/`TextLabel` node renders. This is the explicit, Flight-way
22
+ * replacement for the `textField.htmlText = "…"` magic property: the caller invokes it and assigns
23
+ * the result, rather than the runtime silently parsing markup on assignment.
24
+ *
25
+ * Parsing is two layers. The parse layer here tokenizes the markup (a lenient, text-node-preserving
26
+ * pass — not the strict document tree of `@flighthq/xml`) and owns composition: it walks the tags,
27
+ * maintains a format stack (push a tag's handler contribution on open, pop on close), and emits the
28
+ * `text` and `TextFormatRange[]`. The meaning layer is the `registry` — an open map of tag name →
29
+ * handler that decides what each tag contributes. When no `registry` is passed the standard
30
+ * `htmlText` dialect is used (`registerStandardMarkupTags`), so the default is backward-compatible;
31
+ * pass a custom registry to add, replace, or narrow the supported tags.
32
+ *
33
+ * Nested tags compose — `<font color="#f00"><b>x</b></font>` yields one range carrying both `color`
34
+ * and `bold`. An unregistered tag keeps its enclosed text but applies no format. Entities
35
+ * (`&amp; &lt; &gt; &quot; &apos; &#nn; &#xhh;`) decode; unknown named entities are left verbatim.
36
+ *
37
+ * Malformed markup is recovered best-effort, never thrown: unclosed tags simply extend to the end of
38
+ * the text, a stray `<` with no `>` stays literal text, and an extra closing tag is ignored. The
39
+ * result is always a valid `RichTextContent`.
40
+ */
41
+ export declare function parseTextMarkup(html: string, registry?: Readonly<MarkupTagRegistry>): RichTextContent;
42
+ //# sourceMappingURL=textMarkup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textMarkup.d.ts","sourceRoot":"","sources":["../src/textMarkup.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,iBAAiB,EAEjB,eAAe,EAGhB,MAAM,iBAAiB,CAAC;AAIzB;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,MAAM,CAe3E;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,eAAe,CAcrG"}