@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.
Files changed (149) hide show
  1. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs +1 -1
  2. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs.map +1 -1
  3. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs +1 -1
  4. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -1
  5. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs +5 -0
  6. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs.map +1 -1
  7. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs +1 -1
  8. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs.map +1 -1
  9. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs +1 -1
  10. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs.map +1 -1
  11. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs +1 -1
  12. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -1
  13. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs +1 -1
  14. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -1
  15. package/dist/cjs/index.cjs +56 -2
  16. package/dist/cjs/interpreter/getContent/deepTransform.cjs +1 -0
  17. package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -1
  18. package/dist/cjs/interpreter/getContent/getContent.cjs +2 -2
  19. package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -1
  20. package/dist/cjs/interpreter/getContent/plugins.cjs +3 -2
  21. package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
  22. package/dist/cjs/interpreter/getEnumeration.cjs.map +1 -1
  23. package/dist/cjs/interpreter/getHTML.cjs +106 -0
  24. package/dist/cjs/interpreter/getHTML.cjs.map +1 -0
  25. package/dist/cjs/interpreter/getInsertion.cjs +3 -1
  26. package/dist/cjs/interpreter/getInsertion.cjs.map +1 -1
  27. package/dist/cjs/interpreter/getTranslation.cjs +2 -2
  28. package/dist/cjs/interpreter/getTranslation.cjs.map +1 -1
  29. package/dist/cjs/interpreter/index.cjs +2 -0
  30. package/dist/cjs/localization/getBrowserLocale.cjs +1 -1
  31. package/dist/cjs/localization/getLocale.cjs +4 -3
  32. package/dist/cjs/localization/getLocale.cjs.map +1 -1
  33. package/dist/cjs/markdown/compiler.cjs +806 -0
  34. package/dist/cjs/markdown/compiler.cjs.map +1 -0
  35. package/dist/cjs/markdown/constants.cjs +334 -0
  36. package/dist/cjs/markdown/constants.cjs.map +1 -0
  37. package/dist/cjs/markdown/index.cjs +49 -0
  38. package/dist/cjs/markdown/parser.cjs +73 -0
  39. package/dist/cjs/markdown/parser.cjs.map +1 -0
  40. package/dist/cjs/markdown/renderer.cjs +68 -0
  41. package/dist/cjs/markdown/renderer.cjs.map +1 -0
  42. package/dist/cjs/markdown/types.cjs +0 -0
  43. package/dist/cjs/markdown/utils.cjs +397 -0
  44. package/dist/cjs/markdown/utils.cjs.map +1 -0
  45. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs +15 -0
  46. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs.map +1 -0
  47. package/dist/cjs/transpiler/html/index.cjs +133 -0
  48. package/dist/cjs/transpiler/html/index.cjs.map +1 -0
  49. package/dist/cjs/transpiler/index.cjs +3 -0
  50. package/dist/cjs/transpiler/insertion/getInsertionValues.cjs +2 -2
  51. package/dist/cjs/transpiler/insertion/getInsertionValues.cjs.map +1 -1
  52. package/dist/cjs/transpiler/insertion/insertion.cjs.map +1 -1
  53. package/dist/cjs/utils/intl.cjs +35 -3
  54. package/dist/cjs/utils/intl.cjs.map +1 -1
  55. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs +1 -1
  56. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs.map +1 -1
  57. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs +1 -1
  58. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs.map +1 -1
  59. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs +5 -0
  60. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs.map +1 -1
  61. package/dist/esm/dictionaryManipulator/getEmptyNode.mjs +1 -1
  62. package/dist/esm/dictionaryManipulator/getEmptyNode.mjs.map +1 -1
  63. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs +1 -1
  64. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs.map +1 -1
  65. package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs +1 -1
  66. package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs.map +1 -1
  67. package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs +1 -1
  68. package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs.map +1 -1
  69. package/dist/esm/index.mjs +11 -4
  70. package/dist/esm/interpreter/getContent/deepTransform.mjs +1 -0
  71. package/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -1
  72. package/dist/esm/interpreter/getContent/getContent.mjs +2 -2
  73. package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -1
  74. package/dist/esm/interpreter/getContent/plugins.mjs +3 -2
  75. package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
  76. package/dist/esm/interpreter/getEnumeration.mjs.map +1 -1
  77. package/dist/esm/interpreter/getHTML.mjs +105 -0
  78. package/dist/esm/interpreter/getHTML.mjs.map +1 -0
  79. package/dist/esm/interpreter/getInsertion.mjs +3 -1
  80. package/dist/esm/interpreter/getInsertion.mjs.map +1 -1
  81. package/dist/esm/interpreter/getTranslation.mjs +2 -2
  82. package/dist/esm/interpreter/getTranslation.mjs.map +1 -1
  83. package/dist/esm/interpreter/index.mjs +2 -1
  84. package/dist/esm/localization/getBrowserLocale.mjs +1 -1
  85. package/dist/esm/localization/getLocale.mjs +2 -1
  86. package/dist/esm/localization/getLocale.mjs.map +1 -1
  87. package/dist/esm/markdown/compiler.mjs +804 -0
  88. package/dist/esm/markdown/compiler.mjs.map +1 -0
  89. package/dist/esm/markdown/constants.mjs +254 -0
  90. package/dist/esm/markdown/constants.mjs.map +1 -0
  91. package/dist/esm/markdown/index.mjs +7 -0
  92. package/dist/esm/markdown/parser.mjs +73 -0
  93. package/dist/esm/markdown/parser.mjs.map +1 -0
  94. package/dist/esm/markdown/renderer.mjs +67 -0
  95. package/dist/esm/markdown/renderer.mjs.map +1 -0
  96. package/dist/esm/markdown/types.mjs +0 -0
  97. package/dist/esm/markdown/utils.mjs +368 -0
  98. package/dist/esm/markdown/utils.mjs.map +1 -0
  99. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs +15 -0
  100. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +1 -0
  101. package/dist/esm/transpiler/html/index.mjs +131 -0
  102. package/dist/esm/transpiler/html/index.mjs.map +1 -0
  103. package/dist/esm/transpiler/index.mjs +2 -1
  104. package/dist/esm/transpiler/insertion/getInsertionValues.mjs +2 -2
  105. package/dist/esm/transpiler/insertion/getInsertionValues.mjs.map +1 -1
  106. package/dist/esm/transpiler/insertion/insertion.mjs.map +1 -1
  107. package/dist/esm/utils/intl.mjs +35 -4
  108. package/dist/esm/utils/intl.mjs.map +1 -1
  109. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +11 -10
  110. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts.map +1 -1
  111. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts +3 -2
  112. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts.map +1 -1
  113. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts +11 -10
  114. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts.map +1 -1
  115. package/dist/types/getStorageAttributes.d.ts.map +1 -1
  116. package/dist/types/index.d.ts +11 -3
  117. package/dist/types/interpreter/getContent/getContent.d.ts +1 -1
  118. package/dist/types/interpreter/getContent/getContent.d.ts.map +1 -1
  119. package/dist/types/interpreter/getContent/index.d.ts +2 -2
  120. package/dist/types/interpreter/getContent/plugins.d.ts +58 -18
  121. package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
  122. package/dist/types/interpreter/getEnumeration.d.ts +1 -1
  123. package/dist/types/interpreter/getHTML.d.ts +14 -0
  124. package/dist/types/interpreter/getHTML.d.ts.map +1 -0
  125. package/dist/types/interpreter/getTranslation.d.ts.map +1 -1
  126. package/dist/types/interpreter/index.d.ts +3 -2
  127. package/dist/types/localization/getLocale.d.ts.map +1 -1
  128. package/dist/types/markdown/compiler.d.ts +10 -0
  129. package/dist/types/markdown/compiler.d.ts.map +1 -0
  130. package/dist/types/markdown/constants.d.ts +193 -0
  131. package/dist/types/markdown/constants.d.ts.map +1 -0
  132. package/dist/types/markdown/index.d.ts +7 -0
  133. package/dist/types/markdown/parser.d.ts +17 -0
  134. package/dist/types/markdown/parser.d.ts.map +1 -0
  135. package/dist/types/markdown/renderer.d.ts +23 -0
  136. package/dist/types/markdown/renderer.d.ts.map +1 -0
  137. package/dist/types/markdown/types.d.ts +367 -0
  138. package/dist/types/markdown/types.d.ts.map +1 -0
  139. package/dist/types/markdown/utils.d.ts +141 -0
  140. package/dist/types/markdown/utils.d.ts.map +1 -0
  141. package/dist/types/messageFormat/ICU.d.ts.map +1 -1
  142. package/dist/types/transpiler/html/getHTMLCustomComponents.d.ts +9 -0
  143. package/dist/types/transpiler/html/getHTMLCustomComponents.d.ts.map +1 -0
  144. package/dist/types/transpiler/html/index.d.ts +33 -0
  145. package/dist/types/transpiler/html/index.d.ts.map +1 -0
  146. package/dist/types/transpiler/index.d.ts +2 -1
  147. package/dist/types/utils/intl.d.ts +21 -2
  148. package/dist/types/utils/intl.d.ts.map +1 -1
  149. package/package.json +15 -7
