@wdprlib/ast 2.1.0 → 2.2.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/dist/index.cjs CHANGED
@@ -54,7 +54,8 @@ __export(exports_src, {
54
54
  container: () => container,
55
55
  bold: () => bold,
56
56
  STYLE_SLOT_PREFIX: () => STYLE_SLOT_PREFIX,
57
- DEFAULT_SETTINGS: () => DEFAULT_SETTINGS
57
+ DEFAULT_SETTINGS: () => DEFAULT_SETTINGS,
58
+ CSS_LENGTH_UNITS: () => CSS_LENGTH_UNITS
58
59
  });
59
60
  module.exports = __toCommonJS(exports_src);
60
61
 
@@ -253,6 +254,59 @@ function isParagraphSafe(element) {
253
254
  }
254
255
  // packages/ast/src/constants.ts
255
256
  var STYLE_SLOT_PREFIX = "\x00__IFTAGS_SLOT__";
257
+ // packages/ast/src/css.ts
258
+ var CSS_LENGTH_UNITS = [
259
+ "cqmax",
260
+ "cqmin",
261
+ "cqw",
262
+ "cqh",
263
+ "cqi",
264
+ "cqb",
265
+ "svmin",
266
+ "svmax",
267
+ "lvmin",
268
+ "lvmax",
269
+ "dvmin",
270
+ "dvmax",
271
+ "vmin",
272
+ "vmax",
273
+ "svw",
274
+ "svh",
275
+ "svi",
276
+ "svb",
277
+ "lvw",
278
+ "lvh",
279
+ "lvi",
280
+ "lvb",
281
+ "dvw",
282
+ "dvh",
283
+ "dvi",
284
+ "dvb",
285
+ "vw",
286
+ "vh",
287
+ "vi",
288
+ "vb",
289
+ "rcap",
290
+ "rem",
291
+ "rex",
292
+ "rch",
293
+ "ric",
294
+ "rlh",
295
+ "cap",
296
+ "em",
297
+ "ex",
298
+ "ch",
299
+ "ic",
300
+ "lh",
301
+ "cm",
302
+ "mm",
303
+ "in",
304
+ "pc",
305
+ "pt",
306
+ "px",
307
+ "q",
308
+ "%"
309
+ ];
256
310
  // packages/ast/src/expr-eval.ts
257
311
  var FALSE_VALUES = new Set(["false", "null", "", "0"]);
