@temelj/mdx 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (373) hide show
  1. package/README.md +468 -82
  2. package/dist/character-entities.d.mts +4 -0
  3. package/dist/character-entities.d.mts.map +1 -0
  4. package/dist/character-entities.mjs +2132 -0
  5. package/dist/character-entities.mjs.map +1 -0
  6. package/dist/character-reference.d.mts +6 -0
  7. package/dist/character-reference.d.mts.map +1 -0
  8. package/dist/character-reference.mjs +18 -0
  9. package/dist/character-reference.mjs.map +1 -0
  10. package/dist/compile-analysis.d.mts +28 -0
  11. package/dist/compile-analysis.d.mts.map +1 -0
  12. package/dist/compile-analysis.mjs +74 -0
  13. package/dist/compile-analysis.mjs.map +1 -0
  14. package/dist/compile-emit.d.mts +9 -0
  15. package/dist/compile-emit.d.mts.map +1 -0
  16. package/dist/compile-emit.mjs +187 -0
  17. package/dist/compile-emit.mjs.map +1 -0
  18. package/dist/compile-esm.d.mts +34 -0
  19. package/dist/compile-esm.d.mts.map +1 -0
  20. package/dist/compile-esm.mjs +187 -0
  21. package/dist/compile-esm.mjs.map +1 -0
  22. package/dist/compile-names.d.mts +13 -0
  23. package/dist/compile-names.d.mts.map +1 -0
  24. package/dist/compile-names.mjs +32 -0
  25. package/dist/compile-names.mjs.map +1 -0
  26. package/dist/compiler.d.mts +69 -85
  27. package/dist/compiler.d.mts.map +1 -1
  28. package/dist/compiler.mjs +185 -418
  29. package/dist/compiler.mjs.map +1 -1
  30. package/dist/diagnostics.d.mts +37 -0
  31. package/dist/diagnostics.d.mts.map +1 -0
  32. package/dist/diagnostics.mjs +57 -0
  33. package/dist/diagnostics.mjs.map +1 -0
  34. package/dist/errors.d.mts +157 -0
  35. package/dist/errors.d.mts.map +1 -0
  36. package/dist/errors.mjs +263 -0
  37. package/dist/errors.mjs.map +1 -0
  38. package/dist/footnote-numbering.d.mts +27 -0
  39. package/dist/footnote-numbering.d.mts.map +1 -0
  40. package/dist/footnote-numbering.mjs +49 -0
  41. package/dist/footnote-numbering.mjs.map +1 -0
  42. package/dist/format-context.d.mts +46 -0
  43. package/dist/format-context.d.mts.map +1 -0
  44. package/dist/format-context.mjs +26 -0
  45. package/dist/format-context.mjs.map +1 -0
  46. package/dist/format-directive.d.mts +9 -0
  47. package/dist/format-directive.d.mts.map +1 -0
  48. package/dist/format-directive.mjs +99 -0
  49. package/dist/format-directive.mjs.map +1 -0
  50. package/dist/format-jsx.d.mts +8 -0
  51. package/dist/format-jsx.d.mts.map +1 -0
  52. package/dist/format-jsx.mjs +47 -0
  53. package/dist/format-jsx.mjs.map +1 -0
  54. package/dist/format-math.d.mts +9 -0
  55. package/dist/format-math.d.mts.map +1 -0
  56. package/dist/format-math.mjs +79 -0
  57. package/dist/format-math.mjs.map +1 -0
  58. package/dist/format-safe.d.mts +25 -0
  59. package/dist/format-safe.d.mts.map +1 -0
  60. package/dist/format-safe.mjs +366 -0
  61. package/dist/format-safe.mjs.map +1 -0
  62. package/dist/format-table.d.mts +8 -0
  63. package/dist/format-table.d.mts.map +1 -0
  64. package/dist/format-table.mjs +55 -0
  65. package/dist/format-table.mjs.map +1 -0
  66. package/dist/format-track.d.mts +18 -0
  67. package/dist/format-track.d.mts.map +1 -0
  68. package/dist/format-track.mjs +34 -0
  69. package/dist/format-track.mjs.map +1 -0
  70. package/dist/format.d.mts +7 -0
  71. package/dist/format.d.mts.map +1 -0
  72. package/dist/format.mjs +549 -0
  73. package/dist/format.mjs.map +1 -0
  74. package/dist/frontmatter.d.mts +15 -0
  75. package/dist/frontmatter.d.mts.map +1 -0
  76. package/dist/frontmatter.mjs +187 -0
  77. package/dist/frontmatter.mjs.map +1 -0
  78. package/dist/heading.d.mts +6 -0
  79. package/dist/heading.d.mts.map +1 -0
  80. package/dist/heading.mjs +19 -0
  81. package/dist/heading.mjs.map +1 -0
  82. package/dist/html-format.d.mts +32 -0
  83. package/dist/html-format.d.mts.map +1 -0
  84. package/dist/html-format.mjs +127 -0
  85. package/dist/html-format.mjs.map +1 -0
  86. package/dist/html-lower.d.mts +78 -0
  87. package/dist/html-lower.d.mts.map +1 -0
  88. package/dist/html-lower.mjs +583 -0
  89. package/dist/html-lower.mjs.map +1 -0
  90. package/dist/html-stream.d.mts +13 -0
  91. package/dist/html-stream.d.mts.map +1 -0
  92. package/dist/html-stream.mjs +32 -0
  93. package/dist/html-stream.mjs.map +1 -0
  94. package/dist/html.d.mts +120 -0
  95. package/dist/html.d.mts.map +1 -0
  96. package/dist/html.mjs +77 -0
  97. package/dist/html.mjs.map +1 -0
  98. package/dist/identifier.d.mts +4 -0
  99. package/dist/identifier.d.mts.map +1 -0
  100. package/dist/identifier.mjs +8 -0
  101. package/dist/identifier.mjs.map +1 -0
  102. package/dist/javascript-ast.d.mts +16 -0
  103. package/dist/javascript-ast.d.mts.map +1 -0
  104. package/dist/javascript-ast.mjs +39 -0
  105. package/dist/javascript-ast.mjs.map +1 -0
  106. package/dist/javascript-jsx.d.mts +24 -0
  107. package/dist/javascript-jsx.d.mts.map +1 -0
  108. package/dist/javascript-jsx.mjs +189 -0
  109. package/dist/javascript-jsx.mjs.map +1 -0
  110. package/dist/javascript.d.mts +9 -0
  111. package/dist/javascript.d.mts.map +1 -0
  112. package/dist/javascript.mjs +31 -0
  113. package/dist/javascript.mjs.map +1 -0
  114. package/dist/jsx-reference.d.mts +15 -0
  115. package/dist/jsx-reference.d.mts.map +1 -0
  116. package/dist/jsx-reference.mjs +31 -0
  117. package/dist/jsx-reference.mjs.map +1 -0
  118. package/dist/mod.d.mts +25 -9
  119. package/dist/mod.mjs +19 -8
  120. package/dist/model.d.mts +196 -0
  121. package/dist/model.d.mts.map +1 -0
  122. package/dist/model.mjs +113 -0
  123. package/dist/model.mjs.map +1 -0
  124. package/dist/parser/block-container-recognizers.d.mts +40 -0
  125. package/dist/parser/block-container-recognizers.d.mts.map +1 -0
  126. package/dist/parser/block-container-recognizers.mjs +90 -0
  127. package/dist/parser/block-container-recognizers.mjs.map +1 -0
  128. package/dist/parser/block-directive-recognizers.d.mts +22 -0
  129. package/dist/parser/block-directive-recognizers.d.mts.map +1 -0
  130. package/dist/parser/block-directive-recognizers.mjs +77 -0
  131. package/dist/parser/block-directive-recognizers.mjs.map +1 -0
  132. package/dist/parser/block-leaf-recognizers.d.mts +53 -0
  133. package/dist/parser/block-leaf-recognizers.d.mts.map +1 -0
  134. package/dist/parser/block-leaf-recognizers.mjs +386 -0
  135. package/dist/parser/block-leaf-recognizers.mjs.map +1 -0
  136. package/dist/parser/block-parser.d.mts +38 -0
  137. package/dist/parser/block-parser.d.mts.map +1 -0
  138. package/dist/parser/block-parser.mjs +895 -0
  139. package/dist/parser/block-parser.mjs.map +1 -0
  140. package/dist/parser/block-syntax.d.mts +240 -0
  141. package/dist/parser/block-syntax.d.mts.map +1 -0
  142. package/dist/parser/characters.d.mts +19 -0
  143. package/dist/parser/characters.d.mts.map +1 -0
  144. package/dist/parser/characters.mjs +52 -0
  145. package/dist/parser/characters.mjs.map +1 -0
  146. package/dist/parser/config.d.mts +16 -0
  147. package/dist/parser/config.d.mts.map +1 -0
  148. package/dist/parser/config.mjs +25 -0
  149. package/dist/parser/config.mjs.map +1 -0
  150. package/dist/parser/directive-attributes.d.mts +9 -0
  151. package/dist/parser/directive-attributes.d.mts.map +1 -0
  152. package/dist/parser/directive-attributes.mjs +24 -0
  153. package/dist/parser/directive-attributes.mjs.map +1 -0
  154. package/dist/parser/embedded-scanner.d.mts +18 -0
  155. package/dist/parser/embedded-scanner.d.mts.map +1 -0
  156. package/dist/parser/embedded-scanner.mjs +199 -0
  157. package/dist/parser/embedded-scanner.mjs.map +1 -0
  158. package/dist/parser/inline-autolink.d.mts +7 -0
  159. package/dist/parser/inline-autolink.d.mts.map +1 -0
  160. package/dist/parser/inline-autolink.mjs +42 -0
  161. package/dist/parser/inline-autolink.mjs.map +1 -0
  162. package/dist/parser/inline-character-reference.d.mts +7 -0
  163. package/dist/parser/inline-character-reference.d.mts.map +1 -0
  164. package/dist/parser/inline-character-reference.mjs +22 -0
  165. package/dist/parser/inline-character-reference.mjs.map +1 -0
  166. package/dist/parser/inline-code.d.mts +7 -0
  167. package/dist/parser/inline-code.d.mts.map +1 -0
  168. package/dist/parser/inline-code.mjs +29 -0
  169. package/dist/parser/inline-code.mjs.map +1 -0
  170. package/dist/parser/inline-directive.d.mts +9 -0
  171. package/dist/parser/inline-directive.d.mts.map +1 -0
  172. package/dist/parser/inline-directive.mjs +45 -0
  173. package/dist/parser/inline-directive.mjs.map +1 -0
  174. package/dist/parser/inline-embedded.d.mts +19 -0
  175. package/dist/parser/inline-embedded.d.mts.map +1 -0
  176. package/dist/parser/inline-embedded.mjs +92 -0
  177. package/dist/parser/inline-embedded.mjs.map +1 -0
  178. package/dist/parser/inline-emphasis.d.mts +11 -0
  179. package/dist/parser/inline-emphasis.d.mts.map +1 -0
  180. package/dist/parser/inline-emphasis.mjs +79 -0
  181. package/dist/parser/inline-emphasis.mjs.map +1 -0
  182. package/dist/parser/inline-input.d.mts +46 -0
  183. package/dist/parser/inline-input.d.mts.map +1 -0
  184. package/dist/parser/inline-input.mjs +137 -0
  185. package/dist/parser/inline-input.mjs.map +1 -0
  186. package/dist/parser/inline-link.d.mts +12 -0
  187. package/dist/parser/inline-link.d.mts.map +1 -0
  188. package/dist/parser/inline-link.mjs +187 -0
  189. package/dist/parser/inline-link.mjs.map +1 -0
  190. package/dist/parser/inline-math.d.mts +10 -0
  191. package/dist/parser/inline-math.d.mts.map +1 -0
  192. package/dist/parser/inline-math.mjs +46 -0
  193. package/dist/parser/inline-math.mjs.map +1 -0
  194. package/dist/parser/inline-output.d.mts +34 -0
  195. package/dist/parser/inline-output.d.mts.map +1 -0
  196. package/dist/parser/inline-output.mjs +62 -0
  197. package/dist/parser/inline-output.mjs.map +1 -0
  198. package/dist/parser/inline-parser.d.mts +14 -0
  199. package/dist/parser/inline-parser.d.mts.map +1 -0
  200. package/dist/parser/inline-parser.mjs +328 -0
  201. package/dist/parser/inline-parser.mjs.map +1 -0
  202. package/dist/parser/inline-pending.d.mts +23 -0
  203. package/dist/parser/inline-pending.d.mts.map +1 -0
  204. package/dist/parser/inline-pending.mjs +100 -0
  205. package/dist/parser/inline-pending.mjs.map +1 -0
  206. package/dist/parser/inline-syntax.d.mts +118 -0
  207. package/dist/parser/inline-syntax.d.mts.map +1 -0
  208. package/dist/parser/inline-syntax.mjs +1 -0
  209. package/dist/parser/javascript-boundary.d.mts +16 -0
  210. package/dist/parser/javascript-boundary.d.mts.map +1 -0
  211. package/dist/parser/javascript-boundary.mjs +42 -0
  212. package/dist/parser/javascript-boundary.mjs.map +1 -0
  213. package/dist/parser/javascript-scanner.d.mts +22 -0
  214. package/dist/parser/javascript-scanner.d.mts.map +1 -0
  215. package/dist/parser/javascript-scanner.mjs +122 -0
  216. package/dist/parser/javascript-scanner.mjs.map +1 -0
  217. package/dist/parser/materialize-cache.d.mts +34 -0
  218. package/dist/parser/materialize-cache.d.mts.map +1 -0
  219. package/dist/parser/materialize-cache.mjs +12 -0
  220. package/dist/parser/materialize-cache.mjs.map +1 -0
  221. package/dist/parser/materialize-jsx.d.mts +14 -0
  222. package/dist/parser/materialize-jsx.d.mts.map +1 -0
  223. package/dist/parser/materialize-jsx.mjs +76 -0
  224. package/dist/parser/materialize-jsx.mjs.map +1 -0
  225. package/dist/parser/materialize.d.mts +61 -0
  226. package/dist/parser/materialize.d.mts.map +1 -0
  227. package/dist/parser/materialize.mjs +736 -0
  228. package/dist/parser/materialize.mjs.map +1 -0
  229. package/dist/parser/recognizer.d.mts +20 -0
  230. package/dist/parser/recognizer.d.mts.map +1 -0
  231. package/dist/parser/recognizer.mjs +24 -0
  232. package/dist/parser/recognizer.mjs.map +1 -0
  233. package/dist/parser/session.d.mts +42 -0
  234. package/dist/parser/session.d.mts.map +1 -0
  235. package/dist/parser/session.mjs +89 -0
  236. package/dist/parser/session.mjs.map +1 -0
  237. package/dist/parser.d.mts +25 -0
  238. package/dist/parser.d.mts.map +1 -0
  239. package/dist/parser.mjs +37 -0
  240. package/dist/parser.mjs.map +1 -0
  241. package/dist/plugin-internal.d.mts +25 -0
  242. package/dist/plugin-internal.d.mts.map +1 -0
  243. package/dist/plugin-internal.mjs +99 -0
  244. package/dist/plugin-internal.mjs.map +1 -0
  245. package/dist/plugin.d.mts +37 -0
  246. package/dist/plugin.d.mts.map +1 -0
  247. package/dist/plugin.mjs +1 -0
  248. package/dist/plugins/code-block-metadata.d.mts +42 -0
  249. package/dist/plugins/code-block-metadata.d.mts.map +1 -0
  250. package/dist/plugins/code-block-metadata.mjs +133 -0
  251. package/dist/plugins/code-block-metadata.mjs.map +1 -0
  252. package/dist/plugins/heading-id.d.mts +15 -0
  253. package/dist/plugins/heading-id.d.mts.map +1 -0
  254. package/dist/plugins/heading-id.mjs +45 -0
  255. package/dist/plugins/heading-id.mjs.map +1 -0
  256. package/dist/plugins/lower-heading.d.mts +16 -0
  257. package/dist/plugins/lower-heading.d.mts.map +1 -0
  258. package/dist/plugins/lower-heading.mjs +28 -0
  259. package/dist/plugins/lower-heading.mjs.map +1 -0
  260. package/dist/plugins/math-render.d.mts +26 -0
  261. package/dist/plugins/math-render.d.mts.map +1 -0
  262. package/dist/plugins/math-render.mjs +51 -0
  263. package/dist/plugins/math-render.mjs.map +1 -0
  264. package/dist/plugins/mod.d.mts +9 -6
  265. package/dist/plugins/mod.mjs +8 -6
  266. package/dist/plugins/remove-esm.d.mts +10 -0
  267. package/dist/plugins/remove-esm.d.mts.map +1 -0
  268. package/dist/plugins/remove-esm.mjs +12 -0
  269. package/dist/plugins/remove-esm.mjs.map +1 -0
  270. package/dist/plugins/shiki.d.mts +21 -0
  271. package/dist/plugins/shiki.d.mts.map +1 -0
  272. package/dist/plugins/shiki.mjs +144 -0
  273. package/dist/plugins/shiki.mjs.map +1 -0
  274. package/dist/plugins/syntax-highlight.d.mts +38 -0
  275. package/dist/plugins/syntax-highlight.d.mts.map +1 -0
  276. package/dist/plugins/syntax-highlight.mjs +106 -0
  277. package/dist/plugins/syntax-highlight.mjs.map +1 -0
  278. package/dist/processor.d.mts +60 -0
  279. package/dist/processor.d.mts.map +1 -0
  280. package/dist/processor.mjs +106 -0
  281. package/dist/processor.mjs.map +1 -0
  282. package/dist/ranges.d.mts +10 -0
  283. package/dist/ranges.d.mts.map +1 -0
  284. package/dist/ranges.mjs +22 -0
  285. package/dist/ranges.mjs.map +1 -0
  286. package/dist/source-map.d.mts +28 -0
  287. package/dist/source-map.d.mts.map +1 -0
  288. package/dist/source-map.mjs +90 -0
  289. package/dist/source-map.mjs.map +1 -0
  290. package/dist/source-text.d.mts +35 -0
  291. package/dist/source-text.d.mts.map +1 -0
  292. package/dist/source-text.mjs +132 -0
  293. package/dist/source-text.mjs.map +1 -0
  294. package/dist/source.d.mts +86 -0
  295. package/dist/source.d.mts.map +1 -0
  296. package/dist/source.mjs +264 -0
  297. package/dist/source.mjs.map +1 -0
  298. package/dist/stream-events.d.mts +59 -0
  299. package/dist/stream-events.d.mts.map +1 -0
  300. package/dist/stream-events.mjs +115 -0
  301. package/dist/stream-events.mjs.map +1 -0
  302. package/dist/stream-session.d.mts +79 -0
  303. package/dist/stream-session.d.mts.map +1 -0
  304. package/dist/stream-session.mjs +904 -0
  305. package/dist/stream-session.mjs.map +1 -0
  306. package/dist/stream-tail.d.mts +84 -0
  307. package/dist/stream-tail.d.mts.map +1 -0
  308. package/dist/stream-tail.mjs +359 -0
  309. package/dist/stream-tail.mjs.map +1 -0
  310. package/dist/stream-types.d.mts +89 -0
  311. package/dist/stream-types.d.mts.map +1 -0
  312. package/dist/stream-types.mjs +1 -0
  313. package/dist/stream.d.mts +28 -0
  314. package/dist/stream.d.mts.map +1 -0
  315. package/dist/stream.mjs +68 -0
  316. package/dist/stream.mjs.map +1 -0
  317. package/dist/syntax-options.d.mts +21 -0
  318. package/dist/syntax-options.d.mts.map +1 -0
  319. package/dist/syntax-options.mjs +26 -0
  320. package/dist/syntax-options.mjs.map +1 -0
  321. package/dist/traversal.d.mts +25 -0
  322. package/dist/traversal.d.mts.map +1 -0
  323. package/dist/traversal.mjs +136 -0
  324. package/dist/traversal.mjs.map +1 -0
  325. package/dist/tree.d.mts +18 -0
  326. package/dist/tree.d.mts.map +1 -0
  327. package/dist/tree.mjs +43 -0
  328. package/dist/tree.mjs.map +1 -0
  329. package/dist/unified/adapter.d.mts +24 -0
  330. package/dist/unified/adapter.d.mts.map +1 -0
  331. package/dist/unified/adapter.mjs +44 -0
  332. package/dist/unified/adapter.mjs.map +1 -0
  333. package/dist/unified/mod.d.mts +2 -0
  334. package/dist/unified/mod.mjs +1 -0
  335. package/dist/unified/runtime.d.mts +10 -0
  336. package/dist/unified/runtime.d.mts.map +1 -0
  337. package/dist/unified/runtime.mjs +115 -0
  338. package/dist/unified/runtime.mjs.map +1 -0
  339. package/dist/unified/tree-bridge.d.mts +63 -0
  340. package/dist/unified/tree-bridge.d.mts.map +1 -0
  341. package/dist/unified/tree-bridge.mjs +876 -0
  342. package/dist/unified/tree-bridge.mjs.map +1 -0
  343. package/dist/uri.d.mts +5 -0
  344. package/dist/uri.d.mts.map +1 -0
  345. package/dist/uri.mjs +32 -0
  346. package/dist/uri.mjs.map +1 -0
  347. package/package.json +56 -30
  348. package/dist/plugins/heading-id/plugin.d.mts +0 -17
  349. package/dist/plugins/heading-id/plugin.d.mts.map +0 -1
  350. package/dist/plugins/heading-id/plugin.mjs +0 -23
  351. package/dist/plugins/heading-id/plugin.mjs.map +0 -1
  352. package/dist/plugins/katex/plugin.d.mts +0 -39
  353. package/dist/plugins/katex/plugin.d.mts.map +0 -1
  354. package/dist/plugins/katex/plugin.mjs +0 -107
  355. package/dist/plugins/katex/plugin.mjs.map +0 -1
  356. package/dist/plugins/remove-imports-exports.d.mts +0 -10
  357. package/dist/plugins/remove-imports-exports.d.mts.map +0 -1
  358. package/dist/plugins/remove-imports-exports.mjs +0 -15
  359. package/dist/plugins/remove-imports-exports.mjs.map +0 -1
  360. package/dist/plugins/syntax-highlight/code-meta.d.mts +0 -22
  361. package/dist/plugins/syntax-highlight/code-meta.d.mts.map +0 -1
  362. package/dist/plugins/syntax-highlight/code-meta.mjs +0 -38
  363. package/dist/plugins/syntax-highlight/code-meta.mjs.map +0 -1
  364. package/dist/plugins/syntax-highlight/plugin.d.mts +0 -57
  365. package/dist/plugins/syntax-highlight/plugin.d.mts.map +0 -1
  366. package/dist/plugins/syntax-highlight/plugin.mjs +0 -93
  367. package/dist/plugins/syntax-highlight/plugin.mjs.map +0 -1
  368. package/dist/plugins/tree-processor/plugin.d.mts +0 -19
  369. package/dist/plugins/tree-processor/plugin.d.mts.map +0 -1
  370. package/dist/plugins/tree-processor/plugin.mjs +0 -21
  371. package/dist/plugins/tree-processor/plugin.mjs.map +0 -1
  372. package/dist/types.d.mts +0 -2
  373. /package/dist/{types.mjs → parser/block-syntax.mjs} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-lower.d.mts","names":[],"sources":["../src/html-lower.ts"],"mappings":";;;;;iBAsCiB;WACN;WACA;WACA,+BAEH,wBAAwB;WACrB;WACA;;WAEA,SAAS;;;;;WAKT,gBACP,aACA,wBACA;;;;;;;iBASa;WACN,OAAO,QAAQ,SAAS;WACxB,OAAO,QAAQ,SAAS;;WAExB,OAAO,QAAQ,cAAc;;;UAI9B;WACC;WACA;WACA;WACA;WACA,UAAU;;wBAGL,2BAA2B;;;;;iBAQ1B;WACN,aAAa,uBAAuB;WACpC,WAAW,uBAAuB;WAClC,SAAS;;WAET,aAAa,MAAM,0BAA0B;;WAE7C;WACA,QAAQ;;WAER,WAAW,MAAM,qBAAqB;;KAU5C,cAAc,oBAAoB;wBAYvB,UAAU,UAAU,cAAc,UAAS,oBAAyB;;;;;wBAgCpE,WACd,gBAAgB,WAChB,OAAO,eACP,WAAW,UACV;;wBAKa,WAAW,gBAAgB,aAAa;;wBAKxC,mBAAmB,MAAM,UAAU;;wBA8TnC,qBACd,WAAW,mBACX,OAAO,gBACN;;UAwQO;WACC,oBAAoB;WACpB,eAAe;WACf;;wBAwQK,YACd,eACA,SAAS,mBACT"}
