@wdprlib/ast 2.2.0 → 2.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/dist/index.d.cts CHANGED
@@ -642,6 +642,78 @@ interface ImageData {
642
642
  attributes: AttributeMap;
643
643
  }
644
644
  /**
645
+ * Image size keyword accepted by `[[gallery]]`.
646
+ * Invalid or missing values fall back to `"thumbnail"` at parse time,
647
+ * matching the Wikidot renderer.
648
+ *
649
+ * @group Element Data
650
+ */
651
+ type GallerySize = "small" | "medium" | "thumbnail" | "square" | "original";
652
+ /**
653
+ * Sort order for auto-collected gallery files, normalized at parse time.
654
+ * Deprecated Wikidot aliases (`nameDesc`, `dateAdded`, `dateAddedDesc`) and
655
+ * the ListPages-style `"... desc desc"` forms are folded into these four
656
+ * values. Only meaningful for the content-less (auto) form.
657
+ *
658
+ * @group Element Data
659
+ */
660
+ type GalleryOrder = "name" | "name desc" | "created_at" | "created_at desc";
661
+ /**
662
+ * A single `: source link="..." alt="..."` entry inside `[[gallery]]`.
663
+ *
664
+ * @group Element Data
665
+ */
666
+ interface GalleryItem {
667
+ /**
668
+ * Raw image source string with any leading `*` removed.
669
+ * Classification follows the Wikidot rules and happens at render time:
670
+ * a source containing `://` is external, one containing `/` refers to
671
+ * another page's file, anything else is a file on the current page.
672
+ */
673
+ source: string;
674
+ /**
675
+ * Link target with any leading `*` removed, or null when the item has no
676
+ * `link` attribute.
677
+ */
678
+ link: string | null;
679
+ /** Alternative text for the image, or null when no `alt` attribute is given */
680
+ alt: string | null;
681
+ /** true if the link opens in a new window (`*` prefix on source or link) */
682
+ newWindow: boolean;
683
+ }
684
+ /**
685
+ * Body of a `[[gallery]]` element.
686
+ *
687
+ * - `"items"` — the content form with explicit `: source` lines.
688
+ * `items` is always non-empty: the content form requires at least one
689
+ * line to parse.
690
+ * - `"auto"` — the content-less form, which shows the current page's image
691
+ * attachments. `files` is null until data resolution fills it with the
692
+ * attachment filenames (already sorted by the gallery's `order`).
693
+ *
694
+ * @group Element Data
695
+ */
696
+ type GalleryContent = {
697
+ type: "items";
698
+ items: GalleryItem[];
699
+ } | {
700
+ type: "auto";
701
+ files: string[] | null;
702
+ };
703
+ /**
704
+ * Data for `[[gallery]]` elements.
705
+ *
706
+ * @group Element Data
707
+ */
708
+ interface GalleryData {
709
+ size: GallerySize;
710
+ /** Sort order for auto-collected files (parse-time normalized) */
711
+ order: GalleryOrder;
712
+ /** false when `viewer="no"`/`"false"` disables the lightbox */
713
+ viewer: boolean;
714
+ content: GalleryContent;
715
+ }
716
+ /**
645
717
  * Data for `[[toc]]` (table of contents) elements.
646
718
  *
647
719
  * @group Element Data
@@ -852,6 +924,7 @@ type ElementDataMap = {
852
924
  "anchor-name": string;
853
925
  link: LinkData;
854
926
  image: ImageData;
927
+ gallery: GalleryData;
855
928
  list: ListData;
856
929
  "definition-list": DefinitionListItem[];
857
930
  collapsible: CollapsibleData;
@@ -1330,4 +1403,4 @@ declare function evaluateExpression(expr: string): ExprResult;
1330
1403
  * @group Core
1331
1404
  */
1332
1405
  type Version = "wikidot";
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 };
1406
+ 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, GallerySize, GalleryOrder, GalleryItem, GalleryData, GalleryContent, 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
@@ -642,6 +642,78 @@ interface ImageData {
642
642
  attributes: AttributeMap;
643
643
  }
