@wdprlib/ast 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 +34 -1
- package/dist/index.d.cts +41 -1
- package/dist/index.d.ts +41 -1
- package/dist/index.js +34 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -45,10 +45,12 @@ __export(exports_src, {
|
|
|
45
45
|
isAlignType: () => isAlignType,
|
|
46
46
|
horizontalRule: () => horizontalRule,
|
|
47
47
|
heading: () => heading,
|
|
48
|
+
createSettings: () => createSettings,
|
|
48
49
|
createPosition: () => createPosition,
|
|
49
50
|
createPoint: () => createPoint,
|
|
50
51
|
container: () => container,
|
|
51
|
-
bold: () => bold
|
|
52
|
+
bold: () => bold,
|
|
53
|
+
DEFAULT_SETTINGS: () => DEFAULT_SETTINGS
|
|
52
54
|
});
|
|
53
55
|
module.exports = __toCommonJS(exports_src);
|
|
54
56
|
|
|
@@ -245,3 +247,34 @@ function isParagraphSafe(element) {
|
|
|
245
247
|
return false;
|
|
246
248
|
}
|
|
247
249
|
}
|
|
250
|
+
// packages/ast/src/settings.ts
|
|
251
|
+
function createSettings(mode) {
|
|
252
|
+
switch (mode) {
|
|
253
|
+
case "page":
|
|
254
|
+
return {
|
|
255
|
+
mode,
|
|
256
|
+
enablePageSyntax: true,
|
|
257
|
+
allowLocalPaths: true,
|
|
258
|
+
useTrueIds: true,
|
|
259
|
+
allowStyleElements: true
|
|
260
|
+
};
|
|
261
|
+
case "draft":
|
|
262
|
+
return {
|
|
263
|
+
mode,
|
|
264
|
+
enablePageSyntax: true,
|
|
265
|
+
allowLocalPaths: true,
|
|
266
|
+
useTrueIds: false,
|
|
267
|
+
allowStyleElements: false
|
|
268
|
+
};
|
|
269
|
+
case "forum-post":
|
|
270
|
+
case "direct-message":
|
|
271
|
+
return {
|
|
272
|
+
mode,
|
|
273
|
+
enablePageSyntax: false,
|
|
274
|
+
allowLocalPaths: false,
|
|
275
|
+
useTrueIds: false,
|
|
276
|
+
allowStyleElements: false
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
var DEFAULT_SETTINGS = createSettings("page");
|
package/dist/index.d.cts
CHANGED
|
@@ -589,5 +589,45 @@ declare function isContainerTypeParagraphSafe(type: ContainerType): boolean;
|
|
|
589
589
|
* This does a surface-level check and does not look into element interiors.
|
|
590
590
|
*/
|
|
591
591
|
declare function isParagraphSafe(element: Element): boolean;
|
|
592
|
+
/**
|
|
593
|
+
* Wikitext parsing/rendering mode.
|
|
594
|
+
* Each mode has different default settings for syntax availability.
|
|
595
|
+
*/
|
|
596
|
+
type WikitextMode = "page" | "draft" | "forum-post" | "direct-message";
|
|
597
|
+
/**
|
|
598
|
+
* Settings that control parser and renderer behavior based on context.
|
|
599
|
+
*/
|
|
600
|
+
interface WikitextSettings {
|
|
601
|
+
/** Operating mode */
|
|
602
|
+
mode: WikitextMode;
|
|
603
|
+
/**
|
|
604
|
+
* Whether page-contextual syntax is permitted.
|
|
605
|
+
* Controls: include, module, table-of-contents.
|
|
606
|
+
*/
|
|
607
|
+
enablePageSyntax: boolean;
|
|
608
|
+
/**
|
|
609
|
+
* Whether local file paths (file1, file2, file3) are permitted for images.
|
|
610
|
+
* Disable in contexts without a "local" page (forum posts, direct messages).
|
|
611
|
+
*/
|
|
612
|
+
allowLocalPaths: boolean;
|
|
613
|
+
/**
|
|
614
|
+
* Whether element IDs should be stable sequential values.
|
|
615
|
+
* When false, IDs are randomized to prevent collisions
|
|
616
|
+
* when multiple rendered fragments appear on the same page.
|
|
617
|
+
*/
|
|
618
|
+
useTrueIds: boolean;
|
|
619
|
+
/**
|
|
620
|
+
* Whether [[module CSS]] style elements are rendered as <style> tags.
|
|
621
|
+
* Disable to prevent user-authored CSS from affecting the page layout
|
|
622
|
+
* (e.g., in draft previews, forum posts).
|
|
623
|
+
*/
|
|
624
|
+
allowStyleElements: boolean;
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Create WikitextSettings with defaults for the given mode.
|
|
628
|
+
*/
|
|
629
|
+
declare function createSettings(mode: WikitextMode): WikitextSettings;
|
|
630
|
+
/** Default settings (page mode) */
|
|
631
|
+
declare const DEFAULT_SETTINGS: WikitextSettings;
|
|
592
632
|
type Version = "wikidot";
|
|
593
|
-
export { text, paragraph, listItemSubList, listItemElements, list, link, lineBreak, italics, isStringContainerType, isParagraphSafe, isHeaderType, isContainerTypeParagraphSafe, isAlignType, horizontalRule, heading, createPosition, createPoint, container, bold, Version, VariableMap, UserData, TocEntry, TableRow, TableOfContentsData, TableData, TableCell, TabData, SyntaxTree, StringContainerType, Position, Point, PageRef, Module, MathInlineData, MathData, ListType, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LinkData, IncludeData, ImageSource, ImageData, IframeData, IfTagsData, IfExprData, IfCondData, HtmlData, HeadingLevel, Heading, HeaderType, FootnoteBlockData, FloatAlignment, ExprData, EmbedBlockData, Embed, ElementOf, ElementName, ElementDataMap, ElementData, Element, DefinitionListItem, DateItem, DateData, ContainerType, ContainerData, ColorData, CollapsibleData, CodeBlockData, ClearFloat, BibliographyCiteData, BibliographyBlockData, AttributeMap, AnchorTarget, AnchorData, Alignment, AlignType };
|
|
633
|
+
export { text, paragraph, listItemSubList, listItemElements, list, link, lineBreak, italics, isStringContainerType, isParagraphSafe, isHeaderType, isContainerTypeParagraphSafe, isAlignType, horizontalRule, heading, createSettings, createPosition, createPoint, container, bold, WikitextSettings, WikitextMode, Version, VariableMap, UserData, TocEntry, TableRow, TableOfContentsData, TableData, TableCell, TabData, SyntaxTree, StringContainerType, Position, Point, PageRef, Module, MathInlineData, MathData, ListType, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LinkData, IncludeData, ImageSource, ImageData, IframeData, IfTagsData, IfExprData, IfCondData, HtmlData, HeadingLevel, Heading, HeaderType, FootnoteBlockData, FloatAlignment, ExprData, EmbedBlockData, Embed, ElementOf, ElementName, ElementDataMap, ElementData, Element, DefinitionListItem, DateItem, DateData, DEFAULT_SETTINGS, ContainerType, ContainerData, ColorData, CollapsibleData, CodeBlockData, ClearFloat, BibliographyCiteData, BibliographyBlockData, AttributeMap, AnchorTarget, AnchorData, Alignment, AlignType };
|
package/dist/index.d.ts
CHANGED
|
@@ -589,5 +589,45 @@ declare function isContainerTypeParagraphSafe(type: ContainerType): boolean;
|
|
|
589
589
|
* This does a surface-level check and does not look into element interiors.
|
|
590
590
|
*/
|
|
591
591
|
declare function isParagraphSafe(element: Element): boolean;
|
|
592
|
+
/**
|
|
593
|
+
* Wikitext parsing/rendering mode.
|
|
594
|
+
* Each mode has different default settings for syntax availability.
|
|
595
|
+
*/
|
|
596
|
+
type WikitextMode = "page" | "draft" | "forum-post" | "direct-message";
|
|
597
|
+
/**
|
|
598
|
+
* Settings that control parser and renderer behavior based on context.
|
|
599
|
+
*/
|
|
600
|
+
interface WikitextSettings {
|
|
601
|
+
/** Operating mode */
|
|
602
|
+
mode: WikitextMode;
|
|
603
|
+
/**
|
|
604
|
+
* Whether page-contextual syntax is permitted.
|
|
605
|
+
* Controls: include, module, table-of-contents.
|
|
606
|
+
*/
|
|
607
|
+
enablePageSyntax: boolean;
|
|
608
|
+
/**
|
|
609
|
+
* Whether local file paths (file1, file2, file3) are permitted for images.
|
|
610
|
+
* Disable in contexts without a "local" page (forum posts, direct messages).
|
|
611
|
+
*/
|
|
612
|
+
allowLocalPaths: boolean;
|
|
613
|
+
/**
|
|
614
|
+
* Whether element IDs should be stable sequential values.
|
|
615
|
+
* When false, IDs are randomized to prevent collisions
|
|
616
|
+
* when multiple rendered fragments appear on the same page.
|
|
617
|
+
*/
|
|
618
|
+
useTrueIds: boolean;
|
|
619
|
+
/**
|
|
620
|
+
* Whether [[module CSS]] style elements are rendered as <style> tags.
|
|
621
|
+
* Disable to prevent user-authored CSS from affecting the page layout
|
|
622
|
+
* (e.g., in draft previews, forum posts).
|
|
623
|
+
*/
|
|
624
|
+
allowStyleElements: boolean;
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Create WikitextSettings with defaults for the given mode.
|
|
628
|
+
*/
|
|
629
|
+
declare function createSettings(mode: WikitextMode): WikitextSettings;
|
|
630
|
+
/** Default settings (page mode) */
|
|
631
|
+
declare const DEFAULT_SETTINGS: WikitextSettings;
|
|
592
632
|
type Version = "wikidot";
|
|
593
|
-
export { text, paragraph, listItemSubList, listItemElements, list, link, lineBreak, italics, isStringContainerType, isParagraphSafe, isHeaderType, isContainerTypeParagraphSafe, isAlignType, horizontalRule, heading, createPosition, createPoint, container, bold, Version, VariableMap, UserData, TocEntry, TableRow, TableOfContentsData, TableData, TableCell, TabData, SyntaxTree, StringContainerType, Position, Point, PageRef, Module, MathInlineData, MathData, ListType, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LinkData, IncludeData, ImageSource, ImageData, IframeData, IfTagsData, IfExprData, IfCondData, HtmlData, HeadingLevel, Heading, HeaderType, FootnoteBlockData, FloatAlignment, ExprData, EmbedBlockData, Embed, ElementOf, ElementName, ElementDataMap, ElementData, Element, DefinitionListItem, DateItem, DateData, ContainerType, ContainerData, ColorData, CollapsibleData, CodeBlockData, ClearFloat, BibliographyCiteData, BibliographyBlockData, AttributeMap, AnchorTarget, AnchorData, Alignment, AlignType };
|
|
633
|
+
export { text, paragraph, listItemSubList, listItemElements, list, link, lineBreak, italics, isStringContainerType, isParagraphSafe, isHeaderType, isContainerTypeParagraphSafe, isAlignType, horizontalRule, heading, createSettings, createPosition, createPoint, container, bold, WikitextSettings, WikitextMode, Version, VariableMap, UserData, TocEntry, TableRow, TableOfContentsData, TableData, TableCell, TabData, SyntaxTree, StringContainerType, Position, Point, PageRef, Module, MathInlineData, MathData, ListType, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LinkData, IncludeData, ImageSource, ImageData, IframeData, IfTagsData, IfExprData, IfCondData, HtmlData, HeadingLevel, Heading, HeaderType, FootnoteBlockData, FloatAlignment, ExprData, EmbedBlockData, Embed, ElementOf, ElementName, ElementDataMap, ElementData, Element, DefinitionListItem, DateItem, DateData, DEFAULT_SETTINGS, ContainerType, ContainerData, ColorData, CollapsibleData, CodeBlockData, ClearFloat, BibliographyCiteData, BibliographyBlockData, AttributeMap, AnchorTarget, AnchorData, Alignment, AlignType };
|
package/dist/index.js
CHANGED
|
@@ -191,6 +191,37 @@ function isParagraphSafe(element) {
|
|
|
191
191
|
return false;
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
+
// packages/ast/src/settings.ts
|
|
195
|
+
function createSettings(mode) {
|
|
196
|
+
switch (mode) {
|
|
197
|
+
case "page":
|
|
198
|
+
return {
|
|
199
|
+
mode,
|
|
200
|
+
enablePageSyntax: true,
|
|
201
|
+
allowLocalPaths: true,
|
|
202
|
+
useTrueIds: true,
|
|
203
|
+
allowStyleElements: true
|
|
204
|
+
};
|
|
205
|
+
case "draft":
|
|
206
|
+
return {
|
|
207
|
+
mode,
|
|
208
|
+
enablePageSyntax: true,
|
|
209
|
+
allowLocalPaths: true,
|
|
210
|
+
useTrueIds: false,
|
|
211
|
+
allowStyleElements: false
|
|
212
|
+
};
|
|
213
|
+
case "forum-post":
|
|
214
|
+
case "direct-message":
|
|
215
|
+
return {
|
|
216
|
+
mode,
|
|
217
|
+
enablePageSyntax: false,
|
|
218
|
+
allowLocalPaths: false,
|
|
219
|
+
useTrueIds: false,
|
|
220
|
+
allowStyleElements: false
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
var DEFAULT_SETTINGS = createSettings("page");
|
|
194
225
|
export {
|
|
195
226
|
text,
|
|
196
227
|
paragraph,
|
|
@@ -207,8 +238,10 @@ export {
|
|
|
207
238
|
isAlignType,
|
|
208
239
|
horizontalRule,
|
|
209
240
|
heading,
|
|
241
|
+
createSettings,
|
|
210
242
|
createPosition,
|
|
211
243
|
createPoint,
|
|
212
244
|
container,
|
|
213
|
-
bold
|
|
245
|
+
bold,
|
|
246
|
+
DEFAULT_SETTINGS
|
|
214
247
|
};
|