@@ -0,0 +1,583 @@
1
+ import { FootnoteNumbering } from "./footnote-numbering.mjs";
2
+ import { indexDocument, mdxChildren } from "./model.mjs";
3
+ import { formatMdx } from "./format.mjs";
4
+ import { isUrlControlCharacter, normalizeUri } from "./uri.mjs";
5
+ import { isFunction } from "@temelj/value";
6
+ //#region src/html-lower.ts
7
+ function createHtmlLoweringCache() {
8
+ return {
9
+ loose: /* @__PURE__ */ new WeakMap(),
10
+ tight: /* @__PURE__ */ new WeakMap(),
11
+ lists: /* @__PURE__ */ new WeakMap()
12
+ };
13
+ }
14
+ const percentEncodedByteLength = 2;
15
+ const hexadecimalRadix = 16;
16
+ const percentEncodedByte = /^[0-9A-Fa-f]{2}$/u;
17
+ const linkSchemes = /* @__PURE__ */ new Set([
18
+ "http",
19
+ "https",
20
+ "irc",
21
+ "ircs",
22
+ "mailto",
23
+ "xmpp"
24
+ ]);
25
+ const imageSchemes = /* @__PURE__ */ new Set(["http", "https"]);
26
+ function lowerHtml(document, options = {}) {
27
+ const index = indexDocument(document);
28
+ const numbering = new FootnoteNumbering();
29
+ const occurrences = /* @__PURE__ */ new Map();
30
+ for (const reference of footnoteReferences(document)) if (index.footnotes.has(reference.identifier)) occurrences.set(reference, numbering.reference(reference.identifier));
31
+ const scope = {
32
+ definition: (identifier) => index.definitions.get(identifier),
33
+ footnote: (identifier) => index.footnotes.get(identifier),
34
+ options,
35
+ occurrence: (node) => occurrences.get(node)
36
+ };
37
+ const children = lowerNodes(document.children, scope);
38
+ const footnotes = lowerFootnoteSection(numbering, scope);
39
+ if (footnotes !== void 0) children.push(footnotes);
40
+ return {
41
+ kind: "root",
42
+ children: joinBlocks(children),
43
+ origin: document.origin
44
+ };
45
+ }
46
+ /**
47
+ * Lowers sibling nodes in one scope. `previous` is the sibling before them,
48
+ * because text after a hard break drops its leading spaces.
49
+ */
50
+ function lowerNodes(nodes, scope, previous) {
51
+ return lowerChildren(nodes, {
52
+ scope,
53
+ listLoose: false,
54
+ volatile: { count: 0 }
55
+ }, previous);
56
+ }
57
+ /** Separates top-level blocks with line endings, like a document root. */
58
+ function joinBlocks(nodes) {
59
+ return wrap(nodes, false);
60
+ }
61
+ /** Footnote reference nodes in document order. */
62
+ function footnoteReferences(node) {
63
+ const result = [];
64
+ const visit = (current) => {
65
+ if (current.kind === "footnoteReference") result.push(current);
66
+ mdxChildren(current).forEach(visit);
67
+ };
68
+ visit(node);
69
+ return result;
70
+ }
71
+ function lowerHtmlNode(node, context) {
72
+ const replaced = context.scope.replace?.(node);
73
+ if (replaced !== void 0) {
74
+ context.volatile.count++;
75
+ return replaced;
76
+ }
77
+ const cache = context.listLoose ? context.scope.cache?.loose : context.scope.cache?.tight;
78
+ if (cache?.has(node) === true) return cache.get(node);
79
+ const volatile = context.volatile.count;
80
+ const lowered = lowerHtmlNodeCore(node, context);
81
+ const result = lowered === void 0 || node.origin === void 0 ? lowered : isHtmlNodeArray(lowered) ? lowered.map((item) => withOrigin(item, node.origin)) : withOrigin(lowered, node.origin);
82
+ if (context.volatile.count === volatile) cache?.set(node, result);
83
+ return result;
84
+ }
85
+ function isHtmlNodeArray(value) {
86
+ return Array.isArray(value);
87
+ }
88
+ function withOrigin(node, origin) {
89
+ return origin === void 0 || node.origin !== void 0 ? node : {
90
+ ...node,
91
+ origin
92
+ };
93
+ }
94
+ /** Authored source when the file is known, otherwise canonical MDX. */
95
+ function authored(node, context) {
96
+ const source = context.scope.options.source;
97
+ return source !== void 0 && node.origin !== void 0 ? source.slice(node.origin) : formatMdx(node);
98
+ }
99
+ function lowerHtmlNodeCore(node, context) {
100
+ switch (node.kind) {
101
+ case "text": return text(node.value);
102
+ case "emphasis": return htmlElement("em", node.children, context);
103
+ case "strong": return htmlElement("strong", node.children, context);
104
+ case "delete": return htmlElement("del", node.children, context);
105
+ case "directiveLabel": return lowerChildren(node.children, context);
106
+ case "textDirective": return lowerTextDirective(node, context);
107
+ case "inlineCode": return element("code", {}, [text(node.value.replace(/\r\n?|\n/gu, " "))]);
108
+ case "inlineMath": return {
109
+ kind: "math",
110
+ source: node.value.replace(/\r\n?|\n/gu, " "),
111
+ style: "inline"
112
+ };
113
+ case "hardBreak": return [element("br"), text("\n")];
114
+ case "link": return lowerLink(node.url, node.title, node.children, context);
115
+ case "linkReference": {
116
+ const definition = context.scope.definition(node.identifier);
117
+ if (definition !== void 0) return lowerLink(definition.url, definition.title, node.children, context);
118
+ return context.scope.provisional === true ? unresolvedReference("link", node, lowerChildren(node.children, context), context) : revertReference(node, context);
119
+ }
120
+ case "image": return lowerImage(node.url, node.alt, node.title, context);
121
+ case "imageReference": {
122
+ const definition = context.scope.definition(node.identifier);
123
+ if (definition !== void 0) return lowerImage(definition.url, node.alt, definition.title, context);
124
+ return context.scope.provisional === true ? unresolvedReference("image", node, [text(node.alt)], context) : text(formatMdx(node));
125
+ }
126
+ case "footnoteReference": {
127
+ context.volatile.count++;
128
+ const occurrence = context.scope.occurrence(node);
129
+ if (occurrence !== void 0) return lowerFootnoteReference(node, occurrence, context.scope.options);
130
+ return context.scope.provisional === true ? unresolvedReference("footnote", node, [], context) : text(formatMdx(node));
131
+ }
132
+ case "definition":
133
+ case "footnoteDefinition":
134
+ case "frontmatter":
135
+ case "esm": return;
136
+ case "leafDirective": return lowerLeafDirective(node, context);
137
+ case "containerDirective": return lowerContainerDirective(node, context);
138
+ case "rawHtmlBlock":
139
+ case "rawHtmlInline": return {
140
+ kind: "raw",
141
+ value: node.value
142
+ };
143
+ case "inlineExpression":
144
+ case "blockExpression": return {
145
+ kind: "expression",
146
+ code: node.code,
147
+ fallback: authored(node, context)
148
+ };
149
+ case "jsxTextElement":
150
+ case "jsxFlowElement": return {
151
+ kind: "jsx",
152
+ state: "complete",
153
+ element: node.kind === "jsxFlowElement" ? "flow" : "text",
154
+ name: node.name,
155
+ attributes: node.attributes,
156
+ fallback: authored(node, context),
157
+ children: lowerChildren(node.children, context)
158
+ };
159
+ case "paragraph": return node.children.every(isEmbeddedPhrasing) && node.children.some((child) => child.kind !== "text") ? lowerChildren(node.children, context) : htmlElement("p", node.children, context);
160
+ case "heading": return htmlElement(`h${node.depth}`, node.children, context);
161
+ case "codeBlock": {
162
+ const language = node.language?.trim().split(/\s+/u)[0];
163
+ return language === void 0 || language.length === 0 ? element("pre", {}, [element("code", {}, [text(node.value.length === 0 ? "" : `${node.value}\n`)])]) : {
164
+ kind: "codeBlock",
165
+ code: node.value,
166
+ language,
167
+ meta: node.meta
168
+ };
169
+ }
170
+ case "displayMath": return {
171
+ kind: "math",
172
+ source: node.value,
173
+ style: "display",
174
+ meta: node.meta
175
+ };
176
+ case "thematicBreak": return element("hr");
177
+ case "list": return lowerList(node, context);
178
+ case "listItem": return lowerListItem(node, context);
179
+ case "table": return lowerTable(node, context);
180
+ case "tableRow": return lowerTableRow(node, void 0, false, context);
181
+ case "tableCell": return htmlElement("td", node.children, context);
182
+ case "blockquote": return element("blockquote", {}, wrap(lowerChildren(node.children, context), true));
183
+ case "document": return wrap(lowerChildren(node.children, context), false);
184
+ default: return node;
185
+ }
186
+ }
187
+ function isEmbeddedPhrasing(node) {
188
+ return node.kind === "jsxTextElement" || node.kind === "inlineExpression" || node.kind === "text" && node.value.trim() === "";
189
+ }
190
+ function lowerTextDirective(node, context) {
191
+ return element("span", directiveHtmlAttributes(node.name, "text", node.attributes), node.label === void 0 ? [] : lowerChildren(node.label.children, context));
192
+ }
193
+ function lowerLeafDirective(node, context) {
194
+ return element("div", directiveHtmlAttributes(node.name, "leaf", node.attributes), node.label === void 0 ? [] : [directiveLabel(node, context)]);
195
+ }
196
+ function lowerContainerDirective(node, context) {
197
+ const children = [];
198
+ if (node.label !== void 0) children.push(directiveLabel(node, context));
199
+ children.push(...lowerChildren(node.children, context));
200
+ return element("div", directiveHtmlAttributes(node.name, "container", node.attributes), wrap(children, true));
201
+ }
202
+ function directiveLabel(node, context) {
203
+ return element("span", { "data-directive-label": "" }, lowerChildren(node.label?.children ?? [], context));
204
+ }
205
+ function directiveHtmlAttributes(name, kind, entries) {
206
+ const attributes = {
207
+ "data-directive": name,
208
+ "data-directive-kind": kind
209
+ };
210
+ return entries.length === 0 ? attributes : {
211
+ ...attributes,
212
+ "data-directive-attributes": JSON.stringify(entries.map((entry) => [entry.name, entry.value]))
213
+ };
214
+ }
215
+ function unresolvedReference(reference, node, children, context) {
216
+ return {
217
+ kind: "unresolvedReference",
218
+ reference,
219
+ identifier: node.identifier,
220
+ source: authored(node, context),
221
+ children
222
+ };
223
+ }
224
+ function lowerFootnoteReference(node, occurrence, options) {
225
+ const prefix = options.clobberPrefix ?? "user-content-";
226
+ const identifier = normalizeUri(node.identifier.toLowerCase());
227
+ const suffix = occurrence.occurrence > 1 ? `-${occurrence.occurrence}` : "";
228
+ return {
229
+ kind: "footnoteReference",
230
+ identifier: node.identifier,
231
+ occurrence: occurrence.occurrence,
232
+ ordinal: occurrence.ordinal,
233
+ children: [element("a", {
234
+ href: `#${prefix}fn-${identifier}`,
235
+ id: `${prefix}fnref-${identifier}${suffix}`,
236
+ "data-footnote-ref": "",
237
+ "aria-describedby": "footnote-label"
238
+ }, [text(String(occurrence.ordinal))])]
239
+ };
240
+ }
241
+ /** The generated section for the numbered footnotes, or `undefined` when none is referenced. */
242
+ function lowerFootnoteSection(numbering, scope) {
243
+ const order = numbering.order;
244
+ if (order.length === 0) return;
245
+ const context = {
246
+ scope,
247
+ listLoose: false,
248
+ volatile: { count: 0 }
249
+ };
250
+ const prefix = scope.options.clobberPrefix ?? "user-content-";
251
+ const items = [];
252
+ for (let index = 0; index < order.length; index++) {
253
+ const identifier = order[index];
254
+ const definition = scope.footnote(identifier);
255
+ if (definition === void 0) continue;
256
+ const safeIdentifier = normalizeUri(identifier.toLowerCase());
257
+ const blocks = lowerChildren(definition.children, context);
258
+ const backreferences = footnoteBackreferences(safeIdentifier, index, numbering.count(identifier), prefix, scope.options);
259
+ const tail = blocks.at(-1);
260
+ if (tail?.kind === "element" && tail.tagName === "p") blocks[blocks.length - 1] = {
261
+ ...tail,
262
+ children: [
263
+ ...tail.children,
264
+ ...tail.children.length === 0 ? [] : [text(" ")],
265
+ ...backreferences
266
+ ]
267
+ };
268
+ else {
269
+ if (blocks.length > 0) blocks.push(text("\n"));
270
+ blocks.push(...backreferences);
271
+ }
272
+ items.push(element("li", { id: `${prefix}fn-${safeIdentifier}` }, wrap(blocks, true)));
273
+ }
274
+ const heading = element(scope.options.footnoteLabelTagName ?? "h2", {
275
+ id: "footnote-label",
276
+ class: ["sr-only"]
277
+ }, [text(scope.options.footnoteLabel ?? "Footnotes")]);
278
+ return {
279
+ kind: "footnoteSection",
280
+ identifiers: [...order],
281
+ children: wrap([heading, element("ol", {}, wrap(items, true))], true)
282
+ };
283
+ }
284
+ function footnoteBackreferences(identifier, referenceIndex, count, prefix, options) {
285
+ const values = [];
286
+ for (let reuse = 1; reuse <= count; reuse++) {
287
+ if (values.length > 0) values.push(text(" "));
288
+ const configured = options.footnoteBackLabel;
289
+ const label = isFunction(configured) ? configured(referenceIndex, reuse) : configured ?? defaultFootnoteBackLabel(referenceIndex, reuse);
290
+ values.push(element("a", {
291
+ href: `#${prefix}fnref-${identifier}${reuse > 1 ? `-${reuse}` : ""}`,
292
+ "data-footnote-backref": "",
293
+ "aria-label": label,
294
+ class: ["data-footnote-backref"]
295
+ }, [text("↩"), ...reuse > 1 ? [element("sup", {}, [text(String(reuse))])] : []]));
296
+ }
297
+ return values;
298
+ }
299
+ function defaultFootnoteBackLabel(referenceIndex, reuse) {
300
+ return `Back to reference ${referenceIndex + 1}${reuse > 1 ? `-${reuse}` : ""}`;
301
+ }
302
+ function lowerTable(node, context) {
303
+ const head = node.children[0];
304
+ const children = [];
305
+ if (head !== void 0) children.push(element("thead", {}, [lowerTableRow(head, node.alignments, true, context)]));
306
+ if (node.children.length > 1) children.push(element("tbody", {}, node.children.slice(1).map((row) => lowerTableRow(row, node.alignments, false, context))));
307
+ return element("table", {}, children);
308
+ }
309
+ function lowerTableRow(node, alignments, heading, context) {
310
+ const length = alignments?.length ?? node.children.length;
311
+ const cells = [];
312
+ for (let index = 0; index < length; index++) {
313
+ const cell = node.children.at(index);
314
+ const alignment = alignments?.[index];
315
+ cells.push(element(heading ? "th" : "td", alignment === void 0 || alignment === "none" ? {} : { align: alignment }, cell === void 0 ? [] : lowerChildren(cell.children, context)));
316
+ }
317
+ return element("tr", {}, cells);
318
+ }
319
+ function lowerLink(url, title, children, context) {
320
+ const href = resolveUrl(url, "link", context.scope.options);
321
+ return element("a", href === void 0 ? {} : title === void 0 ? { href } : {
322
+ href,
323
+ title
324
+ }, lowerChildren(children, context));
325
+ }
326
+ function lowerImage(source, alt, title, context) {
327
+ const src = resolveUrl(source, "image", context.scope.options);
328
+ if (src === void 0) return text(alt);
329
+ return element("img", title === void 0 ? {
330
+ src,
331
+ alt
332
+ } : {
333
+ src,
334
+ alt,
335
+ title
336
+ });
337
+ }
338
+ /**
339
+ * A list wraps its items in line endings. A growing list reuses the wrapped
340
+ * children of its unchanged leading items, so an append lowers only new items.
341
+ * Stream previews build long children from fixed fragments, so extending them
342
+ * copies only the fragment list; strict output stays flat.
343
+ */
344
+ function lowerList(node, context) {
345
+ const items = node.children;
346
+ const prefix = listPrefix(items, context.scope.cache);
347
+ const rest = items.slice((prefix?.index ?? -1) + 1);
348
+ const spread = (prefix?.spread ?? false) || rest.some((item) => item.spread);
349
+ const loose = node.spread || spread;
350
+ const tasks = (prefix?.tasks ?? false) || rest.some((item) => item.checked !== void 0);
351
+ const reused = prefix !== void 0 && prefix.loose === loose ? prefix : void 0;
352
+ const itemContext = {
353
+ ...context,
354
+ listLoose: loose
355
+ };
356
+ const children = new ChildSequence(context.scope.provisional === true, reused?.children);
357
+ if (reused === void 0) children.push(newline);
358
+ let stable = true;
359
+ let spreadSoFar = reused?.spread ?? false;
360
+ let tasksSoFar = reused?.tasks ?? false;
361
+ for (let index = (reused?.index ?? -1) + 1; index < items.length; index++) {
362
+ spreadSoFar ||= items[index].spread;
363
+ tasksSoFar ||= items[index].checked !== void 0;
364
+ const volatile = context.volatile.count;
365
+ const lowered = lowerHtmlNode(items[index], itemContext);
366
+ for (const item of lowered === void 0 ? [] : isHtmlNodeArray(lowered) ? lowered : [lowered]) {
367
+ if (children.size > 1) children.push(newline);
368
+ children.push(item);
369
+ }
370
+ stable &&= context.volatile.count === volatile;
371
+ if (stable && index >= items.length - prefixWindow) context.scope.cache?.lists.set(items[index], {
372
+ index,
373
+ loose,
374
+ spread: spreadSoFar,
375
+ tasks: tasksSoFar,
376
+ children: children.prefix()
377
+ });
378
+ }
379
+ const attributes = {};
380
+ if (node.ordered && node.start !== 1) attributes.start = node.start;
381
+ if (tasks) attributes.class = ["contains-task-list"];
382
+ if (children.size > 1) children.push(newline);
383
+ return element(node.ordered ? "ol" : "ul", attributes, children.toArray());
384
+ }
385
+ /**
386
+ * How far back a list prefix can end. The parser closes an item only when the
387
+ * next line completes, so the last two items are rebuilt by each tail draft.
388
+ */
389
+ const prefixWindow = 8;
390
+ /** Children of a long sequence in fragments of this many nodes. */
391
+ const fragmentSize = 64;
392
+ /**
393
+ * Children that grow at the end. With fragments, full groups of nodes become
394
+ * frozen fragments that later prefixes share, so copying a prefix costs only
395
+ * the fragment list and the partial group.
396
+ */
397
+ var ChildSequence = class {
398
+ #fragmented;
399
+ #fragments;
400
+ #rest;
401
+ #size;
402
+ constructor(fragmented, prefix) {
403
+ this.#fragmented = fragmented;
404
+ this.#fragments = prefix === void 0 ? [] : [...prefix.fragments];
405
+ this.#rest = prefix === void 0 ? [] : [...prefix.rest];
406
+ this.#size = prefix?.size ?? 0;
407
+ }
408
+ get size() {
409
+ return this.#size;
410
+ }
411
+ push(node) {
412
+ this.#rest.push(node);
413
+ this.#size++;
414
+ if (this.#fragmented && this.#rest.length === fragmentSize) {
415
+ this.#fragments.push(Object.freeze({
416
+ kind: "root",
417
+ children: this.#rest
418
+ }));
419
+ this.#rest = [];
420
+ }
421
+ }
422
+ prefix() {
423
+ return {
424
+ fragments: [...this.#fragments],
425
+ rest: [...this.#rest],
426
+ size: this.#size
427
+ };
428
+ }
429
+ /** A short sequence stays flat, so fragments appear only where they save copying. */
430
+ toArray() {
431
+ if (this.#fragments.length < 2) return [...this.#fragments.flatMap((fragment) => fragment.children), ...this.#rest];
432
+ return [...this.#fragments, ...this.#rest];
433
+ }
434
+ };
435
+ /** The longest cached prefix of `items`, found from the end. */
436
+ function listPrefix(items, cache) {
437
+ for (let index = items.length - 1; index >= Math.max(0, items.length - prefixWindow); index--) {
438
+ const item = items[index];
439
+ const prefix = item === void 0 ? void 0 : cache?.lists.get(item);
440
+ if (prefix?.index === index) return prefix;
441
+ }
442
+ }
443
+ function lowerListItem(node, context) {
444
+ const blocks = [...lowerChildren(node.children, context)];
445
+ if (node.checked !== void 0) {
446
+ const checkbox = element("input", node.checked ? {
447
+ type: "checkbox",
448
+ disabled: true,
449
+ checked: true
450
+ } : {
451
+ type: "checkbox",
452
+ disabled: true
453
+ });
454
+ const first = blocks[0];
455
+ if (first?.kind === "element" && first.tagName === "p") blocks[0] = {
456
+ ...first,
457
+ children: [
458
+ checkbox,
459
+ ...first.children.length === 0 ? [] : [text(" ")],
460
+ ...first.children
461
+ ]
462
+ };
463
+ else blocks.unshift(element("p", {}, [checkbox]));
464
+ }
465
+ const children = [];
466
+ for (let index = 0; index < blocks.length; index++) {
467
+ const child = blocks[index];
468
+ const paragraph = child.kind === "element" && child.tagName === "p";
469
+ if (context.listLoose || index !== 0 || !paragraph) children.push(text("\n"));
470
+ if (paragraph && !context.listLoose) children.push(...child.children);
471
+ else children.push(child);
472
+ }
473
+ const tail = blocks.at(-1);
474
+ if (tail !== void 0 && (context.listLoose || tail.kind !== "element" || tail.tagName !== "p")) children.push(text("\n"));
475
+ return element("li", node.checked === void 0 ? {} : { class: ["task-list-item"] }, children);
476
+ }
477
+ function revertReference(node, context) {
478
+ const children = lowerChildren(node.children, context);
479
+ const suffix = node.referenceKind === "shortcut" ? "]" : node.referenceKind === "collapsed" ? "][]" : `][${node.identifier}]`;
480
+ if (children.length === 0) return [text(`[${suffix}`)];
481
+ const first = children[0];
482
+ const result = first.kind === "text" ? [text(`[${first.value}`), ...children.slice(1)] : [text("["), ...children];
483
+ const last = result[result.length - 1];
484
+ if (last.kind === "text") result[result.length - 1] = text(last.value + suffix);
485
+ else result.push(text(suffix));
486
+ return result;
487
+ }
488
+ function lowerChildren(children, context, previous) {
489
+ const values = [];
490
+ for (let index = 0; index < children.length; index++) {
491
+ const child = children[index];
492
+ const lowered = lowerHtmlNode(child, context);
493
+ if (lowered === void 0) continue;
494
+ const additions = isHtmlNodeArray(lowered) ? [...lowered] : [lowered];
495
+ if ((index === 0 ? previous : children[index - 1])?.kind === "hardBreak" && additions.length > 0) additions[0] = trimSpaceStart(additions[0]);
496
+ values.push(...additions);
497
+ }
498
+ return values;
499
+ }
500
+ function htmlElement(tagName, children, context) {
501
+ return element(tagName, {}, lowerChildren(children, context));
502
+ }
503
+ function element(tagName, attributes = {}, children = []) {
504
+ return {
505
+ kind: "element",
506
+ tagName,
507
+ attributes,
508
+ children
509
+ };
510
+ }
511
+ function text(value) {
512
+ return {
513
+ kind: "text",
514
+ value
515
+ };
516
+ }
517
+ function trimSpaceStart(node) {
518
+ if (node.kind === "text") return {
519
+ ...node,
520
+ value: node.value.replace(/^[\t ]+/u, "")
521
+ };
522
+ if (node.kind === "element") {
523
+ const first = node.children[0];
524
+ if (first?.kind === "text") return {
525
+ ...node,
526
+ children: [{
527
+ ...first,
528
+ value: first.value.replace(/^[\t ]+/u, "")
529
+ }, ...node.children.slice(1)]
530
+ };
531
+ }
532
+ return node;
533
+ }
534
+ /** Line endings between blocks. Trees are immutable, so every separator shares one node. */
535
+ const newline = Object.freeze({
536
+ kind: "text",
537
+ value: "\n"
538
+ });
539
+ function wrap(nodes, loose) {
540
+ const result = [];
541
+ if (loose) result.push(newline);
542
+ nodes.forEach((node, index) => {
543
+ if (index > 0) result.push(newline);
544
+ result.push(node);
545
+ });
546
+ if (loose && nodes.length > 0) result.push(newline);
547
+ return result;
548
+ }
549
+ function resolveUrl(url, kind, options) {
550
+ const sanitized = sanitizeUrl(url, options, kind);
551
+ return options.urlTransform === void 0 ? sanitized : options.urlTransform(url, kind, sanitized);
552
+ }
553
+ function sanitizeUrl(value, options, use) {
554
+ const decoded = decodeUrlForSchemeCheck(value);
555
+ const colon = decoded.indexOf(":");
556
+ const slash = decoded.indexOf("/");
557
+ const query = decoded.indexOf("?");
558
+ const hash = decoded.indexOf("#");
559
+ if (colon >= 0 && (slash < 0 || colon < slash) && (query < 0 || colon < query) && (hash < 0 || colon < hash) && options.allowUnsafeUrls !== true) {
560
+ const scheme = decoded.slice(0, colon).toLowerCase();
561
+ if (use === "image" ? !imageSchemes.has(scheme) : !linkSchemes.has(scheme)) return;
562
+ }
563
+ return normalizeUri(value);
564
+ }
565
+ function decodeUrlForSchemeCheck(value) {
566
+ const result = [];
567
+ for (let index = 0; index < value.length; index++) {
568
+ const character = value[index];
569
+ const hexadecimal = value.slice(index + 1, index + 1 + percentEncodedByteLength);
570
+ if (character === "%" && percentEncodedByte.test(hexadecimal)) {
571
+ const decoded = String.fromCodePoint(Number.parseInt(hexadecimal, hexadecimalRadix));
572
+ if (!isUrlControlCharacter(decoded)) result.push(decoded);
573
+ index += hexadecimal.length;
574
+ continue;
575
+ }
576
+ if (!isUrlControlCharacter(character)) result.push(character);
577
+ }
578
+ return result.join("");
579
+ }
580
+ //#endregion
581
+ export { createHtmlLoweringCache, footnoteReferences, joinBlocks, lowerFootnoteSection, lowerHtml, lowerNodes, sanitizeUrl };
582
+
583
+ //# sourceMappingURL=html-lower.mjs.map