644
644
  /**
645
+ * Image size keyword accepted by `[[gallery]]`.
646
+ * Invalid or missing values fall back to `"thumbnail"` at parse time,
647
+ * matching the Wikidot renderer.
648
+ *
649
+ * @group Element Data
650
+ */
651
+ type GallerySize = "small" | "medium" | "thumbnail" | "square" | "original";
652
+ /**
653
+ * Sort order for auto-collected gallery files, normalized at parse time.
654
+ * Deprecated Wikidot aliases (`nameDesc`, `dateAdded`, `dateAddedDesc`) and
655
+ * the ListPages-style `"... desc desc"` forms are folded into these four
656
+ * values. Only meaningful for the content-less (auto) form.
657
+ *
658
+ * @group Element Data
659
+ */
660
+ type GalleryOrder = "name" | "name desc" | "created_at" | "created_at desc";
661
+ /**
662
+ * A single `: source link="..." alt="..."` entry inside `[[gallery]]`.
663
+ *
664
+ * @group Element Data
665
+ */
666
+ interface GalleryItem {
667
+ /**
668
+ * Raw image source string with any leading `*` removed.
669
+ * Classification follows the Wikidot rules and happens at render time:
670
+ * a source containing `://` is external, one containing `/` refers to
671
+ * another page's file, anything else is a file on the current page.
672
+ */
673
+ source: string;
674
+ /**
675
+ * Link target with any leading `*` removed, or null when the item has no
676
+ * `link` attribute.
677
+ */
678
+ link: string | null;
679
+ /** Alternative text for the image, or null when no `alt` attribute is given */
680
+ alt: string | null;
681
+ /** true if the link opens in a new window (`*` prefix on source or link) */
682
+ newWindow: boolean;
683
+ }
684
+ /**
685
+ * Body of a `[[gallery]]` element.
686
+ *
687
+ * - `"items"` — the content form with explicit `: source` lines.
688
+ * `items` is always non-empty: the content form requires at least one
689
+ * line to parse.
690
+ * - `"auto"` — the content-less form, which shows the current page's image
691
+ * attachments. `files` is null until data resolution fills it with the
692
+ * attachment filenames (already sorted by the gallery's `order`).
693
+ *
694
+ * @group Element Data
695
+ */
696
+ type GalleryContent = {
697
+ type: "items";
698
+ items: GalleryItem[];
699
+ } | {
700
+ type: "auto";
701
+ files: string[] | null;
702
+ };
703
+ /**
704
+ * Data for `[[gallery]]` elements.
705
+ *
706
+ * @group Element Data
707
+ */
708
+ interface GalleryData {
709
+ size: GallerySize;
710
+ /** Sort order for auto-collected files (parse-time normalized) */
711
+ order: GalleryOrder;
712
+ /** false when `viewer="no"`/`"false"` disables the lightbox */
713
+ viewer: boolean;
714
+ content: GalleryContent;
715
+ }
716
+ /**
645
717
  * Data for `[[toc]]` (table of contents) elements.
646
718
  *
647
719
  * @group Element Data
@@ -852,6 +924,7 @@ type ElementDataMap = {
852
924
  "anchor-name": string;
853
925
  link: LinkData;
854
926
  image: ImageData;
927
+ gallery: GalleryData;
855
928
  list: ListData;
856
929
  "definition-list": DefinitionListItem[];
857
930
  collapsible: CollapsibleData;
@@ -1330,4 +1403,4 @@ declare function evaluateExpression(expr: string): ExprResult;
1330
1403
  * @group Core
1331
1404
  */
