@intlayer/core 7.6.0-canary.0 → 8.0.0-canary.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/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs +1 -1
- package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs +1 -1
- package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs +5 -0
- package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs +1 -1
- package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs +1 -1
- package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs +1 -1
- package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs +1 -1
- package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -1
- package/dist/cjs/index.cjs +56 -2
- package/dist/cjs/interpreter/getContent/deepTransform.cjs +1 -0
- package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -1
- package/dist/cjs/interpreter/getContent/getContent.cjs +2 -2
- package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -1
- package/dist/cjs/interpreter/getContent/plugins.cjs +3 -2
- package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
- package/dist/cjs/interpreter/getEnumeration.cjs.map +1 -1
- package/dist/cjs/interpreter/getHTML.cjs +106 -0
- package/dist/cjs/interpreter/getHTML.cjs.map +1 -0
- package/dist/cjs/interpreter/getInsertion.cjs +3 -1
- package/dist/cjs/interpreter/getInsertion.cjs.map +1 -1
- package/dist/cjs/interpreter/getTranslation.cjs +2 -2
- package/dist/cjs/interpreter/getTranslation.cjs.map +1 -1
- package/dist/cjs/interpreter/index.cjs +2 -0
- package/dist/cjs/localization/getBrowserLocale.cjs +1 -1
- package/dist/cjs/localization/getLocale.cjs +4 -3
- package/dist/cjs/localization/getLocale.cjs.map +1 -1
- package/dist/cjs/markdown/compiler.cjs +806 -0
- package/dist/cjs/markdown/compiler.cjs.map +1 -0
- package/dist/cjs/markdown/constants.cjs +334 -0
- package/dist/cjs/markdown/constants.cjs.map +1 -0
- package/dist/cjs/markdown/index.cjs +49 -0
- package/dist/cjs/markdown/parser.cjs +73 -0
- package/dist/cjs/markdown/parser.cjs.map +1 -0
- package/dist/cjs/markdown/renderer.cjs +68 -0
- package/dist/cjs/markdown/renderer.cjs.map +1 -0
- package/dist/cjs/markdown/types.cjs +0 -0
- package/dist/cjs/markdown/utils.cjs +397 -0
- package/dist/cjs/markdown/utils.cjs.map +1 -0
- package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs +15 -0
- package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs.map +1 -0
- package/dist/cjs/transpiler/html/index.cjs +133 -0
- package/dist/cjs/transpiler/html/index.cjs.map +1 -0
- package/dist/cjs/transpiler/index.cjs +3 -0
- package/dist/cjs/transpiler/insertion/getInsertionValues.cjs +2 -2
- package/dist/cjs/transpiler/insertion/getInsertionValues.cjs.map +1 -1
- package/dist/cjs/transpiler/insertion/insertion.cjs.map +1 -1
- package/dist/cjs/utils/intl.cjs +35 -3
- package/dist/cjs/utils/intl.cjs.map +1 -1
- package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs +1 -1
- package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs +1 -1
- package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getDefaultNode.mjs +5 -0
- package/dist/esm/dictionaryManipulator/getDefaultNode.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getEmptyNode.mjs +1 -1
- package/dist/esm/dictionaryManipulator/getEmptyNode.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getNodeChildren.mjs +1 -1
- package/dist/esm/dictionaryManipulator/getNodeChildren.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs +1 -1
- package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs +1 -1
- package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs.map +1 -1
- package/dist/esm/index.mjs +11 -4
- package/dist/esm/interpreter/getContent/deepTransform.mjs +1 -0
- package/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -1
- package/dist/esm/interpreter/getContent/getContent.mjs +2 -2
- package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -1
- package/dist/esm/interpreter/getContent/plugins.mjs +3 -2
- package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
- package/dist/esm/interpreter/getEnumeration.mjs.map +1 -1
- package/dist/esm/interpreter/getHTML.mjs +105 -0
- package/dist/esm/interpreter/getHTML.mjs.map +1 -0
- package/dist/esm/interpreter/getInsertion.mjs +3 -1
- package/dist/esm/interpreter/getInsertion.mjs.map +1 -1
- package/dist/esm/interpreter/getTranslation.mjs +2 -2
- package/dist/esm/interpreter/getTranslation.mjs.map +1 -1
- package/dist/esm/interpreter/index.mjs +2 -1
- package/dist/esm/localization/getBrowserLocale.mjs +1 -1
- package/dist/esm/localization/getLocale.mjs +2 -1
- package/dist/esm/localization/getLocale.mjs.map +1 -1
- package/dist/esm/markdown/compiler.mjs +804 -0
- package/dist/esm/markdown/compiler.mjs.map +1 -0
- package/dist/esm/markdown/constants.mjs +254 -0
- package/dist/esm/markdown/constants.mjs.map +1 -0
- package/dist/esm/markdown/index.mjs +7 -0
- package/dist/esm/markdown/parser.mjs +73 -0
- package/dist/esm/markdown/parser.mjs.map +1 -0
- package/dist/esm/markdown/renderer.mjs +67 -0
- package/dist/esm/markdown/renderer.mjs.map +1 -0
- package/dist/esm/markdown/types.mjs +0 -0
- package/dist/esm/markdown/utils.mjs +368 -0
- package/dist/esm/markdown/utils.mjs.map +1 -0
- package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs +15 -0
- package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +1 -0
- package/dist/esm/transpiler/html/index.mjs +131 -0
- package/dist/esm/transpiler/html/index.mjs.map +1 -0
- package/dist/esm/transpiler/index.mjs +2 -1
- package/dist/esm/transpiler/insertion/getInsertionValues.mjs +2 -2
- package/dist/esm/transpiler/insertion/getInsertionValues.mjs.map +1 -1
- package/dist/esm/transpiler/insertion/insertion.mjs.map +1 -1
- package/dist/esm/utils/intl.mjs +35 -4
- package/dist/esm/utils/intl.mjs.map +1 -1
- package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +11 -10
- package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts.map +1 -1
- package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts +3 -2
- package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts.map +1 -1
- package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts +11 -10
- package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts.map +1 -1
- package/dist/types/getStorageAttributes.d.ts.map +1 -1
- package/dist/types/index.d.ts +11 -3
- package/dist/types/interpreter/getContent/getContent.d.ts +1 -1
- package/dist/types/interpreter/getContent/getContent.d.ts.map +1 -1
- package/dist/types/interpreter/getContent/index.d.ts +2 -2
- package/dist/types/interpreter/getContent/plugins.d.ts +58 -18
- package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
- package/dist/types/interpreter/getEnumeration.d.ts +1 -1
- package/dist/types/interpreter/getHTML.d.ts +14 -0
- package/dist/types/interpreter/getHTML.d.ts.map +1 -0
- package/dist/types/interpreter/getTranslation.d.ts.map +1 -1
- package/dist/types/interpreter/index.d.ts +3 -2
- package/dist/types/localization/getLocale.d.ts.map +1 -1
- package/dist/types/markdown/compiler.d.ts +10 -0
- package/dist/types/markdown/compiler.d.ts.map +1 -0
- package/dist/types/markdown/constants.d.ts +193 -0
- package/dist/types/markdown/constants.d.ts.map +1 -0
- package/dist/types/markdown/index.d.ts +7 -0
- package/dist/types/markdown/parser.d.ts +17 -0
- package/dist/types/markdown/parser.d.ts.map +1 -0
- package/dist/types/markdown/renderer.d.ts +23 -0
- package/dist/types/markdown/renderer.d.ts.map +1 -0
- package/dist/types/markdown/types.d.ts +367 -0
- package/dist/types/markdown/types.d.ts.map +1 -0
- package/dist/types/markdown/utils.d.ts +141 -0
- package/dist/types/markdown/utils.d.ts.map +1 -0
- package/dist/types/messageFormat/ICU.d.ts.map +1 -1
- package/dist/types/transpiler/html/getHTMLCustomComponents.d.ts +9 -0
- package/dist/types/transpiler/html/getHTMLCustomComponents.d.ts.map +1 -0
- package/dist/types/transpiler/html/index.d.ts +33 -0
- package/dist/types/transpiler/html/index.d.ts.map +1 -0
- package/dist/types/transpiler/index.d.ts +2 -1
- package/dist/types/utils/intl.d.ts +21 -2
- package/dist/types/utils/intl.d.ts.map +1 -1
- package/package.json +15 -7
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
//#region src/markdown/constants.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Constants for the framework-agnostic markdown processor.
|
|
4
|
+
*
|
|
5
|
+
* This is part of the Solution F (Hybrid AST + Callback Pattern) implementation
|
|
6
|
+
* for GitHub Issue #289: Adapt markdown parser in custom packages
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Analogous to `node.type`. Please note that the values here may change at any time,
|
|
10
|
+
* so do not hard code against the value directly.
|
|
11
|
+
*/
|
|
12
|
+
declare const RuleType: {
|
|
13
|
+
readonly blockQuote: "0";
|
|
14
|
+
readonly breakLine: "1";
|
|
15
|
+
readonly breakThematic: "2";
|
|
16
|
+
readonly codeBlock: "3";
|
|
17
|
+
readonly codeFenced: "4";
|
|
18
|
+
readonly codeInline: "5";
|
|
19
|
+
readonly footnote: "6";
|
|
20
|
+
readonly footnoteReference: "7";
|
|
21
|
+
readonly gfmTask: "8";
|
|
22
|
+
readonly heading: "9";
|
|
23
|
+
readonly headingSetext: "10";
|
|
24
|
+
/** only available if not `disableHTMLParsing` */
|
|
25
|
+
readonly htmlBlock: "11";
|
|
26
|
+
readonly htmlComment: "12";
|
|
27
|
+
/** only available if not `disableHTMLParsing` */
|
|
28
|
+
readonly htmlSelfClosing: "13";
|
|
29
|
+
/** Custom components like <Tabs>, <TabItem> */
|
|
30
|
+
readonly customComponent: "34";
|
|
31
|
+
readonly image: "14";
|
|
32
|
+
readonly link: "15";
|
|
33
|
+
/** emits a `link` 'node', does not render directly */
|
|
34
|
+
readonly linkAngleBraceStyleDetector: "16";
|
|
35
|
+
/** emits a `link` 'node', does not render directly */
|
|
36
|
+
readonly linkBareUrlDetector: "17";
|
|
37
|
+
readonly newlineCoalescer: "19";
|
|
38
|
+
readonly orderedList: "20";
|
|
39
|
+
readonly paragraph: "21";
|
|
40
|
+
readonly ref: "22";
|
|
41
|
+
readonly refImage: "23";
|
|
42
|
+
readonly refLink: "24";
|
|
43
|
+
readonly table: "25";
|
|
44
|
+
readonly tableSeparator: "26";
|
|
45
|
+
readonly text: "27";
|
|
46
|
+
readonly textBolded: "28";
|
|
47
|
+
readonly textEmphasized: "29";
|
|
48
|
+
readonly textEscaped: "30";
|
|
49
|
+
readonly textMarked: "31";
|
|
50
|
+
readonly textStrikethroughed: "32";
|
|
51
|
+
readonly unorderedList: "33";
|
|
52
|
+
};
|
|
53
|
+
type RuleTypeValue = (typeof RuleType)[keyof typeof RuleType];
|
|
54
|
+
/**
|
|
55
|
+
* Priority levels for rule ordering.
|
|
56
|
+
*/
|
|
57
|
+
declare const Priority: {
|
|
58
|
+
/** anything that must scan the tree before everything else */
|
|
59
|
+
readonly MAX: 0;
|
|
60
|
+
/** scans for block-level constructs */
|
|
61
|
+
readonly HIGH: 1;
|
|
62
|
+
/** inline w/ more priority than other inline */
|
|
63
|
+
readonly MED: 2;
|
|
64
|
+
/** inline elements */
|
|
65
|
+
readonly LOW: 3;
|
|
66
|
+
/** bare text and stuff that is considered leftovers */
|
|
67
|
+
readonly MIN: 4;
|
|
68
|
+
};
|
|
69
|
+
type PriorityValue = (typeof Priority)[keyof typeof Priority];
|
|
70
|
+
/** Threshold for performance logging (in milliseconds) */
|
|
71
|
+
declare const DURATION_DELAY_TRIGGER = 20;
|
|
72
|
+
/**
|
|
73
|
+
* Map of HTML attributes to their JSX prop equivalents.
|
|
74
|
+
* Some renderers use camelCase for certain attributes.
|
|
75
|
+
*/
|
|
76
|
+
declare const ATTRIBUTE_TO_NODE_PROP_MAP: Record<string, string>;
|
|
77
|
+
/**
|
|
78
|
+
* Default HTML entity to unicode mappings.
|
|
79
|
+
*/
|
|
80
|
+
declare const NAMED_CODES_TO_UNICODE: Record<string, string>;
|
|
81
|
+
/** HTML elements that should not have their content processed */
|
|
82
|
+
declare const DO_NOT_PROCESS_HTML_ELEMENTS: string[];
|
|
83
|
+
/** Attributes that require URL sanitization */
|
|
84
|
+
declare const ATTRIBUTES_TO_SANITIZE: string[];
|
|
85
|
+
/** Attribute extractor regex */
|
|
86
|
+
declare const ATTR_EXTRACTOR_R: RegExp;
|
|
87
|
+
/** Block end detection */
|
|
88
|
+
declare const BLOCK_END_R: RegExp;
|
|
89
|
+
/** Blockquote patterns */
|
|
90
|
+
declare const BLOCKQUOTE_R: RegExp;
|
|
91
|
+
declare const BLOCKQUOTE_TRIM_LEFT_MULTILINE_R: RegExp;
|
|
92
|
+
declare const BLOCKQUOTE_ALERT_R: RegExp;
|
|
93
|
+
/** Line break patterns */
|
|
94
|
+
declare const BREAK_LINE_R: RegExp;
|
|
95
|
+
declare const BREAK_THEMATIC_R: RegExp;
|
|
96
|
+
/** Code block patterns */
|
|
97
|
+
declare const CODE_BLOCK_FENCED_R: RegExp;
|
|
98
|
+
declare const CODE_BLOCK_R: RegExp;
|
|
99
|
+
declare const CODE_INLINE_R: RegExp;
|
|
100
|
+
/** Newline patterns */
|
|
101
|
+
declare const CONSECUTIVE_NEWLINE_R: RegExp;
|
|
102
|
+
declare const CR_NEWLINE_R: RegExp;
|
|
103
|
+
/** Footnote patterns */
|
|
104
|
+
declare const FOOTNOTE_R: RegExp;
|
|
105
|
+
declare const FOOTNOTE_REFERENCE_R: RegExp;
|
|
106
|
+
/** Form feed */
|
|
107
|
+
declare const FORMFEED_R: RegExp;
|
|
108
|
+
/** Front matter */
|
|
109
|
+
declare const FRONT_MATTER_R: RegExp;
|
|
110
|
+
/** GFM task */
|
|
111
|
+
declare const GFM_TASK_R: RegExp;
|
|
112
|
+
/** Heading patterns */
|
|
113
|
+
declare const HEADING_R: RegExp;
|
|
114
|
+
declare const HEADING_ATX_COMPLIANT_R: RegExp;
|
|
115
|
+
declare const HEADING_SETEXT_R: RegExp;
|
|
116
|
+
/** HTML patterns */
|
|
117
|
+
declare const HTML_BLOCK_ELEMENT_R: RegExp;
|
|
118
|
+
declare const HTML_CHAR_CODE_R: RegExp;
|
|
119
|
+
declare const HTML_COMMENT_R: RegExp;
|
|
120
|
+
declare const HTML_CUSTOM_ATTR_R: RegExp;
|
|
121
|
+
declare const HTML_SELF_CLOSING_ELEMENT_R: RegExp;
|
|
122
|
+
/** Custom component pattern */
|
|
123
|
+
declare const CUSTOM_COMPONENT_R: RegExp;
|
|
124
|
+
/** Interpolation */
|
|
125
|
+
declare const INTERPOLATION_R: RegExp;
|
|
126
|
+
/** Link patterns */
|
|
127
|
+
declare const LINK_AUTOLINK_BARE_URL_R: RegExp;
|
|
128
|
+
declare const LINK_AUTOLINK_R: RegExp;
|
|
129
|
+
declare const CAPTURE_LETTER_AFTER_HYPHEN: RegExp;
|
|
130
|
+
/** Table patterns */
|
|
131
|
+
declare const NP_TABLE_R: RegExp;
|
|
132
|
+
declare const TABLE_TRIM_PIPES: RegExp;
|
|
133
|
+
declare const TABLE_CENTER_ALIGN: RegExp;
|
|
134
|
+
declare const TABLE_LEFT_ALIGN: RegExp;
|
|
135
|
+
declare const TABLE_RIGHT_ALIGN: RegExp;
|
|
136
|
+
/** Paragraph */
|
|
137
|
+
declare const PARAGRAPH_R: RegExp;
|
|
138
|
+
/** Reference patterns */
|
|
139
|
+
declare const REFERENCE_IMAGE_OR_LINK: RegExp;
|
|
140
|
+
declare const REFERENCE_IMAGE_R: RegExp;
|
|
141
|
+
declare const REFERENCE_LINK_R: RegExp;
|
|
142
|
+
/** Block detection */
|
|
143
|
+
declare const SHOULD_RENDER_AS_BLOCK_R: RegExp;
|
|
144
|
+
/** Tab and whitespace */
|
|
145
|
+
declare const TAB_R: RegExp;
|
|
146
|
+
declare const TRIM_STARTING_NEWLINES: RegExp;
|
|
147
|
+
declare const HTML_LEFT_TRIM_AMOUNT_R: RegExp;
|
|
148
|
+
/** List patterns */
|
|
149
|
+
declare const LIST_LOOKBEHIND_R: RegExp;
|
|
150
|
+
declare const ORDERED_LIST_BULLET = "(?:\\d+\\.)";
|
|
151
|
+
declare const UNORDERED_LIST_BULLET = "(?:[*+-])";
|
|
152
|
+
/** Text formatting patterns */
|
|
153
|
+
declare const TEXT_ESCAPED_R: RegExp;
|
|
154
|
+
declare const UNESCAPE_R: RegExp;
|
|
155
|
+
declare const TEXT_PLAIN_R: RegExp;
|
|
156
|
+
/** Shortcode pattern */
|
|
157
|
+
declare const SHORTCODE_R: RegExp;
|
|
158
|
+
type ListType = 1 | 2;
|
|
159
|
+
declare const ORDERED: ListType;
|
|
160
|
+
declare const UNORDERED: ListType;
|
|
161
|
+
/**
|
|
162
|
+
* Ensure there's at least one more instance of the delimiter later
|
|
163
|
+
* in the current sequence.
|
|
164
|
+
*/
|
|
165
|
+
declare const LOOKAHEAD: (double: number) => string;
|
|
166
|
+
/**
|
|
167
|
+
* For inline formatting, this partial attempts to ignore characters that
|
|
168
|
+
* may appear in nested formatting.
|
|
169
|
+
*/
|
|
170
|
+
declare const INLINE_SKIP_R = "((?:\\[.*?\\][([].*?[)\\]]|<.*?>(?:.*?<.*?>)?|`.*?`|\\\\[^\\s]|[\\s\\S])+?)";
|
|
171
|
+
/** Bold text pattern */
|
|
172
|
+
declare const TEXT_BOLD_R: RegExp;
|
|
173
|
+
/** Emphasized text pattern */
|
|
174
|
+
declare const TEXT_EMPHASIZED_R: RegExp;
|
|
175
|
+
/** Marked text pattern */
|
|
176
|
+
declare const TEXT_MARKED_R: RegExp;
|
|
177
|
+
/** Strikethrough text pattern */
|
|
178
|
+
declare const TEXT_STRIKETHROUGHED_R: RegExp;
|
|
179
|
+
declare const generateListItemPrefix: (type: ListType) => string;
|
|
180
|
+
declare const ORDERED_LIST_ITEM_PREFIX: string;
|
|
181
|
+
declare const UNORDERED_LIST_ITEM_PREFIX: string;
|
|
182
|
+
declare const generateListItemPrefixRegex: (type: ListType) => RegExp;
|
|
183
|
+
declare const ORDERED_LIST_ITEM_PREFIX_R: RegExp;
|
|
184
|
+
declare const UNORDERED_LIST_ITEM_PREFIX_R: RegExp;
|
|
185
|
+
declare const generateListItemRegex: (type: ListType) => RegExp;
|
|
186
|
+
declare const ORDERED_LIST_ITEM_R: RegExp;
|
|
187
|
+
declare const UNORDERED_LIST_ITEM_R: RegExp;
|
|
188
|
+
declare const generateListRegex: (type: ListType) => RegExp;
|
|
189
|
+
declare const ORDERED_LIST_R: RegExp;
|
|
190
|
+
declare const UNORDERED_LIST_R: RegExp;
|
|
191
|
+
//#endregion
|
|
192
|
+
export { ATTRIBUTES_TO_SANITIZE, ATTRIBUTE_TO_NODE_PROP_MAP, ATTR_EXTRACTOR_R, BLOCKQUOTE_ALERT_R, BLOCKQUOTE_R, BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, BLOCK_END_R, BREAK_LINE_R, BREAK_THEMATIC_R, CAPTURE_LETTER_AFTER_HYPHEN, CODE_BLOCK_FENCED_R, CODE_BLOCK_R, CODE_INLINE_R, CONSECUTIVE_NEWLINE_R, CR_NEWLINE_R, CUSTOM_COMPONENT_R, DO_NOT_PROCESS_HTML_ELEMENTS, DURATION_DELAY_TRIGGER, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, GFM_TASK_R, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, HTML_BLOCK_ELEMENT_R, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_SELF_CLOSING_ELEMENT_R, INLINE_SKIP_R, INTERPOLATION_R, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LIST_LOOKBEHIND_R, LOOKAHEAD, ListType, NAMED_CODES_TO_UNICODE, NP_TABLE_R, ORDERED, ORDERED_LIST_BULLET, ORDERED_LIST_ITEM_PREFIX, ORDERED_LIST_ITEM_PREFIX_R, ORDERED_LIST_ITEM_R, ORDERED_LIST_R, PARAGRAPH_R, Priority, PriorityValue, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, RuleType, RuleTypeValue, SHORTCODE_R, SHOULD_RENDER_AS_BLOCK_R, TABLE_CENTER_ALIGN, TABLE_LEFT_ALIGN, TABLE_RIGHT_ALIGN, TABLE_TRIM_PIPES, TAB_R, TEXT_BOLD_R, TEXT_EMPHASIZED_R, TEXT_ESCAPED_R, TEXT_MARKED_R, TEXT_PLAIN_R, TEXT_STRIKETHROUGHED_R, TRIM_STARTING_NEWLINES, UNESCAPE_R, UNORDERED, UNORDERED_LIST_BULLET, UNORDERED_LIST_ITEM_PREFIX, UNORDERED_LIST_ITEM_PREFIX_R, UNORDERED_LIST_ITEM_R, UNORDERED_LIST_R, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex };
|
|
193
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","names":[],"sources":["../../../src/markdown/constants.ts"],"sourcesContent":[],"mappings":";;AAeA;AAiDA;AASA;AAaA;AAOA;AAUA;AAuDA;AAcA;AAGA;AAca,cA9KA,QA+KmG,EAAA;EAGnG,SAAA,UAAuB,EAAA,GAAA;EAGvB,SAAA,SAA0C,EAAA,GAAA;EAC1C,SAAA,aAAA,EAAA,GAAA;EACA,SAAA,SAAA,EAAA,GAAqD;EAGrD,SAAA,UAAyB,EAAA,GAAA;EACzB,SAAA,UAAwD,EAAA,GAAA;EAGxD,SAAA,QAAA,EAAA,GAC2D;EAC3D,SAAA,iBAAgD,EAApC,GAAA;EACZ,SAAA,OAAgD,EAAA,GAAA;EAGhD,SAAA,OAAA,EAAA,GAAA;EACA,SAAA,aAAuB,EAAA,IAAX;EAGZ;EACA,SAAA,SAAA,EAAA,IAAuC;EAGvC,SAAA,WAAkB,EAAA,IAAR;EAGV;EAGA,SAAA,eAA8B,EAApB,IAAA;EAGV;EACA,SAAA,eAAA,EACuC,IAAA;EACvC,SAAA,KAAA,EAAA,IAAiD;EAGjD,SAAA,IAAA,EAAA,IAAA;EAEA;EAEA,SAAA,2BAAc,EAAyB,IAAA;EACvC;EACA,SAAA,mBAAA,EACkE,IAAA;EAGlE,SAAA,gBACiH,EAAA,IAAA;EAGjH,SAAA,WAA4B,EAAA,IAAA;EAG5B,SAAA,SAAA,EAAA,IAAA;EACA,SAAA,GAAA,EAAA,IAA0C;EAC1C,SAAA,QAAA,EAAA,IAAA;EAGA,SAAA,OACkD,EAAA,IAAA;EAClD,SAAA,KAAA,EAAA,IAAmC;EACnC,SAAA,cAAiC,EAAA,IAAA;EACjC,SAAA,IAAA,EAAA,IAA8B;EAC9B,SAAA,UAAA,EAA+B,IAAA;EAG/B,SAAA,cAAwC,EAAA,IAA7B;EAGX,SAAA,WAAA,EAAA,IACoC;EACpC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;cAEV,kBAAgB;cAChB,oBAAkB;cAClB,kBAAgB;cAChB,mBAAiB;;cAGjB,aAAW;;cAGX,yBAAuB;cAEvB,mBAAiB;cACjB,kBAAgB;;cAGhB,0BAAwB;;cAGxB,OAAK;cACL,wBAAsB;cACtB,yBAAuB;;cAGvB,mBAAiB;cACjB,mBAAA;cACA,qBAAA;;cAGA,gBAAc;cACd,YAAU;cACV,cAAY;;cAIZ,aAAW;KAMZ,QAAA;cACC,SAAS;cACT,WAAW;;;;;cAUX;;;;;cAOA,aAAA;;cAIA,aAAW;;cAKX,mBAAiB;;cAKjB,eAAa;;cAKb,wBAAsB;cAQtB,+BAAgC;cAQhC;cACA;cAEA,oCAAqC,aAAW;cAOhD,4BAA0B;cAC1B,8BAA4B;cAG5B,8BAA+B,aAAW;cAc1C,qBAAmB;cACnB,uBAAqB;cAErB,0BAA2B,aAAW;cAiBtC,gBAAc;cACd,kBAAgB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BlockQuoteNode, BoldTextNode, BreakLineNode, BreakThematicNode, CodeBlockNode, CodeInlineNode, CompileOptions, CustomComponentNode, ElementType, FootnoteNode, FootnoteReferenceNode, GFMTaskNode, HTMLNode, HTMLSelfClosingNode, HTMLTag, HeadingNode, ImageNode, ItalicTextNode, LinkNode, MarkdownContext, MarkdownOptions, MarkdownRuntime, MarkedTextNode, NestedParser, NewlineNode, OrderedListNode, Overrides, ParagraphNode, ParseState, ParserResult, ReferenceImageNode, ReferenceLinkNode, ReferenceNode, RenderRuleHook, Rule, RuleOutput, Rules, StrikethroughTextNode, TableNode, TableSeparatorNode, TextNode, UnorderedListNode } from "./types.js";
|
|
2
|
+
import { compile, compileWithOptions, createCompiler } from "./compiler.js";
|
|
3
|
+
import { ATTRIBUTES_TO_SANITIZE, ATTRIBUTE_TO_NODE_PROP_MAP, DO_NOT_PROCESS_HTML_ELEMENTS, DURATION_DELAY_TRIGGER, ListType, NAMED_CODES_TO_UNICODE, ORDERED, Priority, PriorityValue, RuleType, RuleTypeValue, UNORDERED } from "./constants.js";
|
|
4
|
+
import { parserFor } from "./parser.js";
|
|
5
|
+
import { createRenderer, renderFor } from "./renderer.js";
|
|
6
|
+
import { allowInline, anyScopeRegex, attributeValueToNodePropValue, blockRegex, captureNothing, cx, get, inlineRegex, normalizeAttributeKey, normalizeWhitespace, parseBlock, parseCaptureInline, parseInline, parseSimpleInline, parseStyleAttribute, parseTableAlign, parseTableCells, parseTableRow, qualifies, renderNothing, sanitizer, simpleInlineRegex, slugify, some, trimEnd, trimLeadingWhitespaceOutsideFences, unescapeString, unquote } from "./utils.js";
|
|
7
|
+
export { ATTRIBUTES_TO_SANITIZE, ATTRIBUTE_TO_NODE_PROP_MAP, type BlockQuoteNode, type BoldTextNode, type BreakLineNode, type BreakThematicNode, type CodeBlockNode, type CodeInlineNode, type CompileOptions, type CustomComponentNode, DO_NOT_PROCESS_HTML_ELEMENTS, DURATION_DELAY_TRIGGER, type ElementType, type FootnoteNode, type FootnoteReferenceNode, type GFMTaskNode, type HTMLNode, type HTMLSelfClosingNode, type HTMLTag, type HeadingNode, type ImageNode, type ItalicTextNode, type LinkNode, type ListType, type MarkdownContext, type MarkdownOptions, type MarkdownRuntime, type MarkedTextNode, NAMED_CODES_TO_UNICODE, type NestedParser, type NewlineNode, ORDERED, type OrderedListNode, type Overrides, type ParagraphNode, type ParseState, type ParserResult, Priority, type PriorityValue, type ReferenceImageNode, type ReferenceLinkNode, type ReferenceNode, type RenderRuleHook, type Rule, type RuleOutput, RuleType, type RuleTypeValue, type Rules, type StrikethroughTextNode, type TableNode, type TableSeparatorNode, type TextNode, UNORDERED, type UnorderedListNode, allowInline, anyScopeRegex, attributeValueToNodePropValue, blockRegex, captureNothing, compile, compileWithOptions, createCompiler, createRenderer, cx, get, inlineRegex, normalizeAttributeKey, normalizeWhitespace, parseBlock, parseCaptureInline, parseInline, parseSimpleInline, parseStyleAttribute, parseTableAlign, parseTableCells, parseTableRow, parserFor, qualifies, renderFor, renderNothing, sanitizer, simpleInlineRegex, slugify, some, trimEnd, trimLeadingWhitespaceOutsideFences, unescapeString, unquote };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ParseState, ParserResult, Rules } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/markdown/parser.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates a parser for a given set of rules, with the precedence
|
|
7
|
+
* specified as a list of rules.
|
|
8
|
+
*
|
|
9
|
+
* @param rules - An object containing rule type -> {match, order, parse} objects
|
|
10
|
+
* (lower order is higher precedence)
|
|
11
|
+
*
|
|
12
|
+
* @returns The resulting parse function
|
|
13
|
+
*/
|
|
14
|
+
declare const parserFor: (rules: Rules) => ((source: string, state: ParseState) => ParserResult[]);
|
|
15
|
+
//#endregion
|
|
16
|
+
export { parserFor };
|
|
17
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","names":[],"sources":["../../../src/markdown/parser.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;cAqBa,mBACJ,mCACmB,eAAe"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ParseState, ParserResult, RenderRuleHook, RuleOutput, Rules } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/markdown/renderer.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates a renderer for AST nodes.
|
|
7
|
+
* Renamed from `reactFor` to be framework-agnostic.
|
|
8
|
+
*
|
|
9
|
+
* @param render - The render function to call for each node
|
|
10
|
+
* @returns A function that renders AST to output
|
|
11
|
+
*/
|
|
12
|
+
declare const renderFor: (render: (ast: ParserResult, render: RuleOutput, state: ParseState) => unknown) => (ast: ParserResult | ParserResult[], state?: ParseState) => any;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a renderer from rules with optional custom render hook.
|
|
15
|
+
*
|
|
16
|
+
* @param rules - The rules object containing _render functions
|
|
17
|
+
* @param userRender - Optional custom render hook for full control
|
|
18
|
+
* @returns A render function for AST nodes
|
|
19
|
+
*/
|
|
20
|
+
declare const createRenderer: (rules: Rules, userRender?: RenderRuleHook) => (ast: ParserResult, render: RuleOutput, state: ParseState) => unknown;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { createRenderer, renderFor };
|
|
23
|
+
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","names":[],"sources":["../../../src/markdown/renderer.ts"],"sourcesContent":[],"mappings":";;;;;;;AAiGA;;;;AAE8B,cA3EjB,SA2EiB,EAAA,CAAA,MAAA,EAAA,CAAA,GAAA,EAxEnB,YAwEmB,EAAA,MAAA,EAvEhB,UAuEgB,EAAA,KAAA,EAtEjB,UAsEiB,EAAA,GAAA,OAAA,EAAA,GAAA,CAAA,GAAA,EAnEtB,YAmEsB,GAnEP,YAmEO,EAAA,EAAA,KAAA,CAAA,EAnEgB,UAmEhB,EAAA,GAAA,GAAA;;;;;;;;cAFjB,wBACH,oBAAoB,yBACtB,sBAAsB,mBAAmB"}
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
//#region src/markdown/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Framework-agnostic markdown processor types.
|
|
4
|
+
* No framework-specific imports allowed in this file.
|
|
5
|
+
*
|
|
6
|
+
* This is part of the Solution F (Hybrid AST + Callback Pattern) implementation
|
|
7
|
+
* for GitHub Issue #289: Adapt markdown parser in custom packages
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Permissive element type - core doesn't care what frameworks accept.
|
|
11
|
+
* Can be a string tag ('div', 'span') or any component (function, object, class)
|
|
12
|
+
*/
|
|
13
|
+
type ElementType = string | any;
|
|
14
|
+
/**
|
|
15
|
+
* Simple HTML tag type - no need to enumerate all tags
|
|
16
|
+
*/
|
|
17
|
+
type HTMLTag = string;
|
|
18
|
+
/**
|
|
19
|
+
* Runtime interface that framework adapters must implement.
|
|
20
|
+
* This allows the markdown compiler to work with any framework.
|
|
21
|
+
*/
|
|
22
|
+
interface MarkdownRuntime {
|
|
23
|
+
/**
|
|
24
|
+
* Create an element. Signature matches common UI runtimes.
|
|
25
|
+
* @param type - Tag name or component
|
|
26
|
+
* @param props - Element properties
|
|
27
|
+
* @param children - Child elements
|
|
28
|
+
*/
|
|
29
|
+
createElement: (type: ElementType, props: Record<string, any> | null, ...children: any[]) => unknown;
|
|
30
|
+
/**
|
|
31
|
+
* Fragment component for grouping without wrapper DOM node.
|
|
32
|
+
* Optional - falls back to array if not provided.
|
|
33
|
+
*/
|
|
34
|
+
Fragment?: any;
|
|
35
|
+
/**
|
|
36
|
+
* Normalize props for runtime differences.
|
|
37
|
+
* Called before createElement with (tag, props).
|
|
38
|
+
*
|
|
39
|
+
* Examples:
|
|
40
|
+
* - { className } -> { className } (no change needed)
|
|
41
|
+
* - { className } -> { class }
|
|
42
|
+
* - { htmlFor } -> { for }
|
|
43
|
+
*/
|
|
44
|
+
normalizeProps?: (tag: HTMLTag, props: Record<string, any>) => Record<string, any>;
|
|
45
|
+
/**
|
|
46
|
+
* Adapter-specific helpers can be exposed without coupling core.
|
|
47
|
+
*/
|
|
48
|
+
[key: string]: unknown;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Context passed to the compiler containing runtime and configuration.
|
|
52
|
+
*/
|
|
53
|
+
interface MarkdownContext {
|
|
54
|
+
/** Framework runtime (createElement, etc.) */
|
|
55
|
+
runtime: MarkdownRuntime;
|
|
56
|
+
/** Component components for HTML tags */
|
|
57
|
+
components?: Overrides;
|
|
58
|
+
/** Custom URL sanitizer */
|
|
59
|
+
sanitizer?: (url: string, tag: HTMLTag, attr: string) => string | null;
|
|
60
|
+
/** Custom slugify function for heading IDs */
|
|
61
|
+
slugify?: (text: string, defaultFn: (input: string) => string) => string;
|
|
62
|
+
/** Custom named codes to unicode mappings */
|
|
63
|
+
namedCodesToUnicode?: Record<string, string>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Parser state passed through parsing and rendering.
|
|
67
|
+
*/
|
|
68
|
+
type ParseState = {
|
|
69
|
+
/** true if the current content is inside anchor link grammar */
|
|
70
|
+
inAnchor?: boolean;
|
|
71
|
+
/** true if parsing in an HTML context */
|
|
72
|
+
inHTML?: boolean;
|
|
73
|
+
/** true if parsing in an inline context (subset of rules around formatting and links) */
|
|
74
|
+
inline?: boolean;
|
|
75
|
+
/** true if in a table */
|
|
76
|
+
inTable?: boolean;
|
|
77
|
+
/** use this for the `key` prop */
|
|
78
|
+
key?: string | number;
|
|
79
|
+
/** true if in a list */
|
|
80
|
+
list?: boolean;
|
|
81
|
+
/** used for lookbacks */
|
|
82
|
+
prevCapture?: string;
|
|
83
|
+
/** true if parsing in inline context w/o links */
|
|
84
|
+
simple?: boolean;
|
|
85
|
+
};
|
|
86
|
+
type BlockQuoteNode = {
|
|
87
|
+
type: string;
|
|
88
|
+
alert?: string;
|
|
89
|
+
children: ParserResult[];
|
|
90
|
+
};
|
|
91
|
+
type BreakLineNode = {
|
|
92
|
+
type: string;
|
|
93
|
+
};
|
|
94
|
+
type BreakThematicNode = {
|
|
95
|
+
type: string;
|
|
96
|
+
};
|
|
97
|
+
type CodeBlockNode = {
|
|
98
|
+
type: string;
|
|
99
|
+
attrs?: Record<string, any>;
|
|
100
|
+
lang?: string;
|
|
101
|
+
text: string;
|
|
102
|
+
};
|
|
103
|
+
type CodeFencedNode = {
|
|
104
|
+
type: string;
|
|
105
|
+
};
|
|
106
|
+
type CodeInlineNode = {
|
|
107
|
+
type: string;
|
|
108
|
+
text: string;
|
|
109
|
+
};
|
|
110
|
+
type FootnoteNode = {
|
|
111
|
+
type: string;
|
|
112
|
+
};
|
|
113
|
+
type FootnoteReferenceNode = {
|
|
114
|
+
type: string;
|
|
115
|
+
target: string;
|
|
116
|
+
text: string;
|
|
117
|
+
};
|
|
118
|
+
type GFMTaskNode = {
|
|
119
|
+
type: string;
|
|
120
|
+
completed: boolean;
|
|
121
|
+
};
|
|
122
|
+
type HeadingNode = {
|
|
123
|
+
type: string;
|
|
124
|
+
children: ParserResult[];
|
|
125
|
+
id: string;
|
|
126
|
+
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
127
|
+
};
|
|
128
|
+
type HeadingSetextNode = {
|
|
129
|
+
type: string;
|
|
130
|
+
};
|
|
131
|
+
type HTMLCommentNode = {
|
|
132
|
+
type: string;
|
|
133
|
+
};
|
|
134
|
+
type ImageNode = {
|
|
135
|
+
type: string;
|
|
136
|
+
alt?: string;
|
|
137
|
+
target: string;
|
|
138
|
+
title?: string;
|
|
139
|
+
};
|
|
140
|
+
type LinkNode = {
|
|
141
|
+
type: string;
|
|
142
|
+
children: ParserResult[];
|
|
143
|
+
target: string;
|
|
144
|
+
title?: string;
|
|
145
|
+
};
|
|
146
|
+
type LinkAngleBraceNode = {
|
|
147
|
+
type: string;
|
|
148
|
+
};
|
|
149
|
+
type LinkBareURLNode = {
|
|
150
|
+
type: string;
|
|
151
|
+
};
|
|
152
|
+
type OrderedListNode = {
|
|
153
|
+
type: string;
|
|
154
|
+
items: ParserResult[][];
|
|
155
|
+
ordered: true;
|
|
156
|
+
start?: number;
|
|
157
|
+
};
|
|
158
|
+
type UnorderedListNode = {
|
|
159
|
+
type: string;
|
|
160
|
+
items: ParserResult[][];
|
|
161
|
+
ordered: false;
|
|
162
|
+
};
|
|
163
|
+
type NewlineNode = {
|
|
164
|
+
type: string;
|
|
165
|
+
};
|
|
166
|
+
type ParagraphNode = {
|
|
167
|
+
type: string;
|
|
168
|
+
children: ParserResult[];
|
|
169
|
+
};
|
|
170
|
+
type ReferenceNode = {
|
|
171
|
+
type: string;
|
|
172
|
+
};
|
|
173
|
+
type ReferenceImageNode = {
|
|
174
|
+
type: string;
|
|
175
|
+
alt?: string;
|
|
176
|
+
ref: string;
|
|
177
|
+
};
|
|
178
|
+
type ReferenceLinkNode = {
|
|
179
|
+
type: string;
|
|
180
|
+
children: ParserResult[];
|
|
181
|
+
fallbackChildren: string;
|
|
182
|
+
ref: string;
|
|
183
|
+
};
|
|
184
|
+
type TableNode = {
|
|
185
|
+
type: string;
|
|
186
|
+
align: ('left' | 'right' | 'center')[];
|
|
187
|
+
cells: ParserResult[][][];
|
|
188
|
+
header: ParserResult[][];
|
|
189
|
+
};
|
|
190
|
+
type TableSeparatorNode = {
|
|
191
|
+
type: string;
|
|
192
|
+
};
|
|
193
|
+
type TextNode = {
|
|
194
|
+
type: string;
|
|
195
|
+
text: string;
|
|
196
|
+
};
|
|
197
|
+
type BoldTextNode = {
|
|
198
|
+
type: string;
|
|
199
|
+
children: ParserResult[];
|
|
200
|
+
};
|
|
201
|
+
type ItalicTextNode = {
|
|
202
|
+
type: string;
|
|
203
|
+
children: ParserResult[];
|
|
204
|
+
};
|
|
205
|
+
type EscapedTextNode = {
|
|
206
|
+
type: string;
|
|
207
|
+
};
|
|
208
|
+
type MarkedTextNode = {
|
|
209
|
+
type: string;
|
|
210
|
+
children: ParserResult[];
|
|
211
|
+
};
|
|
212
|
+
type StrikethroughTextNode = {
|
|
213
|
+
type: string;
|
|
214
|
+
children: ParserResult[];
|
|
215
|
+
};
|
|
216
|
+
type HTMLNode = {
|
|
217
|
+
type: string;
|
|
218
|
+
attrs: Record<string, any> | null;
|
|
219
|
+
children?: ParserResult[];
|
|
220
|
+
noInnerParse: boolean;
|
|
221
|
+
tag: HTMLTag;
|
|
222
|
+
text?: string;
|
|
223
|
+
};
|
|
224
|
+
type HTMLSelfClosingNode = {
|
|
225
|
+
type: string;
|
|
226
|
+
attrs: Record<string, any> | null;
|
|
227
|
+
tag: string;
|
|
228
|
+
};
|
|
229
|
+
type CustomComponentNode = {
|
|
230
|
+
type: string;
|
|
231
|
+
attrs: Record<string, any> | null;
|
|
232
|
+
children?: ParserResult[];
|
|
233
|
+
noInnerParse: boolean;
|
|
234
|
+
tag: string;
|
|
235
|
+
text?: string;
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Union of all possible parser result node types.
|
|
239
|
+
*/
|
|
240
|
+
type ParserResult = BlockQuoteNode | BreakLineNode | BreakThematicNode | CodeBlockNode | CodeFencedNode | CodeInlineNode | CustomComponentNode | FootnoteNode | FootnoteReferenceNode | GFMTaskNode | HeadingNode | HeadingSetextNode | HTMLCommentNode | ImageNode | LinkNode | LinkAngleBraceNode | LinkBareURLNode | OrderedListNode | UnorderedListNode | NewlineNode | ParagraphNode | ReferenceNode | ReferenceImageNode | ReferenceLinkNode | TableNode | TableSeparatorNode | TextNode | BoldTextNode | ItalicTextNode | EscapedTextNode | MarkedTextNode | StrikethroughTextNode | HTMLNode | HTMLSelfClosingNode;
|
|
241
|
+
/**
|
|
242
|
+
* Nested parser function type.
|
|
243
|
+
*/
|
|
244
|
+
type NestedParser = (input: string, state: ParseState) => ParserResult[];
|
|
245
|
+
/**
|
|
246
|
+
* Parser function type for a rule.
|
|
247
|
+
*/
|
|
248
|
+
type Parser<ParserOutput> = (capture: RegExpMatchArray, nestedParse: NestedParser, state: ParseState) => ParserOutput;
|
|
249
|
+
/**
|
|
250
|
+
* Output function type for rendering.
|
|
251
|
+
*/
|
|
252
|
+
type RuleOutput = (ast: ParserResult | ParserResult[], state: ParseState) => unknown;
|
|
253
|
+
/**
|
|
254
|
+
* Rule definition for parsing and rendering markdown.
|
|
255
|
+
*/
|
|
256
|
+
type Rule<ParserOutput = ParserResult> = {
|
|
257
|
+
/** Match function - returns regex match or null */
|
|
258
|
+
_match: (source: string, state: ParseState, prevCapturedString?: string) => RegExpMatchArray | null;
|
|
259
|
+
/** Priority order for rule application */
|
|
260
|
+
_order: number;
|
|
261
|
+
/** Parse function - converts regex capture to AST node */
|
|
262
|
+
_parse: Parser<Omit<ParserOutput, 'type'>>;
|
|
263
|
+
/**
|
|
264
|
+
* Optional fast check that can quickly determine if this rule
|
|
265
|
+
* should even be attempted.
|
|
266
|
+
*/
|
|
267
|
+
_qualify?: string[] | ((source: string, state: ParseState) => boolean);
|
|
268
|
+
/**
|
|
269
|
+
* Render function - converts AST node to output.
|
|
270
|
+
* Uses context's runtime.createElement for element creation.
|
|
271
|
+
*/
|
|
272
|
+
_render?: (node: ParserOutput, render: RuleOutput, state: ParseState) => unknown;
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* Map of all rules keyed by rule type.
|
|
276
|
+
*/
|
|
277
|
+
type Rules = {
|
|
278
|
+
[key: string]: Rule<any>;
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* RequireAtLeastOne utility type.
|
|
282
|
+
*/
|
|
283
|
+
type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & { [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>> }[Keys];
|
|
284
|
+
/**
|
|
285
|
+
* Override configuration for a single tag.
|
|
286
|
+
*/
|
|
287
|
+
type Override = RequireAtLeastOne<{
|
|
288
|
+
component: any;
|
|
289
|
+
props: Record<string, any>;
|
|
290
|
+
}> | any;
|
|
291
|
+
/**
|
|
292
|
+
* Map of tag overrides.
|
|
293
|
+
*/
|
|
294
|
+
type Overrides = {
|
|
295
|
+
[tag: string]: Override;
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* Render rule hook for custom rendering logic.
|
|
299
|
+
*/
|
|
300
|
+
type RenderRuleHook = (/** Resume normal processing, call this function as a fallback */
|
|
301
|
+
next: () => unknown, /** The current AST node */
|
|
302
|
+
node: ParserResult, /** Use as renderChildren(node.children) for block nodes */
|
|
303
|
+
renderChildren: RuleOutput, /** Contains key which should be supplied to the topmost element */
|
|
304
|
+
state: ParseState) => unknown;
|
|
305
|
+
/**
|
|
306
|
+
* Options for the markdown compiler.
|
|
307
|
+
* This is the framework-agnostic version of MarkdownProcessorOptions.
|
|
308
|
+
*/
|
|
309
|
+
interface MarkdownOptions {
|
|
310
|
+
/**
|
|
311
|
+
* Disable automatic link detection for bare URLs.
|
|
312
|
+
*/
|
|
313
|
+
disableAutoLink?: boolean;
|
|
314
|
+
/**
|
|
315
|
+
* Disable parsing of raw HTML in markdown.
|
|
316
|
+
*/
|
|
317
|
+
disableParsingRawHTML?: boolean;
|
|
318
|
+
/**
|
|
319
|
+
* Force ATX-compliant headings (require space after #).
|
|
320
|
+
*/
|
|
321
|
+
enforceAtxHeadings?: boolean;
|
|
322
|
+
/**
|
|
323
|
+
* Force block-level output.
|
|
324
|
+
*/
|
|
325
|
+
forceBlock?: boolean;
|
|
326
|
+
/**
|
|
327
|
+
* Force inline output.
|
|
328
|
+
*/
|
|
329
|
+
forceInline?: boolean;
|
|
330
|
+
/**
|
|
331
|
+
* Force wrapper element even for single children.
|
|
332
|
+
*/
|
|
333
|
+
forceWrapper?: boolean;
|
|
334
|
+
/**
|
|
335
|
+
* Custom render rule hook for full control over rendering.
|
|
336
|
+
*/
|
|
337
|
+
renderRule?: RenderRuleHook;
|
|
338
|
+
/**
|
|
339
|
+
* Wrapper element type, or null for no wrapper.
|
|
340
|
+
*/
|
|
341
|
+
wrapper?: HTMLTag | null;
|
|
342
|
+
/**
|
|
343
|
+
* Whether to preserve frontmatter.
|
|
344
|
+
*/
|
|
345
|
+
preserveFrontmatter?: boolean;
|
|
346
|
+
/**
|
|
347
|
+
* Whether to use tag filter.
|
|
348
|
+
*/
|
|
349
|
+
tagfilter?: boolean;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Combined options including context and compiler options.
|
|
353
|
+
* Used by framework adapters.
|
|
354
|
+
*/
|
|
355
|
+
interface CompileOptions extends MarkdownOptions {
|
|
356
|
+
/** Component components */
|
|
357
|
+
components?: Overrides;
|
|
358
|
+
/** Custom named codes to unicode mappings */
|
|
359
|
+
namedCodesToUnicode?: Record<string, string>;
|
|
360
|
+
/** Custom sanitizer function */
|
|
361
|
+
sanitizer?: (value: string, tag: HTMLTag, attribute: string) => string | null;
|
|
362
|
+
/** Custom slugify function */
|
|
363
|
+
slugify?: (input: string, defaultFn: (input: string) => string) => string;
|
|
364
|
+
}
|
|
365
|
+
//#endregion
|
|
366
|
+
export { BlockQuoteNode, BoldTextNode, BreakLineNode, BreakThematicNode, CodeBlockNode, CodeFencedNode, CodeInlineNode, CompileOptions, CustomComponentNode, ElementType, EscapedTextNode, FootnoteNode, FootnoteReferenceNode, GFMTaskNode, HTMLCommentNode, HTMLNode, HTMLSelfClosingNode, HTMLTag, HeadingNode, HeadingSetextNode, ImageNode, ItalicTextNode, LinkAngleBraceNode, LinkBareURLNode, LinkNode, MarkdownContext, MarkdownOptions, MarkdownRuntime, MarkedTextNode, NestedParser, NewlineNode, OrderedListNode, Override, Overrides, ParagraphNode, ParseState, Parser, ParserResult, ReferenceImageNode, ReferenceLinkNode, ReferenceNode, RenderRuleHook, Rule, RuleOutput, Rules, StrikethroughTextNode, TableNode, TableSeparatorNode, TextNode, UnorderedListNode };
|
|
367
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/markdown/types.ts"],"sourcesContent":[],"mappings":";;AAgBA;AAKA;AAMA;;;;;;;AA0CA;AAEW,KAvDC,WAAA,GAuDD,MAAA,GAAA,GAAA;;;;AAQmB,KA1DlB,OAAA,GA0DkB,MAAA;AAU9B;AAuBA;AAMA;AAIA;AAIY,UAnGK,eAAA,CAqGP;EAKE;AAIZ;AAKA;AAIA;AAMA;AAKA;EAOY,aAAA,EAAA,CAAA,IAAiB,EAjInB,WAiImB,EAAA,KAAA,EAhIlB,MAgIkB,CAAA,MAAA,EAAA,GAAA,CAAA,GAAA,IAAA,EAAA,GAAA,QAAA,EAAA,GAAA,EAAA,EAAA,GAAA,OAAA;EAIjB;AAIZ;AAOA;AAOA;EAIY,QAAA,CAAA,EAAA,GAAA;EAIA;AAOZ;AAMA;AAIA;AAKA;AAIA;AAMA;AAOA;AAOA;EAIY,cAAQ,CAAA,EAAA,CAAA,GAAA,EA5LX,OA4LW,EA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