258
312
  function isTruthy(value) {
package/dist/index.d.cts CHANGED
@@ -64,22 +64,29 @@ declare function createPoint(line: number, column: number, offset: number): Poin
64
64
  */
65
65
  declare function createPosition(start: Point, end: Point): Position;
66
66
  /**
67
- * AST element types for Wikidot markup.
67
+ * Shared CSS value definitions used across parser and renderer.
68
68
  *
69
- * Wikidot markup (`+ heading`, `**bold**`, `[[module ListPages]]`, etc.) is parsed into
70
- * a structured representation defined here. Each {@link Element} is a tagged union of
71
- * `{ element: tag, data: payload }`, where the data shape for each tag is defined in
72
- * {@link ElementDataMap}.
69
+ * @module
70
+ */
71
+ /**
72
+ * All CSS length units (plus percentage) accepted where Wikidot markup
73
+ * takes a size value.
73
74
  *
74
- * @example
75
- * ```ts
76
- * import { parse } from "@wdprlib/parser";
77
- * const tree = parse("**Hello** world");
78
- * // tree.elements[0] → { element: "container", data: { type: "paragraph", ... } }
79
- * ```
75
+ * This is intentionally a superset of what legacy Wikidot accepts: wdpr
76
+ * extends size validation to modern CSS units (viewport, container-query,
77
+ * and root-relative units) instead of mirroring Wikidot's historical
78
+ * `px|em|%` allowlists. Units are canonicalized to lowercase.
80
79
  *
81
- * @module
80
+ * @group CSS
81
+ */
82
+ declare const CSS_LENGTH_UNITS: readonly ["cqmax", "cqmin", "cqw", "cqh", "cqi", "cqb", "svmin", "svmax", "lvmin", "lvmax", "dvmin", "dvmax", "vmin", "vmax", "svw", "svh", "svi", "svb", "lvw", "lvh", "lvi", "lvb", "dvw", "dvh", "dvi", "dvb", "vw", "vh", "vi", "vb", "rcap", "rem", "rex", "rch", "ric", "rlh", "cap", "em", "ex", "ch", "ic", "lh", "cm", "mm", "in", "pc", "pt", "px", "q", "%"];
83
+ /**
84
+ * A CSS length unit (or percentage) accepted in size values,
85
+ * canonicalized to lowercase.
86
+ *
87
+ * @group CSS
82
88
  */
89
+ type CssLengthUnit = (typeof CSS_LENGTH_UNITS)[number];
83
90
  /**
84
91
  * Key-value map of HTML attributes.
85
92
  * Populated from the Wikidot `_ class="foo" style="color:red"` attribute syntax.
@@ -488,6 +495,25 @@ type Module = {
488
495
  } | {
489
496
  /** `[[module Rate]]` — page rating widget */
490
497
  module: "rate";
498
+ } | {
499
+ /** `[[module TagCloud]]` — weighted cloud of page tags */
500
+ module: "tag-cloud";
501
+ /** Numeric part of the font size for the lightest-weighted tag */
502
+ "min-font-size": number;
503
+ /** Numeric part of the font size for the heaviest-weighted tag */
504
+ "max-font-size": number;
505
+ /** Unit shared by both font sizes (lowercase) */
506
+ "font-size-unit": CssLengthUnit;
507
+ /** RGB components for the lightest-weighted tag */
508
+ "min-color": [number, number, number];
509
+ /** RGB components for the heaviest-weighted tag */
510
+ "max-color": [number, number, number];
511
+ /** Normalized link target prefix, always ending with `/tag/` */
512
+ target: string;
513
+ /** Maximum number of tags to display */
514
+ limit: number;
515
+ /** Category filter, or null for all categories */
516
+ category: string | null;
491
517
  } | {
492
518
  /** `[[module ListUsers]]` — user listing with template body */
493
519
  module: "list-users";
@@ -1304,4 +1330,4 @@ declare function evaluateExpression(expr: string): ExprResult;
1304
1330
  * @group Core
1305
1331
  */
1306
1332
  type Version = "wikidot";
1307
- export { text, paragraph, listItemSubList, listItemElements, list, link, lineBreak, italics, isTruthy, isStringContainerType, isParagraphSafe, isHeaderType, isContainerTypeParagraphSafe, isAlignType, horizontalRule, heading, formatExprValue, evaluateExpression, createSettings, createPosition, createPoint, container, bold, WikitextSettings, WikitextMode, Version, VariableMap, UserData, TocEntry, TableRow, TableOfContentsData, TableData, TableCell, TabData, SyntaxTree, StringContainerType, STYLE_SLOT_PREFIX, Position, Point, ParseResult, PageRef, Module, MathInlineData, MathData, ListType, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LinkData, IncludeData, ImageSource, ImageData, IframeData, IfTagsData, IfExprData, IfCondData, HtmlData, HeadingLevel, Heading, HeaderType, FootnoteBlockData, FloatAlignment, ExprResult, ExprData, EmbedBlockData, Embed, ElementOf, ElementName, ElementDataMap, ElementData, Element, DiagnosticSeverity, Diagnostic, DefinitionListItem, DateItem, DateData, DEFAULT_SETTINGS, ContainerType, ContainerData, ColorData, CollapsibleData, CodeBlockData, ClearFloat, BibliographyCiteData, BibliographyBlockData, AttributeMap, AnchorTarget, AnchorData, Alignment, AlignType };
1333
+ export { text, paragraph, listItemSubList, listItemElements, list, link, lineBreak, italics, isTruthy, isStringContainerType, isParagraphSafe, isHeaderType, isContainerTypeParagraphSafe, isAlignType, horizontalRule, heading, formatExprValue, evaluateExpression, createSettings, createPosition, createPoint, container, bold, WikitextSettings, WikitextMode, Version, VariableMap, UserData, TocEntry, TableRow, TableOfContentsData, TableData, TableCell, TabData, SyntaxTree, StringContainerType, STYLE_SLOT_PREFIX, Position, Point, ParseResult, PageRef, Module, MathInlineData, MathData, ListType, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LinkData, IncludeData, ImageSource, ImageData, IframeData, IfTagsData, IfExprData, IfCondData, HtmlData, HeadingLevel, Heading, HeaderType, FootnoteBlockData, FloatAlignment, ExprResult, ExprData, EmbedBlockData, Embed, ElementOf, ElementName, ElementDataMap, ElementData, Element, DiagnosticSeverity, Diagnostic, DefinitionListItem, DateItem, DateData, DEFAULT_SETTINGS, CssLengthUnit, ContainerType, ContainerData, ColorData, CollapsibleData, CodeBlockData, ClearFloat, CSS_LENGTH_UNITS, BibliographyCiteData, BibliographyBlockData, AttributeMap, AnchorTarget, AnchorData, Alignment, AlignType };
package/dist/index.d.ts CHANGED
@@ -64,22 +64,29 @@ declare function createPoint(line: number, column: number, offset: number): Poin
64
64
  */
65
65
  declare function createPosition(start: Point, end: Point): Position;
66
66
  /**
67
- * AST element types for Wikidot markup.
67
+ * Shared CSS value definitions used across parser and renderer.
68
68
  *
69
- * Wikidot markup (`+ heading`, `**bold**`, `[[module ListPages]]`, etc.) is parsed into
70
- * a structured representation defined here. Each {@link Element} is a tagged union of
71
- * `{ element: tag, data: payload }`, where the data shape for each tag is defined in
72
- * {@link ElementDataMap}.
69
+ * @module
70
+ */
71
+ /**
72
+ * All CSS length units (plus percentage) accepted where Wikidot markup
73
+ * takes a size value.
73
74
  *
74
- * @example
75
- * ```ts
76
- * import { parse } from "@wdprlib/parser";
77
- * const tree = parse("**Hello** world");
78
- * // tree.elements[0] → { element: "container", data: { type: "paragraph", ... } }
79
- * ```
75
+ * This is intentionally a superset of what legacy Wikidot accepts: wdpr
76
+ * extends size validation to modern CSS units (viewport, container-query,
77
+ * and root-relative units) instead of mirroring Wikidot's historical
78
+ * `px|em|%` allowlists. Units are canonicalized to lowercase.
80
79
  *
81
- * @module
80
+ * @group CSS
81
+ */
82
+ declare const CSS_LENGTH_UNITS: readonly ["cqmax", "cqmin", "cqw", "cqh", "cqi", "cqb", "svmin", "svmax", "lvmin", "lvmax", "dvmin", "dvmax", "vmin", "vmax", "svw", "svh", "svi", "svb", "lvw", "lvh", "lvi", "lvb", "dvw", "dvh", "dvi", "dvb", "vw", "vh", "vi", "vb", "rcap", "rem", "rex", "rch", "ric", "rlh", "cap", "em", "ex", "ch", "ic", "lh", "cm", "mm", "in", "pc", "pt", "px", "q", "%"];
83
+ /**
84
+ * A CSS length unit (or percentage) accepted in size values,
85
+ * canonicalized to lowercase.
86
+ *
87
+ * @group CSS
82
88
  */
89
+ type CssLengthUnit = (typeof CSS_LENGTH_UNITS)[number];
83
90
  /**
84
91
  * Key-value map of HTML attributes.
85
92
  * Populated from the Wikidot `_ class="foo" style="color:red"` attribute syntax.
@@ -488,6 +495,25 @@ type Module = {
488
495
  } | {
489
496
  /** `[[module Rate]]` — page rating widget */
490
497
  module: "rate";
498
+ } | {
499
+ /** `[[module TagCloud]]` — weighted cloud of page tags */
500
+ module: "tag-cloud";
501
+ /** Numeric part of the font size for the lightest-weighted tag */
502
+ "min-font-size": number;
503
+ /** Numeric part of the font size for the heaviest-weighted tag */
504
+ "max-font-size": number;
505
+ /** Unit shared by both font sizes (lowercase) */
506
+ "font-size-unit": CssLengthUnit;
507
+ /** RGB components for the lightest-weighted tag */
508
+ "min-color": [number, number, number];
509
+ /** RGB components for the heaviest-weighted tag */
510
+ "max-color": [number, number, number];
511
+ /** Normalized link target prefix, always ending with `/tag/` */
512
+ target: string;
513
+ /** Maximum number of tags to display */
514
+ limit: number;
515
+ /** Category filter, or null for all categories */
516
+ category: string | null;
491
517
  } | {
492
518
  /** `[[module ListUsers]]` — user listing with template body */
493
519
  module: "list-users";
@@ -1304,4 +1330,4 @@ declare function evaluateExpression(expr: string): ExprResult;
1304
1330
  * @group Core
1305
1331
  */
1306
1332
  type Version = "wikidot";
1307
- export { text, paragraph, listItemSubList, listItemElements, list, link, lineBreak, italics, isTruthy, isStringContainerType, isParagraphSafe, isHeaderType, isContainerTypeParagraphSafe, isAlignType, horizontalRule, heading, formatExprValue, evaluateExpression, createSettings, createPosition, createPoint, container, bold, WikitextSettings, WikitextMode, Version, VariableMap, UserData, TocEntry, TableRow, TableOfContentsData, TableData, TableCell, TabData, SyntaxTree, StringContainerType, STYLE_SLOT_PREFIX, Position, Point, ParseResult, PageRef, Module, MathInlineData, MathData, ListType, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LinkData, IncludeData, ImageSource, ImageData, IframeData, IfTagsData, IfExprData, IfCondData, HtmlData, HeadingLevel, Heading, HeaderType, FootnoteBlockData, FloatAlignment, ExprResult, ExprData, EmbedBlockData, Embed, ElementOf, ElementName, ElementDataMap, ElementData, Element, DiagnosticSeverity, Diagnostic, DefinitionListItem, DateItem, DateData, DEFAULT_SETTINGS, ContainerType, ContainerData, ColorData, CollapsibleData, CodeBlockData, ClearFloat, BibliographyCiteData, BibliographyBlockData, AttributeMap, AnchorTarget, AnchorData, Alignment, AlignType };
1333
+ export { text, paragraph, listItemSubList, listItemElements, list, link, lineBreak, italics, isTruthy, isStringContainerType, isParagraphSafe, isHeaderType, isContainerTypeParagraphSafe, isAlignType, horizontalRule, heading, formatExprValue, evaluateExpression, createSettings, createPosition, createPoint, container, bold, WikitextSettings, WikitextMode, Version, VariableMap, UserData, TocEntry, TableRow, TableOfContentsData, TableData, TableCell, TabData, SyntaxTree, StringContainerType, STYLE_SLOT_PREFIX, Position, Point, ParseResult, PageRef, Module, MathInlineData, MathData, ListType, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LinkData, IncludeData, ImageSource, ImageData, IframeData, IfTagsData, IfExprData, IfCondData, HtmlData, HeadingLevel, Heading, HeaderType, FootnoteBlockData, FloatAlignment, ExprResult, ExprData, EmbedBlockData, Embed, ElementOf, ElementName, ElementDataMap, ElementData, Element, DiagnosticSeverity, Diagnostic, DefinitionListItem, DateItem, DateData, DEFAULT_SETTINGS, CssLengthUnit, ContainerType, ContainerData, ColorData, CollapsibleData, CodeBlockData, ClearFloat, CSS_LENGTH_UNITS, BibliographyCiteData, BibliographyBlockData, AttributeMap, AnchorTarget, AnchorData, Alignment, AlignType };
package/dist/index.js CHANGED
@@ -193,6 +193,59 @@ function isParagraphSafe(element) {
193
193
  }
194
194
  // packages/ast/src/constants.ts
195
195
  var STYLE_SLOT_PREFIX = "\x00__IFTAGS_SLOT__";
196
+ // packages/ast/src/css.ts
197
+ var CSS_LENGTH_UNITS = [
198
+ "cqmax",
199
+ "cqmin",
200
+ "cqw",
201
+ "cqh",
202
+ "cqi",
203
+ "cqb",
204
+ "svmin",
205
+ "svmax",
206
+ "lvmin",
207
+ "lvmax",
208
+ "dvmin",
209
+ "dvmax",
210
+ "vmin",
211
+ "vmax",
212
+ "svw",
213
+ "svh",
214
+ "svi",
215
+ "svb",
216
+ "lvw",
217
+ "lvh",
218
+ "lvi",
219
+ "lvb",
220
+ "dvw",
221
+ "dvh",
222
+ "dvi",
223
+ "dvb",
224
+ "vw",
225
+ "vh",
226
+ "vi",
227
+ "vb",
228
+ "rcap",
229
+ "rem",
230
+ "rex",
231
+ "rch",
232
+ "ric",
233
+ "rlh",
234
+ "cap",
235
+ "em",
236
+ "ex",
237
+ "ch",
238
+ "ic",
239
+ "lh",
240
+ "cm",
241
+ "mm",
242
+ "in",
243
+ "pc",
244
+ "pt",
245
+ "px",
246
+ "q",
247
+ "%"
248
+ ];
196
249
  // packages/ast/src/expr-eval.ts
197
250
  var FALSE_VALUES = new Set(["false", "null", "", "0"]);
198
251
  function isTruthy(value) {
@@ -640,5 +693,6 @@ export {
640
693
  container,
641
694
  bold,
642
695
  STYLE_SLOT_PREFIX,
643
- DEFAULT_SETTINGS
696
+ DEFAULT_SETTINGS,
697
+ CSS_LENGTH_UNITS
644
698
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdprlib/ast",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "AST types for Wikidot markup",
5
5
  "keywords": [
6
6
  "ast",
package/src/css.ts ADDED
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Shared CSS value definitions used across parser and renderer.
3
+ *
4
+ * @module
5
+ */
6
+
7
+ /**
8
+ * All CSS length units (plus percentage) accepted where Wikidot markup
9
+ * takes a size value.
10
+ *
11
+ * This is intentionally a superset of what legacy Wikidot accepts: wdpr
12
+ * extends size validation to modern CSS units (viewport, container-query,
13
+ * and root-relative units) instead of mirroring Wikidot's historical
14
+ * `px|em|%` allowlists. Units are canonicalized to lowercase.
15
+ *
16
+ * @group CSS
17
+ */
18
+ export const CSS_LENGTH_UNITS = [
19
+ // Container-query units
20
+ "cqmax",
21
+ "cqmin",
22
+ "cqw",
23
+ "cqh",
24
+ "cqi",
25
+ "cqb",
26
+ // Viewport units
27
+ "svmin",
28
+ "svmax",
29
+ "lvmin",
30
+ "lvmax",
31
+ "dvmin",
32
+ "dvmax",
33
+ "vmin",
34
+ "vmax",
35
+ "svw",
36
+ "svh",
37
+ "svi",
38
+ "svb",
39
+ "lvw",
40
+ "lvh",
41
+ "lvi",
42
+ "lvb",
43
+ "dvw",
44
+ "dvh",
45
+ "dvi",
46
+ "dvb",
47
+ "vw",
48
+ "vh",
49
+ "vi",
50
+ "vb",
51
+ // Root-relative font units
52
+ "rcap",
53
+ "rem",
54
+ "rex",
55
+ "rch",
56
+ "ric",
57
+ "rlh",
58
+ // Font-relative units
59
+ "cap",
60
+ "em",
61
+ "ex",
62
+ "ch",
63
+ "ic",
64
+ "lh",
65
+ // Absolute units
66
+ "cm",
67
+ "mm",
68
+ "in",
69
+ "pc",
70
+ "pt",
71
+ "px",
72
+ "q",
73
+ // Percentage
74
+ "%",
75
+ ] as const;
76
+
77
+ /**
78
+ * A CSS length unit (or percentage) accepted in size values,
79
+ * canonicalized to lowercase.
80
+ *
81
+ * @group CSS
82
+ */
83
+ export type CssLengthUnit = (typeof CSS_LENGTH_UNITS)[number];
package/src/element.ts CHANGED
@@ -16,6 +16,8 @@
16
16
  * @module
17
17
  */
18
18
 
19
+ import type { CssLengthUnit } from "./css";
20
+
19
21
  // ---------------------------------------------------------------------------
20
22
  // Primitive types
21
23
  // ---------------------------------------------------------------------------
@@ -500,6 +502,26 @@ export type Module =
500
502
  /** `[[module Rate]]` — page rating widget */
501
503
  module: "rate";
502
504
  }
505
+ | {
506
+ /** `[[module TagCloud]]` — weighted cloud of page tags */
507
+ module: "tag-cloud";
508
+ /** Numeric part of the font size for the lightest-weighted tag */
509
+ "min-font-size": number;
510
+ /** Numeric part of the font size for the heaviest-weighted tag */
511
+ "max-font-size": number;
512
+ /** Unit shared by both font sizes (lowercase) */
513
+ "font-size-unit": CssLengthUnit;
514
+ /** RGB components for the lightest-weighted tag */
515
+ "min-color": [number, number, number];
516
+ /** RGB components for the heaviest-weighted tag */
517
+ "max-color": [number, number, number];
518
+ /** Normalized link target prefix, always ending with `/tag/` */
519
+ target: string;
520
+ /** Maximum number of tags to display */
521
+ limit: number;
522
+ /** Category filter, or null for all categories */
523
+ category: string | null;
524
+ }
503
525
  | {
504
526
  /** `[[module ListUsers]]` — user listing with template body */
505
527
  module: "list-users";
package/src/index.ts CHANGED
@@ -110,6 +110,10 @@ export type { Diagnostic, DiagnosticSeverity, ParseResult } from "./diagnostic";
110
110
  // Constants
111
111
  export { STYLE_SLOT_PREFIX } from "./constants";
112
112
 
113
+ // CSS value definitions
114
+ export type { CssLengthUnit } from "./css";
115
+ export { CSS_LENGTH_UNITS } from "./css";
116
+
113
117
  // Wikitext settings
114
118
  export type { WikitextMode, WikitextSettings } from "./settings";
115
119