1332
1405
  type Version = "wikidot";
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 };
1406
+ 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, GallerySize, GalleryOrder, GalleryItem, GalleryData, GalleryContent, 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdprlib/ast",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "AST types for Wikidot markup",
5
5
  "keywords": [
6
6
  "ast",
package/src/element.ts CHANGED
@@ -658,6 +658,79 @@ export interface ImageData {
658
658
  attributes: AttributeMap;
659
659
  }
660
660
 
661
+ /**
662
+ * Image size keyword accepted by `[[gallery]]`.
663
+ * Invalid or missing values fall back to `"thumbnail"` at parse time,
664
+ * matching the Wikidot renderer.
665
+ *
666
+ * @group Element Data
667
+ */
668
+ export type GallerySize = "small" | "medium" | "thumbnail" | "square" | "original";
669
+
670
+ /**
671
+ * Sort order for auto-collected gallery files, normalized at parse time.
672
+ * Deprecated Wikidot aliases (`nameDesc`, `dateAdded`, `dateAddedDesc`) and
673
+ * the ListPages-style `"... desc desc"` forms are folded into these four
674
+ * values. Only meaningful for the content-less (auto) form.
675
+ *
676
+ * @group Element Data
677
+ */
678
+ export type GalleryOrder = "name" | "name desc" | "created_at" | "created_at desc";
679
+
680
+ /**
681
+ * A single `: source link="..." alt="..."` entry inside `[[gallery]]`.
682
+ *
683
+ * @group Element Data
684
+ */
685
+ export interface GalleryItem {
686
+ /**
687
+ * Raw image source string with any leading `*` removed.
688
+ * Classification follows the Wikidot rules and happens at render time:
689
+ * a source containing `://` is external, one containing `/` refers to
690
+ * another page's file, anything else is a file on the current page.
691
+ */
692
+ source: string;
693
+ /**
694
+ * Link target with any leading `*` removed, or null when the item has no
695
+ * `link` attribute.
696
+ */
697
+ link: string | null;
698
+ /** Alternative text for the image, or null when no `alt` attribute is given */
699
+ alt: string | null;
700
+ /** true if the link opens in a new window (`*` prefix on source or link) */
701
+ newWindow: boolean;
702
+ }
703
+
704
+ /**
705
+ * Body of a `[[gallery]]` element.
706
+ *
707
+ * - `"items"` — the content form with explicit `: source` lines.
708
+ * `items` is always non-empty: the content form requires at least one
709
+ * line to parse.
710
+ * - `"auto"` — the content-less form, which shows the current page's image
711
+ * attachments. `files` is null until data resolution fills it with the
712
+ * attachment filenames (already sorted by the gallery's `order`).
713
+ *
714
+ * @group Element Data
715
+ */
716
+ export type GalleryContent =
717
+ | { type: "items"; items: GalleryItem[] }
718
+ | { type: "auto"; files: string[] | null };
719
+
720
+ /**
721
+ * Data for `[[gallery]]` elements.
722
+ *
723
+ * @group Element Data
724
+ */
725
+ export interface GalleryData {
726
+ size: GallerySize;
727
+ /** Sort order for auto-collected files (parse-time normalized) */
728
+ order: GalleryOrder;
729
+ /** false when `viewer="no"`/`"false"` disables the lightbox */
730
+ viewer: boolean;
731
+ content: GalleryContent;
732
+ }
733
+
661
734
  /**
662
735
  * Data for `[[toc]]` (table of contents) elements.
663
736
  *
@@ -890,6 +963,7 @@ export type ElementDataMap = {
890
963
  "anchor-name": string;
891
964
  link: LinkData;
892
965
  image: ImageData;
966
+ gallery: GalleryData;
893
967
  list: ListData;
894
968
  "definition-list": DefinitionListItem[];
895
969
  collapsible: CollapsibleData;
package/src/index.ts CHANGED
@@ -67,6 +67,11 @@ export type {
67
67
  AnchorData,
68
68
  LinkData,
69
69
  ImageData,
70
+ GallerySize,
71
+ GalleryOrder,
72
+ GalleryItem,
73
+ GalleryContent,
74
+ GalleryData,
70
75
  TableOfContentsData,
71
76
  FootnoteBlockData,
72
77
  BibliographyCiteData,