@wdprlib/parser 2.1.0 → 3.0.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 +871 -446
- package/dist/index.d.cts +31 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +871 -446
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -80,6 +80,15 @@ declare class Lexer {
|
|
|
80
80
|
private state;
|
|
81
81
|
private options;
|
|
82
82
|
private splitBlockClosePositions;
|
|
83
|
+
/**
|
|
84
|
+
* Nesting depth of block-opener context (between `[[` / `[[/` and the
|
|
85
|
+
* matching `]]`). Used to scope `QUOTED_STRING` recognition so that
|
|
86
|
+
* `"` after `=` only becomes a quoted attribute value while we are
|
|
87
|
+
* actually parsing block attributes — otherwise inline `=` followed by
|
|
88
|
+
* `"` (e.g. inside `[[footnote]]="[[/footnote]]`) would erroneously
|
|
89
|
+
* consume content up to the next `"` or newline.
|
|
90
|
+
*/
|
|
91
|
+
private blockOpenerDepth;
|
|
83
92
|
constructor(source: string, options?: LexerOptions);
|
|
84
93
|
/**
|
|
85
94
|
* Tokenize the entire source
|
|
@@ -848,6 +857,27 @@ declare function parseNumericSelector(value: string): NormalizedNumericSelector
|
|
|
848
857
|
* @returns Normalized query with structured types
|
|
849
858
|
*/
|
|
850
859
|
declare function normalizeQuery(query: ListPagesQuery): NormalizedListPagesQuery;
|
|
860
|
+
/**
|
|
861
|
+
* Expand `[[iftags ...]]X[[/iftags]]` directives in `source` against the
|
|
862
|
+
* current page's tags.
|
|
863
|
+
*
|
|
864
|
+
* Returns `source` unchanged when `pageTags` is `null`, which signals
|
|
865
|
+
* that the caller could not resolve tag membership (e.g. rendering a
|
|
866
|
+
* draft preview without a real page). In that case the AST-level
|
|
867
|
+
* resolver remains responsible for evaluation later.
|
|
868
|
+
*
|
|
869
|
+
* Behaviour:
|
|
870
|
+
* - Raw regions (`[[code]]`, `[[html]]`, `@@...@@`, `@<...>@`) are
|
|
871
|
+
* protected: literal `[[iftags]]` tokens inside them are not expanded.
|
|
872
|
+
* - Nested `[[iftags]]` are processed innermost-first, so an outer
|
|
873
|
+
* block can re-process the now-flattened inner body uniformly.
|
|
874
|
+
*
|
|
875
|
+
* @param source Raw wikitext (typically after include expansion).
|
|
876
|
+
* @param pageTags Tags of the page being rendered, or `null` to skip.
|
|
877
|
+
* @returns Source with matching iftags replaced by their bodies and
|
|
878
|
+
* unmatched iftags removed entirely.
|
|
879
|
+
*/
|
|
880
|
+
declare function preprocessIftags(source: string, pageTags: string[] | null): string;
|
|
851
881
|
import { PageRef, WikitextSettings as WikitextSettings3 } from "@wdprlib/ast";
|
|
852
882
|
/**
|
|
853
883
|
* Callback to fetch page content for include resolution.
|
|
@@ -1011,4 +1041,4 @@ interface ResolveOptions {
|
|
|
1011
1041
|
*/
|
|
1012
1042
|
declare function resolveModules(ast: SyntaxTree2, dataProvider: DataProvider, options: ResolveOptions): Promise<SyntaxTree2>;
|
|
1013
1043
|
import { STYLE_SLOT_PREFIX } from "@wdprlib/ast";
|
|
1014
|
-
export { tokenize, text, resolveModules, resolveListUsers, resolveIncludesAsync, resolveIncludes, parseTags, parseParent, parseOrder, parseNumericSelector, parseDateSelector, parseCategory, parse, paragraph, normalizeQuery, listItemSubList, listItemElements, list, link, lineBreak, italics, isListUsersModule, horizontalRule, heading, extractListUsersVariables, extractDataRequirements, createToken, createSettings, createPosition, createPoint, container, compileTemplate, compileListUsersTemplate, bold, WikitextSettings4 as WikitextSettings, WikitextMode, Version2 as Version, VariableMap, VariableContext, UserInfo, TokenType, Token, TocEntry2 as TocEntry, TableRow, TableData, TableCell, TabData, SyntaxTree3 as SyntaxTree, SiteContext, STYLE_SLOT_PREFIX, ResolveOptions, ResolveIncludesOptions, Position2 as Position, Point, ParserOptions, Parser, ParseResult2 as ParseResult, ParseFunction, PageRef2 as PageRef, PageData, NormalizedTags, NormalizedParent, NormalizedOrder, NormalizedNumericSelector, NormalizedListPagesQuery, NormalizedDateSelector, NormalizedCategory, Module4 as Module, ListUsersVariableContext, ListUsersVariable, ListUsersUserData, ListUsersExternalData, ListUsersDataRequirement, ListUsersDataFetcher, ListUsersCompiledTemplate, ListType, ListPagesVariable, ListPagesQuery, ListPagesExternalData, ListPagesDataRequirement, ListPagesDataFetcher, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LexerOptions, Lexer, IncludeFetcher, ImageSource, HeadingLevel, Heading, HeaderType, FloatAlignment, ExtractionResult, Embed, Element6 as Element, DiagnosticSeverity, Diagnostic2 as Diagnostic, DefinitionListItem, DateItem, DataRequirements, DataProvider, DEFAULT_SETTINGS, ContainerType, ContainerData, CompiledTemplate, CollapsibleData, CodeBlockData2 as CodeBlockData, ClearFloat, AttributeMap, AsyncIncludeFetcher, AnchorTarget, Alignment, AlignType };
|
|
1044
|
+
export { tokenize, text, resolveModules, resolveListUsers, resolveIncludesAsync, resolveIncludes, preprocessIftags, parseTags, parseParent, parseOrder, parseNumericSelector, parseDateSelector, parseCategory, parse, paragraph, normalizeQuery, listItemSubList, listItemElements, list, link, lineBreak, italics, isListUsersModule, horizontalRule, heading, extractListUsersVariables, extractDataRequirements, createToken, createSettings, createPosition, createPoint, container, compileTemplate, compileListUsersTemplate, bold, WikitextSettings4 as WikitextSettings, WikitextMode, Version2 as Version, VariableMap, VariableContext, UserInfo, TokenType, Token, TocEntry2 as TocEntry, TableRow, TableData, TableCell, TabData, SyntaxTree3 as SyntaxTree, SiteContext, STYLE_SLOT_PREFIX, ResolveOptions, ResolveIncludesOptions, Position2 as Position, Point, ParserOptions, Parser, ParseResult2 as ParseResult, ParseFunction, PageRef2 as PageRef, PageData, NormalizedTags, NormalizedParent, NormalizedOrder, NormalizedNumericSelector, NormalizedListPagesQuery, NormalizedDateSelector, NormalizedCategory, Module4 as Module, ListUsersVariableContext, ListUsersVariable, ListUsersUserData, ListUsersExternalData, ListUsersDataRequirement, ListUsersDataFetcher, ListUsersCompiledTemplate, ListType, ListPagesVariable, ListPagesQuery, ListPagesExternalData, ListPagesDataRequirement, ListPagesDataFetcher, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LexerOptions, Lexer, IncludeFetcher, ImageSource, HeadingLevel, Heading, HeaderType, FloatAlignment, ExtractionResult, Embed, Element6 as Element, DiagnosticSeverity, Diagnostic2 as Diagnostic, DefinitionListItem, DateItem, DataRequirements, DataProvider, DEFAULT_SETTINGS, ContainerType, ContainerData, CompiledTemplate, CollapsibleData, CodeBlockData2 as CodeBlockData, ClearFloat, AttributeMap, AsyncIncludeFetcher, AnchorTarget, Alignment, AlignType };
|
package/dist/index.d.ts
CHANGED
|
@@ -80,6 +80,15 @@ declare class Lexer {
|
|
|
80
80
|
private state;
|
|
81
81
|
private options;
|
|
82
82
|
private splitBlockClosePositions;
|
|
83
|
+
/**
|
|
84
|
+
* Nesting depth of block-opener context (between `[[` / `[[/` and the
|
|
85
|
+
* matching `]]`). Used to scope `QUOTED_STRING` recognition so that
|
|
86
|
+
* `"` after `=` only becomes a quoted attribute value while we are
|
|
87
|
+
* actually parsing block attributes — otherwise inline `=` followed by
|
|
88
|
+
* `"` (e.g. inside `[[footnote]]="[[/footnote]]`) would erroneously
|
|
89
|
+
* consume content up to the next `"` or newline.
|
|
90
|
+
*/
|
|
91
|
+
private blockOpenerDepth;
|
|
83
92
|
constructor(source: string, options?: LexerOptions);
|
|
84
93
|
/**
|
|
85
94
|
* Tokenize the entire source
|
|
@@ -848,6 +857,27 @@ declare function parseNumericSelector(value: string): NormalizedNumericSelector
|
|
|
848
857
|
* @returns Normalized query with structured types
|
|
849
858
|
*/
|
|
850
859
|
declare function normalizeQuery(query: ListPagesQuery): NormalizedListPagesQuery;
|
|
860
|
+
/**
|
|
861
|
+
* Expand `[[iftags ...]]X[[/iftags]]` directives in `source` against the
|
|
862
|
+
* current page's tags.
|
|
863
|
+
*
|
|
864
|
+
* Returns `source` unchanged when `pageTags` is `null`, which signals
|
|
865
|
+
* that the caller could not resolve tag membership (e.g. rendering a
|
|
866
|
+
* draft preview without a real page). In that case the AST-level
|
|
867
|
+
* resolver remains responsible for evaluation later.
|
|
868
|
+
*
|
|
869
|
+
* Behaviour:
|
|
870
|
+
* - Raw regions (`[[code]]`, `[[html]]`, `@@...@@`, `@<...>@`) are
|
|
871
|
+
* protected: literal `[[iftags]]` tokens inside them are not expanded.
|
|
872
|
+
* - Nested `[[iftags]]` are processed innermost-first, so an outer
|
|
873
|
+
* block can re-process the now-flattened inner body uniformly.
|
|
874
|
+
*
|
|
875
|
+
* @param source Raw wikitext (typically after include expansion).
|
|
876
|
+
* @param pageTags Tags of the page being rendered, or `null` to skip.
|
|
877
|
+
* @returns Source with matching iftags replaced by their bodies and
|
|
878
|
+
* unmatched iftags removed entirely.
|
|
879
|
+
*/
|
|
880
|
+
declare function preprocessIftags(source: string, pageTags: string[] | null): string;
|
|
851
881
|
import { PageRef, WikitextSettings as WikitextSettings3 } from "@wdprlib/ast";
|
|
852
882
|
/**
|
|
853
883
|
* Callback to fetch page content for include resolution.
|
|
@@ -1011,4 +1041,4 @@ interface ResolveOptions {
|
|
|
1011
1041
|
*/
|
|
1012
1042
|
declare function resolveModules(ast: SyntaxTree2, dataProvider: DataProvider, options: ResolveOptions): Promise<SyntaxTree2>;
|
|
1013
1043
|
import { STYLE_SLOT_PREFIX } from "@wdprlib/ast";
|
|
1014
|
-
export { tokenize, text, resolveModules, resolveListUsers, resolveIncludesAsync, resolveIncludes, parseTags, parseParent, parseOrder, parseNumericSelector, parseDateSelector, parseCategory, parse, paragraph, normalizeQuery, listItemSubList, listItemElements, list, link, lineBreak, italics, isListUsersModule, horizontalRule, heading, extractListUsersVariables, extractDataRequirements, createToken, createSettings, createPosition, createPoint, container, compileTemplate, compileListUsersTemplate, bold, WikitextSettings4 as WikitextSettings, WikitextMode, Version2 as Version, VariableMap, VariableContext, UserInfo, TokenType, Token, TocEntry2 as TocEntry, TableRow, TableData, TableCell, TabData, SyntaxTree3 as SyntaxTree, SiteContext, STYLE_SLOT_PREFIX, ResolveOptions, ResolveIncludesOptions, Position2 as Position, Point, ParserOptions, Parser, ParseResult2 as ParseResult, ParseFunction, PageRef2 as PageRef, PageData, NormalizedTags, NormalizedParent, NormalizedOrder, NormalizedNumericSelector, NormalizedListPagesQuery, NormalizedDateSelector, NormalizedCategory, Module4 as Module, ListUsersVariableContext, ListUsersVariable, ListUsersUserData, ListUsersExternalData, ListUsersDataRequirement, ListUsersDataFetcher, ListUsersCompiledTemplate, ListType, ListPagesVariable, ListPagesQuery, ListPagesExternalData, ListPagesDataRequirement, ListPagesDataFetcher, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LexerOptions, Lexer, IncludeFetcher, ImageSource, HeadingLevel, Heading, HeaderType, FloatAlignment, ExtractionResult, Embed, Element6 as Element, DiagnosticSeverity, Diagnostic2 as Diagnostic, DefinitionListItem, DateItem, DataRequirements, DataProvider, DEFAULT_SETTINGS, ContainerType, ContainerData, CompiledTemplate, CollapsibleData, CodeBlockData2 as CodeBlockData, ClearFloat, AttributeMap, AsyncIncludeFetcher, AnchorTarget, Alignment, AlignType };
|
|
1044
|
+
export { tokenize, text, resolveModules, resolveListUsers, resolveIncludesAsync, resolveIncludes, preprocessIftags, parseTags, parseParent, parseOrder, parseNumericSelector, parseDateSelector, parseCategory, parse, paragraph, normalizeQuery, listItemSubList, listItemElements, list, link, lineBreak, italics, isListUsersModule, horizontalRule, heading, extractListUsersVariables, extractDataRequirements, createToken, createSettings, createPosition, createPoint, container, compileTemplate, compileListUsersTemplate, bold, WikitextSettings4 as WikitextSettings, WikitextMode, Version2 as Version, VariableMap, VariableContext, UserInfo, TokenType, Token, TocEntry2 as TocEntry, TableRow, TableData, TableCell, TabData, SyntaxTree3 as SyntaxTree, SiteContext, STYLE_SLOT_PREFIX, ResolveOptions, ResolveIncludesOptions, Position2 as Position, Point, ParserOptions, Parser, ParseResult2 as ParseResult, ParseFunction, PageRef2 as PageRef, PageData, NormalizedTags, NormalizedParent, NormalizedOrder, NormalizedNumericSelector, NormalizedListPagesQuery, NormalizedDateSelector, NormalizedCategory, Module4 as Module, ListUsersVariableContext, ListUsersVariable, ListUsersUserData, ListUsersExternalData, ListUsersDataRequirement, ListUsersDataFetcher, ListUsersCompiledTemplate, ListType, ListPagesVariable, ListPagesQuery, ListPagesExternalData, ListPagesDataRequirement, ListPagesDataFetcher, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LexerOptions, Lexer, IncludeFetcher, ImageSource, HeadingLevel, Heading, HeaderType, FloatAlignment, ExtractionResult, Embed, Element6 as Element, DiagnosticSeverity, Diagnostic2 as Diagnostic, DefinitionListItem, DateItem, DataRequirements, DataProvider, DEFAULT_SETTINGS, ContainerType, ContainerData, CompiledTemplate, CollapsibleData, CodeBlockData2 as CodeBlockData, ClearFloat, AttributeMap, AsyncIncludeFetcher, AnchorTarget, Alignment, AlignType };
|