@intlayer/core 8.1.2 → 8.1.3

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