@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,806 @@
1
+ const require_markdown_constants = require('./constants.cjs');
2
+ const require_markdown_utils = require('./utils.cjs');
3
+ const require_markdown_parser = require('./parser.cjs');
4
+ const require_markdown_renderer = require('./renderer.cjs');
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 = require_markdown_utils.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 = require_markdown_utils.get(components, `${tag}.props`, {}) ?? {};
43
+ const className = require_markdown_utils.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, require_markdown_utils.slugify) : require_markdown_utils.slugify(input);
69
+ const sanitize = ctx.sanitizer ?? require_markdown_utils.sanitizer;
70
+ const namedCodesToUnicode = ctx.namedCodesToUnicode ? {
71
+ ...require_markdown_constants.NAMED_CODES_TO_UNICODE,
72
+ ...ctx.namedCodesToUnicode
73
+ } : require_markdown_constants.NAMED_CODES_TO_UNICODE;
74
+ const generateListRule = (type) => {
75
+ const ordered = type === require_markdown_constants.ORDERED;
76
+ const LIST_R = ordered ? require_markdown_constants.ORDERED_LIST_R : require_markdown_constants.UNORDERED_LIST_R;
77
+ const LIST_ITEM_R = ordered ? require_markdown_constants.ORDERED_LIST_ITEM_R : require_markdown_constants.UNORDERED_LIST_ITEM_R;
78
+ const LIST_ITEM_PREFIX_R = ordered ? require_markdown_constants.ORDERED_LIST_ITEM_PREFIX_R : require_markdown_constants.UNORDERED_LIST_ITEM_PREFIX_R;
79
+ return {
80
+ _qualify: (source) => LIST_ITEM_PREFIX_R.test(source),
81
+ _match: require_markdown_utils.allowInline((source, state) => {
82
+ const isStartOfLine = require_markdown_constants.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: require_markdown_constants.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(require_markdown_constants.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 = `${require_markdown_utils.trimEnd(content)}\n\n`;
118
+ } else {
119
+ state.inline = true;
120
+ adjustedContent = require_markdown_utils.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 (require_markdown_utils.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 = require_markdown_utils.trimEnd(match);
152
+ if (captured === "") return null;
153
+ return [
154
+ match,
155
+ void 0,
156
+ captured
157
+ ];
158
+ };
159
+ return {
160
+ [require_markdown_constants.RuleType.blockQuote]: {
161
+ _qualify: [">"],
162
+ _match: require_markdown_utils.blockRegex(require_markdown_constants.BLOCKQUOTE_R),
163
+ _order: require_markdown_constants.Priority.HIGH,
164
+ _parse(capture, parse, state) {
165
+ const matchAlert = capture[0].replace(require_markdown_constants.BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, "").match(require_markdown_constants.BLOCKQUOTE_ALERT_R);
166
+ const alert = matchAlert?.[1];
167
+ const content = matchAlert?.[2] ?? "";
168
+ return {
169
+ alert,
170
+ children: content.indexOf("\n") !== -1 ? require_markdown_utils.parseBlock(parse, content, state) : require_markdown_utils.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: require_markdown_constants.RuleType.text,
181
+ text: node.alert
182
+ }],
183
+ noInnerParse: true,
184
+ type: require_markdown_constants.RuleType.htmlBlock,
185
+ tag: "header"
186
+ });
187
+ }
188
+ return createElement("blockquote", props, output(node.children, state));
189
+ }
190
+ },
191
+ [require_markdown_constants.RuleType.breakLine]: {
192
+ _qualify: [" "],
193
+ _match: require_markdown_utils.anyScopeRegex(require_markdown_constants.BREAK_LINE_R),
194
+ _order: require_markdown_constants.Priority.HIGH,
195
+ _parse: require_markdown_utils.captureNothing,
196
+ _render(_, __, state = {}) {
197
+ return createElement("br", { key: state.key });
198
+ }
199
+ },
200
+ [require_markdown_constants.RuleType.breakThematic]: {
201
+ _qualify: [
202
+ "--",
203
+ "__",
204
+ "**",
205
+ "- ",
206
+ "* ",
207
+ "_ "
208
+ ],
209
+ _match: require_markdown_utils.blockRegex(require_markdown_constants.BREAK_THEMATIC_R),
210
+ _order: require_markdown_constants.Priority.HIGH,
211
+ _parse: require_markdown_utils.captureNothing,
212
+ _render(_, __, state = {}) {
213
+ return createElement("hr", { key: state.key });
214
+ }
215
+ },
216
+ [require_markdown_constants.RuleType.codeBlock]: {
217
+ _qualify: [" "],
218
+ _match: require_markdown_utils.blockRegex(require_markdown_constants.CODE_BLOCK_R),
219
+ _order: require_markdown_constants.Priority.MAX,
220
+ _parse(capture) {
221
+ return {
222
+ type: require_markdown_constants.RuleType.codeBlock,
223
+ lang: void 0,
224
+ text: require_markdown_utils.unescapeString(require_markdown_utils.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
+ [require_markdown_constants.RuleType.codeFenced]: {
236
+ _qualify: ["```", "~~~"],
237
+ _match: require_markdown_utils.blockRegex(require_markdown_constants.CODE_BLOCK_FENCED_R),
238
+ _order: require_markdown_constants.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: require_markdown_constants.RuleType.codeBlock
245
+ };
246
+ }
247
+ },
248
+ [require_markdown_constants.RuleType.codeInline]: {
249
+ _qualify: ["`"],
250
+ _match: require_markdown_utils.simpleInlineRegex(require_markdown_constants.CODE_INLINE_R),
251
+ _order: require_markdown_constants.Priority.LOW,
252
+ _parse(capture) {
253
+ return { text: require_markdown_utils.unescapeString(capture[2]) };
254
+ },
255
+ _render(node, _, state = {}) {
256
+ return createElement("code", { key: state.key }, node.text);
257
+ }
258
+ },
259
+ [require_markdown_constants.RuleType.footnote]: {
260
+ _qualify: ["[^"],
261
+ _match: require_markdown_utils.blockRegex(require_markdown_constants.FOOTNOTE_R),
262
+ _order: require_markdown_constants.Priority.MAX,
263
+ _parse(capture) {
264
+ footnotes.push({
265
+ footnote: capture[2],
266
+ identifier: capture[1]
267
+ });
268
+ return {};
269
+ },
270
+ _render: require_markdown_utils.renderNothing
271
+ },
272
+ [require_markdown_constants.RuleType.footnoteReference]: {
273
+ _qualify: ["[^"],
274
+ _match: require_markdown_utils.inlineRegex(require_markdown_constants.FOOTNOTE_REFERENCE_R),
275
+ _order: require_markdown_constants.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
+ [require_markdown_constants.RuleType.gfmTask]: {
290
+ _qualify: ["[ ]", "[x]"],
291
+ _match: require_markdown_utils.inlineRegex(require_markdown_constants.GFM_TASK_R),
292
+ _order: require_markdown_constants.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
+ [require_markdown_constants.RuleType.heading]: {
306
+ _qualify: ["#"],
307
+ _match: require_markdown_utils.blockRegex(options.enforceAtxHeadings ? require_markdown_constants.HEADING_ATX_COMPLIANT_R : require_markdown_constants.HEADING_R),
308
+ _order: require_markdown_constants.Priority.HIGH,
309
+ _parse(capture, parse, state) {
310
+ return {
311
+ children: require_markdown_utils.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
+ [require_markdown_constants.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: require_markdown_utils.blockRegex(require_markdown_constants.HEADING_SETEXT_R),
329
+ _order: require_markdown_constants.Priority.MAX,
330
+ _parse(capture, parse, state) {
331
+ return {
332
+ children: require_markdown_utils.parseInline(parse, capture[1], state),
333
+ level: capture[2] === "=" ? 1 : 2,
334
+ type: require_markdown_constants.RuleType.heading
335
+ };
336
+ }
337
+ },
338
+ [require_markdown_constants.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: require_markdown_utils.anyScopeRegex(require_markdown_constants.HTML_BLOCK_ELEMENT_R),
349
+ _order: require_markdown_constants.Priority.HIGH,
350
+ _parse(capture, parse, state) {
351
+ const whitespace = capture[3].match(require_markdown_constants.HTML_LEFT_TRIM_AMOUNT_R)?.[1] ?? "";
352
+ const trimmed = require_markdown_utils.trimLeadingWhitespaceOutsideFences(capture[3], whitespace);
353
+ const parseFunc = containsBlockSyntax(trimmed) ? require_markdown_utils.parseBlock : require_markdown_utils.parseInline;
354
+ const tagName = capture[1].toLowerCase();
355
+ const noInnerParse = require_markdown_constants.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
+ [require_markdown_constants.RuleType.htmlComment]: {
381
+ _qualify: ["<!"],
382
+ _match: require_markdown_utils.anyScopeRegex(require_markdown_constants.HTML_COMMENT_R),
383
+ _order: require_markdown_constants.Priority.HIGH,
384
+ _parse: require_markdown_utils.captureNothing,
385
+ _render: require_markdown_utils.renderNothing
386
+ },
387
+ [require_markdown_constants.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: require_markdown_utils.anyScopeRegex(require_markdown_constants.HTML_SELF_CLOSING_ELEMENT_R),
394
+ _order: require_markdown_constants.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
+ [require_markdown_constants.RuleType.customComponent]: {
410
+ _qualify: (source) => source[0] === "<" && /^ *<([A-Z][a-zA-Z0-9]*)/.test(source),
411
+ _match: require_markdown_utils.blockRegex(require_markdown_constants.CUSTOM_COMPONENT_R),
412
+ _order: require_markdown_constants.Priority.MAX,
413
+ _parse(capture, parse, state) {
414
+ const whitespace = capture[3].match(require_markdown_constants.HTML_LEFT_TRIM_AMOUNT_R)?.[1] ?? "";
415
+ const trimmed = require_markdown_utils.trimLeadingWhitespaceOutsideFences(capture[3], whitespace);
416
+ const parseFunc = containsBlockSyntax(trimmed) ? require_markdown_utils.parseBlock : require_markdown_utils.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
+ [require_markdown_constants.RuleType.paragraph]: {
437
+ _match: matchParagraph,
438
+ _order: require_markdown_constants.Priority.LOW,
439
+ _parse: require_markdown_utils.parseCaptureInline,
440
+ _render(node, output, state = {}) {
441
+ return createElement("p", { key: state.key }, output(node.children, state));
442
+ }
443
+ },
444
+ [require_markdown_constants.RuleType.image]: {
445
+ _qualify: ["!["],
446
+ _match: require_markdown_utils.simpleInlineRegex(IMAGE_R),
447
+ _order: require_markdown_constants.Priority.HIGH,
448
+ _parse(capture) {
449
+ return {
450
+ alt: require_markdown_utils.unescapeString(capture[1]),
451
+ target: require_markdown_utils.unescapeString(capture[2]),
452
+ title: require_markdown_utils.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
+ [require_markdown_constants.RuleType.link]: {
465
+ _qualify: ["["],
466
+ _match: require_markdown_utils.inlineRegex(LINK_R),
467
+ _order: require_markdown_constants.Priority.LOW,
468
+ _parse(capture, parse, state) {
469
+ return {
470
+ children: require_markdown_utils.parseSimpleInline(parse, capture[1], state),
471
+ target: require_markdown_utils.unescapeString(capture[2]),
472
+ title: require_markdown_utils.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
+ [require_markdown_constants.RuleType.linkAngleBraceStyleDetector]: {
484
+ _qualify: ["<"],
485
+ _match: require_markdown_utils.inlineRegex(require_markdown_constants.LINK_AUTOLINK_R),
486
+ _order: require_markdown_constants.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: require_markdown_constants.RuleType.text
498
+ }],
499
+ target: isEmail ? `mailto:${target}` : target,
500
+ type: require_markdown_constants.RuleType.link
501
+ };
502
+ }
503
+ },
504
+ [require_markdown_constants.RuleType.linkBareUrlDetector]: {
505
+ _qualify: (source, state) => !!(state.inline && !state.inAnchor && !options.disableAutoLink && (require_markdown_utils.startsWith(source, "http://") || require_markdown_utils.startsWith(source, "https://"))),
506
+ _match: require_markdown_utils.inlineRegex(require_markdown_constants.LINK_AUTOLINK_BARE_URL_R),
507
+ _order: require_markdown_constants.Priority.MAX,
508
+ _parse(capture) {
509
+ return {
510
+ children: [{
511
+ text: capture[1],
512
+ type: require_markdown_constants.RuleType.text
513
+ }],
514
+ target: capture[1],
515
+ type: require_markdown_constants.RuleType.link
516
+ };
517
+ }
518
+ },
519
+ [require_markdown_constants.RuleType.newlineCoalescer]: {
520
+ _match: require_markdown_utils.blockRegex(require_markdown_constants.CONSECUTIVE_NEWLINE_R),
521
+ _order: require_markdown_constants.Priority.LOW,
522
+ _parse: require_markdown_utils.captureNothing,
523
+ _render() {
524
+ return "\n";
525
+ }
526
+ },
527
+ [require_markdown_constants.RuleType.orderedList]: generateListRule(require_markdown_constants.ORDERED),
528
+ [require_markdown_constants.RuleType.unorderedList]: generateListRule(require_markdown_constants.UNORDERED),
529
+ [require_markdown_constants.RuleType.ref]: {
530
+ _qualify: ["["],
531
+ _match: require_markdown_utils.anyScopeRegex(require_markdown_constants.REFERENCE_IMAGE_OR_LINK),
532
+ _order: require_markdown_constants.Priority.MAX,
533
+ _parse(capture) {
534
+ refs[capture[1]] = {
535
+ target: capture[2],
536
+ title: capture[4]
537
+ };
538
+ return {};
539
+ },
540
+ _render: require_markdown_utils.renderNothing
541
+ },
542
+ [require_markdown_constants.RuleType.refImage]: {
543
+ _qualify: ["!["],
544
+ _match: require_markdown_utils.simpleInlineRegex(require_markdown_constants.REFERENCE_IMAGE_R),
545
+ _order: require_markdown_constants.Priority.MAX,
546
+ _parse(capture) {
547
+ return {
548
+ alt: capture[1] ? require_markdown_utils.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
+ [require_markdown_constants.RuleType.refLink]: {
564
+ _qualify: (source) => source[0] === "[" && source.indexOf("](") === -1,
565
+ _match: require_markdown_utils.inlineRegex(require_markdown_constants.REFERENCE_LINK_R),
566
+ _order: require_markdown_constants.Priority.MAX,
567
+ _parse(capture, parse, state) {
568
+ return {
569
+ children: require_markdown_utils.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
+ [require_markdown_constants.RuleType.table]: {
585
+ _qualify: ["|"],
586
+ _match: require_markdown_utils.blockRegex(require_markdown_constants.NP_TABLE_R),
587
+ _order: require_markdown_constants.Priority.HIGH,
588
+ _parse(capture, parse, state) {
589
+ state.inline = true;
590
+ const align = capture[2] ? require_markdown_utils.parseTableAlign(capture[2]) : [];
591
+ const cells = capture[3] ? require_markdown_utils.parseTableCells(capture[3], parse, state) : [];
592
+ const header = require_markdown_utils.parseTableRow(capture[1], parse, state, !!cells.length);
593
+ state.inline = false;
594
+ return cells.length ? {
595
+ align,
596
+ cells,
597
+ header,
598
+ type: require_markdown_constants.RuleType.table
599
+ } : {
600
+ children: header.flat(),
601
+ type: require_markdown_constants.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
+ [require_markdown_constants.RuleType.tableSeparator]: {
617
+ _match: (source, state) => state.inTable && source[0] === "|" ? /^\|/.exec(source) : null,
618
+ _order: require_markdown_constants.Priority.HIGH,
619
+ _parse() {
620
+ return { type: require_markdown_constants.RuleType.tableSeparator };
621
+ },
622
+ _render() {
623
+ return " | ";
624
+ }
625
+ },
626
+ [require_markdown_constants.RuleType.text]: {
627
+ _match: require_markdown_utils.allowInline((source, _state) => {
628
+ const shortMatch = require_markdown_constants.SHORTCODE_R.exec(source);
629
+ if (shortMatch) return shortMatch;
630
+ return require_markdown_constants.TEXT_PLAIN_R.exec(source) || /^[\s\S]/.exec(source);
631
+ }),
632
+ _order: require_markdown_constants.Priority.MIN,
633
+ _parse(capture) {
634
+ const text = capture[0];
635
+ return { text: text.indexOf("&") === -1 ? text : text.replace(require_markdown_constants.HTML_CHAR_CODE_R, (f, i) => namedCodesToUnicode[i] || f) };
636
+ },
637
+ _render(node) {
638
+ return node.text;
639
+ }
640
+ },
641
+ [require_markdown_constants.RuleType.textBolded]: {
642
+ _qualify: ["**", "__"],
643
+ _match: require_markdown_utils.simpleInlineRegex(require_markdown_constants.TEXT_BOLD_R),
644
+ _order: require_markdown_constants.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
+ [require_markdown_constants.RuleType.textEmphasized]: {
653
+ _qualify: ["*", "_"],
654
+ _match: require_markdown_utils.simpleInlineRegex(require_markdown_constants.TEXT_EMPHASIZED_R),
655
+ _order: require_markdown_constants.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
+ [require_markdown_constants.RuleType.textEscaped]: {
664
+ _qualify: ["\\"],
665
+ _match: require_markdown_utils.simpleInlineRegex(require_markdown_constants.TEXT_ESCAPED_R),
666
+ _order: require_markdown_constants.Priority.HIGH,
667
+ _parse(capture) {
668
+ return {
669
+ text: capture[1],
670
+ type: require_markdown_constants.RuleType.text
671
+ };
672
+ }
673
+ },
674
+ [require_markdown_constants.RuleType.textMarked]: {
675
+ _qualify: ["=="],
676
+ _match: require_markdown_utils.simpleInlineRegex(require_markdown_constants.TEXT_MARKED_R),
677
+ _order: require_markdown_constants.Priority.LOW,
678
+ _parse: require_markdown_utils.parseCaptureInline,
679
+ _render(node, output, state = {}) {
680
+ return createElement("mark", { key: state.key }, output(node.children, state));
681
+ }
682
+ },
683
+ [require_markdown_constants.RuleType.textStrikethroughed]: {
684
+ _qualify: ["~~"],
685
+ _match: require_markdown_utils.simpleInlineRegex(require_markdown_constants.TEXT_STRIKETHROUGHED_R),
686
+ _order: require_markdown_constants.Priority.LOW,
687
+ _parse: require_markdown_utils.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, require_markdown_utils.slugify) : require_markdown_utils.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(require_markdown_constants.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 = require_markdown_utils.normalizeAttributeKey(raw.slice(0, delimiterIdx)).trim();
715
+ const value = require_markdown_utils.unquote(raw.slice(delimiterIdx + 1).trim());
716
+ const mappedKey = require_markdown_constants.ATTRIBUTE_TO_NODE_PROP_MAP[key] ?? key;
717
+ if (mappedKey === "ref") return map;
718
+ map[mappedKey] = require_markdown_utils.attributeValueToNodePropValue(tag, key, value, ctx.sanitizer ?? require_markdown_utils.sanitizer);
719
+ if (typeof map[mappedKey] === "string" && (require_markdown_constants.HTML_BLOCK_ELEMENT_R.test(map[mappedKey]) || require_markdown_constants.HTML_SELF_CLOSING_ELEMENT_R.test(map[mappedKey]))) map[mappedKey] = compileInner(map[mappedKey].trim());
720
+ } else if (raw !== "style") map[require_markdown_constants.ATTRIBUTE_TO_NODE_PROP_MAP[raw] ?? raw] = true;
721
+ return map;
722
+ }, {});
723
+ };
724
+ const nonParagraphBlockSyntaxes = [
725
+ require_markdown_constants.BLOCKQUOTE_R,
726
+ require_markdown_constants.CODE_BLOCK_FENCED_R,
727
+ require_markdown_constants.CODE_BLOCK_R,
728
+ options.enforceAtxHeadings ? require_markdown_constants.HEADING_ATX_COMPLIANT_R : require_markdown_constants.HEADING_R,
729
+ require_markdown_constants.HEADING_SETEXT_R,
730
+ require_markdown_constants.NP_TABLE_R,
731
+ require_markdown_constants.ORDERED_LIST_R,
732
+ require_markdown_constants.UNORDERED_LIST_R
733
+ ];
734
+ const containsBlockSyntax = (input) => {
735
+ const cleaned = input.replace(require_markdown_constants.TRIM_STARTING_NEWLINES, "");
736
+ const slice = cleaned.length > 2048 ? cleaned.slice(0, 2048) : cleaned;
737
+ return require_markdown_utils.some(options.disableParsingRawHTML ? nonParagraphBlockSyntaxes : [
738
+ ...nonParagraphBlockSyntaxes,
739
+ require_markdown_constants.PARAGRAPH_R,
740
+ require_markdown_constants.HTML_BLOCK_ELEMENT_R,
741
+ require_markdown_constants.HTML_COMMENT_R,
742
+ require_markdown_constants.HTML_SELF_CLOSING_ELEMENT_R,
743
+ require_markdown_constants.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 !== require_markdown_constants.RuleType.htmlBlock && key !== require_markdown_constants.RuleType.htmlSelfClosing) acc[key] = baseRules[key];
749
+ return acc;
750
+ }, {}) : baseRules;
751
+ const parser = require_markdown_parser.parserFor(rules);
752
+ const emitter = require_markdown_renderer.renderFor(require_markdown_renderer.createRenderer(rules, options.renderRule));
753
+ const compileInner = (input) => {
754
+ const result$1 = options.preserveFrontmatter ? input : input.replace(require_markdown_constants.FRONT_MATTER_R, "");
755
+ const inline = options.forceInline || !options.forceBlock && require_markdown_constants.SHOULD_RENDER_AS_BLOCK_R.test(result$1.replace(require_markdown_constants.TRIM_STARTING_NEWLINES, "")) === false;
756
+ const arr = emitter(parser(inline ? result$1 : `${require_markdown_utils.trimEnd(result$1).replace(require_markdown_constants.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 = require_markdown_utils.get(components, "p.props", {}) ?? {};
767
+ const mergedClassName = require_markdown_utils.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 (process.env.NODE_ENV !== "production" && 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
+ exports.compile = compile;
804
+ exports.compileWithOptions = compileWithOptions;
805
+ exports.createCompiler = createCompiler;
806
+ //# sourceMappingURL=compiler.cjs.map