@@ -0,0 +1,804 @@
1
+ import { 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, CODE_BLOCK_FENCED_R, CODE_BLOCK_R, CODE_INLINE_R, CONSECUTIVE_NEWLINE_R, CUSTOM_COMPONENT_R, DO_NOT_PROCESS_HTML_ELEMENTS, FOOTNOTE_R, FOOTNOTE_REFERENCE_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_LEFT_TRIM_AMOUNT_R, HTML_SELF_CLOSING_ELEMENT_R, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LIST_LOOKBEHIND_R, NAMED_CODES_TO_UNICODE, NP_TABLE_R, ORDERED, ORDERED_LIST_ITEM_PREFIX_R, ORDERED_LIST_ITEM_R, ORDERED_LIST_R, PARAGRAPH_R, Priority, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, RuleType, SHORTCODE_R, SHOULD_RENDER_AS_BLOCK_R, TEXT_BOLD_R, TEXT_EMPHASIZED_R, TEXT_ESCAPED_R, TEXT_MARKED_R, TEXT_PLAIN_R, TEXT_STRIKETHROUGHED_R, TRIM_STARTING_NEWLINES, UNORDERED, UNORDERED_LIST_ITEM_PREFIX_R, UNORDERED_LIST_ITEM_R, UNORDERED_LIST_R } from "./constants.mjs";
2
+ import { allowInline, anyScopeRegex, attributeValueToNodePropValue, blockRegex, captureNothing, cx, get, inlineRegex, normalizeAttributeKey, parseBlock, parseCaptureInline, parseInline, parseSimpleInline, parseTableAlign, parseTableCells, parseTableRow, renderNothing, sanitizer, simpleInlineRegex, slugify, some, startsWith, trimEnd, trimLeadingWhitespaceOutsideFences, unescapeString, unquote } from "./utils.mjs";
3
+ import { parserFor } from "./parser.mjs";
4
+ import { createRenderer, renderFor } from "./renderer.mjs";
5
+
6
+ //#region src/markdown/compiler.ts
7
+ /**
8
+ * Framework-agnostic markdown compiler.
9
+ * Contains all rules and the main compile function.
10
+ *
11
+ * This is part of the Solution F (Hybrid AST + Callback Pattern) implementation
12
+ * for GitHub Issue #289: Adapt markdown parser in custom packages
13
+ */
14
+ const IMAGE_R = /^!\[(.*?)\]\( *((?:\([^)]*\)|[^() ])*) *"?([^)"]*)?"?\)/;
15
+ const LINK_R = /* @__PURE__ */ new RegExp(`^\\[((?:\\[[^\\[\\]]*(?:\\[[^\\[\\]]*\\][^\\[\\]]*)*\\]|[^\\[\\]])*)\\]\\(\\s*<?((?:\\([^)]*\\)|[^\\s\\\\]|\\\\.)*?)>?(?:\\s+['"]([\\s\\S]*?)['"])?\\s*\\)`);
16
+ const getTag = (tag, components) => {
17
+ if (typeof tag !== "string") return tag;
18
+ const override = get(components, tag);
19
+ if (!override) return tag;
20
+ if (typeof override === "function") return override;
21
+ if (typeof override === "object" && !("component" in override) && !("props" in override)) return override;
22
+ if (typeof override === "object" && "component" in override) return override.component ?? tag;
23
+ return tag;
24
+ };
25
+ const createElementFactory = (ctx, options) => {
26
+ const { runtime, components = {} } = ctx;
27
+ const filteredTags = options.tagfilter ? [
28
+ "title",
29
+ "textarea",
30
+ "style",
31
+ "xmp",
32
+ "iframe",
33
+ "noembed",
34
+ "noframes",
35
+ "script",
36
+ "plaintext"
37
+ ] : [];
38
+ return (tag, props, ...children) => {
39
+ if (typeof tag === "string" && filteredTags.includes(tag.toLowerCase())) return null;
40
+ const isStringTag = typeof tag === "string";
41
+ let overrideProps = {};
42
+ if (isStringTag) overrideProps = get(components, `${tag}.props`, {}) ?? {};
43
+ const className = cx(props?.className, props?.class, overrideProps?.className, overrideProps?.class);
44
+ const initialMergedProps = {
45
+ ...props,
46
+ ...overrideProps
47
+ };
48
+ const mergedProps = {};
49
+ let classNameHandled = false;
50
+ for (const key in initialMergedProps) {
51
+ const value = initialMergedProps[key];
52
+ if (value === void 0 || value === null) continue;
53
+ if (key === "className" || key === "class") {
54
+ if (!classNameHandled) {
55
+ if (className) mergedProps.className = className;
56
+ classNameHandled = true;
57
+ }
58
+ } else mergedProps[key] = value;
59
+ }
60
+ if (!classNameHandled && className) mergedProps.className = className;
61
+ let finalProps = mergedProps;
62
+ if (runtime.normalizeProps && isStringTag) finalProps = runtime.normalizeProps(tag, mergedProps);
63
+ const component = getTag(tag, components);
64
+ return runtime.createElement(component, finalProps, ...children.length === 1 ? [children[0]] : children);
65
+ };
66
+ };
67
+ const createRules = (createElement, ctx, options, footnotes, refs, attrStringToMap, containsBlockSyntax, nonParagraphBlockSyntaxes) => {
68
+ const slug = (input) => ctx.slugify ? ctx.slugify(input, slugify) : slugify(input);
69
+ const sanitize = ctx.sanitizer ?? sanitizer;
70
+ const namedCodesToUnicode = ctx.namedCodesToUnicode ? {
71
+ ...NAMED_CODES_TO_UNICODE,
72
+ ...ctx.namedCodesToUnicode
73
+ } : NAMED_CODES_TO_UNICODE;
74
+ const generateListRule = (type) => {
75
+ const ordered = type === ORDERED;
76
+ const LIST_R = ordered ? ORDERED_LIST_R : UNORDERED_LIST_R;
77
+ const LIST_ITEM_R = ordered ? ORDERED_LIST_ITEM_R : UNORDERED_LIST_ITEM_R;
78
+ const LIST_ITEM_PREFIX_R = ordered ? ORDERED_LIST_ITEM_PREFIX_R : UNORDERED_LIST_ITEM_PREFIX_R;
79
+ return {
80
+ _qualify: (source) => LIST_ITEM_PREFIX_R.test(source),
81
+ _match: allowInline((source, state) => {
82
+ const isStartOfLine = LIST_LOOKBEHIND_R.exec(state.prevCapture ?? "");
83
+ const isListAllowed = state.list ?? (!state.inline && !state.simple);
84
+ if (isStartOfLine && isListAllowed) {
85
+ const matchSource = (isStartOfLine[1] || "") + source;
86
+ return LIST_R.exec(matchSource);
87
+ }
88
+ return null;
89
+ }),
90
+ _order: Priority.HIGH,
91
+ _parse(capture, parse, state) {
92
+ performance.now();
93
+ const bullet = capture[2];
94
+ const startValue = ordered ? +bullet.slice(0, -1) : void 0;
95
+ const items = capture[0].replace(BLOCK_END_R, "\n").match(LIST_ITEM_R);
96
+ if (!items) return {
97
+ items: [],
98
+ ordered,
99
+ start: startValue
100
+ };
101
+ let lastItemWasAParagraph = false;
102
+ return {
103
+ items: items.map((item, i) => {
104
+ const prefixCapture = LIST_ITEM_PREFIX_R.exec(item);
105
+ const space = prefixCapture ? prefixCapture[0].length : 0;
106
+ const spaceRegex = new RegExp(`^ {1,${space}}`, "gm");
107
+ const content = item.replace(spaceRegex, "").replace(LIST_ITEM_PREFIX_R, "");
108
+ const isLastItem = i === items.length - 1;
109
+ const thisItemIsAParagraph = content.indexOf("\n\n") !== -1 || isLastItem && lastItemWasAParagraph;
110
+ lastItemWasAParagraph = thisItemIsAParagraph;
111
+ const oldStateInline = state.inline;
112
+ const oldStateList = state.list;
113
+ state.list = true;
114
+ let adjustedContent;
115
+ if (thisItemIsAParagraph) {
116
+ state.inline = false;
117
+ adjustedContent = `${trimEnd(content)}\n\n`;
118
+ } else {
119
+ state.inline = true;
120
+ adjustedContent = trimEnd(content);
121
+ }
122
+ const parsed = parse(adjustedContent, state);
123
+ state.inline = oldStateInline;
124
+ state.list = oldStateList;
125
+ return parsed;
126
+ }),
127
+ ordered,
128
+ start: startValue
129
+ };
130
+ },
131
+ _render(node, output, state = {}) {
132
+ const Tag = node.ordered ? "ol" : "ul";
133
+ const props = { key: state.key };
134
+ if (node.ordered && node.start != null) props.start = node.start;
135
+ return createElement(Tag, props, ...node.items.map((item, i) => createElement("li", { key: i }, output(item, state))));
136
+ }
137
+ };
138
+ };
139
+ const matchParagraph = (source, state) => {
140
+ if (state.inline || state.simple || state.inHTML && source.indexOf("\n\n") === -1 && state.prevCapture?.indexOf("\n\n") === -1) return null;
141
+ let start = 0;
142
+ while (true) {
143
+ const newlineIndex = source.indexOf("\n", start);
144
+ const line = source.slice(start, newlineIndex === -1 ? void 0 : newlineIndex + 1);
145
+ if (some(nonParagraphBlockSyntaxes, line)) break;
146
+ if (newlineIndex === -1 || !line.trim()) break;
147
+ start = newlineIndex + 1;
148
+ }
149
+ const match = source.slice(0, start);
150
+ if (match === "") return null;
151
+ const captured = trimEnd(match);
152
+ if (captured === "") return null;
153
+ return [
154
+ match,
155
+ void 0,
156
+ captured
157
+ ];
158
+ };
159
+ return {
160
+ [RuleType.blockQuote]: {
161
+ _qualify: [">"],
162
+ _match: blockRegex(BLOCKQUOTE_R),
163
+ _order: Priority.HIGH,
164
+ _parse(capture, parse, state) {
165
+ const matchAlert = capture[0].replace(BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, "").match(BLOCKQUOTE_ALERT_R);
166
+ const alert = matchAlert?.[1];
167
+ const content = matchAlert?.[2] ?? "";
168
+ return {
169
+ alert,
170
+ children: content.indexOf("\n") !== -1 ? parseBlock(parse, content, state) : parseInline(parse, content, state)
171
+ };
172
+ },
173
+ _render(node, output, state = {}) {
174
+ const props = { key: state.key };
175
+ if (node.alert) {
176
+ props.className = `markdown-alert-${slug(node.alert.toLowerCase())}`;
177
+ node.children.unshift({
178
+ attrs: {},
179
+ children: [{
180
+ type: RuleType.text,
181
+ text: node.alert
182
+ }],
183
+ noInnerParse: true,
184
+ type: RuleType.htmlBlock,
185
+ tag: "header"
186
+ });
187
+ }
188
+ return createElement("blockquote", props, output(node.children, state));
189
+ }
190
+ },
191
+ [RuleType.breakLine]: {
192
+ _qualify: [" "],
193
+ _match: anyScopeRegex(BREAK_LINE_R),
194
+ _order: Priority.HIGH,
195
+ _parse: captureNothing,
196
+ _render(_, __, state = {}) {
197
+ return createElement("br", { key: state.key });
198
+ }
199
+ },
200
+ [RuleType.breakThematic]: {
201
+ _qualify: [
202
+ "--",
203
+ "__",
204
+ "**",
205
+ "- ",
206
+ "* ",
207
+ "_ "
208
+ ],
209
+ _match: blockRegex(BREAK_THEMATIC_R),
210
+ _order: Priority.HIGH,
211
+ _parse: captureNothing,
212
+ _render(_, __, state = {}) {
213
+ return createElement("hr", { key: state.key });
214
+ }
215
+ },
216
+ [RuleType.codeBlock]: {
217
+ _qualify: [" "],
218
+ _match: blockRegex(CODE_BLOCK_R),
219
+ _order: Priority.MAX,
220
+ _parse(capture) {
221
+ return {
222
+ type: RuleType.codeBlock,
223
+ lang: void 0,
224
+ text: unescapeString(trimEnd(capture[0].replace(/^ {4}/gm, "")))
225
+ };
226
+ },
227
+ _render(node, _, state = {}) {
228
+ const attrs = { ...node.attrs ?? {} };
229
+ const langClass = node.lang ? `lang-${node.lang}` : "lang-plaintext";
230
+ attrs.className = attrs.className ? `${attrs.className} ${langClass}` : langClass;
231
+ if (node.lang && !attrs.lang) attrs.lang = node.lang;
232
+ return createElement("pre", { key: state.key }, createElement("code", attrs, node.text));
233
+ }
234
+ },
235
+ [RuleType.codeFenced]: {
236
+ _qualify: ["```", "~~~"],
237
+ _match: blockRegex(CODE_BLOCK_FENCED_R),
238
+ _order: Priority.MAX,
239
+ _parse(capture) {
240
+ return {
241
+ attrs: attrStringToMap("code", capture[3] ?? ""),
242
+ lang: capture[2] || void 0,
243
+ text: capture[4],
244
+ type: RuleType.codeBlock
245
+ };
246
+ }
247
+ },
248
+ [RuleType.codeInline]: {
249
+ _qualify: ["`"],
250
+ _match: simpleInlineRegex(CODE_INLINE_R),
251
+ _order: Priority.LOW,
252
+ _parse(capture) {
253
+ return { text: unescapeString(capture[2]) };
254
+ },
255
+ _render(node, _, state = {}) {
256
+ return createElement("code", { key: state.key }, node.text);
257
+ }
258
+ },
259
+ [RuleType.footnote]: {
260
+ _qualify: ["[^"],
261
+ _match: blockRegex(FOOTNOTE_R),
262
+ _order: Priority.MAX,
263
+ _parse(capture) {
264
+ footnotes.push({
265
+ footnote: capture[2],
266
+ identifier: capture[1]
267
+ });
268
+ return {};
269
+ },
270
+ _render: renderNothing
271
+ },
272
+ [RuleType.footnoteReference]: {
273
+ _qualify: ["[^"],
274
+ _match: inlineRegex(FOOTNOTE_REFERENCE_R),
275
+ _order: Priority.HIGH,
276
+ _parse(capture) {
277
+ return {
278
+ target: `#${slug(capture[1])}`,
279
+ text: capture[1]
280
+ };
281
+ },
282
+ _render(node, _, state = {}) {
283
+ return createElement("a", {
284
+ key: state.key,
285
+ href: sanitize(node.target, "a", "href") ?? void 0
286
+ }, createElement("sup", { key: state.key }, node.text));
287
+ }
288
+ },
289
+ [RuleType.gfmTask]: {
290
+ _qualify: ["[ ]", "[x]"],
291
+ _match: inlineRegex(GFM_TASK_R),
292
+ _order: Priority.HIGH,
293
+ _parse(capture) {
294
+ return { completed: capture[1].toLowerCase() === "x" };
295
+ },
296
+ _render(node, _, state = {}) {
297
+ return createElement("input", {
298
+ checked: node.completed,
299
+ key: state.key,
300
+ readOnly: true,
301
+ type: "checkbox"
302
+ });
303
+ }
304
+ },
305
+ [RuleType.heading]: {
306
+ _qualify: ["#"],
307
+ _match: blockRegex(options.enforceAtxHeadings ? HEADING_ATX_COMPLIANT_R : HEADING_R),
308
+ _order: Priority.HIGH,
309
+ _parse(capture, parse, state) {
310
+ return {
311
+ children: parseInline(parse, capture[2], state),
312
+ id: slug(capture[2]),
313
+ level: capture[1].length
314
+ };
315
+ },
316
+ _render(node, output, state = {}) {
317
+ return createElement(`h${node.level}`, {
318
+ id: node.id,
319
+ key: state.key
320
+ }, output(node.children, state));
321
+ }
322
+ },
323
+ [RuleType.headingSetext]: {
324
+ _qualify: (source) => {
325
+ const nlIndex = source.indexOf("\n");
326
+ return nlIndex > 0 && nlIndex < source.length - 1 && (source[nlIndex + 1] === "=" || source[nlIndex + 1] === "-");
327
+ },
328
+ _match: blockRegex(HEADING_SETEXT_R),
329
+ _order: Priority.MAX,
330
+ _parse(capture, parse, state) {
331
+ return {
332
+ children: parseInline(parse, capture[1], state),
333
+ level: capture[2] === "=" ? 1 : 2,
334
+ type: RuleType.heading
335
+ };
336
+ }
337
+ },
338
+ [RuleType.htmlBlock]: {
339
+ _qualify: (source) => {
340
+ if (options.disableParsingRawHTML) return false;
341
+ if (source[0] !== "<") return false;
342
+ if (!/^<([a-z][a-z0-9:-]*)\b/.test(source)) return false;
343
+ const tagMatch = source.match(/^<([a-z][a-z0-9:-]*)\b/);
344
+ if (!tagMatch) return false;
345
+ const tag = tagMatch[1];
346
+ return source.toLowerCase().indexOf(`</${tag.toLowerCase()}>`) !== -1;
347
+ },
348
+ _match: anyScopeRegex(HTML_BLOCK_ELEMENT_R),
349
+ _order: Priority.HIGH,
350
+ _parse(capture, parse, state) {
351
+ const whitespace = capture[3].match(HTML_LEFT_TRIM_AMOUNT_R)?.[1] ?? "";
352
+ const trimmed = trimLeadingWhitespaceOutsideFences(capture[3], whitespace);
353
+ const parseFunc = containsBlockSyntax(trimmed) ? parseBlock : parseInline;
354
+ const tagName = capture[1].toLowerCase();
355
+ const noInnerParse = DO_NOT_PROCESS_HTML_ELEMENTS.indexOf(tagName) !== -1;
356
+ const tag = (noInnerParse ? tagName : capture[1]).trim();
357
+ const ast = {
358
+ attrs: attrStringToMap(tag, capture[2] ?? ""),
359
+ noInnerParse,
360
+ tag
361
+ };
362
+ state.inAnchor = state.inAnchor || tagName === "a";
363
+ if (noInnerParse) ast.text = capture[3];
364
+ else {
365
+ const prevInHTML = state.inHTML;
366
+ state.inHTML = true;
367
+ ast.children = parseFunc(parse, trimmed, state);
368
+ state.inHTML = prevInHTML;
369
+ }
370
+ state.inAnchor = false;
371
+ return ast;
372
+ },
373
+ _render(node, output, state = {}) {
374
+ return createElement(node.tag, {
375
+ key: state.key,
376
+ ...node.attrs ?? {}
377
+ }, node.text ?? (node.children ? output(node.children, state) : ""));
378
+ }
379
+ },
380
+ [RuleType.htmlComment]: {
381
+ _qualify: ["<!"],
382
+ _match: anyScopeRegex(HTML_COMMENT_R),
383
+ _order: Priority.HIGH,
384
+ _parse: captureNothing,
385
+ _render: renderNothing
386
+ },
387
+ [RuleType.htmlSelfClosing]: {
388
+ _qualify: (source) => {
389
+ if (options.disableParsingRawHTML) return false;
390
+ if (source[0] !== "<") return false;
391
+ return /^<([a-zA-Z][a-zA-Z0-9:]*)[\s>/]/.test(source);
392
+ },
393
+ _match: anyScopeRegex(HTML_SELF_CLOSING_ELEMENT_R),
394
+ _order: Priority.HIGH,
395
+ _parse(capture) {
396
+ const tag = capture[1].trim();
397
+ return {
398
+ attrs: attrStringToMap(tag, capture[2] || ""),
399
+ tag
400
+ };
401
+ },
402
+ _render(node, _, state = {}) {
403
+ return createElement(node.tag, {
404
+ key: state.key,
405
+ ...node.attrs ?? {}
406
+ });
407
+ }
408
+ },
409
+ [RuleType.customComponent]: {
410
+ _qualify: (source) => source[0] === "<" && /^ *<([A-Z][a-zA-Z0-9]*)/.test(source),
411
+ _match: blockRegex(CUSTOM_COMPONENT_R),
412
+ _order: Priority.MAX,
413
+ _parse(capture, parse, state) {
414
+ const whitespace = capture[3].match(HTML_LEFT_TRIM_AMOUNT_R)?.[1] ?? "";
415
+ const trimmed = trimLeadingWhitespaceOutsideFences(capture[3], whitespace);
416
+ const parseFunc = containsBlockSyntax(trimmed) ? parseBlock : parseInline;
417
+ const tag = capture[1].trim();
418
+ const ast = {
419
+ attrs: attrStringToMap(tag, capture[2] ?? ""),
420
+ noInnerParse: false,
421
+ tag
422
+ };
423
+ const prevInHTML = state.inHTML;
424
+ state.inHTML = true;
425
+ ast.children = parseFunc(parse, trimmed, state);
426
+ state.inHTML = prevInHTML;
427
+ return ast;
428
+ },
429
+ _render(node, output, state = {}) {
430
+ return createElement(node.tag, {
431
+ key: state.key,
432
+ ...node.attrs ?? {}
433
+ }, node.text ?? (node.children ? output(node.children, state) : ""));
434
+ }
435
+ },
436
+ [RuleType.paragraph]: {
437
+ _match: matchParagraph,
438
+ _order: Priority.LOW,
439
+ _parse: parseCaptureInline,
440
+ _render(node, output, state = {}) {
441
+ return createElement("p", { key: state.key }, output(node.children, state));
442
+ }
443
+ },
444
+ [RuleType.image]: {
445
+ _qualify: ["!["],
446
+ _match: simpleInlineRegex(IMAGE_R),
447
+ _order: Priority.HIGH,
448
+ _parse(capture) {
449
+ return {
450
+ alt: unescapeString(capture[1]),
451
+ target: unescapeString(capture[2]),
452
+ title: unescapeString(capture[3])
453
+ };
454
+ },
455
+ _render(node, _, state = {}) {
456
+ return createElement("img", {
457
+ key: state.key,
458
+ alt: node.alt ?? void 0,
459
+ title: node.title ?? void 0,
460
+ src: sanitize(node.target, "img", "src") ?? void 0
461
+ });
462
+ }
463
+ },
464
+ [RuleType.link]: {
465
+ _qualify: ["["],
466
+ _match: inlineRegex(LINK_R),
467
+ _order: Priority.LOW,
468
+ _parse(capture, parse, state) {
469
+ return {
470
+ children: parseSimpleInline(parse, capture[1], state),
471
+ target: unescapeString(capture[2]),
472
+ title: unescapeString(capture[3])
473
+ };
474
+ },
475
+ _render(node, output, state = {}) {
476
+ return createElement("a", {
477
+ key: state.key,
478
+ href: sanitize(node.target, "a", "href") ?? void 0,
479
+ title: node.title ?? void 0
480
+ }, output(node.children, state));
481
+ }
482
+ },
483
+ [RuleType.linkAngleBraceStyleDetector]: {
484
+ _qualify: ["<"],
485
+ _match: inlineRegex(LINK_AUTOLINK_R),
486
+ _order: Priority.MAX,
487
+ _parse(capture) {
488
+ let target = capture[1];
489
+ let isEmail = false;
490
+ if (target.indexOf("@") !== -1 && target.indexOf("//") === -1) {
491
+ isEmail = true;
492
+ target = target.replace("mailto:", "");
493
+ }
494
+ return {
495
+ children: [{
496
+ text: target,
497
+ type: RuleType.text
498
+ }],
499
+ target: isEmail ? `mailto:${target}` : target,
500
+ type: RuleType.link
501
+ };
502
+ }
503
+ },
504
+ [RuleType.linkBareUrlDetector]: {
505
+ _qualify: (source, state) => !!(state.inline && !state.inAnchor && !options.disableAutoLink && (startsWith(source, "http://") || startsWith(source, "https://"))),
506
+ _match: inlineRegex(LINK_AUTOLINK_BARE_URL_R),
507
+ _order: Priority.MAX,
508
+ _parse(capture) {
509
+ return {
510
+ children: [{
511
+ text: capture[1],
512
+ type: RuleType.text
513
+ }],
514
+ target: capture[1],
515
+ type: RuleType.link
516
+ };
517
+ }
518
+ },
519
+ [RuleType.newlineCoalescer]: {
520
+ _match: blockRegex(CONSECUTIVE_NEWLINE_R),
521
+ _order: Priority.LOW,
522
+ _parse: captureNothing,
523
+ _render() {
524
+ return "\n";
525
+ }
526
+ },
527
+ [RuleType.orderedList]: generateListRule(ORDERED),
528
+ [RuleType.unorderedList]: generateListRule(UNORDERED),
529
+ [RuleType.ref]: {
530
+ _qualify: ["["],
531
+ _match: anyScopeRegex(REFERENCE_IMAGE_OR_LINK),
532
+ _order: Priority.MAX,
533
+ _parse(capture) {
534
+ refs[capture[1]] = {
535
+ target: capture[2],
536
+ title: capture[4]
537
+ };
538
+ return {};
539
+ },
540
+ _render: renderNothing
541
+ },
542
+ [RuleType.refImage]: {
543
+ _qualify: ["!["],
544
+ _match: simpleInlineRegex(REFERENCE_IMAGE_R),
545
+ _order: Priority.MAX,
546
+ _parse(capture) {
547
+ return {
548
+ alt: capture[1] ? unescapeString(capture[1]) : void 0,
549
+ ref: capture[2]
550
+ };
551
+ },
552
+ _render(node, _, state = {}) {
553
+ const ref = refs[node.ref];
554
+ if (!ref) return null;
555
+ return createElement("img", {
556
+ key: state.key,
557
+ alt: node.alt,
558
+ src: sanitize(ref.target, "img", "src") ?? void 0,
559
+ title: ref.title
560
+ });
561
+ }
562
+ },
563
+ [RuleType.refLink]: {
564
+ _qualify: (source) => source[0] === "[" && source.indexOf("](") === -1,
565
+ _match: inlineRegex(REFERENCE_LINK_R),
566
+ _order: Priority.MAX,
567
+ _parse(capture, parse, state) {
568
+ return {
569
+ children: parseSimpleInline(parse, capture[1], state),
570
+ fallbackChildren: capture[0],
571
+ ref: capture[2]
572
+ };
573
+ },
574
+ _render(node, output, state = {}) {
575
+ const ref = refs[node.ref];
576
+ if (!ref) return createElement("span", { key: state.key }, node.fallbackChildren);
577
+ return createElement("a", {
578
+ key: state.key,
579
+ href: sanitize(ref.target, "a", "href") ?? void 0,
580
+ title: ref.title
581
+ }, output(node.children, state));
582
+ }
583
+ },
584
+ [RuleType.table]: {
585
+ _qualify: ["|"],
586
+ _match: blockRegex(NP_TABLE_R),
587
+ _order: Priority.HIGH,
588
+ _parse(capture, parse, state) {
589
+ state.inline = true;
590
+ const align = capture[2] ? parseTableAlign(capture[2]) : [];
591
+ const cells = capture[3] ? parseTableCells(capture[3], parse, state) : [];
592
+ const header = parseTableRow(capture[1], parse, state, !!cells.length);
593
+ state.inline = false;
594
+ return cells.length ? {
595
+ align,
596
+ cells,
597
+ header,
598
+ type: RuleType.table
599
+ } : {
600
+ children: header.flat(),
601
+ type: RuleType.paragraph
602
+ };
603
+ },
604
+ _render(node, output, state = {}) {
605
+ const table = node;
606
+ const getStyle = (i) => table.align[i] ? { textAlign: table.align[i] } : {};
607
+ return createElement("table", { key: state.key }, createElement("thead", null, createElement("tr", null, ...table.header.map((c, i) => createElement("th", {
608
+ key: i,
609
+ style: getStyle(i)
610
+ }, output(c, state))))), createElement("tbody", null, ...table.cells.map((row, i) => createElement("tr", { key: i }, ...row.map((c, j) => createElement("td", {
611
+ key: j,
612
+ style: getStyle(j)
613
+ }, output(c, state)))))));
614
+ }
615
+ },
616
+ [RuleType.tableSeparator]: {
617
+ _match: (source, state) => state.inTable && source[0] === "|" ? /^\|/.exec(source) : null,
618
+ _order: Priority.HIGH,
619
+ _parse() {
620
+ return { type: RuleType.tableSeparator };
621
+ },
622
+ _render() {
623
+ return " | ";
624
+ }
625
+ },
626
+ [RuleType.text]: {
627
+ _match: allowInline((source, _state) => {
628
+ const shortMatch = SHORTCODE_R.exec(source);
629
+ if (shortMatch) return shortMatch;
630
+ return TEXT_PLAIN_R.exec(source) || /^[\s\S]/.exec(source);
631
+ }),
632
+ _order: Priority.MIN,
633
+ _parse(capture) {
634
+ const text = capture[0];
635
+ return { text: text.indexOf("&") === -1 ? text : text.replace(HTML_CHAR_CODE_R, (f, i) => namedCodesToUnicode[i] || f) };
636
+ },
637
+ _render(node) {
638
+ return node.text;
639
+ }
640
+ },
641
+ [RuleType.textBolded]: {
642
+ _qualify: ["**", "__"],
643
+ _match: simpleInlineRegex(TEXT_BOLD_R),
644
+ _order: Priority.MED,
645
+ _parse(capture, parse, state) {
646
+ return { children: parse(capture[2], state) };
647
+ },
648
+ _render(node, output, state = {}) {
649
+ return createElement("strong", { key: state.key }, output(node.children, state));
650
+ }
651
+ },
652
+ [RuleType.textEmphasized]: {
653
+ _qualify: ["*", "_"],
654
+ _match: simpleInlineRegex(TEXT_EMPHASIZED_R),
655
+ _order: Priority.LOW,
656
+ _parse(capture, parse, state) {
657
+ return { children: parse(capture[2], state) };
658
+ },
659
+ _render(node, output, state = {}) {
660
+ return createElement("em", { key: state.key }, output(node.children, state));
661
+ }
662
+ },
663
+ [RuleType.textEscaped]: {
664
+ _qualify: ["\\"],
665
+ _match: simpleInlineRegex(TEXT_ESCAPED_R),
666
+ _order: Priority.HIGH,
667
+ _parse(capture) {
668
+ return {
669
+ text: capture[1],
670
+ type: RuleType.text
671
+ };
672
+ }
673
+ },
674
+ [RuleType.textMarked]: {
675
+ _qualify: ["=="],
676
+ _match: simpleInlineRegex(TEXT_MARKED_R),
677
+ _order: Priority.LOW,
678
+ _parse: parseCaptureInline,
679
+ _render(node, output, state = {}) {
680
+ return createElement("mark", { key: state.key }, output(node.children, state));
681
+ }
682
+ },
683
+ [RuleType.textStrikethroughed]: {
684
+ _qualify: ["~~"],
685
+ _match: simpleInlineRegex(TEXT_STRIKETHROUGHED_R),
686
+ _order: Priority.LOW,
687
+ _parse: parseCaptureInline,
688
+ _render(node, output, state = {}) {
689
+ return createElement("del", { key: state.key }, output(node.children, state));
690
+ }
691
+ }
692
+ };
693
+ };
694
+ const compilerCache = /* @__PURE__ */ new Map();
695
+ const compile = (markdown = "", ctx, options = {}) => {
696
+ const cacheKey = JSON.stringify({
697
+ markdown,
698
+ options,
699
+ components: ctx.components ? Object.keys(ctx.components) : []
700
+ });
701
+ if (compilerCache.has(cacheKey)) return compilerCache.get(cacheKey);
702
+ const components = ctx.components ?? {};
703
+ const slug = (input) => ctx.slugify ? ctx.slugify(input, slugify) : slugify(input);
704
+ const createElement = createElementFactory(ctx, options);
705
+ const footnotes = [];
706
+ const refs = {};
707
+ const attrStringToMap = (tag, str) => {
708
+ if (!str || !str.trim()) return null;
709
+ const attributes = str.match(ATTR_EXTRACTOR_R);
710
+ if (!attributes) return null;
711
+ return attributes.reduce((map, raw) => {
712
+ const delimiterIdx = raw.indexOf("=");
713
+ if (delimiterIdx !== -1) {
714
+ const key = normalizeAttributeKey(raw.slice(0, delimiterIdx)).trim();
715
+ const value = unquote(raw.slice(delimiterIdx + 1).trim());
716
+ const mappedKey = ATTRIBUTE_TO_NODE_PROP_MAP[key] ?? key;
717
+ if (mappedKey === "ref") return map;
718
+ map[mappedKey] = attributeValueToNodePropValue(tag, key, value, ctx.sanitizer ?? sanitizer);
719
+ if (typeof map[mappedKey] === "string" && (HTML_BLOCK_ELEMENT_R.test(map[mappedKey]) || HTML_SELF_CLOSING_ELEMENT_R.test(map[mappedKey]))) map[mappedKey] = compileInner(map[mappedKey].trim());
720
+ } else if (raw !== "style") map[ATTRIBUTE_TO_NODE_PROP_MAP[raw] ?? raw] = true;
721
+ return map;
722
+ }, {});
723
+ };
724
+ const nonParagraphBlockSyntaxes = [
725
+ BLOCKQUOTE_R,
726
+ CODE_BLOCK_FENCED_R,
727
+ CODE_BLOCK_R,
728
+ options.enforceAtxHeadings ? HEADING_ATX_COMPLIANT_R : HEADING_R,
729
+ HEADING_SETEXT_R,
730
+ NP_TABLE_R,
731
+ ORDERED_LIST_R,
732
+ UNORDERED_LIST_R
733
+ ];
734
+ const containsBlockSyntax = (input) => {
735
+ const cleaned = input.replace(TRIM_STARTING_NEWLINES, "");
736
+ const slice = cleaned.length > 2048 ? cleaned.slice(0, 2048) : cleaned;
737
+ return some(options.disableParsingRawHTML ? nonParagraphBlockSyntaxes : [
738
+ ...nonParagraphBlockSyntaxes,
739
+ PARAGRAPH_R,
740
+ HTML_BLOCK_ELEMENT_R,
741
+ HTML_COMMENT_R,
742
+ HTML_SELF_CLOSING_ELEMENT_R,
743
+ CUSTOM_COMPONENT_R
744
+ ], slice);
745
+ };
746
+ const baseRules = createRules(createElement, ctx, options, footnotes, refs, attrStringToMap, containsBlockSyntax, nonParagraphBlockSyntaxes);
747
+ const rules = options.disableParsingRawHTML ? Object.keys(baseRules).reduce((acc, key) => {
748
+ if (key !== RuleType.htmlBlock && key !== RuleType.htmlSelfClosing) acc[key] = baseRules[key];
749
+ return acc;
750
+ }, {}) : baseRules;
751
+ const parser = parserFor(rules);
752
+ const emitter = renderFor(createRenderer(rules, options.renderRule));
753
+ const compileInner = (input) => {
754
+ const result$1 = options.preserveFrontmatter ? input : input.replace(FRONT_MATTER_R, "");
755
+ const inline = options.forceInline || !options.forceBlock && SHOULD_RENDER_AS_BLOCK_R.test(result$1.replace(TRIM_STARTING_NEWLINES, "")) === false;
756
+ const arr = emitter(parser(inline ? result$1 : `${trimEnd(result$1).replace(TRIM_STARTING_NEWLINES, "")}\n\n`, { inline }), { inline });
757
+ while (typeof arr[arr.length - 1] === "string" && !arr[arr.length - 1].trim()) arr.pop();
758
+ if (options.wrapper === null) return arr;
759
+ const wrapper = options.wrapper ?? (inline ? "span" : "div");
760
+ if (arr.length > 1 || options.forceWrapper) return createElement(wrapper, { key: "outer" }, arr);
761
+ if (arr.length === 1) {
762
+ const node$1 = arr[0];
763
+ if (typeof node$1 === "string") {
764
+ const spanProps = { key: "outer" };
765
+ if (!inline && components) {
766
+ const pOverrideProps = get(components, "p.props", {}) ?? {};
767
+ const mergedClassName = cx(spanProps.className, pOverrideProps.className);
768
+ const finalSpanProps = {
769
+ ...spanProps,
770
+ ...pOverrideProps
771
+ };
772
+ if (mergedClassName) finalSpanProps.className = mergedClassName;
773
+ return createElement("span", finalSpanProps, node$1);
774
+ }
775
+ return createElement("span", spanProps, node$1);
776
+ }
777
+ return node$1;
778
+ }
779
+ return createElement(wrapper, { key: "outer" }, null);
780
+ };
781
+ if (typeof markdown !== "string") throw new Error("intlayer: the first argument must be a string");
782
+ const node = compileInner(markdown);
783
+ const result = footnotes.length ? createElement("div", null, node, createElement("footer", { key: "footer" }, ...footnotes.map((def) => createElement("div", {
784
+ id: slug(def.identifier),
785
+ key: def.identifier
786
+ }, def.identifier, emitter(parser(def.footnote, { inline: true }), { inline: true }))))) : node;
787
+ compilerCache.set(cacheKey, result);
788
+ return result;
789
+ };
790
+ const createCompiler = (ctx) => (markdown, options) => compile(markdown, ctx, options);
791
+ const compileWithOptions = (markdown, runtime, options = {}) => {
792
+ const { components, namedCodesToUnicode, sanitizer: sanitizer$1, slugify: slugify$1, ...compilerOptions } = options;
793
+ return compile(markdown, {
794
+ runtime,
795
+ components,
796
+ namedCodesToUnicode,
797
+ sanitizer: sanitizer$1,
798
+ slugify: slugify$1
799
+ }, compilerOptions);
800
+ };
801
+
802
+ //#endregion
803
+ export { compile, compileWithOptions, createCompiler };
804
+ //# sourceMappingURL=compiler.mjs.map