@wdprlib/parser 1.0.0 → 1.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.
- package/dist/index.cjs +38 -16
- package/dist/index.d.cts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +23 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,7 @@ var __export = (target, all) => {
|
|
|
31
31
|
var exports_src = {};
|
|
32
32
|
__export(exports_src, {
|
|
33
33
|
tokenize: () => tokenize,
|
|
34
|
-
text: () =>
|
|
34
|
+
text: () => import_ast3.text,
|
|
35
35
|
resolveModules: () => resolveModules,
|
|
36
36
|
resolveListUsers: () => resolveListUsers,
|
|
37
37
|
resolveIncludes: () => resolveIncludes,
|
|
@@ -42,31 +42,34 @@ __export(exports_src, {
|
|
|
42
42
|
parseDateSelector: () => parseDateSelector,
|
|
43
43
|
parseCategory: () => parseCategory,
|
|
44
44
|
parse: () => parse,
|
|
45
|
-
paragraph: () =>
|
|
45
|
+
paragraph: () => import_ast3.paragraph,
|
|
46
46
|
normalizeQuery: () => normalizeQuery,
|
|
47
|
-
listItemSubList: () =>
|
|
48
|
-
listItemElements: () =>
|
|
49
|
-
list: () =>
|
|
50
|
-
link: () =>
|
|
51
|
-
lineBreak: () =>
|
|
52
|
-
italics: () =>
|
|
47
|
+
listItemSubList: () => import_ast3.listItemSubList,
|
|
48
|
+
listItemElements: () => import_ast3.listItemElements,
|
|
49
|
+
list: () => import_ast3.list,
|
|
50
|
+
link: () => import_ast3.link,
|
|
51
|
+
lineBreak: () => import_ast3.lineBreak,
|
|
52
|
+
italics: () => import_ast3.italics,
|
|
53
53
|
isListUsersModule: () => isListUsersModule2,
|
|
54
|
-
horizontalRule: () =>
|
|
55
|
-
heading: () =>
|
|
54
|
+
horizontalRule: () => import_ast3.horizontalRule,
|
|
55
|
+
heading: () => import_ast3.heading,
|
|
56
56
|
extractListUsersVariables: () => extractListUsersVariables,
|
|
57
57
|
extractDataRequirements: () => extractDataRequirements,
|
|
58
58
|
createToken: () => createToken,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
createSettings: () => import_ast4.createSettings,
|
|
60
|
+
createPosition: () => import_ast3.createPosition,
|
|
61
|
+
createPoint: () => import_ast3.createPoint,
|
|
62
|
+
container: () => import_ast3.container,
|
|
62
63
|
compileTemplate: () => compileTemplate,
|
|
63
64
|
compileListUsersTemplate: () => compileListUsersTemplate,
|
|
64
|
-
bold: () =>
|
|
65
|
+
bold: () => import_ast3.bold,
|
|
65
66
|
Parser: () => Parser,
|
|
66
|
-
Lexer: () => Lexer
|
|
67
|
+
Lexer: () => Lexer,
|
|
68
|
+
DEFAULT_SETTINGS: () => import_ast4.DEFAULT_SETTINGS
|
|
67
69
|
});
|
|
68
70
|
module.exports = __toCommonJS(exports_src);
|
|
69
|
-
var
|
|
71
|
+
var import_ast3 = require("@wdprlib/ast");
|
|
72
|
+
var import_ast4 = require("@wdprlib/ast");
|
|
70
73
|
|
|
71
74
|
// packages/parser/src/lexer/tokens.ts
|
|
72
75
|
function createToken(type, value, position, lineStart = false) {
|
|
@@ -555,6 +558,9 @@ function preprocess(text) {
|
|
|
555
558
|
return result;
|
|
556
559
|
}
|
|
557
560
|
|
|
561
|
+
// packages/parser/src/parser/parse.ts
|
|
562
|
+
var import_ast2 = require("@wdprlib/ast");
|
|
563
|
+
|
|
558
564
|
// packages/parser/src/parser/rules/types.ts
|
|
559
565
|
function currentToken(ctx) {
|
|
560
566
|
return ctx.tokens[ctx.pos] ?? eofToken();
|
|
@@ -3559,6 +3565,9 @@ var moduleRule = {
|
|
|
3559
3565
|
if (!nameResult || nameResult.name !== "module" && nameResult.name !== "module654") {
|
|
3560
3566
|
return { success: false };
|
|
3561
3567
|
}
|
|
3568
|
+
if (!ctx.settings.enablePageSyntax) {
|
|
3569
|
+
return { success: false };
|
|
3570
|
+
}
|
|
3562
3571
|
pos += nameResult.consumed;
|
|
3563
3572
|
consumed += nameResult.consumed;
|
|
3564
3573
|
while (ctx.tokens[pos]?.type === "WHITESPACE") {
|
|
@@ -4273,6 +4282,9 @@ var includeRule = {
|
|
|
4273
4282
|
if (!nameResult || nameResult.name.toLowerCase() !== "include") {
|
|
4274
4283
|
return { success: false };
|
|
4275
4284
|
}
|
|
4285
|
+
if (!ctx.settings.enablePageSyntax) {
|
|
4286
|
+
return { success: false };
|
|
4287
|
+
}
|
|
4276
4288
|
pos += nameResult.consumed;
|
|
4277
4289
|
consumed += nameResult.consumed;
|
|
4278
4290
|
while (ctx.tokens[pos]?.type === "WHITESPACE") {
|
|
@@ -4880,6 +4892,9 @@ var tocRule = {
|
|
|
4880
4892
|
}
|
|
4881
4893
|
const firstValue = firstToken.value.toLowerCase();
|
|
4882
4894
|
if (firstValue === "toc") {
|
|
4895
|
+
if (!ctx.settings.enablePageSyntax) {
|
|
4896
|
+
return { success: false };
|
|
4897
|
+
}
|
|
4883
4898
|
pos++;
|
|
4884
4899
|
} else if (firstValue === "f") {
|
|
4885
4900
|
pos++;
|
|
@@ -4903,6 +4918,9 @@ var tocRule = {
|
|
|
4903
4918
|
if (tocToken.value.toLowerCase() !== "toc") {
|
|
4904
4919
|
return { success: false };
|
|
4905
4920
|
}
|
|
4921
|
+
if (!ctx.settings.enablePageSyntax) {
|
|
4922
|
+
return { success: false };
|
|
4923
|
+
}
|
|
4906
4924
|
pos++;
|
|
4907
4925
|
} else {
|
|
4908
4926
|
return { success: false };
|
|
@@ -8288,6 +8306,7 @@ class Parser {
|
|
|
8288
8306
|
pos: 0,
|
|
8289
8307
|
version: options.version ?? "wikidot",
|
|
8290
8308
|
trackPositions: options.trackPositions ?? true,
|
|
8309
|
+
settings: options.settings ?? import_ast2.DEFAULT_SETTINGS,
|
|
8291
8310
|
footnotes: [],
|
|
8292
8311
|
tocEntries: [],
|
|
8293
8312
|
codeBlocks: [],
|
|
@@ -9587,6 +9606,9 @@ function resolveIfTags(data, pageTags) {
|
|
|
9587
9606
|
}
|
|
9588
9607
|
// packages/parser/src/parser/rules/block/module/include/resolve.ts
|
|
9589
9608
|
function resolveIncludes(source, fetcher, options) {
|
|
9609
|
+
if (options?.settings && !options.settings.enablePageSyntax) {
|
|
9610
|
+
return source;
|
|
9611
|
+
}
|
|
9590
9612
|
const maxDepth = options?.maxDepth ?? 5;
|
|
9591
9613
|
const cache = new Map;
|
|
9592
9614
|
const cachedFetcher = (pageRef) => {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Position as Position2, Point, Version as Version2, Element as Element6, SyntaxTree as SyntaxTree4, ContainerType, ContainerData, AttributeMap, VariableMap, Alignment, LinkType, LinkLocation, LinkLabel, PageRef as PageRef2, ImageSource, FloatAlignment, ListType, ListItem, ListData, CodeBlockData as CodeBlockData2, TabData, TableCell, TableRow, TableData, DefinitionListItem, Module as Module4, CollapsibleData, ClearFloat, AnchorTarget, HeaderType, AlignType, HeadingLevel, Heading, DateItem, Embed, TocEntry as TocEntry2 } from "@wdprlib/ast";
|
|
2
2
|
import { createPoint, createPosition, text, container, paragraph, bold, italics, heading, lineBreak, horizontalRule, link, list, listItemElements, listItemSubList } from "@wdprlib/ast";
|
|
3
|
+
import { WikitextMode, WikitextSettings as WikitextSettings4 } from "@wdprlib/ast";
|
|
4
|
+
import { createSettings, DEFAULT_SETTINGS } from "@wdprlib/ast";
|
|
3
5
|
import { Position } from "@wdprlib/ast";
|
|
4
6
|
/**
|
|
5
7
|
* Token types for Wikidot markup
|
|
@@ -79,7 +81,7 @@ declare class Lexer {
|
|
|
79
81
|
* Tokenize source string
|
|
80
82
|
*/
|
|
81
83
|
declare function tokenize(source: string, options?: LexerOptions): Token[];
|
|
82
|
-
import { SyntaxTree } from "@wdprlib/ast";
|
|
84
|
+
import { SyntaxTree, WikitextSettings } from "@wdprlib/ast";
|
|
83
85
|
/**
|
|
84
86
|
* Parser options
|
|
85
87
|
*/
|
|
@@ -88,6 +90,8 @@ interface ParserOptions {
|
|
|
88
90
|
version?: "wikidot";
|
|
89
91
|
/** Track position information */
|
|
90
92
|
trackPositions?: boolean;
|
|
93
|
+
/** Wikitext settings controlling syntax availability */
|
|
94
|
+
settings?: WikitextSettings;
|
|
91
95
|
}
|
|
92
96
|
/**
|
|
93
97
|
* Wikidot markup parser
|
|
@@ -655,7 +659,7 @@ declare function parseNumericSelector(value: string): NormalizedNumericSelector
|
|
|
655
659
|
* @returns Normalized query with structured types
|
|
656
660
|
*/
|
|
657
661
|
declare function normalizeQuery(query: ListPagesQuery): NormalizedListPagesQuery;
|
|
658
|
-
import { PageRef } from "@wdprlib/ast";
|
|
662
|
+
import { PageRef, WikitextSettings as WikitextSettings3 } from "@wdprlib/ast";
|
|
659
663
|
/**
|
|
660
664
|
* Callback to fetch page content for include resolution.
|
|
661
665
|
* Returns the wikitext source of the page, or null if the page does not exist.
|
|
@@ -671,6 +675,8 @@ type IncludeFetcher = (pageRef: PageRef) => string | null;
|
|
|
671
675
|
interface ResolveIncludesOptions {
|
|
672
676
|
/** Maximum recursion depth for nested includes (default: 5) */
|
|
673
677
|
maxDepth?: number;
|
|
678
|
+
/** Wikitext settings. If enablePageSyntax is false, includes are not expanded. */
|
|
679
|
+
settings?: WikitextSettings3;
|
|
674
680
|
}
|
|
675
681
|
/**
|
|
676
682
|
* Expand all [[include]] directives in the source text.
|
|
@@ -749,4 +755,4 @@ interface ResolveOptions {
|
|
|
749
755
|
* @param options - Resolution options including requirements
|
|
750
756
|
*/
|
|
751
757
|
declare function resolveModules(ast: SyntaxTree3, dataProvider: DataProvider, options: ResolveOptions): Promise<SyntaxTree3>;
|
|
752
|
-
export { tokenize, text, resolveModules, resolveListUsers, resolveIncludes, parseTags, parseParent, parseOrder, parseNumericSelector, parseDateSelector, parseCategory, parse, paragraph, normalizeQuery, listItemSubList, listItemElements, list, link, lineBreak, italics, isListUsersModule, horizontalRule, heading, extractListUsersVariables, extractDataRequirements, createToken, createPosition, createPoint, container, compileTemplate, compileListUsersTemplate, bold, Version2 as Version, VariableMap, VariableContext, UserInfo, TokenType, Token, TocEntry2 as TocEntry, TableRow, TableData, TableCell, TabData, SyntaxTree4 as SyntaxTree, SiteContext, ResolveOptions, ResolveIncludesOptions, Position2 as Position, Point, ParserOptions, Parser, 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, DefinitionListItem, DateItem, DataRequirements, DataProvider, ContainerType, ContainerData, CompiledTemplate, CollapsibleData, CodeBlockData2 as CodeBlockData, ClearFloat, AttributeMap, AnchorTarget, Alignment, AlignType };
|
|
758
|
+
export { tokenize, text, resolveModules, resolveListUsers, 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, SyntaxTree4 as SyntaxTree, SiteContext, ResolveOptions, ResolveIncludesOptions, Position2 as Position, Point, ParserOptions, Parser, 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, DefinitionListItem, DateItem, DataRequirements, DataProvider, DEFAULT_SETTINGS, ContainerType, ContainerData, CompiledTemplate, CollapsibleData, CodeBlockData2 as CodeBlockData, ClearFloat, AttributeMap, AnchorTarget, Alignment, AlignType };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Position as Position2, Point, Version as Version2, Element as Element6, SyntaxTree as SyntaxTree4, ContainerType, ContainerData, AttributeMap, VariableMap, Alignment, LinkType, LinkLocation, LinkLabel, PageRef as PageRef2, ImageSource, FloatAlignment, ListType, ListItem, ListData, CodeBlockData as CodeBlockData2, TabData, TableCell, TableRow, TableData, DefinitionListItem, Module as Module4, CollapsibleData, ClearFloat, AnchorTarget, HeaderType, AlignType, HeadingLevel, Heading, DateItem, Embed, TocEntry as TocEntry2 } from "@wdprlib/ast";
|
|
2
2
|
import { createPoint, createPosition, text, container, paragraph, bold, italics, heading, lineBreak, horizontalRule, link, list, listItemElements, listItemSubList } from "@wdprlib/ast";
|
|
3
|
+
import { WikitextMode, WikitextSettings as WikitextSettings4 } from "@wdprlib/ast";
|
|
4
|
+
import { createSettings, DEFAULT_SETTINGS } from "@wdprlib/ast";
|
|
3
5
|
import { Position } from "@wdprlib/ast";
|
|
4
6
|
/**
|
|
5
7
|
* Token types for Wikidot markup
|
|
@@ -79,7 +81,7 @@ declare class Lexer {
|
|
|
79
81
|
* Tokenize source string
|
|
80
82
|
*/
|
|
81
83
|
declare function tokenize(source: string, options?: LexerOptions): Token[];
|
|
82
|
-
import { SyntaxTree } from "@wdprlib/ast";
|
|
84
|
+
import { SyntaxTree, WikitextSettings } from "@wdprlib/ast";
|
|
83
85
|
/**
|
|
84
86
|
* Parser options
|
|
85
87
|
*/
|
|
@@ -88,6 +90,8 @@ interface ParserOptions {
|
|
|
88
90
|
version?: "wikidot";
|
|
89
91
|
/** Track position information */
|
|
90
92
|
trackPositions?: boolean;
|
|
93
|
+
/** Wikitext settings controlling syntax availability */
|
|
94
|
+
settings?: WikitextSettings;
|
|
91
95
|
}
|
|
92
96
|
/**
|
|
93
97
|
* Wikidot markup parser
|
|
@@ -655,7 +659,7 @@ declare function parseNumericSelector(value: string): NormalizedNumericSelector
|
|
|
655
659
|
* @returns Normalized query with structured types
|
|
656
660
|
*/
|
|
657
661
|
declare function normalizeQuery(query: ListPagesQuery): NormalizedListPagesQuery;
|
|
658
|
-
import { PageRef } from "@wdprlib/ast";
|
|
662
|
+
import { PageRef, WikitextSettings as WikitextSettings3 } from "@wdprlib/ast";
|
|
659
663
|
/**
|
|
660
664
|
* Callback to fetch page content for include resolution.
|
|
661
665
|
* Returns the wikitext source of the page, or null if the page does not exist.
|
|
@@ -671,6 +675,8 @@ type IncludeFetcher = (pageRef: PageRef) => string | null;
|
|
|
671
675
|
interface ResolveIncludesOptions {
|
|
672
676
|
/** Maximum recursion depth for nested includes (default: 5) */
|
|
673
677
|
maxDepth?: number;
|
|
678
|
+
/** Wikitext settings. If enablePageSyntax is false, includes are not expanded. */
|
|
679
|
+
settings?: WikitextSettings3;
|
|
674
680
|
}
|
|
675
681
|
/**
|
|
676
682
|
* Expand all [[include]] directives in the source text.
|
|
@@ -749,4 +755,4 @@ interface ResolveOptions {
|
|
|
749
755
|
* @param options - Resolution options including requirements
|
|
750
756
|
*/
|
|
751
757
|
declare function resolveModules(ast: SyntaxTree3, dataProvider: DataProvider, options: ResolveOptions): Promise<SyntaxTree3>;
|
|
752
|
-
export { tokenize, text, resolveModules, resolveListUsers, resolveIncludes, parseTags, parseParent, parseOrder, parseNumericSelector, parseDateSelector, parseCategory, parse, paragraph, normalizeQuery, listItemSubList, listItemElements, list, link, lineBreak, italics, isListUsersModule, horizontalRule, heading, extractListUsersVariables, extractDataRequirements, createToken, createPosition, createPoint, container, compileTemplate, compileListUsersTemplate, bold, Version2 as Version, VariableMap, VariableContext, UserInfo, TokenType, Token, TocEntry2 as TocEntry, TableRow, TableData, TableCell, TabData, SyntaxTree4 as SyntaxTree, SiteContext, ResolveOptions, ResolveIncludesOptions, Position2 as Position, Point, ParserOptions, Parser, 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, DefinitionListItem, DateItem, DataRequirements, DataProvider, ContainerType, ContainerData, CompiledTemplate, CollapsibleData, CodeBlockData2 as CodeBlockData, ClearFloat, AttributeMap, AnchorTarget, Alignment, AlignType };
|
|
758
|
+
export { tokenize, text, resolveModules, resolveListUsers, 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, SyntaxTree4 as SyntaxTree, SiteContext, ResolveOptions, ResolveIncludesOptions, Position2 as Position, Point, ParserOptions, Parser, 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, DefinitionListItem, DateItem, DataRequirements, DataProvider, DEFAULT_SETTINGS, ContainerType, ContainerData, CompiledTemplate, CollapsibleData, CodeBlockData2 as CodeBlockData, ClearFloat, AttributeMap, AnchorTarget, Alignment, AlignType };
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
listItemElements,
|
|
16
16
|
listItemSubList
|
|
17
17
|
} from "@wdprlib/ast";
|
|
18
|
+
import { createSettings, DEFAULT_SETTINGS as DEFAULT_SETTINGS2 } from "@wdprlib/ast";
|
|
18
19
|
|
|
19
20
|
// packages/parser/src/lexer/tokens.ts
|
|
20
21
|
function createToken(type, value, position, lineStart = false) {
|
|
@@ -503,6 +504,9 @@ function preprocess(text) {
|
|
|
503
504
|
return result;
|
|
504
505
|
}
|
|
505
506
|
|
|
507
|
+
// packages/parser/src/parser/parse.ts
|
|
508
|
+
import { DEFAULT_SETTINGS } from "@wdprlib/ast";
|
|
509
|
+
|
|
506
510
|
// packages/parser/src/parser/rules/types.ts
|
|
507
511
|
function currentToken(ctx) {
|
|
508
512
|
return ctx.tokens[ctx.pos] ?? eofToken();
|
|
@@ -3507,6 +3511,9 @@ var moduleRule = {
|
|
|
3507
3511
|
if (!nameResult || nameResult.name !== "module" && nameResult.name !== "module654") {
|
|
3508
3512
|
return { success: false };
|
|
3509
3513
|
}
|
|
3514
|
+
if (!ctx.settings.enablePageSyntax) {
|
|
3515
|
+
return { success: false };
|
|
3516
|
+
}
|
|
3510
3517
|
pos += nameResult.consumed;
|
|
3511
3518
|
consumed += nameResult.consumed;
|
|
3512
3519
|
while (ctx.tokens[pos]?.type === "WHITESPACE") {
|
|
@@ -4221,6 +4228,9 @@ var includeRule = {
|
|
|
4221
4228
|
if (!nameResult || nameResult.name.toLowerCase() !== "include") {
|
|
4222
4229
|
return { success: false };
|
|
4223
4230
|
}
|
|
4231
|
+
if (!ctx.settings.enablePageSyntax) {
|
|
4232
|
+
return { success: false };
|
|
4233
|
+
}
|
|
4224
4234
|
pos += nameResult.consumed;
|
|
4225
4235
|
consumed += nameResult.consumed;
|
|
4226
4236
|
while (ctx.tokens[pos]?.type === "WHITESPACE") {
|
|
@@ -4828,6 +4838,9 @@ var tocRule = {
|
|
|
4828
4838
|
}
|
|
4829
4839
|
const firstValue = firstToken.value.toLowerCase();
|
|
4830
4840
|
if (firstValue === "toc") {
|
|
4841
|
+
if (!ctx.settings.enablePageSyntax) {
|
|
4842
|
+
return { success: false };
|
|
4843
|
+
}
|
|
4831
4844
|
pos++;
|
|
4832
4845
|
} else if (firstValue === "f") {
|
|
4833
4846
|
pos++;
|
|
@@ -4851,6 +4864,9 @@ var tocRule = {
|
|
|
4851
4864
|
if (tocToken.value.toLowerCase() !== "toc") {
|
|
4852
4865
|
return { success: false };
|
|
4853
4866
|
}
|
|
4867
|
+
if (!ctx.settings.enablePageSyntax) {
|
|
4868
|
+
return { success: false };
|
|
4869
|
+
}
|
|
4854
4870
|
pos++;
|
|
4855
4871
|
} else {
|
|
4856
4872
|
return { success: false };
|
|
@@ -8236,6 +8252,7 @@ class Parser {
|
|
|
8236
8252
|
pos: 0,
|
|
8237
8253
|
version: options.version ?? "wikidot",
|
|
8238
8254
|
trackPositions: options.trackPositions ?? true,
|
|
8255
|
+
settings: options.settings ?? DEFAULT_SETTINGS,
|
|
8239
8256
|
footnotes: [],
|
|
8240
8257
|
tocEntries: [],
|
|
8241
8258
|
codeBlocks: [],
|
|
@@ -9535,6 +9552,9 @@ function resolveIfTags(data, pageTags) {
|
|
|
9535
9552
|
}
|
|
9536
9553
|
// packages/parser/src/parser/rules/block/module/include/resolve.ts
|
|
9537
9554
|
function resolveIncludes(source, fetcher, options) {
|
|
9555
|
+
if (options?.settings && !options.settings.enablePageSyntax) {
|
|
9556
|
+
return source;
|
|
9557
|
+
}
|
|
9538
9558
|
const maxDepth = options?.maxDepth ?? 5;
|
|
9539
9559
|
const cache = new Map;
|
|
9540
9560
|
const cachedFetcher = (pageRef) => {
|
|
@@ -9842,6 +9862,7 @@ export {
|
|
|
9842
9862
|
extractListUsersVariables,
|
|
9843
9863
|
extractDataRequirements,
|
|
9844
9864
|
createToken,
|
|
9865
|
+
createSettings,
|
|
9845
9866
|
createPosition2 as createPosition,
|
|
9846
9867
|
createPoint2 as createPoint,
|
|
9847
9868
|
container,
|
|
@@ -9849,5 +9870,6 @@ export {
|
|
|
9849
9870
|
compileListUsersTemplate,
|
|
9850
9871
|
bold,
|
|
9851
9872
|
Parser,
|
|
9852
|
-
Lexer
|
|
9873
|
+
Lexer,
|
|
9874
|
+
DEFAULT_SETTINGS2 as DEFAULT_SETTINGS
|
|
9853
9875
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdprlib/parser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Parser for Wikidot markup",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ast",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@braintree/sanitize-url": "^7.1.1",
|
|
42
|
-
"@wdprlib/ast": "1.
|
|
42
|
+
"@wdprlib/ast": "1.1.0"
|
|
43
43
|
}
|
|
44
44
|
}
|