@intlayer/core 9.5.3 → 9.5.4
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/README.md +8 -8
- package/dist/cjs/markdown/compiler.cjs +18 -1
- package/dist/cjs/markdown/compiler.cjs.map +1 -1
- package/dist/cjs/markdown/constants.cjs +0 -1
- package/dist/cjs/markdown/constants.cjs.map +1 -1
- package/dist/esm/markdown/compiler.mjs +18 -1
- package/dist/esm/markdown/compiler.mjs.map +1 -1
- package/dist/esm/markdown/constants.mjs +0 -1
- package/dist/esm/markdown/constants.mjs.map +1 -1
- package/dist/types/markdown/compiler.d.ts.map +1 -1
- package/dist/types/markdown/constants.d.ts.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<a href="https://intlayer.org" rel="">
|
|
3
|
-
<img src="https://raw.githubusercontent.com/aymericzip/intlayer/main/docs/assets/cover.
|
|
3
|
+
<img src="https://raw.githubusercontent.com/aymericzip/intlayer/main/docs/assets/cover.webp" width="60%" alt="Intlayer Logo" />
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
@@ -49,10 +49,10 @@ With **per-locale content files**, **TypeScript autocompletion**, **tree-shakabl
|
|
|
49
49
|
|
|
50
50
|
| Feature | Description |
|
|
51
51
|
| --------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
52
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.
|
|
52
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.webp?raw=true" alt="Feature" width="700"> | **Cross-Frameworks Support**<br><br>Intlayer is compatible with all major frameworks and libraries, including Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, and more. |
|
|
53
53
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.jpg?raw=true" alt="Feature" width="700"> | **JavaScript-Powered Content Management**<br><br>Harness the flexibility of JavaScript to define and manage your content efficiently. <br><br> - [Content declaration](https://intlayer.org/doc/concept/content) |
|
|
54
54
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/per_locale_content_declaration_file.png?raw=true" alt="Feature" width="700"> | **Per-Locale Content Declaration File**<br><br>Speed up your development by declaring your content once, before auto generation.<br><br> - [Per-Locale Content Declaration File](https://intlayer.org/doc/concept/per-locale-file) |
|
|
55
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/compiler.
|
|
55
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/compiler.webp?raw=true" alt="Feature" width="700"> | **Compiler**<br><br>The Intlayer Compiler extract automatically the content from the components and generate the dictionary files.<br><br> - [Compiler](https://intlayer.org/doc/compiler) |
|
|
56
56
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true" alt="Feature" width="700"> | **Type-Safe Environment**<br><br>Leverage TypeScript to ensure your content definitions and code are error-free, while also benefiting from IDE autocompletion.<br><br> - [TypeScript configuration](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
|
|
57
57
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/config_file.png?raw=true" alt="Feature" width="700"> | **Simplified Setup**<br><br>Get up and running quickly with minimal configuration. Adjust settings for internationalization, routing, AI, build, and content handling with ease. <br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
58
58
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/content_retrieval.png?raw=true" alt="Feature" width="700"> | **Simplified Content Retrieval**<br><br>No need to call your `t` function for each piece of content. Retrieve all your content directly using a single hook.<br><br> - [React integration](https://intlayer.org/doc/environment/create-react-app) |
|
|
@@ -60,12 +60,12 @@ With **per-locale content files**, **TypeScript autocompletion**, **tree-shakabl
|
|
|
60
60
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/file_tree.png?raw=true" alt="Feature" width="700"> | **Organized Codebase**<br><br>Keep your codebase more organized: 1 component = 1 dictionary in the same folder. Translations close to their respective components, enhance maintainability and clarity. <br><br> - [How Intlayer works](https://intlayer.org/doc/concept/how-works-intlayer) |
|
|
61
61
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/url_routing.png?raw=true" alt="Feature" width="700"> | **Enhanced Routing**<br><br>Full support of app routing, adapting seamlessly to complex application structures, for Next.js, React, Vite, Vue.js, etc.<br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
62
62
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/markdown.png?raw=true" alt="Feature" width="700"> | **Markdown Support**<br><br>Import and interpret, locale files and remote Markdown for multilingual content like privacy policies, documentation, etc. Interpret and make Markdown metadata accessible in your code.<br><br> - [Content files](https://intlayer.org/doc/concept/content/file) |
|
|
63
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/visual_editor.
|
|
64
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/bundle.
|
|
65
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/static_rendering.
|
|
63
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/visual_editor.webp?raw=true" alt="Feature" width="700"> | **Free Visual Editor & CMS**<br><br>A free visual editor and CMS are available for content writers, removing the need for a localization platform. Keep your content synchronized using Git, or externalize it totally or partially with the CMS.<br><br> - [Intlayer Editor](https://intlayer.org/doc/concept/editor) <br> - [Intlayer CMS](https://intlayer.org/doc/concept/cms) |
|
|
64
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/bundle.webp?raw=true" alt="Feature" width="700"> | **Tree-shakable Content**<br><br>Tree-shakable content, reducing the size of the final bundle. Loads content per component, excluding any unused content from your bundle. Supports lazy loading to enhance app loading efficiency. <br><br> - [App build optimization](https://intlayer.org/doc/concept/how-works-intlayer#app-build-optimization) |
|
|
65
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/static_rendering.webp?raw=true" alt="Feature" width="700"> | **Static Rendering**<br><br>Doesn't block Static Rendering. <br><br> - [Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
66
66
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/AI_translation.png?raw=true" alt="Feature" width="700"> | **AI-Powered Translation**<br><br>Transform your website into 231 languages with just one click using Intlayer's advanced AI-powered translation tools using your own AI provider / API key. <br><br> - [CI/CD integration](https://intlayer.org/doc/concept/ci-cd) <br> - [Intlayer CLI](https://intlayer.org/doc/concept/cli) <br> - [Auto fill](https://intlayer.org/doc/concept/auto-fill) |
|
|
67
67
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/mcp.png?raw=true" alt="Feature" width="700"> | **MCP Server Integration**<br><br>Provides an MCP (Model Context Protocol) server for IDE automation, enabling seamless content management and i18n workflows directly within your development environment. <br><br> - [MCP Server](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/mcp_server.md) |
|
|
68
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/vscode_extension.
|
|
68
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/vscode_extension.webp?raw=true" alt="Feature" width="700"> | **VSCode Extension**<br><br>Intlayer provides a VSCode extension to help you manage your content and translations, building your dictionaries, translating your content, and more. <br><br> - [VSCode Extension](https://intlayer.org/doc/vs-code-extension) |
|
|
69
69
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/interoperability.png?raw=true" alt="Feature" width="700"> | **Interoperability**<br><br>Allow interoperability with react-i18next, next-i18next, next-intl, react-intl, vue-i18n. <br><br> - [Intlayer and react-intl](https://intlayer.org/blog/intlayer-with-react-intl) <br> - [Intlayer and next-intl](https://intlayer.org/blog/intlayer-with-next-intl) <br> - [Intlayer and next-i18next](https://intlayer.org/blog/intlayer-with-next-i18next) <br> - [Intlayer and vue-i18n](https://intlayer.org/blog/intlayer-with-vue-i18n) <br> - [Intlayer compat adapters](https://intlayer.org/doc/compatibility) |
|
|
70
70
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/benchmark.png?raw=true" alt="Feature" width="700"> | **Performances & Benchmark**<br><br>Uses advanced tree-shaking and dynamic loading to boost performances and keep the solution as light as possible. <br><br> - [Performances & Benchmark](https://intlayer.org/doc/benchmark) |
|
|
71
71
|
|
|
@@ -262,7 +262,7 @@ Intlayer connects **developers**, **copywriters**, and **AI agents** in one work
|
|
|
262
262
|
- Feature flags
|
|
263
263
|
- Headless CMSs (e.g. Contentful, Strapi, Sanity)
|
|
264
264
|
|
|
265
|
-

