@wdprlib/ast 2.2.0 → 2.4.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 +2 -0
- package/dist/index.d.cts +103 -1
- package/dist/index.d.ts +103 -1
- package/dist/index.js +2 -0
- package/package.json +1 -1
- package/src/constants.ts +8 -0
- package/src/element.ts +74 -0
- package/src/index.ts +9 -1
- package/src/page-context.ts +23 -0
package/dist/index.cjs
CHANGED
|
@@ -54,6 +54,7 @@ __export(exports_src, {
|
|
|
54
54
|
container: () => container,
|
|
55
55
|
bold: () => bold,
|
|
56
56
|
STYLE_SLOT_PREFIX: () => STYLE_SLOT_PREFIX,
|
|
57
|
+
STYLE_ANCHOR_PREFIX: () => STYLE_ANCHOR_PREFIX,
|
|
57
58
|
DEFAULT_SETTINGS: () => DEFAULT_SETTINGS,
|
|
58
59
|
CSS_LENGTH_UNITS: () => CSS_LENGTH_UNITS
|
|
59
60
|
});
|
|
@@ -254,6 +255,7 @@ function isParagraphSafe(element) {
|
|
|
254
255
|
}
|
|
255
256
|
// packages/ast/src/constants.ts
|
|
256
257
|
var STYLE_SLOT_PREFIX = "\x00__IFTAGS_SLOT__";
|
|
258
|
+
var STYLE_ANCHOR_PREFIX = "\x00__STYLE_ANCHOR__";
|
|
257
259
|
// packages/ast/src/css.ts
|
|
258
260
|
var CSS_LENGTH_UNITS = [
|
|
259
261
|
"cqmax",
|
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;
|
|
@@ -1160,6 +1233,13 @@ interface ParseResult {
|
|
|
1160
1233
|
*/
|
|
1161
1234
|
declare const STYLE_SLOT_PREFIX = "\0__IFTAGS_SLOT__";
|
|
1162
1235
|
/**
|
|
1236
|
+
* Sentinel prefix for invisible style-position anchors retained in the AST.
|
|
1237
|
+
*
|
|
1238
|
+
* The suffix is the previously collected CSS text. Renderers must not emit
|
|
1239
|
+
* these synthetic style elements.
|
|
1240
|
+
*/
|
|
1241
|
+
declare const STYLE_ANCHOR_PREFIX = "\0__STYLE_ANCHOR__";
|
|
1242
|
+
/**
|
|
1163
1243
|
* Context-dependent settings for the Wikidot parser and renderer.
|
|
1164
1244
|
*
|
|
1165
1245
|
* Wikidot content appears in several different contexts — full wiki pages,
|
|
@@ -1321,6 +1401,28 @@ declare function formatExprValue(n: number): string;
|
|
|
1321
1401
|
* @returns A success result with a numeric value, or an error result with a message.
|
|
1322
1402
|
*/
|
|
1323
1403
|
declare function evaluateExpression(expr: string): ExprResult;
|
|
1404
|
+
/** Attachment metadata used by page-contextual gallery rendering. */
|
|
1405
|
+
interface WikitextPageFile {
|
|
1406
|
+
name: string;
|
|
1407
|
+
createdAt?: number;
|
|
1408
|
+
}
|
|
1409
|
+
/**
|
|
1410
|
+
* Page data shared by high-level parser and renderer APIs.
|
|
1411
|
+
*
|
|
1412
|
+
* `fullName` is the category-qualified Wikidot page name. `unixName`, when
|
|
1413
|
+
* available, is the separately named URL-safe page identifier.
|
|
1414
|
+
*/
|
|
1415
|
+
interface WikitextPageContext {
|
|
1416
|
+
fullName: string;
|
|
1417
|
+
unixName?: string;
|
|
1418
|
+
tags: string[];
|
|
1419
|
+
urlPath?: string;
|
|
1420
|
+
site?: string;
|
|
1421
|
+
domain?: string;
|
|
1422
|
+
siteDomains?: Record<string, string>;
|
|
1423
|
+
resolveSiteDomain?: (site: string) => string | null | undefined;
|
|
1424
|
+
files?: WikitextPageFile[];
|
|
1425
|
+
}
|
|
1324
1426
|
/**
|
|
1325
1427
|
* Identifies the source markup dialect.
|
|
1326
1428
|
*
|
|
@@ -1330,4 +1432,4 @@ declare function evaluateExpression(expr: string): ExprResult;
|
|
|
1330
1432
|
* @group Core
|
|
1331
1433
|
*/
|
|
1332
1434
|
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 };
|
|
1435
|
+
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, WikitextPageFile, WikitextPageContext, WikitextMode, Version, VariableMap, UserData, TocEntry, TableRow, TableOfContentsData, TableData, TableCell, TabData, SyntaxTree, StringContainerType, STYLE_SLOT_PREFIX, STYLE_ANCHOR_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;
|
|
@@ -1160,6 +1233,13 @@ interface ParseResult {
|
|
|
1160
1233
|
*/
|
|
1161
1234
|
declare const STYLE_SLOT_PREFIX = "\0__IFTAGS_SLOT__";
|
|
1162
1235
|
/**
|
|
1236
|
+
* Sentinel prefix for invisible style-position anchors retained in the AST.
|
|
1237
|
+
*
|
|
1238
|
+
* The suffix is the previously collected CSS text. Renderers must not emit
|
|
1239
|
+
* these synthetic style elements.
|
|
1240
|
+
*/
|
|
1241
|
+
declare const STYLE_ANCHOR_PREFIX = "\0__STYLE_ANCHOR__";
|
|
1242
|
+
/**
|
|
1163
1243
|
* Context-dependent settings for the Wikidot parser and renderer.
|
|
1164
1244
|
*
|
|
1165
1245
|
* Wikidot content appears in several different contexts — full wiki pages,
|
|
@@ -1321,6 +1401,28 @@ declare function formatExprValue(n: number): string;
|
|
|
1321
1401
|
* @returns A success result with a numeric value, or an error result with a message.
|
|
1322
1402
|
*/
|
|
1323
1403
|
declare function evaluateExpression(expr: string): ExprResult;
|
|
1404
|
+
/** Attachment metadata used by page-contextual gallery rendering. */
|
|
1405
|
+
interface WikitextPageFile {
|
|
1406
|
+
name: string;
|
|
1407
|
+
createdAt?: number;
|
|
1408
|
+
}
|
|
1409
|
+
/**
|
|
1410
|
+
* Page data shared by high-level parser and renderer APIs.
|
|
1411
|
+
*
|
|
1412
|
+
* `fullName` is the category-qualified Wikidot page name. `unixName`, when
|
|
1413
|
+
* available, is the separately named URL-safe page identifier.
|
|
1414
|
+
*/
|
|
1415
|
+
interface WikitextPageContext {
|
|
1416
|
+
fullName: string;
|
|
1417
|
+
unixName?: string;
|
|
1418
|
+
tags: string[];
|
|
1419
|
+
urlPath?: string;
|
|
1420
|
+
site?: string;
|
|
1421
|
+
domain?: string;
|
|
1422
|
+
siteDomains?: Record<string, string>;
|
|
1423
|
+
resolveSiteDomain?: (site: string) => string | null | undefined;
|
|
1424
|
+
files?: WikitextPageFile[];
|
|
1425
|
+
}
|
|
1324
1426
|
/**
|
|
1325
1427
|
* Identifies the source markup dialect.
|
|
1326
1428
|
*
|
|
@@ -1330,4 +1432,4 @@ declare function evaluateExpression(expr: string): ExprResult;
|
|
|
1330
1432
|
* @group Core
|
|
1331
1433
|
*/
|
|
1332
1434
|
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 };
|
|
1435
|
+
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, WikitextPageFile, WikitextPageContext, WikitextMode, Version, VariableMap, UserData, TocEntry, TableRow, TableOfContentsData, TableData, TableCell, TabData, SyntaxTree, StringContainerType, STYLE_SLOT_PREFIX, STYLE_ANCHOR_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.js
CHANGED
|
@@ -193,6 +193,7 @@ function isParagraphSafe(element) {
|
|
|
193
193
|
}
|
|
194
194
|
// packages/ast/src/constants.ts
|
|
195
195
|
var STYLE_SLOT_PREFIX = "\x00__IFTAGS_SLOT__";
|
|
196
|
+
var STYLE_ANCHOR_PREFIX = "\x00__STYLE_ANCHOR__";
|
|
196
197
|
// packages/ast/src/css.ts
|
|
197
198
|
var CSS_LENGTH_UNITS = [
|
|
198
199
|
"cqmax",
|
|
@@ -693,6 +694,7 @@ export {
|
|
|
693
694
|
container,
|
|
694
695
|
bold,
|
|
695
696
|
STYLE_SLOT_PREFIX,
|
|
697
|
+
STYLE_ANCHOR_PREFIX,
|
|
696
698
|
DEFAULT_SETTINGS,
|
|
697
699
|
CSS_LENGTH_UNITS
|
|
698
700
|
};
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
|
@@ -10,3 +10,11 @@
|
|
|
10
10
|
* A null-byte prefix ensures no collision with valid CSS content.
|
|
11
11
|
*/
|
|
12
12
|
export const STYLE_SLOT_PREFIX = "\0__IFTAGS_SLOT__";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Sentinel prefix for invisible style-position anchors retained in the AST.
|
|
16
|
+
*
|
|
17
|
+
* The suffix is the previously collected CSS text. Renderers must not emit
|
|
18
|
+
* these synthetic style elements.
|
|
19
|
+
*/
|
|
20
|
+
export const STYLE_ANCHOR_PREFIX = "\0__STYLE_ANCHOR__";
|
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,
|
|
@@ -108,7 +113,7 @@ export {
|
|
|
108
113
|
export type { Diagnostic, DiagnosticSeverity, ParseResult } from "./diagnostic";
|
|
109
114
|
|
|
110
115
|
// Constants
|
|
111
|
-
export { STYLE_SLOT_PREFIX } from "./constants";
|
|
116
|
+
export { STYLE_ANCHOR_PREFIX, STYLE_SLOT_PREFIX } from "./constants";
|
|
112
117
|
|
|
113
118
|
// CSS value definitions
|
|
114
119
|
export type { CssLengthUnit } from "./css";
|
|
@@ -121,3 +126,6 @@ export type { WikitextMode, WikitextSettings } from "./settings";
|
|
|
121
126
|
export { evaluateExpression, isTruthy, formatExprValue } from "./expr-eval";
|
|
122
127
|
export type { ExprResult } from "./expr-eval";
|
|
123
128
|
export { createSettings, DEFAULT_SETTINGS } from "./settings";
|
|
129
|
+
|
|
130
|
+
// Shared high-level pipeline page context
|
|
131
|
+
export type { WikitextPageContext, WikitextPageFile } from "./page-context";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Attachment metadata used by page-contextual gallery rendering. */
|
|
2
|
+
export interface WikitextPageFile {
|
|
3
|
+
name: string;
|
|
4
|
+
createdAt?: number;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Page data shared by high-level parser and renderer APIs.
|
|
9
|
+
*
|
|
10
|
+
* `fullName` is the category-qualified Wikidot page name. `unixName`, when
|
|
11
|
+
* available, is the separately named URL-safe page identifier.
|
|
12
|
+
*/
|
|
13
|
+
export interface WikitextPageContext {
|
|
14
|
+
fullName: string;
|
|
15
|
+
unixName?: string;
|
|
16
|
+
tags: string[];
|
|
17
|
+
urlPath?: string;
|
|
18
|
+
site?: string;
|
|
19
|
+
domain?: string;
|
|
20
|
+
siteDomains?: Record<string, string>;
|
|
21
|
+
resolveSiteDomain?: (site: string) => string | null | undefined;
|
|
22
|
+
files?: WikitextPageFile[];
|
|
23
|
+
}
|