|
|
266
266
|
|
|
267
267
|
## 🌐 Readme in other languages
|
|
268
268
|
|
|
@@ -179,9 +179,26 @@ const createRules = (createElement, ctx, options, scope, attrStringToMap, contai
|
|
|
179
179
|
* things only real HTML needs — the never-parse element list, and tracking
|
|
180
180
|
* whether we are inside an anchor.
|
|
181
181
|
*/
|
|
182
|
+
/**
|
|
183
|
+
* Whether `source` opens an element at the start of a block line, allowing
|
|
184
|
+
* the up-to-three-space indentation CommonMark grants to HTML blocks.
|
|
185
|
+
*
|
|
186
|
+
* The scanner already skips leading spaces, but the dispatch only handed it
|
|
187
|
+
* sources starting with `<`. An indented ` <Tab>` inside a `<Tabs>` block
|
|
188
|
+
* then fell through to the paragraph rule, which swallowed the opening tag
|
|
189
|
+
* as inline HTML and lost every sibling that followed it.
|
|
190
|
+
*/
|
|
191
|
+
const qualifiesPairedElement = (source, state) => {
|
|
192
|
+
if (source.charCodeAt(0) === 60) return true;
|
|
193
|
+
if (!(!state.inline && !state.simple && state.prevCaptureIndent !== void 0)) return false;
|
|
194
|
+
let index = 0;
|
|
195
|
+
while (index < 3 && source.charCodeAt(index) === 32) index++;
|
|
196
|
+
return index > 0 && source.charCodeAt(index) === 60;
|
|
197
|
+
};
|
|
182
198
|
const pairedElementRule = (match, order, rawHtml, scope = require_markdown_constants.SCOPE_BOTH) => ({
|
|
183
199
|
_scope: scope,
|
|
184
|
-
|
|
200
|
+
_firstChars: [60, 32],
|
|
201
|
+
_qualify: qualifiesPairedElement,
|
|
185
202
|
_match: require_markdown_utils.anyScopeRegex(match),
|
|
186
203
|
_order: order,
|
|
187
204
|
_parse(capture, parse, state) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.cjs","names":["get","defaultSlugify","cx","parserFor","renderFor","createRenderer","defaultSanitizer","NAMED_CODES_TO_UNICODE","SCOPE_BOTH","anyScopeRegex","HTML_LEFT_TRIM_AMOUNT_R","trimLeadingWhitespaceOutsideFences","parseBlock","parseInline","DO_NOT_PROCESS_HTML_ELEMENTS","ORDERED_LIST_R","UNORDERED_LIST_R","ORDERED_LIST_ITEM_R","UNORDERED_LIST_ITEM_R","ORDERED_LIST_ITEM_PREFIX_R","UNORDERED_LIST_ITEM_PREFIX_R","allowInline","Priority","BLOCK_END_R","trimEnd","some","RuleType","SCOPE_BLOCK","blockRegex","BLOCKQUOTE_R","BLOCKQUOTE_TRIM_LEFT_MULTILINE_R","BLOCKQUOTE_ALERT_R","BREAK_LINE_R","captureNothing","BREAK_THEMATIC_R","CODE_BLOCK_R","unescapeString","CODE_BLOCK_FENCED_R","SCOPE_INLINE","simpleInlineRegex","CODE_INLINE_R","FOOTNOTE_R","renderNothing","inlineRegex","FOOTNOTE_REFERENCE_R","GFM_TASK_R","HEADING_ATX_COMPLIANT_R","HEADING_R","HEADING_SETEXT_R","matchHtmlBlockElement","HTML_COMMENT_R","matchSelfClosingElement","matchCustomComponent","parseCaptureInline","parseSimpleInline","LINK_AUTOLINK_R","startsWith","LINK_AUTOLINK_BARE_URL_R","CONSECUTIVE_NEWLINE_R","REFERENCE_IMAGE_OR_LINK","REFERENCE_IMAGE_R","REFERENCE_LINK_R","NP_TABLE_R","parseTableAlign","parseTableCells","parseTableRow","SHORTCODE_R","HTML_CHAR_CODE_R","TEXT_BOLD_R","TEXT_EMPHASIZED_R","TEXT_ESCAPED_R","TEXT_MARKED_R","TEXT_STRIKETHROUGHED_R","ATTR_EXTRACTOR_R","normalizeAttributeKey","unquote","ATTRIBUTE_TO_NODE_PROP_MAP","attributeValueToNodePropValue","startsWithElement","startsWithCustomComponent","PARAGRAPH_R","startsWithHtmlBlockElement","startsWithSelfClosingElement","TRIM_STARTING_NEWLINES","FRONT_MATTER_R","SHOULD_RENDER_AS_BLOCK_R"],"sources":["../../../src/markdown/compiler.ts"],"sourcesContent":["import {\n ATTR_EXTRACTOR_R,\n ATTRIBUTE_TO_NODE_PROP_MAP,\n BLOCK_END_R,\n BLOCKQUOTE_ALERT_R,\n BLOCKQUOTE_R,\n BLOCKQUOTE_TRIM_LEFT_MULTILINE_R,\n BREAK_LINE_R,\n BREAK_THEMATIC_R,\n CODE_BLOCK_FENCED_R,\n CODE_BLOCK_R,\n CODE_INLINE_R,\n CONSECUTIVE_NEWLINE_R,\n DO_NOT_PROCESS_HTML_ELEMENTS,\n FOOTNOTE_R,\n FOOTNOTE_REFERENCE_R,\n FRONT_MATTER_R,\n GFM_TASK_R,\n HEADING_ATX_COMPLIANT_R,\n HEADING_R,\n HEADING_SETEXT_R,\n HTML_CHAR_CODE_R,\n HTML_COMMENT_R,\n HTML_LEFT_TRIM_AMOUNT_R,\n LINK_AUTOLINK_BARE_URL_R,\n LINK_AUTOLINK_R,\n type ListType,\n NAMED_CODES_TO_UNICODE,\n NP_TABLE_R,\n ORDERED,\n ORDERED_LIST_ITEM_PREFIX_R,\n ORDERED_LIST_ITEM_R,\n ORDERED_LIST_R,\n PARAGRAPH_R,\n Priority,\n REFERENCE_IMAGE_OR_LINK,\n REFERENCE_IMAGE_R,\n REFERENCE_LINK_R,\n type RuleScopeValue,\n RuleType,\n SCOPE_BLOCK,\n SCOPE_BOTH,\n SCOPE_INLINE,\n SHORTCODE_R,\n SHOULD_RENDER_AS_BLOCK_R,\n TEXT_BOLD_R,\n TEXT_EMPHASIZED_R,\n TEXT_ESCAPED_R,\n TEXT_MARKED_R,\n TEXT_STRIKETHROUGHED_R,\n TRIM_STARTING_NEWLINES,\n UNORDERED,\n UNORDERED_LIST_ITEM_PREFIX_R,\n UNORDERED_LIST_ITEM_R,\n UNORDERED_LIST_R,\n} from './constants';\nimport {\n matchCustomComponent,\n matchHtmlBlockElement,\n matchSelfClosingElement,\n startsWithCustomComponent,\n startsWithElement,\n startsWithHtmlBlockElement,\n startsWithSelfClosingElement,\n} from './elementScanner';\nimport { parserFor } from './parser';\nimport { createRenderer, renderFor } from './renderer';\nimport type {\n CompileOptions,\n ComponentOverrides as ComponentDefinition,\n HeadingNode,\n HTMLTag,\n MarkdownContext,\n MarkdownOptions,\n MarkdownRuntime,\n OrderedListNode,\n ParseState,\n Rule,\n Rules,\n TableNode,\n UnorderedListNode,\n} from './types';\nimport {\n allowInline,\n anyScopeRegex,\n attributeValueToNodePropValue,\n type BlockSyntaxProbe,\n blockRegex,\n captureNothing,\n cx,\n sanitizer as defaultSanitizer,\n slugify as defaultSlugify,\n get,\n inlineRegex,\n normalizeAttributeKey,\n parseBlock,\n parseCaptureInline,\n parseInline,\n parseSimpleInline,\n parseTableAlign,\n parseTableCells,\n parseTableRow,\n renderNothing,\n simpleInlineRegex,\n some,\n startsWith,\n trimEnd,\n trimLeadingWhitespaceOutsideFences,\n unescapeString,\n unquote,\n} from './utils';\n\ntype CreateElementFunction = (\n tag: any,\n props: Record<string, any> | null,\n ...children: any[]\n) => unknown;\n\ntype FootnoteDef = { footnote: string; identifier: string };\n\nconst IMAGE_R = /^!\\[(.*?)\\]\\( *((?:\\([^)]*\\)|[^() ])*) *\"?([^)\"]*)?\"?\\)/;\nconst LINK_INSIDE =\n '(?:\\\\[[^\\\\[\\\\]]*(?:\\\\[[^\\\\[\\\\]]*\\\\][^\\\\[\\\\]]*)*\\\\]|[^\\\\[\\\\]])*';\nconst LINK_HREF_AND_TITLE =\n '\\\\s*<?((?:\\\\([^)]*\\\\)|[^\\\\s\\\\\\\\]|\\\\\\\\.)*?)>?(?:\\\\s+[\\'\"]([\\\\s\\\\S]*?)[\\'\"])?\\\\s*';\nconst LINK_R = new RegExp(\n `^\\\\[(${LINK_INSIDE})\\\\]\\\\(${LINK_HREF_AND_TITLE}\\\\)`\n);\n\n/**\n * Case-insensitive `</tag>` probes, cached per tag name.\n *\n * The `htmlBlock` rule is qualified at every candidate position, and it used to\n * lowercase the whole remaining document to look its closing tag up — copying\n * the rest of the file on each probe.\n */\n/**\n * Builds a tag -> component resolver for one set of overrides.\n *\n * The case-insensitive fallback used to rescan every override key on each\n * element created; the lowercase index is now built once per document instead.\n */\nconst createTagResolver = (components: ComponentDefinition<any>) => {\n let lowercaseKeys: Map<string, string> | null = null;\n\n // With no overrides declared — the common case — every tag resolves to\n // itself, so the whole lookup is skipped.\n if (Object.keys(components).length === 0) return (tag: any): any => tag;\n\n const resolved = new Map<string, any>();\n\n return (tag: any): any => {\n if (typeof tag !== 'string') return tag;\n\n const memoized = resolved.get(tag);\n if (memoized !== undefined) return memoized;\n\n const override = get(components, tag);\n\n if (override) {\n resolved.set(tag, override);\n return override;\n }\n\n if (!lowercaseKeys) {\n lowercaseKeys = new Map();\n\n // Later keys win, matching `Array.prototype.find` on `Object.keys`\n // only when they are unique — so the first key of a given lowercase\n // form is kept, as before.\n for (const key of Object.keys(components)) {\n const lowercased = key.toLowerCase();\n\n if (!lowercaseKeys.has(lowercased)) lowercaseKeys.set(lowercased, key);\n }\n }\n\n const key = lowercaseKeys.get(tag.toLowerCase());\n const result = (key ? get(components, key) : undefined) || tag;\n\n resolved.set(tag, result);\n\n return result;\n };\n};\n\n/** Resolves the slugifier for a context, falling back to the built-in one. */\nconst createSlugger =\n (ctx: MarkdownContext<any>) =>\n (input: string): string =>\n ctx.slugify ? ctx.slugify(input, defaultSlugify) : defaultSlugify(input);\n\nconst createElementFactory = (\n ctx: MarkdownContext<any>,\n options: MarkdownOptions\n): CreateElementFunction => {\n const { runtime, components = {} } = ctx;\n const resolveTag = createTagResolver(components);\n const filteredTags = options.tagfilter\n ? new Set([\n 'title',\n 'textarea',\n 'style',\n 'xmp',\n 'iframe',\n 'noembed',\n 'noframes',\n 'script',\n 'plaintext',\n ])\n : null;\n\n /**\n * True when `props` can be handed to the runtime untouched: no `class`\n * alias to fold into `className`, and no empty value to drop. Rules build a\n * fresh literal for every element, so reusing it is safe, and it saves an\n * object per element — the single largest allocation in the render phase.\n */\n const needsPropsRewrite = (props: Record<string, any>): boolean => {\n if ('class' in props) return true;\n for (const key in props) {\n const value = props[key];\n if (value === undefined || value === null) return true;\n }\n return false;\n };\n\n return (\n tag: any,\n props: Record<string, any> | null,\n ...children: any[]\n ): unknown => {\n const isStringTag = typeof tag === 'string';\n\n if (\n filteredTags &&\n isStringTag &&\n (filteredTags.has(tag) || filteredTags.has(tag.toLowerCase()))\n ) {\n return null;\n }\n\n let finalProps: Record<string, any>;\n\n if (!props) {\n finalProps = {};\n } else if (!needsPropsRewrite(props)) {\n finalProps = props;\n } else {\n const className = cx(props.className, props.class);\n const mergedProps: Record<string, any> = {};\n let classNameHandled = false;\n\n // Preserve attribute order while merging className\n for (const key in props) {\n const value = props[key];\n\n if (value === undefined || value === null) continue;\n\n if (key === 'className' || key === 'class') {\n if (!classNameHandled) {\n if (className) mergedProps.className = className;\n classNameHandled = true;\n }\n } else {\n mergedProps[key] = value;\n }\n }\n\n if (!classNameHandled && className) {\n mergedProps.className = className;\n }\n\n finalProps = mergedProps;\n }\n\n if (runtime.normalizeProps && isStringTag)\n finalProps = runtime.normalizeProps(tag as string, finalProps);\n\n const component = resolveTag(tag);\n return runtime.createElement(component, finalProps, ...children);\n };\n};\n\n/**\n * Footnote and reference tables belonging to the document currently being\n * parsed or rendered. Rules reach them through a ref so a rule set can outlive\n * a single document and be reused.\n */\ntype DocumentScope = {\n footnotes: FootnoteDef[];\n references: MarkdownReferences;\n};\n\ntype DocumentScopeRef = { current: DocumentScope };\n\nconst createDocumentScope = (): DocumentScope => ({\n footnotes: [],\n references: {},\n});\n\n/**\n * A cached rule set, together with the values it was built from. The signature\n * holds every input that changes the shape of the rules; anything else (the\n * markdown itself, the document scope) is free to vary between uses.\n */\ntype DocumentParser = ReturnType<typeof parserFor>;\ntype DocumentEmitter = ReturnType<typeof renderFor>;\n\ntype RuleSetCacheEntry = {\n /** The inputs this set was built from, compared field by field on lookup. */\n ctx: MarkdownContext<any>;\n options: MarkdownOptions;\n parseOnly: boolean;\n createElement: CreateElementFunction;\n scope: DocumentScopeRef;\n /**\n * Built with the rules, not per call. `parserFor` resolves precedence and\n * fills the first-character dispatch tables, and `renderFor` walks the rule\n * set — repeating either for every string was most of what compiling a\n * dictionary of short strings cost.\n */\n parse: DocumentParser;\n emit: DocumentEmitter;\n};\n\n/**\n * Small enough to scan linearly, large enough that an app mixing a few option\n * sets — say prose and a dictionary rendered with different components — keeps\n * hitting it.\n */\nconst RULE_SET_CACHE_LIMIT = 8;\n\nconst ruleSetCache: RuleSetCacheEntry[] = [];\n\n/**\n * Every input that changes how rules are built. Compared directly rather than\n * through a signature array, which would allocate on every compile.\n */\nconst builtFromSame = (\n entry: RuleSetCacheEntry,\n ctx: MarkdownContext<any>,\n options: MarkdownOptions,\n parseOnly: boolean\n): boolean =>\n entry.parseOnly === parseOnly &&\n entry.ctx.runtime === ctx.runtime &&\n entry.ctx.components === ctx.components &&\n entry.ctx.namedCodesToUnicode === ctx.namedCodesToUnicode &&\n entry.ctx.sanitizer === ctx.sanitizer &&\n entry.ctx.slugify === ctx.slugify &&\n entry.options.disableAutoLink === options.disableAutoLink &&\n entry.options.disableParsingRawHTML === options.disableParsingRawHTML &&\n entry.options.enforceAtxHeadings === options.enforceAtxHeadings &&\n entry.options.tagfilter === options.tagfilter &&\n entry.options.renderRule === options.renderRule;\n\n/**\n * Returns the rule set for these options, building it only when no cached set\n * was made from the same inputs.\n */\nexport const getRuleSet = (\n ctx: MarkdownContext<any>,\n options: MarkdownOptions,\n parseOnly: boolean\n): RuleSetCacheEntry => {\n for (let index = 0; index < ruleSetCache.length; index++) {\n const entry = ruleSetCache[index]!;\n if (!builtFromSame(entry, ctx, options, parseOnly)) continue;\n\n // Most-recently-used first, so the hot option set stays at the front.\n if (index > 0) {\n ruleSetCache.splice(index, 1);\n ruleSetCache.unshift(entry);\n }\n return entry;\n }\n\n const scope: DocumentScopeRef = { current: createDocumentScope() };\n const createElement = parseOnly\n ? noopCreateElement\n : createElementFactory(ctx, options);\n const rules = createDocumentRules(createElement, ctx, options, scope);\n const entry: RuleSetCacheEntry = {\n ctx,\n options,\n parseOnly,\n createElement,\n scope,\n parse: parserFor(rules),\n emit: renderFor(createRenderer(rules, options.renderRule)),\n };\n\n ruleSetCache.unshift(entry);\n if (ruleSetCache.length > RULE_SET_CACHE_LIMIT) ruleSetCache.pop();\n\n return entry;\n};\n\n/**\n * Runs `operation` with `scope` installed as the current document, restoring\n * whatever was there before. The save/restore keeps a nested compile — a custom\n * component that renders markdown of its own — from clobbering its caller.\n */\nconst withDocumentScope = <TResult>(\n ref: DocumentScopeRef,\n scope: DocumentScope,\n operation: () => TResult\n): TResult => {\n const previous = ref.current;\n ref.current = scope;\n try {\n return operation();\n } finally {\n ref.current = previous;\n }\n};\n\nconst createRules = (\n createElement: CreateElementFunction,\n ctx: MarkdownContext<any>,\n options: MarkdownOptions,\n scope: DocumentScopeRef,\n attrStringToMap: (tag: HTMLTag, str: string) => Record<string, any> | null,\n containsBlockSyntax: (input: string) => boolean,\n nonParagraphBlockSyntaxes: BlockSyntaxProbe[]\n): Rules => {\n const slug = createSlugger(ctx);\n const sanitize = ctx.sanitizer ?? defaultSanitizer;\n const namedCodesToUnicode = ctx.namedCodesToUnicode\n ? { ...NAMED_CODES_TO_UNICODE, ...ctx.namedCodesToUnicode }\n : NAMED_CODES_TO_UNICODE;\n\n /**\n * Raw HTML blocks and custom components differ only in how their tag is\n * spelled: both trim the captured content, decide block or inline parsing\n * from it, and render the tag with its attributes. `rawHtml` adds the two\n * things only real HTML needs — the never-parse element list, and tracking\n * whether we are inside an anchor.\n */\n const pairedElementRule = (\n match: (source: string) => RegExpMatchArray | null,\n order: number,\n rawHtml: boolean,\n scope: RuleScopeValue = SCOPE_BOTH\n ): Rule<any> => ({\n _scope: scope,\n _qualify: ['<'],\n _match: anyScopeRegex(match),\n _order: order,\n _parse(capture, parse, state) {\n const content = capture[3] ?? '';\n const whitespace = content.match(HTML_LEFT_TRIM_AMOUNT_R)?.[1] ?? '';\n const trimmed = trimLeadingWhitespaceOutsideFences(content, whitespace);\n const parseFunc = containsBlockSyntax(trimmed) ? parseBlock : parseInline;\n const tagName = (capture[1] ?? '').trim();\n const lowercased = tagName.toLowerCase();\n const noInnerParse =\n rawHtml && DO_NOT_PROCESS_HTML_ELEMENTS.indexOf(lowercased) !== -1;\n const tag = (noInnerParse ? lowercased : tagName) as HTMLTag;\n const ast: any = {\n attrs: attrStringToMap(tag, capture[2] ?? ''),\n noInnerParse,\n tag,\n };\n\n if (rawHtml) state.inAnchor = state.inAnchor || lowercased === 'a';\n\n if (noInnerParse) {\n ast.text = content;\n } else {\n const prevInHTML = state.inHTML;\n state.inHTML = true;\n ast.children = parseFunc(parse, trimmed, state);\n state.inHTML = prevInHTML;\n }\n\n if (rawHtml) state.inAnchor = false;\n\n return ast;\n },\n _render(node, output, state = {}) {\n return createElement(\n node.tag,\n { key: state.key, ...(node.attrs ?? {}) },\n node.text ?? (node.children ? output(node.children, state) : '')\n );\n },\n });\n\n const generateListRule = (\n type: ListType\n ): Rule<OrderedListNode | UnorderedListNode> => {\n const ordered = type === ORDERED;\n const LIST_R = ordered ? ORDERED_LIST_R : UNORDERED_LIST_R;\n const LIST_ITEM_R = ordered ? ORDERED_LIST_ITEM_R : UNORDERED_LIST_ITEM_R;\n const LIST_ITEM_PREFIX_R = ordered\n ? ORDERED_LIST_ITEM_PREFIX_R\n : UNORDERED_LIST_ITEM_PREFIX_R;\n\n const firstChars = ordered\n ? [32, 9, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57]\n : [32, 9, 42, 43, 45];\n\n return {\n _scope: SCOPE_BOTH,\n _firstChars: firstChars,\n _qualify: (source, state) =>\n state.prevCaptureIndent !== undefined &&\n Boolean(state.list ?? (!state.inline && !state.simple)) &&\n LIST_ITEM_PREFIX_R.test(source),\n _match: allowInline((source, state) => {\n const lineIndent = state.prevCaptureIndent;\n const isStartOfLine = lineIndent !== undefined;\n const isListAllowed = state.list ?? (!state.inline && !state.simple);\n\n if (isStartOfLine && isListAllowed) {\n const matchSource = lineIndent ? lineIndent + source : source;\n\n const match = LIST_R.exec(matchSource);\n if (!match) return null;\n\n if (lineIndent && match[0].startsWith(lineIndent)) {\n const adjusted = [...match] as RegExpMatchArray;\n adjusted[0] = match[0].slice(lineIndent.length);\n (adjusted as any).fullMatch = match[0];\n return adjusted;\n }\n\n return match;\n }\n\n return null;\n }),\n _order: Priority.HIGH,\n _parse(capture, parse, state) {\n const bullet = capture[2] ?? '';\n const startValue = ordered ? +bullet.slice(0, -1) : undefined;\n const fullSource = (capture as any).fullMatch ?? capture[0] ?? '';\n const items = fullSource\n .replace(BLOCK_END_R, '\\n')\n .match(LIST_ITEM_R) as string[];\n\n if (!items) return { items: [], ordered, start: startValue } as any;\n\n let lastItemWasAParagraph = false;\n\n const result = items.map((item, i) => {\n const prefixCapture = LIST_ITEM_PREFIX_R.exec(item);\n const space = prefixCapture ? prefixCapture[0].length : 0;\n const spaceRegex =\n space <= 8\n ? STRIP_INDENT_REGEXES[space]!\n : new RegExp(`^ {1,${space}}`, 'gm');\n // Slicing the prefix off is the same as stripping the item's own\n // indentation and then its bullet, because the bullet run is greedy:\n // the first line never keeps a leading space either way. It saves a\n // second pass of the prefix pattern over every item.\n const content = item.slice(space).replace(spaceRegex, '');\n const isLastItem = i === items.length - 1;\n const containsBlocks = content.indexOf('\\n\\n') !== -1;\n const thisItemIsAParagraph =\n containsBlocks || (isLastItem && lastItemWasAParagraph);\n\n lastItemWasAParagraph = thisItemIsAParagraph;\n\n const oldStateInline = state.inline;\n const oldStateList = state.list;\n state.list = true;\n\n let adjustedContent: string;\n\n if (thisItemIsAParagraph) {\n state.inline = false;\n adjustedContent = `${trimEnd(content)}\\n\\n`;\n } else {\n state.inline = true;\n adjustedContent = trimEnd(content);\n }\n\n const parsed = parse(adjustedContent, state);\n state.inline = oldStateInline;\n state.list = oldStateList;\n\n return parsed;\n });\n\n return { items: result, ordered, start: startValue };\n },\n _render(node, output, state = {}) {\n return createElement(\n ordered ? 'ol' : 'ul',\n { key: state.key, start: (node as OrderedListNode).start },\n ...node.items.map((item, i) =>\n createElement('li', { key: i }, output(item, state))\n )\n );\n },\n };\n };\n\n const matchParagraph = (\n source: string,\n state: ParseState\n ): RegExpMatchArray | null => {\n if (\n state.inline ||\n state.simple ||\n (state.inHTML &&\n source.indexOf('\\n\\n') === -1 &&\n !state.prevCaptureHasBlankLine)\n )\n return null;\n let start = 0;\n const srcLen = source.length;\n while (start < srcLen) {\n const newlineIndex = source.indexOf('\\n', start);\n const lineEnd = newlineIndex === -1 ? srcLen : newlineIndex;\n\n let p = start;\n while (\n p < lineEnd &&\n (source.charCodeAt(p) === 32 || source.charCodeAt(p) === 9)\n ) {\n p++;\n }\n\n if (p >= lineEnd) {\n break;\n }\n\n if (p - start >= 4 || source.charCodeAt(start) === 9) {\n break;\n }\n\n const ch = source.charCodeAt(p);\n const isDelim =\n ch === 62 || // >\n ch === 96 || // `\n ch === 126 || // ~\n ch === 35 || // #\n ch === 124 || // |\n ch === 42 || // *\n ch === 43 || // +\n ch === 45 || // -\n ch === 61 || // =\n ch === 60 || // <\n (ch >= 48 && ch <= 57); // 0-9\n\n if (isDelim) {\n const line = source.slice(\n start,\n newlineIndex === -1 ? undefined : newlineIndex + 1\n );\n\n if (some(nonParagraphBlockSyntaxes, line)) break;\n }\n\n if (newlineIndex === -1) {\n start = srcLen;\n break;\n }\n start = newlineIndex + 1;\n }\n const match = source.slice(0, start);\n // Align with original simple-markdown behavior: capture the whole match including newlines\n\n if (match === '') return null;\n const captured = trimEnd(match);\n\n if (captured === '') return null;\n\n return [match, undefined, captured] as unknown as RegExpMatchArray;\n };\n\n const rules: Rules = {\n [RuleType.blockQuote]: {\n _scope: SCOPE_BLOCK,\n _qualify: ['>'],\n _match: blockRegex(BLOCKQUOTE_R),\n _order: Priority.HIGH,\n _parse(capture, parse, state) {\n const matchAlert = (capture[0] ?? '')\n .replace(BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, '')\n .match(BLOCKQUOTE_ALERT_R);\n const alert = matchAlert?.[1];\n const content = matchAlert?.[2] ?? '';\n const hasNewline = content.indexOf('\\n') !== -1;\n const children = hasNewline\n ? parseBlock(parse, content, state)\n : parseInline(parse, content, state);\n\n return { alert, children };\n },\n _render(node, output, state = {}) {\n const props: Record<string, any> = { key: state.key };\n\n if (node.alert) {\n props.className = `markdown-alert-${slug(node.alert.toLowerCase())}`;\n node.children.unshift({\n attrs: {},\n children: [{ type: RuleType.text, text: node.alert }],\n noInnerParse: true,\n type: RuleType.htmlBlock,\n tag: 'header',\n } as any);\n }\n\n return createElement('blockquote', props, output(node.children, state));\n },\n },\n [RuleType.breakLine]: {\n _scope: SCOPE_BOTH,\n _qualify: [' '],\n _match: anyScopeRegex(BREAK_LINE_R),\n _order: Priority.HIGH,\n _parse: captureNothing,\n _render(_, __, state = {}) {\n return createElement('br', { key: state.key });\n },\n },\n [RuleType.breakThematic]: {\n _scope: SCOPE_BLOCK,\n _qualify: ['--', '__', '**', '- ', '* ', '_ '],\n _match: blockRegex(BREAK_THEMATIC_R),\n _order: Priority.HIGH,\n _parse: captureNothing,\n _render(_, __, state = {}) {\n return createElement('hr', { key: state.key });\n },\n },\n [RuleType.codeBlock]: {\n _scope: SCOPE_BLOCK,\n _qualify: [' '],\n _match: blockRegex(CODE_BLOCK_R),\n _order: Priority.MAX,\n _parse(capture) {\n return {\n type: RuleType.codeBlock,\n lang: undefined,\n text: unescapeString(\n trimEnd((capture[0] ?? '').replace(/^ {4}/gm, ''))\n ),\n };\n },\n _render(node, _, state = {}) {\n const attrs = { ...((node as any).attrs ?? {}) } as Record<string, any>;\n const langClass = node.lang ? `lang-${node.lang}` : 'lang-plaintext';\n attrs.className = attrs.className\n ? `${attrs.className} ${langClass}`\n : langClass;\n\n return createElement(\n 'pre',\n { key: state.key },\n createElement('code', attrs, node.text)\n );\n },\n },\n [RuleType.codeFenced]: {\n _scope: SCOPE_BLOCK,\n _qualify: ['```', '~~~'],\n _match: blockRegex(CODE_BLOCK_FENCED_R),\n _order: Priority.MAX,\n _parse(capture) {\n return {\n attrs: attrStringToMap('code', capture[3] ?? ''),\n lang: capture[2] || undefined,\n text: capture[4] ?? '',\n type: RuleType.codeBlock,\n };\n },\n },\n [RuleType.codeInline]: {\n _scope: SCOPE_INLINE,\n _firstChars: [96 /* ` */],\n _qualify: (source) =>\n source.charCodeAt(0) === 96 && source.indexOf('`', 1) !== -1,\n _match: simpleInlineRegex(CODE_INLINE_R),\n _order: Priority.LOW,\n _parse(capture) {\n return { text: unescapeString(capture[2] ?? '') };\n },\n _render(node, _, state = {}) {\n return createElement('code', { key: state.key }, node.text);\n },\n },\n [RuleType.footnote]: {\n _scope: SCOPE_INLINE,\n _qualify: ['[^'],\n _match: blockRegex(FOOTNOTE_R),\n _order: Priority.MAX,\n _parse(capture) {\n scope.current.footnotes.push({\n footnote: capture[2] ?? '',\n identifier: capture[1] ?? '',\n });\n\n return {};\n },\n _render: renderNothing,\n },\n [RuleType.footnoteReference]: {\n _scope: SCOPE_INLINE,\n _qualify: ['[^'],\n _match: inlineRegex(FOOTNOTE_REFERENCE_R),\n _order: Priority.HIGH,\n _parse(capture) {\n const text = capture[1] ?? '';\n return { target: `#${slug(text)}`, text };\n },\n _render(node, _, state = {}) {\n return createElement(\n 'a',\n {\n key: state.key,\n href: sanitize(node.target, 'a', 'href') ?? undefined,\n },\n createElement('sup', { key: state.key }, node.text)\n );\n },\n },\n [RuleType.gfmTask]: {\n _scope: SCOPE_INLINE,\n _qualify: ['[ ]', '[x]'],\n _match: inlineRegex(GFM_TASK_R),\n _order: Priority.HIGH,\n _parse(capture) {\n return { completed: (capture[1] ?? '').toLowerCase() === 'x' };\n },\n _render(node, _, state = {}) {\n return createElement('input', {\n checked: node.completed,\n key: state.key,\n readOnly: true,\n type: 'checkbox',\n });\n },\n },\n [RuleType.heading]: {\n _scope: SCOPE_BLOCK,\n _qualify: ['#'],\n _match: blockRegex(\n options.enforceAtxHeadings ? HEADING_ATX_COMPLIANT_R : HEADING_R\n ),\n _order: Priority.HIGH,\n _parse(capture, parse, state) {\n const text = capture[2] ?? '';\n return {\n children: parseInline(parse, text, state),\n id: slug(text),\n level: (capture[1]?.length ?? 1) as HeadingNode['level'],\n };\n },\n _render(node, output, state = {}) {\n return createElement(\n `h${node.level}` as HTMLTag,\n { id: node.id, key: state.key },\n output(node.children, state)\n );\n },\n },\n [RuleType.headingSetext]: {\n _scope: SCOPE_BLOCK,\n _qualify: (source, state) => {\n if (\n state.prevCaptureIndent === undefined ||\n state.inline ||\n state.simple\n )\n return false;\n const nlIndex = source.indexOf('\\n');\n\n return (\n nlIndex > 0 &&\n nlIndex < source.length - 1 &&\n (source[nlIndex + 1] === '=' || source[nlIndex + 1] === '-')\n );\n },\n _match: blockRegex(HEADING_SETEXT_R),\n _order: Priority.MAX,\n _parse(capture, parse, state) {\n return {\n children: parseInline(parse, capture[1] ?? '', state),\n level: capture[2] === '=' ? 1 : 2,\n type: RuleType.heading,\n };\n },\n },\n [RuleType.htmlBlock]: pairedElementRule(\n // The rule is dropped outright when raw HTML is disabled, and the scanner\n matchHtmlBlockElement,\n Priority.HIGH,\n true,\n SCOPE_BOTH\n ),\n [RuleType.htmlComment]: {\n _scope: SCOPE_BOTH,\n _qualify: ['<!'],\n _match: anyScopeRegex(HTML_COMMENT_R),\n _order: Priority.HIGH,\n _parse: captureNothing,\n _render: renderNothing,\n },\n [RuleType.htmlSelfClosing]: {\n _scope: SCOPE_BOTH,\n _qualify: ['<'],\n _match: anyScopeRegex(matchSelfClosingElement),\n _order: Priority.HIGH,\n _parse(capture) {\n const tag = (capture[1] ?? '').trim() as HTMLTag;\n\n return { attrs: attrStringToMap(tag, capture[2] || ''), tag };\n },\n _render(node, _, state = {}) {\n return createElement(node.tag, {\n key: state.key,\n ...(node.attrs ?? {}),\n });\n },\n },\n [RuleType.customComponent]: pairedElementRule(\n matchCustomComponent,\n Priority.MAX,\n false,\n SCOPE_BOTH\n ),\n [RuleType.paragraph]: {\n _scope: SCOPE_BLOCK,\n _qualify: (_source, state) => !state.inline && !state.simple,\n _match: matchParagraph,\n _order: Priority.LOW,\n _parse: parseCaptureInline,\n _render(node, output, state = {}) {\n return createElement(\n 'p',\n { key: state.key },\n output(node.children, state)\n );\n },\n },\n [RuleType.image]: {\n _scope: SCOPE_INLINE,\n _firstChars: [33 /* ! */],\n _qualify: (source) =>\n source.startsWith(' !== -1,\n _match: simpleInlineRegex(IMAGE_R),\n _order: Priority.HIGH,\n _parse(capture) {\n return {\n alt: unescapeString(capture[1] ?? ''),\n target: unescapeString(capture[2] ?? ''),\n title: capture[3] ? unescapeString(capture[3]) : undefined,\n };\n },\n _render(node, _, state = {}) {\n return createElement('img', {\n key: state.key,\n alt: node.alt ?? undefined,\n title: node.title ?? undefined,\n src: sanitize(node.target, 'img', 'src') ?? undefined,\n });\n },\n },\n [RuleType.link]: {\n _scope: SCOPE_INLINE,\n _firstChars: [91 /* [ */],\n _qualify: (source) =>\n source.charCodeAt(0) === 91 && source.indexOf('](') !== -1,\n _match: inlineRegex(LINK_R),\n _order: Priority.LOW,\n _parse(capture, parse, state) {\n return {\n children: parseSimpleInline(parse, capture[1] ?? '', state),\n target: unescapeString(capture[2] ?? ''),\n title: capture[3] ? unescapeString(capture[3]) : undefined,\n };\n },\n _render(node, output, state = {}) {\n const sanitizedHref = sanitize(node.target, 'a', 'href');\n return createElement(\n 'a',\n {\n key: state.key,\n href: sanitizedHref ?? undefined,\n title: node.title ?? undefined,\n },\n output(node.children, state)\n );\n },\n },\n [RuleType.linkAngleBraceStyleDetector]: {\n _scope: SCOPE_INLINE,\n _qualify: ['<'],\n _match: inlineRegex(LINK_AUTOLINK_R),\n _order: Priority.MAX,\n _parse(capture) {\n let target = capture[1] ?? '';\n let isEmail = false;\n\n if (target.indexOf('@') !== -1 && target.indexOf('//') === -1) {\n isEmail = true;\n target = target.replace('mailto:', '');\n }\n\n return {\n children: [{ text: target, type: RuleType.text }],\n target: isEmail ? `mailto:${target}` : target,\n type: RuleType.link,\n };\n },\n },\n [RuleType.linkBareUrlDetector]: {\n _scope: SCOPE_INLINE,\n _firstChars: [104 /* h */],\n _qualify: (source, state) =>\n Boolean(\n state.inline &&\n !state.inAnchor &&\n !options.disableAutoLink &&\n (startsWith(source, 'http://') || startsWith(source, 'https://'))\n ),\n _match: inlineRegex(LINK_AUTOLINK_BARE_URL_R),\n _order: Priority.MAX,\n _parse(capture) {\n const url = capture[1] ?? '';\n return {\n children: [{ text: url, type: RuleType.text }],\n target: url,\n type: RuleType.link,\n };\n },\n },\n [RuleType.newlineCoalescer]: {\n _scope: SCOPE_BOTH,\n _qualify: ['\\n'],\n _match: blockRegex(CONSECUTIVE_NEWLINE_R),\n _order: Priority.LOW,\n _parse: captureNothing,\n _render() {\n return '\\n';\n },\n },\n [RuleType.orderedList]: generateListRule(ORDERED),\n [RuleType.unorderedList]: generateListRule(UNORDERED),\n [RuleType.ref]: {\n _scope: SCOPE_BOTH,\n _qualify: ['['],\n _match: anyScopeRegex(REFERENCE_IMAGE_OR_LINK),\n _order: Priority.MAX,\n _parse(capture) {\n const identifier = capture[1];\n\n if (identifier !== undefined) {\n scope.current.references[identifier] = {\n target: capture[2] ?? '',\n title: capture[4],\n };\n }\n\n return {};\n },\n _render: renderNothing,\n },\n [RuleType.refImage]: {\n _scope: SCOPE_INLINE,\n _firstChars: [33 /* ! */],\n _qualify: (source) =>\n source.startsWith(' === -1,\n _match: simpleInlineRegex(REFERENCE_IMAGE_R),\n _order: Priority.MAX,\n _parse(capture) {\n return {\n alt: capture[1] ? unescapeString(capture[1]) : undefined,\n ref: capture[2] ?? '',\n };\n },\n _render(node, _, state = {}) {\n const ref = scope.current.references[node.ref];\n\n if (!ref) return null;\n\n return createElement('img', {\n key: state.key,\n alt: node.alt,\n src: sanitize(ref.target, 'img', 'src') ?? undefined,\n title: ref.title,\n });\n },\n },\n [RuleType.refLink]: {\n _scope: SCOPE_INLINE,\n _firstChars: [91 /* [ */],\n _qualify: (source) => source.indexOf('](') === -1,\n _match: inlineRegex(REFERENCE_LINK_R),\n _order: Priority.MAX,\n _parse(capture, parse, state) {\n return {\n children: parseSimpleInline(parse, capture[1] ?? '', state),\n fallbackChildren: capture[0] ?? '',\n ref: capture[2] ?? '',\n };\n },\n _render(node, output, state = {}) {\n const ref = scope.current.references[node.ref];\n\n if (!ref)\n return createElement(\n 'span',\n { key: state.key },\n node.fallbackChildren\n );\n\n return createElement(\n 'a',\n {\n key: state.key,\n href: sanitize(ref.target, 'a', 'href') ?? undefined,\n title: ref.title,\n },\n output(node.children, state)\n );\n },\n },\n [RuleType.table]: {\n _scope: SCOPE_BLOCK,\n _qualify: ['|'],\n _match: blockRegex(NP_TABLE_R),\n _order: Priority.HIGH,\n _parse(capture, parse, state) {\n state.inline = true;\n const align = capture[2] ? parseTableAlign(capture[2]) : [];\n const cells = capture[3]\n ? parseTableCells(capture[3], parse, state)\n : [];\n const header = parseTableRow(\n capture[1] ?? '',\n parse,\n state,\n !!cells.length\n );\n state.inline = false;\n\n return cells.length\n ? { align, cells, header, type: RuleType.table }\n : { children: header.flat(), type: RuleType.paragraph };\n },\n _render(node, output, state = {}) {\n const table = node as TableNode;\n const getStyle = (i: number) =>\n table.align[i] && table.align[i] !== 'left'\n ? { textAlign: table.align[i] }\n : {};\n\n return createElement(\n 'table',\n { key: state.key },\n createElement(\n 'thead',\n { key: 'thead' },\n createElement(\n 'tr',\n null,\n ...table.header.map((c, i) =>\n createElement(\n 'th',\n { key: i, style: getStyle(i) },\n output(c, state)\n )\n )\n )\n ),\n createElement(\n 'tbody',\n { key: 'tbody' },\n ...table.cells.map((row, i) =>\n createElement(\n 'tr',\n { key: i },\n ...row.map((c, j) =>\n createElement(\n 'td',\n { key: j, style: getStyle(j) },\n output(c, state)\n )\n )\n )\n )\n )\n );\n },\n },\n [RuleType.tableSeparator]: {\n _scope: SCOPE_INLINE,\n _qualify: ['|'],\n _match: (source, state) => (state.inTable ? /^\\|/.exec(source) : null),\n _order: Priority.HIGH,\n _parse() {\n return { type: RuleType.tableSeparator };\n },\n _render() {\n return ' | ';\n },\n },\n [RuleType.text]: {\n _scope: SCOPE_INLINE,\n _match: allowInline((source, _state) => {\n const len = source.length;\n if (source.charCodeAt(0) === 10 /* \\n */) {\n let j = 1;\n while (j < len && source.charCodeAt(j) === 32 /* space */) {\n j++;\n }\n if (\n j < len &&\n (source.charCodeAt(j) === 42 || // *\n source.charCodeAt(j) === 43 || // +\n source.charCodeAt(j) === 45 || // -\n (source.charCodeAt(j) >= 48 && source.charCodeAt(j) <= 57)) // 0-9\n ) {\n return [source.slice(0, j)] as unknown as RegExpMatchArray;\n }\n return ['\\n'] as unknown as RegExpMatchArray;\n }\n\n if (source.charCodeAt(0) === 58 /* : */) {\n const shortMatch = SHORTCODE_R.exec(source);\n if (shortMatch) return shortMatch;\n }\n // The first character always belongs to the run, whatever it is.\n TEXT_RUN_R.lastIndex = 1;\n TEXT_RUN_R.test(source);\n\n // Text is the most frequent capture by a wide margin, and its `_parse`\n // never re-enters the parser, so one scratch array serves every run\n // instead of allocating one per token.\n TEXT_CAPTURE[0] = source.slice(\n 0,\n trimHardBreak(source, TEXT_RUN_R.lastIndex)\n );\n\n return TEXT_CAPTURE;\n }),\n _order: Priority.MIN,\n _parse(capture) {\n const text = capture[0] ?? '';\n\n // Declaring `type` here — rather than letting the parser add it —\n // keeps every text node on one hidden class. `&` stops a run, so an\n // entity can only ever open one: testing the first character replaces\n // a scan of every character of every text node in the document.\n return {\n type: RuleType.text,\n text:\n text.charCodeAt(0) !== 38 /* & */\n ? text\n : text.replace(HTML_CHAR_CODE_R, (f, i) => {\n if (i.startsWith('#x'))\n return String.fromCharCode(parseInt(i.slice(2), 16));\n if (i.startsWith('#'))\n return String.fromCharCode(parseInt(i.slice(1), 10));\n return namedCodesToUnicode[i] || f;\n }),\n };\n },\n _render(node) {\n return node.text;\n },\n },\n [RuleType.textBolded]: {\n _scope: SCOPE_INLINE,\n _firstChars: [42 /* * */, 95 /* _ */],\n _qualify: (source) => {\n const c = source.charCodeAt(0);\n if (c === 42) {\n const next = source.charCodeAt(2);\n if (next === 32 || next === 10 || next === 9) return false;\n return source.charCodeAt(1) === 42 && source.indexOf('**', 2) !== -1;\n }\n if (c === 95) {\n const next = source.charCodeAt(2);\n if (next === 32 || next === 10 || next === 9) return false;\n return source.charCodeAt(1) === 95 && source.indexOf('__', 2) !== -1;\n }\n return false;\n },\n _match: simpleInlineRegex(TEXT_BOLD_R),\n _order: Priority.MED,\n _parse(capture, parse, state) {\n return { children: parse(capture[2] ?? '', state) };\n },\n _render(node, output, state = {}) {\n return createElement(\n 'strong',\n { key: state.key },\n output(node.children, state)\n );\n },\n },\n [RuleType.textEmphasized]: {\n _scope: SCOPE_INLINE,\n _firstChars: [42 /* * */, 95 /* _ */],\n _qualify: (source) => {\n const c = source.charCodeAt(0);\n const next = source.charCodeAt(1);\n if (next === 32 || next === 10 || next === 9) return false;\n return (\n (c === 42 && source.indexOf('*', 1) !== -1) ||\n (c === 95 && source.indexOf('_', 1) !== -1)\n );\n },\n _match: simpleInlineRegex(TEXT_EMPHASIZED_R),\n _order: Priority.LOW,\n _parse(capture, parse, state) {\n return { children: parse(capture[2] ?? '', state) };\n },\n _render(node, output, state = {}) {\n return createElement(\n 'em',\n { key: state.key },\n output(node.children, state)\n );\n },\n },\n [RuleType.textEscaped]: {\n _scope: SCOPE_INLINE,\n _qualify: ['\\\\'],\n _match: simpleInlineRegex(TEXT_ESCAPED_R),\n _order: Priority.HIGH,\n _parse(capture) {\n return { text: capture[1] ?? '', type: RuleType.text };\n },\n },\n [RuleType.textMarked]: {\n _scope: SCOPE_INLINE,\n _firstChars: [61 /* = */],\n _qualify: (source) => {\n const next = source.charCodeAt(2);\n if (next === 32 || next === 10 || next === 9) return false;\n return source.charCodeAt(1) === 61 && source.indexOf('==', 2) !== -1;\n },\n _match: simpleInlineRegex(TEXT_MARKED_R),\n _order: Priority.LOW,\n _parse(capture, parse, state) {\n return { children: parseCaptureInline(capture, parse, state).children };\n },\n _render(node, output, state = {}) {\n return createElement(\n 'mark',\n { key: state.key },\n output(node.children, state)\n );\n },\n },\n [RuleType.textStrikethroughed]: {\n _scope: SCOPE_INLINE,\n _firstChars: [126 /* ~ */],\n _qualify: (source) => {\n const next = source.charCodeAt(2);\n if (next === 32 || next === 10 || next === 9) return false;\n return source.charCodeAt(1) === 126 && source.indexOf('~~', 2) !== -1;\n },\n _match: simpleInlineRegex(TEXT_STRIKETHROUGHED_R),\n _order: Priority.LOW,\n _parse(capture, parse, state) {\n return { children: parseCaptureInline(capture, parse, state).children };\n },\n _render(node, output, state = {}) {\n return createElement(\n 'del',\n { key: state.key },\n output(node.children, state)\n );\n },\n },\n };\n\n return rules;\n};\n\n// Removed compilerCache completely to avoid issues with props changes not invalidating cache\n// const compilerCache = new Map<string, unknown>();\n\n/** Link/image reference definitions (`[id]: target \"title\"`) collected while parsing. */\nexport type MarkdownReferences = Record<\n string,\n { target: string; title?: string }\n>;\n\nexport type ParsedMarkdown = {\n ast: any[];\n footnotes: FootnoteDef[];\n /**\n * Reference definitions gathered during parsing. They must be carried over to\n * the render stage, since `refLink` / `refImage` nodes only store the\n * reference id and resolve their target at render time.\n */\n references: MarkdownReferences;\n inline: boolean;\n};\n\nconst STRIP_INDENT_REGEXES = [\n null,\n /^ {1,1}/gm,\n /^ {1,2}/gm,\n /^ {1,3}/gm,\n /^ {1,4}/gm,\n /^ {1,5}/gm,\n /^ {1,6}/gm,\n /^ {1,7}/gm,\n /^ {1,8}/gm,\n];\n\n/** Scratch capture reused by the text rule; see its `_match`. */\nconst TEXT_CAPTURE = [''] as unknown as RegExpMatchArray;\n\n/**\n * Consumes a run of plain text, stopping before the next character that could\n * open another inline rule or a bare URL. Anchored so `test` leaves the stop\n * offset in `lastIndex` without allocating a match array, and so the scan\n * itself runs in the regex engine.\n *\n * The bare-URL guard is an alternation branch rather than a per-character\n * lookahead, because a lookahead is re-evaluated at every offset while this\n * branch is only reached on an `h`. `&` stops a run purely so that an HTML\n * entity can only ever sit at offset 0 of a text node; adjacent text nodes are\n * merged by the parser, so the tree is unchanged.\n */\nconst TEXT_RUN_R = /(?:[^\\n&h!*:<=[\\\\_`~]+|h(?!ttp))*/y;\n\n/**\n * Pull a run's stop offset back before a hard line break it just swallowed.\n *\n * A run never contains a newline, so ` \\n` can only sit immediately before the\n * stop offset — which makes this O(1) check equivalent to the per-character\n * `(?! {2}\\n)` lookahead the run scanner used to carry.\n */\nconst trimHardBreak = (source: string, end: number): number =>\n end >= 3 &&\n source.charCodeAt(end) === 10 /* \\n */ &&\n source.charCodeAt(end - 1) === 32 /* space */ &&\n source.charCodeAt(end - 2) === 32\n ? end - 2\n : end;\n\nconst noopCreateElement: CreateElementFunction = (\n type,\n props,\n ...children\n) => ({\n children,\n props,\n type,\n});\n\n/**\n * Builds the rule set backing one document.\n *\n * Rules read the document's footnote and reference tables through `scope`\n * rather than closing over them, so one set serves every document sharing the\n * same options. Building this graph dominated the cost of compiling the many\n * short strings a dictionary holds; `getRuleSet` caches it.\n */\nconst createDocumentRules = (\n createElement: CreateElementFunction,\n ctx: MarkdownContext<any>,\n options: MarkdownOptions,\n scope: DocumentScopeRef\n): Rules => {\n const attrStringToMap = (\n tag: HTMLTag,\n str: string\n ): Record<string, any> | null => {\n if (!str?.trim()) return null;\n\n const attributes = str.match(ATTR_EXTRACTOR_R);\n\n if (!attributes) return null;\n\n return attributes.reduce((map: any, raw) => {\n const delimiterIdx = raw.indexOf('=');\n\n if (delimiterIdx !== -1) {\n const key = normalizeAttributeKey(raw.slice(0, delimiterIdx)).trim();\n const value = unquote(raw.slice(delimiterIdx + 1).trim());\n const mappedKey = ATTRIBUTE_TO_NODE_PROP_MAP[key] ?? key;\n\n if (mappedKey === 'ref') return map;\n map[mappedKey] = attributeValueToNodePropValue(\n tag,\n key,\n value,\n ctx.sanitizer ?? defaultSanitizer\n );\n\n if (\n typeof map[mappedKey] === 'string' &&\n startsWithElement(map[mappedKey])\n ) {\n map[mappedKey] = parseMarkdown(\n map[mappedKey].trim(),\n ctx,\n options\n ).ast;\n }\n } else if (raw !== 'style') {\n map[ATTRIBUTE_TO_NODE_PROP_MAP[raw] ?? raw] = true;\n }\n\n return map;\n }, {});\n };\n\n const nonParagraphBlockSyntaxes = [\n BLOCKQUOTE_R,\n CODE_BLOCK_FENCED_R,\n CODE_BLOCK_R,\n options.enforceAtxHeadings ? HEADING_ATX_COMPLIANT_R : HEADING_R,\n NP_TABLE_R,\n ORDERED_LIST_R,\n UNORDERED_LIST_R,\n startsWithCustomComponent,\n ];\n\n // Built once: this list is fixed for the whole parse, and rebuilding it per\n // call put a fresh array on every block-syntax probe.\n const blockSyntaxes = (\n options.disableParsingRawHTML\n ? nonParagraphBlockSyntaxes\n : [\n ...nonParagraphBlockSyntaxes,\n PARAGRAPH_R,\n startsWithHtmlBlockElement,\n HTML_COMMENT_R,\n startsWithSelfClosingElement,\n startsWithCustomComponent,\n ]\n ) as BlockSyntaxProbe[];\n\n const containsBlockSyntax = (input: string): boolean => {\n const cleaned = input.replace(TRIM_STARTING_NEWLINES, '');\n const slice = cleaned.length > 2048 ? cleaned.slice(0, 2048) : cleaned;\n\n if (slice.indexOf('\\n\\n') !== -1) return true;\n\n return some(blockSyntaxes, slice);\n };\n\n const baseRules = createRules(\n createElement,\n ctx,\n options,\n scope,\n attrStringToMap,\n containsBlockSyntax,\n nonParagraphBlockSyntaxes\n );\n\n return options.disableParsingRawHTML\n ? Object.keys(baseRules).reduce((acc, key) => {\n if (key !== RuleType.htmlBlock && key !== RuleType.htmlSelfClosing) {\n acc[key] = baseRules[key]!;\n }\n\n return acc;\n }, {} as Rules)\n : baseRules;\n};\n\n/** Runs the parse phase against an already-built rule set. */\nconst parseWithRules = (\n markdown: string,\n options: MarkdownOptions,\n parser: DocumentParser,\n footnotes: FootnoteDef[],\n refs: MarkdownReferences\n): ParsedMarkdown => {\n const result =\n !options.preserveFrontmatter && markdown.charCodeAt(0) === 45 /* - */\n ? markdown.replace(FRONT_MATTER_R, '')\n : markdown;\n // Stripped once and reused: both the block/inline decision and the block\n // input below need the source without its leading newlines.\n const trimmedStart =\n result.charCodeAt(0) === 10 /* \\n */\n ? result.replace(TRIM_STARTING_NEWLINES, '')\n : result;\n const inline =\n options.forceInline ||\n (!options.forceBlock &&\n SHOULD_RENDER_AS_BLOCK_R.test(trimmedStart) === false);\n\n const ast = parser(inline ? result : `${trimEnd(trimmedStart)}\\n\\n`, {\n inline,\n });\n\n if (footnotes.length > 0) {\n // Parse footnotes content as well\n for (const def of footnotes) {\n (def as any).parsedAst = parser(def.footnote, { inline: true });\n }\n }\n\n return { ast, footnotes, references: refs, inline };\n};\n\n/** Runs the render phase against an already-built rule set. */\nconst renderWithRules = (\n parsed: ParsedMarkdown,\n ctx: MarkdownContext<any>,\n options: MarkdownOptions,\n emitter: DocumentEmitter,\n createElement: CreateElementFunction\n): unknown => {\n const components = ctx.components ?? {};\n const slug = createSlugger(ctx);\n const footnotes = parsed.footnotes || [];\n\n const inline = parsed.inline;\n const arr = emitter(parsed.ast, { inline }) as unknown as any[];\n\n while (typeof arr[arr.length - 1] === 'string' && !arr[arr.length - 1].trim())\n arr.pop();\n\n const getOuterNode = () => {\n if (options.wrapper === null) return arr;\n const wrapper = options.wrapper ?? (inline ? 'span' : 'div');\n\n if (arr.length > 1 || options.forceWrapper)\n return createElement(wrapper, { key: 'outer' }, arr);\n\n if (arr.length === 1) {\n const node = arr[0];\n\n if (Array.isArray(node)) {\n return createElement(wrapper, { key: 'outer' }, node);\n }\n\n if (typeof node === 'string') {\n const spanProps: Record<string, any> = { key: 'outer' };\n\n if (!inline && components) {\n const pOverrideProps = (get(components, 'p.props', {}) ??\n {}) as Record<string, any>;\n const mergedClassName = cx(\n spanProps.className,\n pOverrideProps.className\n );\n const finalSpanProps: Record<string, any> = {\n ...spanProps,\n ...pOverrideProps,\n };\n\n if (mergedClassName) finalSpanProps.className = mergedClassName;\n\n return createElement('span', finalSpanProps, node);\n }\n\n return createElement('span', spanProps, node);\n }\n\n return node;\n }\n\n return createElement(wrapper, { key: 'outer' }, null);\n };\n\n const node = getOuterNode();\n\n const result = footnotes.length\n ? createElement(\n 'div',\n null,\n node,\n createElement(\n 'footer',\n { key: 'footer' },\n ...footnotes.map((def) =>\n createElement(\n 'div',\n { id: slug(def.identifier), key: def.identifier },\n def.identifier,\n emitter((def as any).parsedAst || def.footnote, { inline: true })\n )\n )\n )\n )\n : node;\n\n return result;\n};\n\nexport const parseMarkdown = (\n markdown: string = '',\n ctx: MarkdownContext<any>,\n options: MarkdownOptions = {}\n): ParsedMarkdown => {\n // Parsing never emits elements, so it gets its own cache entry built around\n // the no-op factory rather than the render one.\n const { parse, scope } = getRuleSet(ctx, options, true);\n const documentScope = createDocumentScope();\n\n return withDocumentScope(scope, documentScope, () =>\n parseWithRules(\n markdown,\n options,\n parse,\n documentScope.footnotes,\n documentScope.references\n )\n );\n};\n\nexport const renderMarkdownAst = (\n parsed: ParsedMarkdown,\n ctx: MarkdownContext<any>,\n options: MarkdownOptions = {}\n): unknown => {\n const { emit, createElement, scope } = getRuleSet(ctx, options, false);\n const documentScope: DocumentScope = {\n footnotes: parsed.footnotes ?? [],\n references: parsed.references ?? {},\n };\n\n return withDocumentScope(scope, documentScope, () =>\n renderWithRules(parsed, ctx, options, emit, createElement)\n );\n};\n\nexport const compile = (\n markdown: string = '',\n ctx: MarkdownContext<any>,\n options: MarkdownOptions = {}\n): unknown => {\n if (typeof markdown !== 'string') {\n if (process.env.NODE_ENV !== 'production') {\n console.error(\n 'intlayer: the first argument must be a string. Received',\n typeof markdown\n );\n }\n throw new Error('intlayer: the first argument must be a string');\n }\n\n // Both phases share one rule set: building it twice was the dominant cost\n // when compiling the many short strings a typical dictionary holds.\n const { parse, emit, createElement, scope } = getRuleSet(ctx, options, false);\n const documentScope = createDocumentScope();\n\n return withDocumentScope(scope, documentScope, () => {\n const parsed = parseWithRules(\n markdown,\n options,\n parse,\n documentScope.footnotes,\n documentScope.references\n );\n\n return renderWithRules(parsed, ctx, options, emit, createElement);\n });\n};\n\nexport const createCompiler =\n (ctx: MarkdownContext<any>) =>\n (markdown: string, options?: MarkdownOptions): unknown =>\n compile(markdown, ctx, options);\n\nexport const compileWithOptions = (\n markdown: string,\n runtime: MarkdownRuntime,\n options: CompileOptions<any> = {}\n): unknown => {\n const {\n components,\n namedCodesToUnicode,\n sanitizer,\n slugify,\n ...compilerOptions\n } = options;\n\n return compile(\n markdown,\n { runtime, components, namedCodesToUnicode, sanitizer, slugify },\n compilerOptions\n );\n};\n"],"mappings":";;;;;;;;AAwHA,MAAM,UAAU;AAKhB,MAAM,SAAS,IAAI,OACjB,4JACF;;;;;;;;;;;;;;AAeA,MAAM,qBAAqB,eAAyC;CAClE,IAAI,gBAA4C;CAIhD,IAAI,OAAO,KAAK,UAAU,CAAC,CAAC,WAAW,GAAG,QAAQ,QAAkB;CAEpE,MAAM,2BAAW,IAAI,IAAiB;CAEtC,QAAQ,QAAkB;EACxB,IAAI,OAAO,QAAQ,UAAU,OAAO;EAEpC,MAAM,WAAW,SAAS,IAAI,GAAG;EACjC,IAAI,aAAa,QAAW,OAAO;EAEnC,MAAM,WAAWA,2BAAI,YAAY,GAAG;EAEpC,IAAI,UAAU;GACZ,SAAS,IAAI,KAAK,QAAQ;GAC1B,OAAO;EACT;EAEA,IAAI,CAAC,eAAe;GAClB,gCAAgB,IAAI,IAAI;GAKxB,KAAK,MAAM,OAAO,OAAO,KAAK,UAAU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serFor","renderFor","createRenderer","defaultSanitizer","NAMED_CODES_TO_UNICODE","SCOPE_BOTH","anyScopeRegex","HTML_LEFT_TRIM_AMOUNT_R","trimLeadingWhitespaceOutsideFences","parseBlock","parseInline","DO_NOT_PROCESS_HTML_ELEMENTS","ORDERED_LIST_R","UNORDERED_LIST_R","ORDERED_LIST_ITEM_R","UNORDERED_LIST_ITEM_R","ORDERED_LIST_ITEM_PREFIX_R","UNORDERED_LIST_ITEM_PREFIX_R","allowInline","Priority","BLOCK_END_R","trimEnd","some","RuleType","SCOPE_BLOCK","blockRegex","BLOCKQUOTE_R","BLOCKQUOTE_TRIM_LEFT_MULTILINE_R","BLOCKQUOTE_ALERT_R","BREAK_LINE_R","captureNothing","BREAK_THEMATIC_R","CODE_BLOCK_R","unescapeString","CODE_BLOCK_FENCED_R","SCOPE_INLINE","simpleInlineRegex","CODE_INLINE_R","FOOTNOTE_R","renderNothing","inlineRegex","FOOTNOTE_REFERENCE_R","GFM_TASK_R","HEADING_ATX_COMPLIANT_R","HEADING_R","HEADING_SETEXT_R","matchHtmlBlockElement","HTML_COMMENT_R","matchSelfClosingElement","matchCustomComponent","parseCaptureInline","parseSimpleInline","LINK_AUTOLINK_R","startsWith","LINK_AUTOLINK_BARE_URL_R","CONSECUTIVE_NEWLINE_R","REFERENCE_IMAGE_OR_LINK","REFERENCE_IMAGE_R","REFERENCE_LINK_R","NP_TABLE_R","parseTableAlign","parseTableCells","parseTableRow","SHORTCODE_R","HTML_CHAR_CODE_R","TEXT_BOLD_R","TEXT_EMPHASIZED_R","TEXT_ESCAPED_R","TEXT_MARKED_R","TEXT_STRIKETHROUGHED_R","ATTR_EXTRACTOR_R","normalizeAttributeKey","unquote","ATTRIBUTE_TO_NODE_PROP_MAP","attributeValueToNodePropValue","startsWithElement","startsWithCustomComponent","PARAGRAPH_R","startsWithHtmlBlockElement","startsWithSelfClosingElement","TRIM_STARTING_NEWLINES","FRONT_MATTER_R","SHOULD_RENDER_AS_BLOCK_R"],"sources":["../../../src/markdown/compiler.ts"],"sourcesContent":["import {\n ATTR_EXTRACTOR_R,\n ATTRIBUTE_TO_NODE_PROP_MAP,\n BLOCK_END_R,\n BLOCKQUOTE_ALERT_R,\n BLOCKQUOTE_R,\n BLOCKQUOTE_TRIM_LEFT_MULTILINE_R,\n BREAK_LINE_R,\n BREAK_THEMATIC_R,\n CODE_BLOCK_FENCED_R,\n CODE_BLOCK_R,\n CODE_INLINE_R,\n CONSECUTIVE_NEWLINE_R,\n DO_NOT_PROCESS_HTML_ELEMENTS,\n FOOTNOTE_R,\n FOOTNOTE_REFERENCE_R,\n FRONT_MATTER_R,\n GFM_TASK_R,\n HEADING_ATX_COMPLIANT_R,\n HEADING_R,\n HEADING_SETEXT_R,\n HTML_CHAR_CODE_R,\n HTML_COMMENT_R,\n HTML_LEFT_TRIM_AMOUNT_R,\n LINK_AUTOLINK_BARE_URL_R,\n LINK_AUTOLINK_R,\n type ListType,\n NAMED_CODES_TO_UNICODE,\n NP_TABLE_R,\n ORDERED,\n ORDERED_LIST_ITEM_PREFIX_R,\n ORDERED_LIST_ITEM_R,\n ORDERED_LIST_R,\n PARAGRAPH_R,\n Priority,\n REFERENCE_IMAGE_OR_LINK,\n REFERENCE_IMAGE_R,\n REFERENCE_LINK_R,\n type RuleScopeValue,\n RuleType,\n SCOPE_BLOCK,\n SCOPE_BOTH,\n SCOPE_INLINE,\n SHORTCODE_R,\n SHOULD_RENDER_AS_BLOCK_R,\n TEXT_BOLD_R,\n TEXT_EMPHASIZED_R,\n TEXT_ESCAPED_R,\n TEXT_MARKED_R,\n TEXT_STRIKETHROUGHED_R,\n TRIM_STARTING_NEWLINES,\n UNORDERED,\n UNORDERED_LIST_ITEM_PREFIX_R,\n UNORDERED_LIST_ITEM_R,\n UNORDERED_LIST_R,\n} from './constants';\nimport {\n matchCustomComponent,\n matchHtmlBlockElement,\n matchSelfClosingElement,\n startsWithCustomComponent,\n startsWithElement,\n startsWithHtmlBlockElement,\n startsWithSelfClosingElement,\n} from './elementScanner';\nimport { parserFor } from './parser';\nimport { createRenderer, renderFor } from './renderer';\nimport type {\n CompileOptions,\n ComponentOverrides as ComponentDefinition,\n HeadingNode,\n HTMLTag,\n MarkdownContext,\n MarkdownOptions,\n MarkdownRuntime,\n OrderedListNode,\n ParseState,\n Rule,\n Rules,\n TableNode,\n UnorderedListNode,\n} from './types';\nimport {\n allowInline,\n anyScopeRegex,\n attributeValueToNodePropValue,\n type BlockSyntaxProbe,\n blockRegex,\n captureNothing,\n cx,\n sanitizer as defaultSanitizer,\n slugify as defaultSlugify,\n get,\n inlineRegex,\n normalizeAttributeKey,\n parseBlock,\n parseCaptureInline,\n parseInline,\n parseSimpleInline,\n parseTableAlign,\n parseTableCells,\n parseTableRow,\n renderNothing,\n simpleInlineRegex,\n some,\n startsWith,\n trimEnd,\n trimLeadingWhitespaceOutsideFences,\n unescapeString,\n unquote,\n} from './utils';\n\ntype CreateElementFunction = (\n tag: any,\n props: Record<string, any> | null,\n ...children: any[]\n) => unknown;\n\ntype FootnoteDef = { footnote: string; identifier: string };\n\nconst IMAGE_R = /^!\\[(.*?)\\]\\( *((?:\\([^)]*\\)|[^() ])*) *\"?([^)\"]*)?\"?\\)/;\nconst LINK_INSIDE =\n '(?:\\\\[[^\\\\[\\\\]]*(?:\\\\[[^\\\\[\\\\]]*\\\\][^\\\\[\\\\]]*)*\\\\]|[^\\\\[\\\\]])*';\nconst LINK_HREF_AND_TITLE =\n '\\\\s*<?((?:\\\\([^)]*\\\\)|[^\\\\s\\\\\\\\]|\\\\\\\\.)*?)>?(?:\\\\s+[\\'\"]([\\\\s\\\\S]*?)[\\'\"])?\\\\s*';\nconst LINK_R = new RegExp(\n `^\\\\[(${LINK_INSIDE})\\\\]\\\\(${LINK_HREF_AND_TITLE}\\\\)`\n);\n\n/**\n * Case-insensitive `</tag>` probes, cached per tag name.\n *\n * The `htmlBlock` rule is qualified at every candidate position, and it used to\n * lowercase the whole remaining document to look its closing tag up — copying\n * the rest of the file on each probe.\n */\n/**\n * Builds a tag -> component resolver for one set of overrides.\n *\n * The case-insensitive fallback used to rescan every override key on each\n * element created; the lowercase index is now built once per document instead.\n */\nconst createTagResolver = (components: ComponentDefinition<any>) => {\n let lowercaseKeys: Map<string, string> | null = null;\n\n // With no overrides declared — the common case — every tag resolves to\n // itself, so the whole lookup is skipped.\n if (Object.keys(components).length === 0) return (tag: any): any => tag;\n\n const resolved = new Map<string, any>();\n\n return (tag: any): any => {\n if (typeof tag !== 'string') return tag;\n\n const memoized = resolved.get(tag);\n if (memoized !== undefined) return memoized;\n\n const override = get(components, tag);\n\n if (override) {\n resolved.set(tag, override);\n return override;\n }\n\n if (!lowercaseKeys) {\n lowercaseKeys = new Map();\n\n // Later keys win, matching `Array.prototype.find` on `Object.keys`\n // only when they are unique — so the first key of a given lowercase\n // form is kept, as before.\n for (const key of Object.keys(components)) {\n const lowercased = key.toLowerCase();\n\n if (!lowercaseKeys.has(lowercased)) lowercaseKeys.set(lowercased, key);\n }\n }\n\n const key = lowercaseKeys.get(tag.toLowerCase());\n const result = (key ? get(components, key) : undefined) || tag;\n\n resolved.set(tag, result);\n\n return result;\n };\n};\n\n/** Resolves the slugifier for a context, falling back to the built-in one. */\nconst createSlugger =\n (ctx: MarkdownContext<any>) =>\n (input: string): string =>\n ctx.slugify ? ctx.slugify(input, defaultSlugify) : defaultSlugify(input);\n\nconst createElementFactory = (\n ctx: MarkdownContext<any>,\n options: MarkdownOptions\n): CreateElementFunction => {\n const { runtime, components = {} } = ctx;\n const resolveTag = createTagResolver(components);\n const filteredTags = options.tagfilter\n ? new Set([\n 'title',\n 'textarea',\n 'style',\n 'xmp',\n 'iframe',\n 'noembed',\n 'noframes',\n 'script',\n 'plaintext',\n ])\n : null;\n\n /**\n * True when `props` can be handed to the runtime untouched: no `class`\n * alias to fold into `className`, and no empty value to drop. Rules build a\n * fresh literal for every element, so reusing it is safe, and it saves an\n * object per element — the single largest allocation in the render phase.\n */\n const needsPropsRewrite = (props: Record<string, any>): boolean => {\n if ('class' in props) return true;\n for (const key in props) {\n const value = props[key];\n if (value === undefined || value === null) return true;\n }\n return false;\n };\n\n return (\n tag: any,\n props: Record<string, any> | null,\n ...children: any[]\n ): unknown => {\n const isStringTag = typeof tag === 'string';\n\n if (\n filteredTags &&\n isStringTag &&\n (filteredTags.has(tag) || filteredTags.has(tag.toLowerCase()))\n ) {\n return null;\n }\n\n let finalProps: Record<string, any>;\n\n if (!props) {\n finalProps = {};\n } else if (!needsPropsRewrite(props)) {\n finalProps = props;\n } else {\n const className = cx(props.className, props.class);\n const mergedProps: Record<string, any> = {};\n let classNameHandled = false;\n\n // Preserve attribute order while merging className\n for (const key in props) {\n const value = props[key];\n\n if (value === undefined || value === null) continue;\n\n if (key === 'className' || key === 'class') {\n if (!classNameHandled) {\n if (className) mergedProps.className = className;\n classNameHandled = true;\n }\n } else {\n mergedProps[key] = value;\n }\n }\n\n if (!classNameHandled && className) {\n mergedProps.className = className;\n }\n\n finalProps = mergedProps;\n }\n\n if (runtime.normalizeProps && isStringTag)\n finalProps = runtime.normalizeProps(tag as string, finalProps);\n\n const component = resolveTag(tag);\n return runtime.createElement(component, finalProps, ...children);\n };\n};\n\n/**\n * Footnote and reference tables belonging to the document currently being\n * parsed or rendered. Rules reach them through a ref so a rule set can outlive\n * a single document and be reused.\n */\ntype DocumentScope = {\n footnotes: FootnoteDef[];\n references: MarkdownReferences;\n};\n\ntype DocumentScopeRef = { current: DocumentScope };\n\nconst createDocumentScope = (): DocumentScope => ({\n footnotes: [],\n references: {},\n});\n\n/**\n * A cached rule set, together with the values it was built from. The signature\n * holds every input that changes the shape of the rules; anything else (the\n * markdown itself, the document scope) is free to vary between uses.\n */\ntype DocumentParser = ReturnType<typeof parserFor>;\ntype DocumentEmitter = ReturnType<typeof renderFor>;\n\ntype RuleSetCacheEntry = {\n /** The inputs this set was built from, compared field by field on lookup. */\n ctx: MarkdownContext<any>;\n options: MarkdownOptions;\n parseOnly: boolean;\n createElement: CreateElementFunction;\n scope: DocumentScopeRef;\n /**\n * Built with the rules, not per call. `parserFor` resolves precedence and\n * fills the first-character dispatch tables, and `renderFor` walks the rule\n * set — repeating either for every string was most of what compiling a\n * dictionary of short strings cost.\n */\n parse: DocumentParser;\n emit: DocumentEmitter;\n};\n\n/**\n * Small enough to scan linearly, large enough that an app mixing a few option\n * sets — say prose and a dictionary rendered with different components — keeps\n * hitting it.\n */\nconst RULE_SET_CACHE_LIMIT = 8;\n\nconst ruleSetCache: RuleSetCacheEntry[] = [];\n\n/**\n * Every input that changes how rules are built. Compared directly rather than\n * through a signature array, which would allocate on every compile.\n */\nconst builtFromSame = (\n entry: RuleSetCacheEntry,\n ctx: MarkdownContext<any>,\n options: MarkdownOptions,\n parseOnly: boolean\n): boolean =>\n entry.parseOnly === parseOnly &&\n entry.ctx.runtime === ctx.runtime &&\n entry.ctx.components === ctx.components &&\n entry.ctx.namedCodesToUnicode === ctx.namedCodesToUnicode &&\n entry.ctx.sanitizer === ctx.sanitizer &&\n entry.ctx.slugify === ctx.slugify &&\n entry.options.disableAutoLink === options.disableAutoLink &&\n entry.options.disableParsingRawHTML === options.disableParsingRawHTML &&\n entry.options.enforceAtxHeadings === options.enforceAtxHeadings &&\n entry.options.tagfilter === options.tagfilter &&\n entry.options.renderRule === options.renderRule;\n\n/**\n * Returns the rule set for these options, building it only when no cached set\n * was made from the same inputs.\n */\nexport const getRuleSet = (\n ctx: MarkdownContext<any>,\n options: MarkdownOptions,\n parseOnly: boolean\n): RuleSetCacheEntry => {\n for (let index = 0; index < ruleSetCache.length; index++) {\n const entry = ruleSetCache[index]!;\n if (!builtFromSame(entry, ctx, options, parseOnly)) continue;\n\n // Most-recently-used first, so the hot option set stays at the front.\n if (index > 0) {\n ruleSetCache.splice(index, 1);\n ruleSetCache.unshift(entry);\n }\n return entry;\n }\n\n const scope: DocumentScopeRef = { current: createDocumentScope() };\n const createElement = parseOnly\n ? noopCreateElement\n : createElementFactory(ctx, options);\n const rules = createDocumentRules(createElement, ctx, options, scope);\n const entry: RuleSetCacheEntry = {\n ctx,\n options,\n parseOnly,\n createElement,\n scope,\n parse: parserFor(rules),\n emit: renderFor(createRenderer(rules, options.renderRule)),\n };\n\n ruleSetCache.unshift(entry);\n if (ruleSetCache.length > RULE_SET_CACHE_LIMIT) ruleSetCache.pop();\n\n return entry;\n};\n\n/**\n * Runs `operation` with `scope` installed as the current document, restoring\n * whatever was there before. The save/restore keeps a nested compile — a custom\n * component that renders markdown of its own — from clobbering its caller.\n */\nconst withDocumentScope = <TResult>(\n ref: DocumentScopeRef,\n scope: DocumentScope,\n operation: () => TResult\n): TResult => {\n const previous = ref.current;\n ref.current = scope;\n try {\n return operation();\n } finally {\n ref.current = previous;\n }\n};\n\nconst createRules = (\n createElement: CreateElementFunction,\n ctx: MarkdownContext<any>,\n options: MarkdownOptions,\n scope: DocumentScopeRef,\n attrStringToMap: (tag: HTMLTag, str: string) => Record<string, any> | null,\n containsBlockSyntax: (input: string) => boolean,\n nonParagraphBlockSyntaxes: BlockSyntaxProbe[]\n): Rules => {\n const slug = createSlugger(ctx);\n const sanitize = ctx.sanitizer ?? defaultSanitizer;\n const namedCodesToUnicode = ctx.namedCodesToUnicode\n ? { ...NAMED_CODES_TO_UNICODE, ...ctx.namedCodesToUnicode }\n : NAMED_CODES_TO_UNICODE;\n\n /**\n * Raw HTML blocks and custom components differ only in how their tag is\n * spelled: both trim the captured content, decide block or inline parsing\n * from it, and render the tag with its attributes. `rawHtml` adds the two\n * things only real HTML needs — the never-parse element list, and tracking\n * whether we are inside an anchor.\n */\n /**\n * Whether `source` opens an element at the start of a block line, allowing\n * the up-to-three-space indentation CommonMark grants to HTML blocks.\n *\n * The scanner already skips leading spaces, but the dispatch only handed it\n * sources starting with `<`. An indented ` <Tab>` inside a `<Tabs>` block\n * then fell through to the paragraph rule, which swallowed the opening tag\n * as inline HTML and lost every sibling that followed it.\n */\n const qualifiesPairedElement = (source: string, state: ParseState) => {\n if (source.charCodeAt(0) === 60 /* < */) return true;\n\n const isBlockLineStart =\n !state.inline && !state.simple && state.prevCaptureIndent !== undefined;\n\n if (!isBlockLineStart) return false;\n\n let index = 0;\n while (index < 3 && source.charCodeAt(index) === 32 /* space */) index++;\n\n return index > 0 && source.charCodeAt(index) === 60;\n };\n\n const pairedElementRule = (\n match: (source: string) => RegExpMatchArray | null,\n order: number,\n rawHtml: boolean,\n scope: RuleScopeValue = SCOPE_BOTH\n ): Rule<any> => ({\n _scope: scope,\n _firstChars: [60 /* < */, 32 /* space */],\n _qualify: qualifiesPairedElement,\n _match: anyScopeRegex(match),\n _order: order,\n _parse(capture, parse, state) {\n const content = capture[3] ?? '';\n const whitespace = content.match(HTML_LEFT_TRIM_AMOUNT_R)?.[1] ?? '';\n const trimmed = trimLeadingWhitespaceOutsideFences(content, whitespace);\n const parseFunc = containsBlockSyntax(trimmed) ? parseBlock : parseInline;\n const tagName = (capture[1] ?? '').trim();\n const lowercased = tagName.toLowerCase();\n const noInnerParse =\n rawHtml && DO_NOT_PROCESS_HTML_ELEMENTS.indexOf(lowercased) !== -1;\n const tag = (noInnerParse ? lowercased : tagName) as HTMLTag;\n const ast: any = {\n attrs: attrStringToMap(tag, capture[2] ?? ''),\n noInnerParse,\n tag,\n };\n\n if (rawHtml) state.inAnchor = state.inAnchor || lowercased === 'a';\n\n if (noInnerParse) {\n ast.text = content;\n } else {\n const prevInHTML = state.inHTML;\n state.inHTML = true;\n ast.children = parseFunc(parse, trimmed, state);\n state.inHTML = prevInHTML;\n }\n\n if (rawHtml) state.inAnchor = false;\n\n return ast;\n },\n _render(node, output, state = {}) {\n return createElement(\n node.tag,\n { key: state.key, ...(node.attrs ?? {}) },\n node.text ?? (node.children ? output(node.children, state) : '')\n );\n },\n });\n\n const generateListRule = (\n type: ListType\n ): Rule<OrderedListNode | UnorderedListNode> => {\n const ordered = type === ORDERED;\n const LIST_R = ordered ? ORDERED_LIST_R : UNORDERED_LIST_R;\n const LIST_ITEM_R = ordered ? ORDERED_LIST_ITEM_R : UNORDERED_LIST_ITEM_R;\n const LIST_ITEM_PREFIX_R = ordered\n ? ORDERED_LIST_ITEM_PREFIX_R\n : UNORDERED_LIST_ITEM_PREFIX_R;\n\n const firstChars = ordered\n ? [32, 9, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57]\n : [32, 9, 42, 43, 45];\n\n return {\n _scope: SCOPE_BOTH,\n _firstChars: firstChars,\n _qualify: (source, state) =>\n state.prevCaptureIndent !== undefined &&\n Boolean(state.list ?? (!state.inline && !state.simple)) &&\n LIST_ITEM_PREFIX_R.test(source),\n _match: allowInline((source, state) => {\n const lineIndent = state.prevCaptureIndent;\n const isStartOfLine = lineIndent !== undefined;\n const isListAllowed = state.list ?? (!state.inline && !state.simple);\n\n if (isStartOfLine && isListAllowed) {\n const matchSource = lineIndent ? lineIndent + source : source;\n\n const match = LIST_R.exec(matchSource);\n if (!match) return null;\n\n if (lineIndent && match[0].startsWith(lineIndent)) {\n const adjusted = [...match] as RegExpMatchArray;\n adjusted[0] = match[0].slice(lineIndent.length);\n (adjusted as any).fullMatch = match[0];\n return adjusted;\n }\n\n return match;\n }\n\n return null;\n }),\n _order: Priority.HIGH,\n _parse(capture, parse, state) {\n const bullet = capture[2] ?? '';\n const startValue = ordered ? +bullet.slice(0, -1) : undefined;\n const fullSource = (capture as any).fullMatch ?? capture[0] ?? '';\n const items = fullSource\n .replace(BLOCK_END_R, '\\n')\n .match(LIST_ITEM_R) as string[];\n\n if (!items) return { items: [], ordered, start: startValue } as any;\n\n let lastItemWasAParagraph = false;\n\n const result = items.map((item, i) => {\n const prefixCapture = LIST_ITEM_PREFIX_R.exec(item);\n const space = prefixCapture ? prefixCapture[0].length : 0;\n const spaceRegex =\n space <= 8\n ? STRIP_INDENT_REGEXES[space]!\n : new RegExp(`^ {1,${space}}`, 'gm');\n // Slicing the prefix off is the same as stripping the item's own\n // indentation and then its bullet, because the bullet run is greedy:\n // the first line never keeps a leading space either way. It saves a\n // second pass of the prefix pattern over every item.\n const content = item.slice(space).replace(spaceRegex, '');\n const isLastItem = i === items.length - 1;\n const containsBlocks = content.indexOf('\\n\\n') !== -1;\n const thisItemIsAParagraph =\n containsBlocks || (isLastItem && lastItemWasAParagraph);\n\n lastItemWasAParagraph = thisItemIsAParagraph;\n\n const oldStateInline = state.inline;\n const oldStateList = state.list;\n state.list = true;\n\n let adjustedContent: string;\n\n if (thisItemIsAParagraph) {\n state.inline = false;\n adjustedContent = `${trimEnd(content)}\\n\\n`;\n } else {\n state.inline = true;\n adjustedContent = trimEnd(content);\n }\n\n const parsed = parse(adjustedContent, state);\n state.inline = oldStateInline;\n state.list = oldStateList;\n\n return parsed;\n });\n\n return { items: result, ordered, start: startValue };\n },\n _render(node, output, state = {}) {\n return createElement(\n ordered ? 'ol' : 'ul',\n { key: state.key, start: (node as OrderedListNode).start },\n ...node.items.map((item, i) =>\n createElement('li', { key: i }, output(item, state))\n )\n );\n },\n };\n };\n\n const matchParagraph = (\n source: string,\n state: ParseState\n ): RegExpMatchArray | null => {\n if (\n state.inline ||\n state.simple ||\n (state.inHTML &&\n source.indexOf('\\n\\n') === -1 &&\n !state.prevCaptureHasBlankLine)\n )\n return null;\n let start = 0;\n const srcLen = source.length;\n while (start < srcLen) {\n const newlineIndex = source.indexOf('\\n', start);\n const lineEnd = newlineIndex === -1 ? srcLen : newlineIndex;\n\n let p = start;\n while (\n p < lineEnd &&\n (source.charCodeAt(p) === 32 || source.charCodeAt(p) === 9)\n ) {\n p++;\n }\n\n if (p >= lineEnd) {\n break;\n }\n\n if (p - start >= 4 || source.charCodeAt(start) === 9) {\n break;\n }\n\n const ch = source.charCodeAt(p);\n const isDelim =\n ch === 62 || // >\n ch === 96 || // `\n ch === 126 || // ~\n ch === 35 || // #\n ch === 124 || // |\n ch === 42 || // *\n ch === 43 || // +\n ch === 45 || // -\n ch === 61 || // =\n ch === 60 || // <\n (ch >= 48 && ch <= 57); // 0-9\n\n if (isDelim) {\n const line = source.slice(\n start,\n newlineIndex === -1 ? undefined : newlineIndex + 1\n );\n\n if (some(nonParagraphBlockSyntaxes, line)) break;\n }\n\n if (newlineIndex === -1) {\n start = srcLen;\n break;\n }\n start = newlineIndex + 1;\n }\n const match = source.slice(0, start);\n // Align with original simple-markdown behavior: capture the whole match including newlines\n\n if (match === '') return null;\n const captured = trimEnd(match);\n\n if (captured === '') return null;\n\n return [match, undefined, captured] as unknown as RegExpMatchArray;\n };\n\n const rules: Rules = {\n [RuleType.blockQuote]: {\n _scope: SCOPE_BLOCK,\n _qualify: ['>'],\n _match: blockRegex(BLOCKQUOTE_R),\n _order: Priority.HIGH,\n _parse(capture, parse, state) {\n const matchAlert = (capture[0] ?? '')\n .replace(BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, '')\n .match(BLOCKQUOTE_ALERT_R);\n const alert = matchAlert?.[1];\n const content = matchAlert?.[2] ?? '';\n const hasNewline = content.indexOf('\\n') !== -1;\n const children = hasNewline\n ? parseBlock(parse, content, state)\n : parseInline(parse, content, state);\n\n return { alert, children };\n },\n _render(node, output, state = {}) {\n const props: Record<string, any> = { key: state.key };\n\n if (node.alert) {\n props.className = `markdown-alert-${slug(node.alert.toLowerCase())}`;\n node.children.unshift({\n attrs: {},\n children: [{ type: RuleType.text, text: node.alert }],\n noInnerParse: true,\n type: RuleType.htmlBlock,\n tag: 'header',\n } as any);\n }\n\n return createElement('blockquote', props, output(node.children, state));\n },\n },\n [RuleType.breakLine]: {\n _scope: SCOPE_BOTH,\n _qualify: [' '],\n _match: anyScopeRegex(BREAK_LINE_R),\n _order: Priority.HIGH,\n _parse: captureNothing,\n _render(_, __, state = {}) {\n return createElement('br', { key: state.key });\n },\n },\n [RuleType.breakThematic]: {\n _scope: SCOPE_BLOCK,\n _qualify: ['--', '__', '**', '- ', '* ', '_ '],\n _match: blockRegex(BREAK_THEMATIC_R),\n _order: Priority.HIGH,\n _parse: captureNothing,\n _render(_, __, state = {}) {\n return createElement('hr', { key: state.key });\n },\n },\n [RuleType.codeBlock]: {\n _scope: SCOPE_BLOCK,\n _qualify: [' '],\n _match: blockRegex(CODE_BLOCK_R),\n _order: Priority.MAX,\n _parse(capture) {\n return {\n type: RuleType.codeBlock,\n lang: undefined,\n text: unescapeString(\n trimEnd((capture[0] ?? '').replace(/^ {4}/gm, ''))\n ),\n };\n },\n _render(node, _, state = {}) {\n const attrs = { ...((node as any).attrs ?? {}) } as Record<string, any>;\n const langClass = node.lang ? `lang-${node.lang}` : 'lang-plaintext';\n attrs.className = attrs.className\n ? `${attrs.className} ${langClass}`\n : langClass;\n\n return createElement(\n 'pre',\n { key: state.key },\n createElement('code', attrs, node.text)\n );\n },\n },\n [RuleType.codeFenced]: {\n _scope: SCOPE_BLOCK,\n _qualify: ['```', '~~~'],\n _match: blockRegex(CODE_BLOCK_FENCED_R),\n _order: Priority.MAX,\n _parse(capture) {\n return {\n attrs: attrStringToMap('code', capture[3] ?? ''),\n lang: capture[2] || undefined,\n text: capture[4] ?? '',\n type: RuleType.codeBlock,\n };\n },\n },\n [RuleType.codeInline]: {\n _scope: SCOPE_INLINE,\n _firstChars: [96 /* ` */],\n _qualify: (source) =>\n source.charCodeAt(0) === 96 && source.indexOf('`', 1) !== -1,\n _match: simpleInlineRegex(CODE_INLINE_R),\n _order: Priority.LOW,\n _parse(capture) {\n return { text: unescapeString(capture[2] ?? '') };\n },\n _render(node, _, state = {}) {\n return createElement('code', { key: state.key }, node.text);\n },\n },\n [RuleType.footnote]: {\n _scope: SCOPE_INLINE,\n _qualify: ['[^'],\n _match: blockRegex(FOOTNOTE_R),\n _order: Priority.MAX,\n _parse(capture) {\n scope.current.footnotes.push({\n footnote: capture[2] ?? '',\n identifier: capture[1] ?? '',\n });\n\n return {};\n },\n _render: renderNothing,\n },\n [RuleType.footnoteReference]: {\n _scope: SCOPE_INLINE,\n _qualify: ['[^'],\n _match: inlineRegex(FOOTNOTE_REFERENCE_R),\n _order: Priority.HIGH,\n _parse(capture) {\n const text = capture[1] ?? '';\n return { target: `#${slug(text)}`, text };\n },\n _render(node, _, state = {}) {\n return createElement(\n 'a',\n {\n key: state.key,\n href: sanitize(node.target, 'a', 'href') ?? undefined,\n },\n createElement('sup', { key: state.key }, node.text)\n );\n },\n },\n [RuleType.gfmTask]: {\n _scope: SCOPE_INLINE,\n _qualify: ['[ ]', '[x]'],\n _match: inlineRegex(GFM_TASK_R),\n _order: Priority.HIGH,\n _parse(capture) {\n return { completed: (capture[1] ?? '').toLowerCase() === 'x' };\n },\n _render(node, _, state = {}) {\n return createElement('input', {\n checked: node.completed,\n key: state.key,\n readOnly: true,\n type: 'checkbox',\n });\n },\n },\n [RuleType.heading]: {\n _scope: SCOPE_BLOCK,\n _qualify: ['#'],\n _match: blockRegex(\n options.enforceAtxHeadings ? HEADING_ATX_COMPLIANT_R : HEADING_R\n ),\n _order: Priority.HIGH,\n _parse(capture, parse, state) {\n const text = capture[2] ?? '';\n return {\n children: parseInline(parse, text, state),\n id: slug(text),\n level: (capture[1]?.length ?? 1) as HeadingNode['level'],\n };\n },\n _render(node, output, state = {}) {\n return createElement(\n `h${node.level}` as HTMLTag,\n { id: node.id, key: state.key },\n output(node.children, state)\n );\n },\n },\n [RuleType.headingSetext]: {\n _scope: SCOPE_BLOCK,\n _qualify: (source, state) => {\n if (\n state.prevCaptureIndent === undefined ||\n state.inline ||\n state.simple\n )\n return false;\n const nlIndex = source.indexOf('\\n');\n\n return (\n nlIndex > 0 &&\n nlIndex < source.length - 1 &&\n (source[nlIndex + 1] === '=' || source[nlIndex + 1] === '-')\n );\n },\n _match: blockRegex(HEADING_SETEXT_R),\n _order: Priority.MAX,\n _parse(capture, parse, state) {\n return {\n children: parseInline(parse, capture[1] ?? '', state),\n level: capture[2] === '=' ? 1 : 2,\n type: RuleType.heading,\n };\n },\n },\n [RuleType.htmlBlock]: pairedElementRule(\n // The rule is dropped outright when raw HTML is disabled, and the scanner\n matchHtmlBlockElement,\n Priority.HIGH,\n true,\n SCOPE_BOTH\n ),\n [RuleType.htmlComment]: {\n _scope: SCOPE_BOTH,\n _qualify: ['<!'],\n _match: anyScopeRegex(HTML_COMMENT_R),\n _order: Priority.HIGH,\n _parse: captureNothing,\n _render: renderNothing,\n },\n [RuleType.htmlSelfClosing]: {\n _scope: SCOPE_BOTH,\n _qualify: ['<'],\n _match: anyScopeRegex(matchSelfClosingElement),\n _order: Priority.HIGH,\n _parse(capture) {\n const tag = (capture[1] ?? '').trim() as HTMLTag;\n\n return { attrs: attrStringToMap(tag, capture[2] || ''), tag };\n },\n _render(node, _, state = {}) {\n return createElement(node.tag, {\n key: state.key,\n ...(node.attrs ?? {}),\n });\n },\n },\n [RuleType.customComponent]: pairedElementRule(\n matchCustomComponent,\n Priority.MAX,\n false,\n SCOPE_BOTH\n ),\n [RuleType.paragraph]: {\n _scope: SCOPE_BLOCK,\n _qualify: (_source, state) => !state.inline && !state.simple,\n _match: matchParagraph,\n _order: Priority.LOW,\n _parse: parseCaptureInline,\n _render(node, output, state = {}) {\n return createElement(\n 'p',\n { key: state.key },\n output(node.children, state)\n );\n },\n },\n [RuleType.image]: {\n _scope: SCOPE_INLINE,\n _firstChars: [33 /* ! */],\n _qualify: (source) =>\n source.startsWith(' !== -1,\n _match: simpleInlineRegex(IMAGE_R),\n _order: Priority.HIGH,\n _parse(capture) {\n return {\n alt: unescapeString(capture[1] ?? ''),\n target: unescapeString(capture[2] ?? ''),\n title: capture[3] ? unescapeString(capture[3]) : undefined,\n };\n },\n _render(node, _, state = {}) {\n return createElement('img', {\n key: state.key,\n alt: node.alt ?? undefined,\n title: node.title ?? undefined,\n src: sanitize(node.target, 'img', 'src') ?? undefined,\n });\n },\n },\n [RuleType.link]: {\n _scope: SCOPE_INLINE,\n _firstChars: [91 /* [ */],\n _qualify: (source) =>\n source.charCodeAt(0) === 91 && source.indexOf('](') !== -1,\n _match: inlineRegex(LINK_R),\n _order: Priority.LOW,\n _parse(capture, parse, state) {\n return {\n children: parseSimpleInline(parse, capture[1] ?? '', state),\n target: unescapeString(capture[2] ?? ''),\n title: capture[3] ? unescapeString(capture[3]) : undefined,\n };\n },\n _render(node, output, state = {}) {\n const sanitizedHref = sanitize(node.target, 'a', 'href');\n return createElement(\n 'a',\n {\n key: state.key,\n href: sanitizedHref ?? undefined,\n title: node.title ?? undefined,\n },\n output(node.children, state)\n );\n },\n },\n [RuleType.linkAngleBraceStyleDetector]: {\n _scope: SCOPE_INLINE,\n _qualify: ['<'],\n _match: inlineRegex(LINK_AUTOLINK_R),\n _order: Priority.MAX,\n _parse(capture) {\n let target = capture[1] ?? '';\n let isEmail = false;\n\n if (target.indexOf('@') !== -1 && target.indexOf('//') === -1) {\n isEmail = true;\n target = target.replace('mailto:', '');\n }\n\n return {\n children: [{ text: target, type: RuleType.text }],\n target: isEmail ? `mailto:${target}` : target,\n type: RuleType.link,\n };\n },\n },\n [RuleType.linkBareUrlDetector]: {\n _scope: SCOPE_INLINE,\n _firstChars: [104 /* h */],\n _qualify: (source, state) =>\n Boolean(\n state.inline &&\n !state.inAnchor &&\n !options.disableAutoLink &&\n (startsWith(source, 'http://') || startsWith(source, 'https://'))\n ),\n _match: inlineRegex(LINK_AUTOLINK_BARE_URL_R),\n _order: Priority.MAX,\n _parse(capture) {\n const url = capture[1] ?? '';\n return {\n children: [{ text: url, type: RuleType.text }],\n target: url,\n type: RuleType.link,\n };\n },\n },\n [RuleType.newlineCoalescer]: {\n _scope: SCOPE_BOTH,\n _qualify: ['\\n'],\n _match: blockRegex(CONSECUTIVE_NEWLINE_R),\n _order: Priority.LOW,\n _parse: captureNothing,\n _render() {\n return '\\n';\n },\n },\n [RuleType.orderedList]: generateListRule(ORDERED),\n [RuleType.unorderedList]: generateListRule(UNORDERED),\n [RuleType.ref]: {\n _scope: SCOPE_BOTH,\n _qualify: ['['],\n _match: anyScopeRegex(REFERENCE_IMAGE_OR_LINK),\n _order: Priority.MAX,\n _parse(capture) {\n const identifier = capture[1];\n\n if (identifier !== undefined) {\n scope.current.references[identifier] = {\n target: capture[2] ?? '',\n title: capture[4],\n };\n }\n\n return {};\n },\n _render: renderNothing,\n },\n [RuleType.refImage]: {\n _scope: SCOPE_INLINE,\n _firstChars: [33 /* ! */],\n _qualify: (source) =>\n source.startsWith(' === -1,\n _match: simpleInlineRegex(REFERENCE_IMAGE_R),\n _order: Priority.MAX,\n _parse(capture) {\n return {\n alt: capture[1] ? unescapeString(capture[1]) : undefined,\n ref: capture[2] ?? '',\n };\n },\n _render(node, _, state = {}) {\n const ref = scope.current.references[node.ref];\n\n if (!ref) return null;\n\n return createElement('img', {\n key: state.key,\n alt: node.alt,\n src: sanitize(ref.target, 'img', 'src') ?? undefined,\n title: ref.title,\n });\n },\n },\n [RuleType.refLink]: {\n _scope: SCOPE_INLINE,\n _firstChars: [91 /* [ */],\n _qualify: (source) => source.indexOf('](') === -1,\n _match: inlineRegex(REFERENCE_LINK_R),\n _order: Priority.MAX,\n _parse(capture, parse, state) {\n return {\n children: parseSimpleInline(parse, capture[1] ?? '', state),\n fallbackChildren: capture[0] ?? '',\n ref: capture[2] ?? '',\n };\n },\n _render(node, output, state = {}) {\n const ref = scope.current.references[node.ref];\n\n if (!ref)\n return createElement(\n 'span',\n { key: state.key },\n node.fallbackChildren\n );\n\n return createElement(\n 'a',\n {\n key: state.key,\n href: sanitize(ref.target, 'a', 'href') ?? undefined,\n title: ref.title,\n },\n output(node.children, state)\n );\n },\n },\n [RuleType.table]: {\n _scope: SCOPE_BLOCK,\n _qualify: ['|'],\n _match: blockRegex(NP_TABLE_R),\n _order: Priority.HIGH,\n _parse(capture, parse, state) {\n state.inline = true;\n const align = capture[2] ? parseTableAlign(capture[2]) : [];\n const cells = capture[3]\n ? parseTableCells(capture[3], parse, state)\n : [];\n const header = parseTableRow(\n capture[1] ?? '',\n parse,\n state,\n !!cells.length\n );\n state.inline = false;\n\n return cells.length\n ? { align, cells, header, type: RuleType.table }\n : { children: header.flat(), type: RuleType.paragraph };\n },\n _render(node, output, state = {}) {\n const table = node as TableNode;\n const getStyle = (i: number) =>\n table.align[i] && table.align[i] !== 'left'\n ? { textAlign: table.align[i] }\n : {};\n\n return createElement(\n 'table',\n { key: state.key },\n createElement(\n 'thead',\n { key: 'thead' },\n createElement(\n 'tr',\n null,\n ...table.header.map((c, i) =>\n createElement(\n 'th',\n { key: i, style: getStyle(i) },\n output(c, state)\n )\n )\n )\n ),\n createElement(\n 'tbody',\n { key: 'tbody' },\n ...table.cells.map((row, i) =>\n createElement(\n 'tr',\n { key: i },\n ...row.map((c, j) =>\n createElement(\n 'td',\n { key: j, style: getStyle(j) },\n output(c, state)\n )\n )\n )\n )\n )\n );\n },\n },\n [RuleType.tableSeparator]: {\n _scope: SCOPE_INLINE,\n _qualify: ['|'],\n _match: (source, state) => (state.inTable ? /^\\|/.exec(source) : null),\n _order: Priority.HIGH,\n _parse() {\n return { type: RuleType.tableSeparator };\n },\n _render() {\n return ' | ';\n },\n },\n [RuleType.text]: {\n _scope: SCOPE_INLINE,\n _match: allowInline((source, _state) => {\n const len = source.length;\n if (source.charCodeAt(0) === 10 /* \\n */) {\n let j = 1;\n while (j < len && source.charCodeAt(j) === 32 /* space */) {\n j++;\n }\n if (\n j < len &&\n (source.charCodeAt(j) === 42 || // *\n source.charCodeAt(j) === 43 || // +\n source.charCodeAt(j) === 45 || // -\n (source.charCodeAt(j) >= 48 && source.charCodeAt(j) <= 57)) // 0-9\n ) {\n return [source.slice(0, j)] as unknown as RegExpMatchArray;\n }\n return ['\\n'] as unknown as RegExpMatchArray;\n }\n\n if (source.charCodeAt(0) === 58 /* : */) {\n const shortMatch = SHORTCODE_R.exec(source);\n if (shortMatch) return shortMatch;\n }\n // The first character always belongs to the run, whatever it is.\n TEXT_RUN_R.lastIndex = 1;\n TEXT_RUN_R.test(source);\n\n // Text is the most frequent capture by a wide margin, and its `_parse`\n // never re-enters the parser, so one scratch array serves every run\n // instead of allocating one per token.\n TEXT_CAPTURE[0] = source.slice(\n 0,\n trimHardBreak(source, TEXT_RUN_R.lastIndex)\n );\n\n return TEXT_CAPTURE;\n }),\n _order: Priority.MIN,\n _parse(capture) {\n const text = capture[0] ?? '';\n\n // Declaring `type` here — rather than letting the parser add it —\n // keeps every text node on one hidden class. `&` stops a run, so an\n // entity can only ever open one: testing the first character replaces\n // a scan of every character of every text node in the document.\n return {\n type: RuleType.text,\n text:\n text.charCodeAt(0) !== 38 /* & */\n ? text\n : text.replace(HTML_CHAR_CODE_R, (f, i) => {\n if (i.startsWith('#x'))\n return String.fromCharCode(parseInt(i.slice(2), 16));\n if (i.startsWith('#'))\n return String.fromCharCode(parseInt(i.slice(1), 10));\n return namedCodesToUnicode[i] || f;\n }),\n };\n },\n _render(node) {\n return node.text;\n },\n },\n [RuleType.textBolded]: {\n _scope: SCOPE_INLINE,\n _firstChars: [42 /* * */, 95 /* _ */],\n _qualify: (source) => {\n const c = source.charCodeAt(0);\n if (c === 42) {\n const next = source.charCodeAt(2);\n if (next === 32 || next === 10 || next === 9) return false;\n return source.charCodeAt(1) === 42 && source.indexOf('**', 2) !== -1;\n }\n if (c === 95) {\n const next = source.charCodeAt(2);\n if (next === 32 || next === 10 || next === 9) return false;\n return source.charCodeAt(1) === 95 && source.indexOf('__', 2) !== -1;\n }\n return false;\n },\n _match: simpleInlineRegex(TEXT_BOLD_R),\n _order: Priority.MED,\n _parse(capture, parse, state) {\n return { children: parse(capture[2] ?? '', state) };\n },\n _render(node, output, state = {}) {\n return createElement(\n 'strong',\n { key: state.key },\n output(node.children, state)\n );\n },\n },\n [RuleType.textEmphasized]: {\n _scope: SCOPE_INLINE,\n _firstChars: [42 /* * */, 95 /* _ */],\n _qualify: (source) => {\n const c = source.charCodeAt(0);\n const next = source.charCodeAt(1);\n if (next === 32 || next === 10 || next === 9) return false;\n return (\n (c === 42 && source.indexOf('*', 1) !== -1) ||\n (c === 95 && source.indexOf('_', 1) !== -1)\n );\n },\n _match: simpleInlineRegex(TEXT_EMPHASIZED_R),\n _order: Priority.LOW,\n _parse(capture, parse, state) {\n return { children: parse(capture[2] ?? '', state) };\n },\n _render(node, output, state = {}) {\n return createElement(\n 'em',\n { key: state.key },\n output(node.children, state)\n );\n },\n },\n [RuleType.textEscaped]: {\n _scope: SCOPE_INLINE,\n _qualify: ['\\\\'],\n _match: simpleInlineRegex(TEXT_ESCAPED_R),\n _order: Priority.HIGH,\n _parse(capture) {\n return { text: capture[1] ?? '', type: RuleType.text };\n },\n },\n [RuleType.textMarked]: {\n _scope: SCOPE_INLINE,\n _firstChars: [61 /* = */],\n _qualify: (source) => {\n const next = source.charCodeAt(2);\n if (next === 32 || next === 10 || next === 9) return false;\n return source.charCodeAt(1) === 61 && source.indexOf('==', 2) !== -1;\n },\n _match: simpleInlineRegex(TEXT_MARKED_R),\n _order: Priority.LOW,\n _parse(capture, parse, state) {\n return { children: parseCaptureInline(capture, parse, state).children };\n },\n _render(node, output, state = {}) {\n return createElement(\n 'mark',\n { key: state.key },\n output(node.children, state)\n );\n },\n },\n [RuleType.textStrikethroughed]: {\n _scope: SCOPE_INLINE,\n _firstChars: [126 /* ~ */],\n _qualify: (source) => {\n const next = source.charCodeAt(2);\n if (next === 32 || next === 10 || next === 9) return false;\n return source.charCodeAt(1) === 126 && source.indexOf('~~', 2) !== -1;\n },\n _match: simpleInlineRegex(TEXT_STRIKETHROUGHED_R),\n _order: Priority.LOW,\n _parse(capture, parse, state) {\n return { children: parseCaptureInline(capture, parse, state).children };\n },\n _render(node, output, state = {}) {\n return createElement(\n 'del',\n { key: state.key },\n output(node.children, state)\n );\n },\n },\n };\n\n return rules;\n};\n\n// Removed compilerCache completely to avoid issues with props changes not invalidating cache\n// const compilerCache = new Map<string, unknown>();\n\n/** Link/image reference definitions (`[id]: target \"title\"`) collected while parsing. */\nexport type MarkdownReferences = Record<\n string,\n { target: string; title?: string }\n>;\n\nexport type ParsedMarkdown = {\n ast: any[];\n footnotes: FootnoteDef[];\n /**\n * Reference definitions gathered during parsing. They must be carried over to\n * the render stage, since `refLink` / `refImage` nodes only store the\n * reference id and resolve their target at render time.\n */\n references: MarkdownReferences;\n inline: boolean;\n};\n\nconst STRIP_INDENT_REGEXES = [\n null,\n /^ {1,1}/gm,\n /^ {1,2}/gm,\n /^ {1,3}/gm,\n /^ {1,4}/gm,\n /^ {1,5}/gm,\n /^ {1,6}/gm,\n /^ {1,7}/gm,\n /^ {1,8}/gm,\n];\n\n/** Scratch capture reused by the text rule; see its `_match`. */\nconst TEXT_CAPTURE = [''] as unknown as RegExpMatchArray;\n\n/**\n * Consumes a run of plain text, stopping before the next character that could\n * open another inline rule or a bare URL. Anchored so `test` leaves the stop\n * offset in `lastIndex` without allocating a match array, and so the scan\n * itself runs in the regex engine.\n *\n * The bare-URL guard is an alternation branch rather than a per-character\n * lookahead, because a lookahead is re-evaluated at every offset while this\n * branch is only reached on an `h`. `&` stops a run purely so that an HTML\n * entity can only ever sit at offset 0 of a text node; adjacent text nodes are\n * merged by the parser, so the tree is unchanged.\n */\nconst TEXT_RUN_R = /(?:[^\\n&h!*:<=[\\\\_`~]+|h(?!ttp))*/y;\n\n/**\n * Pull a run's stop offset back before a hard line break it just swallowed.\n *\n * A run never contains a newline, so ` \\n` can only sit immediately before the\n * stop offset — which makes this O(1) check equivalent to the per-character\n * `(?! {2}\\n)` lookahead the run scanner used to carry.\n */\nconst trimHardBreak = (source: string, end: number): number =>\n end >= 3 &&\n source.charCodeAt(end) === 10 /* \\n */ &&\n source.charCodeAt(end - 1) === 32 /* space */ &&\n source.charCodeAt(end - 2) === 32\n ? end - 2\n : end;\n\nconst noopCreateElement: CreateElementFunction = (\n type,\n props,\n ...children\n) => ({\n children,\n props,\n type,\n});\n\n/**\n * Builds the rule set backing one document.\n *\n * Rules read the document's footnote and reference tables through `scope`\n * rather than closing over them, so one set serves every document sharing the\n * same options. Building this graph dominated the cost of compiling the many\n * short strings a dictionary holds; `getRuleSet` caches it.\n */\nconst createDocumentRules = (\n createElement: CreateElementFunction,\n ctx: MarkdownContext<any>,\n options: MarkdownOptions,\n scope: DocumentScopeRef\n): Rules => {\n const attrStringToMap = (\n tag: HTMLTag,\n str: string\n ): Record<string, any> | null => {\n if (!str?.trim()) return null;\n\n const attributes = str.match(ATTR_EXTRACTOR_R);\n\n if (!attributes) return null;\n\n return attributes.reduce((map: any, raw) => {\n const delimiterIdx = raw.indexOf('=');\n\n if (delimiterIdx !== -1) {\n const key = normalizeAttributeKey(raw.slice(0, delimiterIdx)).trim();\n const value = unquote(raw.slice(delimiterIdx + 1).trim());\n const mappedKey = ATTRIBUTE_TO_NODE_PROP_MAP[key] ?? key;\n\n if (mappedKey === 'ref') return map;\n map[mappedKey] = attributeValueToNodePropValue(\n tag,\n key,\n value,\n ctx.sanitizer ?? defaultSanitizer\n );\n\n if (\n typeof map[mappedKey] === 'string' &&\n startsWithElement(map[mappedKey])\n ) {\n map[mappedKey] = parseMarkdown(\n map[mappedKey].trim(),\n ctx,\n options\n ).ast;\n }\n } else if (raw !== 'style') {\n map[ATTRIBUTE_TO_NODE_PROP_MAP[raw] ?? raw] = true;\n }\n\n return map;\n }, {});\n };\n\n const nonParagraphBlockSyntaxes = [\n BLOCKQUOTE_R,\n CODE_BLOCK_FENCED_R,\n CODE_BLOCK_R,\n options.enforceAtxHeadings ? HEADING_ATX_COMPLIANT_R : HEADING_R,\n NP_TABLE_R,\n ORDERED_LIST_R,\n UNORDERED_LIST_R,\n startsWithCustomComponent,\n ];\n\n // Built once: this list is fixed for the whole parse, and rebuilding it per\n // call put a fresh array on every block-syntax probe.\n const blockSyntaxes = (\n options.disableParsingRawHTML\n ? nonParagraphBlockSyntaxes\n : [\n ...nonParagraphBlockSyntaxes,\n PARAGRAPH_R,\n startsWithHtmlBlockElement,\n HTML_COMMENT_R,\n startsWithSelfClosingElement,\n startsWithCustomComponent,\n ]\n ) as BlockSyntaxProbe[];\n\n const containsBlockSyntax = (input: string): boolean => {\n const cleaned = input.replace(TRIM_STARTING_NEWLINES, '');\n const slice = cleaned.length > 2048 ? cleaned.slice(0, 2048) : cleaned;\n\n if (slice.indexOf('\\n\\n') !== -1) return true;\n\n return some(blockSyntaxes, slice);\n };\n\n const baseRules = createRules(\n createElement,\n ctx,\n options,\n scope,\n attrStringToMap,\n containsBlockSyntax,\n nonParagraphBlockSyntaxes\n );\n\n return options.disableParsingRawHTML\n ? Object.keys(baseRules).reduce((acc, key) => {\n if (key !== RuleType.htmlBlock && key !== RuleType.htmlSelfClosing) {\n acc[key] = baseRules[key]!;\n }\n\n return acc;\n }, {} as Rules)\n : baseRules;\n};\n\n/** Runs the parse phase against an already-built rule set. */\nconst parseWithRules = (\n markdown: string,\n options: MarkdownOptions,\n parser: DocumentParser,\n footnotes: FootnoteDef[],\n refs: MarkdownReferences\n): ParsedMarkdown => {\n const result =\n !options.preserveFrontmatter && markdown.charCodeAt(0) === 45 /* - */\n ? markdown.replace(FRONT_MATTER_R, '')\n : markdown;\n // Stripped once and reused: both the block/inline decision and the block\n // input below need the source without its leading newlines.\n const trimmedStart =\n result.charCodeAt(0) === 10 /* \\n */\n ? result.replace(TRIM_STARTING_NEWLINES, '')\n : result;\n const inline =\n options.forceInline ||\n (!options.forceBlock &&\n SHOULD_RENDER_AS_BLOCK_R.test(trimmedStart) === false);\n\n const ast = parser(inline ? result : `${trimEnd(trimmedStart)}\\n\\n`, {\n inline,\n });\n\n if (footnotes.length > 0) {\n // Parse footnotes content as well\n for (const def of footnotes) {\n (def as any).parsedAst = parser(def.footnote, { inline: true });\n }\n }\n\n return { ast, footnotes, references: refs, inline };\n};\n\n/** Runs the render phase against an already-built rule set. */\nconst renderWithRules = (\n parsed: ParsedMarkdown,\n ctx: MarkdownContext<any>,\n options: MarkdownOptions,\n emitter: DocumentEmitter,\n createElement: CreateElementFunction\n): unknown => {\n const components = ctx.components ?? {};\n const slug = createSlugger(ctx);\n const footnotes = parsed.footnotes || [];\n\n const inline = parsed.inline;\n const arr = emitter(parsed.ast, { inline }) as unknown as any[];\n\n while (typeof arr[arr.length - 1] === 'string' && !arr[arr.length - 1].trim())\n arr.pop();\n\n const getOuterNode = () => {\n if (options.wrapper === null) return arr;\n const wrapper = options.wrapper ?? (inline ? 'span' : 'div');\n\n if (arr.length > 1 || options.forceWrapper)\n return createElement(wrapper, { key: 'outer' }, arr);\n\n if (arr.length === 1) {\n const node = arr[0];\n\n if (Array.isArray(node)) {\n return createElement(wrapper, { key: 'outer' }, node);\n }\n\n if (typeof node === 'string') {\n const spanProps: Record<string, any> = { key: 'outer' };\n\n if (!inline && components) {\n const pOverrideProps = (get(components, 'p.props', {}) ??\n {}) as Record<string, any>;\n const mergedClassName = cx(\n spanProps.className,\n pOverrideProps.className\n );\n const finalSpanProps: Record<string, any> = {\n ...spanProps,\n ...pOverrideProps,\n };\n\n if (mergedClassName) finalSpanProps.className = mergedClassName;\n\n return createElement('span', finalSpanProps, node);\n }\n\n return createElement('span', spanProps, node);\n }\n\n return node;\n }\n\n return createElement(wrapper, { key: 'outer' }, null);\n };\n\n const node = getOuterNode();\n\n const result = footnotes.length\n ? createElement(\n 'div',\n null,\n node,\n createElement(\n 'footer',\n { key: 'footer' },\n ...footnotes.map((def) =>\n createElement(\n 'div',\n { id: slug(def.identifier), key: def.identifier },\n def.identifier,\n emitter((def as any).parsedAst || def.footnote, { inline: true })\n )\n )\n )\n )\n : node;\n\n return result;\n};\n\nexport const parseMarkdown = (\n markdown: string = '',\n ctx: MarkdownContext<any>,\n options: MarkdownOptions = {}\n): ParsedMarkdown => {\n // Parsing never emits elements, so it gets its own cache entry built around\n // the no-op factory rather than the render one.\n const { parse, scope } = getRuleSet(ctx, options, true);\n const documentScope = createDocumentScope();\n\n return withDocumentScope(scope, documentScope, () =>\n parseWithRules(\n markdown,\n options,\n parse,\n documentScope.footnotes,\n documentScope.references\n )\n );\n};\n\nexport const renderMarkdownAst = (\n parsed: ParsedMarkdown,\n ctx: MarkdownContext<any>,\n options: MarkdownOptions = {}\n): unknown => {\n const { emit, createElement, scope } = getRuleSet(ctx, options, false);\n const documentScope: DocumentScope = {\n footnotes: parsed.footnotes ?? [],\n references: parsed.references ?? {},\n };\n\n return withDocumentScope(scope, documentScope, () =>\n renderWithRules(parsed, ctx, options, emit, createElement)\n );\n};\n\nexport const compile = (\n markdown: string = '',\n ctx: MarkdownContext<any>,\n options: MarkdownOptions = {}\n): unknown => {\n if (typeof markdown !== 'string') {\n if (process.env.NODE_ENV !== 'production') {\n console.error(\n 'intlayer: the first argument must be a string. Received',\n typeof markdown\n );\n }\n throw new Error('intlayer: the first argument must be a string');\n }\n\n // Both phases share one rule set: building it twice was the dominant cost\n // when compiling the many short strings a typical dictionary holds.\n const { parse, emit, createElement, scope } = getRuleSet(ctx, options, false);\n const documentScope = createDocumentScope();\n\n return withDocumentScope(scope, documentScope, () => {\n const parsed = parseWithRules(\n markdown,\n options,\n parse,\n documentScope.footnotes,\n documentScope.references\n );\n\n return renderWithRules(parsed, ctx, options, emit, createElement);\n });\n};\n\nexport const createCompiler =\n (ctx: MarkdownContext<any>) =>\n (markdown: string, options?: MarkdownOptions): unknown =>\n compile(markdown, ctx, options);\n\nexport const compileWithOptions = (\n markdown: string,\n runtime: MarkdownRuntime,\n options: CompileOptions<any> = {}\n): unknown => {\n const {\n components,\n namedCodesToUnicode,\n sanitizer,\n slugify,\n ...compilerOptions\n } = options;\n\n return compile(\n markdown,\n { runtime, components, namedCodesToUnicode, sanitizer, slugify },\n compilerOptions\n );\n};\n"],"mappings":";;;;;;;;AAwHA,MAAM,UAAU;AAKhB,MAAM,SAAS,IAAI,OACjB,4JACF;;;;;;;;;;;;;;AAeA,MAAM,qBAAqB,eAAyC;CAClE,IAAI,gBAA4C;CAIhD,IAAI,OAAO,KAAK,UAAU,CAAC,CAAC,WAAW,GAAG,QAAQ,QAAkB;CAEpE,MAAM,2BAAW,IAAI,IAAiB;CAEtC,QAAQ,QAAkB;EACxB,IAAI,OAAO,QAAQ,UAAU,OAAO;EAEpC,MAAM,WAAW,SAAS,IAAI,GAAG;EACjC,IAAI,aAAa,QAAW,OAAO;EAEnC,MAAM,WAAWA,2BAAI,YAAY,GAAG;EAEpC,IAAI,UAAU;GACZ,SAAS,IAAI,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