react-native-marcus 0.1.0 → 0.2.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 (294) hide show
  1. package/README.md +220 -63
  2. package/RNMarcus.podspec +6 -0
  3. package/android/src/main/java/app/getbullet/marcus/MarcusPackage.kt +2 -1
  4. package/android/src/main/java/app/getbullet/marcus/MarcusTextDecoratorView.kt +168 -0
  5. package/android/src/main/java/app/getbullet/marcus/MarcusTextDecoratorViewManager.kt +38 -0
  6. package/android/src/main/java/app/getbullet/marcus/MarcusTextDecoratorViewManagerSpec.kt +19 -0
  7. package/android/src/main/java/app/getbullet/marcus/MarcusTextInputDecoratorView.kt +23 -1
  8. package/android/src/main/java/app/getbullet/marcus/MarkdownBackgroundPainter.kt +147 -0
  9. package/android/src/main/java/app/getbullet/marcus/MarkdownBackgroundPass.kt +19 -0
  10. package/android/src/main/java/app/getbullet/marcus/MarkdownCopy.kt +87 -0
  11. package/android/src/main/java/app/getbullet/marcus/MarkdownFormatter.kt +652 -113
  12. package/android/src/main/java/app/getbullet/marcus/MarkdownRanges.kt +47 -0
  13. package/android/src/main/java/app/getbullet/marcus/MarkdownStyle.kt +140 -61
  14. package/android/src/main/java/app/getbullet/marcus/MarkdownUtils.kt +37 -7
  15. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownAbsoluteLineHeightSpan.kt +48 -0
  16. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownBackgroundSpan.kt +102 -48
  17. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownBlockIndentSpan.kt +22 -4
  18. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownBulletSpan.kt +78 -0
  19. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownCodeBlockSpan.kt +177 -0
  20. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownFontStyleSpan.kt +32 -0
  21. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownFontWeightSpan.kt +34 -0
  22. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownGapSpan.kt +24 -11
  23. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownLetterSpacingSpan.kt +32 -0
  24. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownTextShadowSpan.kt +32 -0
  25. package/android/src/main/new_arch/CMakeLists.txt +17 -0
  26. package/android/src/main/new_arch/RNMarcusSpec.h +1 -0
  27. package/android/src/main/new_arch/react/renderer/components/RNMarcusSpec/MarcusTextDecoratorShadowNode.cpp +235 -0
  28. package/android/src/main/new_arch/react/renderer/components/RNMarcusSpec/MarcusTextDecoratorShadowNode.h +62 -0
  29. package/android/src/reactNativeVersionPatch/CustomMountingManager/81/app/getbullet/marcus/CustomFabricUIManager.java +22 -3
  30. package/android/src/reactNativeVersionPatch/CustomMountingManager/latest/app/getbullet/marcus/CustomFabricUIManager.java +22 -3
  31. package/android/src/test/java/app/getbullet/marcus/MarkdownCopyTest.kt +69 -0
  32. package/android/src/test/java/app/getbullet/marcus/MarkdownFormatterTest.kt +170 -25
  33. package/android/src/test/java/app/getbullet/marcus/RenderModel.kt +22 -5
  34. package/android/src/test/java/app/getbullet/marcus/spans/MarkdownCodeBlockSpanTest.kt +91 -0
  35. package/android/src/test/resources/render-model.txt +221 -16
  36. package/apple/MarcusSwizzle.h +25 -0
  37. package/apple/MarcusTextDecoratorComponentView.h +22 -0
  38. package/apple/MarcusTextDecoratorComponentView.mm +72 -0
  39. package/apple/MarcusTextDecoratorShadowNode.h +62 -0
  40. package/apple/MarcusTextDecoratorShadowNode.mm +192 -0
  41. package/apple/MarcusTextDecoratorViewManager.h +4 -0
  42. package/apple/MarcusTextDecoratorViewManager.mm +11 -0
  43. package/apple/MarcusTextInputDecoratorComponentView.mm +1 -1
  44. package/apple/MarcusTextInputDecoratorShadowNode.mm +1 -1
  45. package/apple/MarcusTextLayoutManager.h +40 -0
  46. package/apple/MarcusTextLayoutManager.mm +173 -0
  47. package/apple/MarkdownAttributes.h +23 -2
  48. package/apple/MarkdownAttributes.m +6 -0
  49. package/apple/MarkdownCopy.swift +63 -0
  50. package/apple/MarkdownDecorator.swift +2 -2
  51. package/apple/MarkdownFormatter+React.swift +23 -0
  52. package/apple/MarkdownFormatter.swift +869 -148
  53. package/apple/MarkdownParagraphLayoutManager.swift +455 -0
  54. package/apple/MarkdownSwiftInterop.h +0 -1
  55. package/apple/MarkdownTextBackground.swift +59 -1
  56. package/apple/MarkdownTextFieldObserver.swift +2 -2
  57. package/apple/MarkdownTextLayoutFragment.swift +159 -33
  58. package/apple/MarkdownTextLayoutManagerDelegate.swift +67 -3
  59. package/apple/MarkdownTextStorageDelegate.swift +2 -2
  60. package/apple/MarkdownTextViewObserver.swift +2 -2
  61. package/apple/MarkdownUtils.swift +38 -0
  62. package/apple/MarkdownWritingDirection.swift +132 -0
  63. package/apple/RCTMarcusStyle+Codegen.h +115 -9
  64. package/apple/RCTMarcusStyle.h +128 -31
  65. package/apple/RCTMarcusStyle.m +48 -0
  66. package/apple/RCTParagraphComponentView+Marcus.h +17 -0
  67. package/apple/RCTParagraphComponentView+Marcus.mm +38 -0
  68. package/apple/RCTTextInputComponentView+Marcus.mm +1 -25
  69. package/cpp/react/renderer/components/RNMarcusSpec/MarcusTextDecoratorState.h +37 -0
  70. package/cpp/react/renderer/components/RNMarcusSpec/MarcusTextDecoratorViewComponentDescriptor.h +17 -0
  71. package/lib/commonjs/MarcusTextDecoratorViewNativeComponent.ts +199 -0
  72. package/lib/commonjs/MarcusTextInputDecoratorViewNativeComponent.ts +145 -58
  73. package/lib/commonjs/MarkdownText.js +330 -0
  74. package/lib/commonjs/MarkdownText.js.map +1 -0
  75. package/lib/commonjs/MarkdownText.web.js +529 -0
  76. package/lib/commonjs/MarkdownText.web.js.map +1 -0
  77. package/lib/commonjs/MarkdownTextInput.js +22 -27
  78. package/lib/commonjs/MarkdownTextInput.js.map +1 -1
  79. package/lib/commonjs/MarkdownTextInput.web.js +12 -7
  80. package/lib/commonjs/MarkdownTextInput.web.js.map +1 -1
  81. package/lib/commonjs/atomUtils.js +112 -0
  82. package/lib/commonjs/atomUtils.js.map +1 -0
  83. package/lib/commonjs/childrenUtils.js +36 -0
  84. package/lib/commonjs/childrenUtils.js.map +1 -0
  85. package/lib/commonjs/index.js +8 -7
  86. package/lib/commonjs/index.js.map +1 -1
  87. package/lib/commonjs/math/environment.js +69 -0
  88. package/lib/commonjs/math/environment.js.map +1 -0
  89. package/lib/commonjs/math/index.js +61 -0
  90. package/lib/commonjs/math/index.js.map +1 -0
  91. package/lib/commonjs/math/mathjax.js +548 -0
  92. package/lib/commonjs/math/mathjax.js.map +1 -0
  93. package/lib/commonjs/metro.js +172 -0
  94. package/lib/commonjs/metro.js.map +1 -0
  95. package/lib/commonjs/parser/index.d.ts +3 -0
  96. package/lib/commonjs/parser/index.js +450 -42
  97. package/lib/commonjs/parser/index.js.map +4 -4
  98. package/lib/commonjs/stripUtils.js +743 -0
  99. package/lib/commonjs/stripUtils.js.map +1 -0
  100. package/lib/commonjs/styleUtils.js +194 -23
  101. package/lib/commonjs/styleUtils.js.map +1 -1
  102. package/lib/commonjs/web/MarkdownElements.css +67 -0
  103. package/lib/commonjs/web/MarkdownTextInput.css +9 -7
  104. package/lib/commonjs/web/utils/blockLayout.js +95 -7
  105. package/lib/commonjs/web/utils/blockLayout.js.map +1 -1
  106. package/lib/commonjs/web/utils/blockUtils.js +327 -54
  107. package/lib/commonjs/web/utils/blockUtils.js.map +1 -1
  108. package/lib/commonjs/web/utils/elementUtils.js +80 -0
  109. package/lib/commonjs/web/utils/elementUtils.js.map +1 -0
  110. package/lib/commonjs/web/utils/parserUtils.js +84 -28
  111. package/lib/commonjs/web/utils/parserUtils.js.map +1 -1
  112. package/lib/commonjs/web/utils/treeUtils.js +6 -0
  113. package/lib/commonjs/web/utils/treeUtils.js.map +1 -1
  114. package/lib/commonjs/web/utils/webStyleUtils.js +25 -5
  115. package/lib/commonjs/web/utils/webStyleUtils.js.map +1 -1
  116. package/lib/module/MarcusTextDecoratorViewNativeComponent.ts +199 -0
  117. package/lib/module/MarcusTextInputDecoratorViewNativeComponent.ts +145 -58
  118. package/lib/module/MarkdownText.js +325 -0
  119. package/lib/module/MarkdownText.js.map +1 -0
  120. package/lib/module/MarkdownText.web.js +524 -0
  121. package/lib/module/MarkdownText.web.js.map +1 -0
  122. package/lib/module/MarkdownTextInput.js +24 -29
  123. package/lib/module/MarkdownTextInput.js.map +1 -1
  124. package/lib/module/MarkdownTextInput.web.js +12 -7
  125. package/lib/module/MarkdownTextInput.web.js.map +1 -1
  126. package/lib/module/atomUtils.js +106 -0
  127. package/lib/module/atomUtils.js.map +1 -0
  128. package/lib/module/childrenUtils.js +33 -0
  129. package/lib/module/childrenUtils.js.map +1 -0
  130. package/lib/module/index.js +1 -1
  131. package/lib/module/index.js.map +1 -1
  132. package/lib/module/math/environment.js +67 -0
  133. package/lib/module/math/environment.js.map +1 -0
  134. package/lib/module/math/index.js +56 -0
  135. package/lib/module/math/index.js.map +1 -0
  136. package/lib/module/math/mathjax.js +541 -0
  137. package/lib/module/math/mathjax.js.map +1 -0
  138. package/lib/module/metro.js +169 -0
  139. package/lib/module/metro.js.map +1 -0
  140. package/lib/module/parser/index.d.ts +3 -0
  141. package/lib/module/parser/index.js +450 -42
  142. package/lib/module/parser/index.js.map +4 -4
  143. package/lib/module/stripUtils.js +739 -0
  144. package/lib/module/stripUtils.js.map +1 -0
  145. package/lib/module/styleUtils.js +196 -25
  146. package/lib/module/styleUtils.js.map +1 -1
  147. package/lib/module/web/MarkdownElements.css +67 -0
  148. package/lib/module/web/MarkdownTextInput.css +9 -7
  149. package/lib/module/web/utils/blockLayout.js +94 -8
  150. package/lib/module/web/utils/blockLayout.js.map +1 -1
  151. package/lib/module/web/utils/blockUtils.js +328 -56
  152. package/lib/module/web/utils/blockUtils.js.map +1 -1
  153. package/lib/module/web/utils/elementUtils.js +75 -0
  154. package/lib/module/web/utils/elementUtils.js.map +1 -0
  155. package/lib/module/web/utils/parserUtils.js +86 -30
  156. package/lib/module/web/utils/parserUtils.js.map +1 -1
  157. package/lib/module/web/utils/treeUtils.js +6 -0
  158. package/lib/module/web/utils/treeUtils.js.map +1 -1
  159. package/lib/module/web/utils/webStyleUtils.js +25 -5
  160. package/lib/module/web/utils/webStyleUtils.js.map +1 -1
  161. package/lib/typescript/commonjs/e2e/links.test.d.ts +2 -0
  162. package/lib/typescript/commonjs/e2e/links.test.d.ts.map +1 -0
  163. package/lib/typescript/commonjs/src/MarcusTextDecoratorViewNativeComponent.d.ts +93 -0
  164. package/lib/typescript/commonjs/src/MarcusTextDecoratorViewNativeComponent.d.ts.map +1 -0
  165. package/lib/typescript/commonjs/src/MarcusTextInputDecoratorViewNativeComponent.d.ts +64 -51
  166. package/lib/typescript/commonjs/src/MarcusTextInputDecoratorViewNativeComponent.d.ts.map +1 -1
  167. package/lib/typescript/commonjs/src/MarkdownText.d.ts +127 -0
  168. package/lib/typescript/commonjs/src/MarkdownText.d.ts.map +1 -0
  169. package/lib/typescript/commonjs/src/MarkdownText.web.d.ts +126 -0
  170. package/lib/typescript/commonjs/src/MarkdownText.web.d.ts.map +1 -0
  171. package/lib/typescript/commonjs/src/MarkdownTextInput.d.ts +23 -1
  172. package/lib/typescript/commonjs/src/MarkdownTextInput.d.ts.map +1 -1
  173. package/lib/typescript/commonjs/src/MarkdownTextInput.web.d.ts +26 -4
  174. package/lib/typescript/commonjs/src/MarkdownTextInput.web.d.ts.map +1 -1
  175. package/lib/typescript/commonjs/src/atomUtils.d.ts +58 -0
  176. package/lib/typescript/commonjs/src/atomUtils.d.ts.map +1 -0
  177. package/lib/typescript/commonjs/src/childrenUtils.d.ts +12 -0
  178. package/lib/typescript/commonjs/src/childrenUtils.d.ts.map +1 -0
  179. package/lib/typescript/commonjs/src/commonTypes.d.ts +39 -3
  180. package/lib/typescript/commonjs/src/commonTypes.d.ts.map +1 -1
  181. package/lib/typescript/commonjs/src/index.d.ts +2 -1
  182. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  183. package/lib/typescript/commonjs/src/math/environment.d.ts +7 -0
  184. package/lib/typescript/commonjs/src/math/environment.d.ts.map +1 -0
  185. package/lib/typescript/commonjs/src/math/index.d.ts +64 -0
  186. package/lib/typescript/commonjs/src/math/index.d.ts.map +1 -0
  187. package/lib/typescript/commonjs/src/math/mathjax.d.ts +63 -0
  188. package/lib/typescript/commonjs/src/math/mathjax.d.ts.map +1 -0
  189. package/lib/typescript/commonjs/src/metro.d.ts +59 -0
  190. package/lib/typescript/commonjs/src/metro.d.ts.map +1 -0
  191. package/lib/typescript/commonjs/src/parser/index.d.ts +3 -3
  192. package/lib/typescript/commonjs/src/parser/index.d.ts.map +1 -1
  193. package/lib/typescript/commonjs/src/parser/micromark-extension-mentions.d.ts.map +1 -1
  194. package/lib/typescript/commonjs/src/rangeUtils.d.ts +1 -1
  195. package/lib/typescript/commonjs/src/stripUtils.d.ts +108 -0
  196. package/lib/typescript/commonjs/src/stripUtils.d.ts.map +1 -0
  197. package/lib/typescript/commonjs/src/styleUtils.d.ts +62 -4
  198. package/lib/typescript/commonjs/src/styleUtils.d.ts.map +1 -1
  199. package/lib/typescript/commonjs/src/web/utils/blockLayout.d.ts +32 -4
  200. package/lib/typescript/commonjs/src/web/utils/blockLayout.d.ts.map +1 -1
  201. package/lib/typescript/commonjs/src/web/utils/blockUtils.d.ts +20 -8
  202. package/lib/typescript/commonjs/src/web/utils/blockUtils.d.ts.map +1 -1
  203. package/lib/typescript/commonjs/src/web/utils/elementUtils.d.ts +37 -0
  204. package/lib/typescript/commonjs/src/web/utils/elementUtils.d.ts.map +1 -0
  205. package/lib/typescript/commonjs/src/web/utils/parserUtils.d.ts +5 -5
  206. package/lib/typescript/commonjs/src/web/utils/parserUtils.d.ts.map +1 -1
  207. package/lib/typescript/commonjs/src/web/utils/treeUtils.d.ts +6 -1
  208. package/lib/typescript/commonjs/src/web/utils/treeUtils.d.ts.map +1 -1
  209. package/lib/typescript/commonjs/src/web/utils/webStyleUtils.d.ts +2 -2
  210. package/lib/typescript/commonjs/src/web/utils/webStyleUtils.d.ts.map +1 -1
  211. package/lib/typescript/module/e2e/links.test.d.ts +2 -0
  212. package/lib/typescript/module/e2e/links.test.d.ts.map +1 -0
  213. package/lib/typescript/module/src/MarcusTextDecoratorViewNativeComponent.d.ts +93 -0
  214. package/lib/typescript/module/src/MarcusTextDecoratorViewNativeComponent.d.ts.map +1 -0
  215. package/lib/typescript/module/src/MarcusTextInputDecoratorViewNativeComponent.d.ts +64 -51
  216. package/lib/typescript/module/src/MarcusTextInputDecoratorViewNativeComponent.d.ts.map +1 -1
  217. package/lib/typescript/module/src/MarkdownText.d.ts +127 -0
  218. package/lib/typescript/module/src/MarkdownText.d.ts.map +1 -0
  219. package/lib/typescript/module/src/MarkdownText.web.d.ts +126 -0
  220. package/lib/typescript/module/src/MarkdownText.web.d.ts.map +1 -0
  221. package/lib/typescript/module/src/MarkdownTextInput.d.ts +23 -1
  222. package/lib/typescript/module/src/MarkdownTextInput.d.ts.map +1 -1
  223. package/lib/typescript/module/src/MarkdownTextInput.web.d.ts +26 -4
  224. package/lib/typescript/module/src/MarkdownTextInput.web.d.ts.map +1 -1
  225. package/lib/typescript/module/src/atomUtils.d.ts +58 -0
  226. package/lib/typescript/module/src/atomUtils.d.ts.map +1 -0
  227. package/lib/typescript/module/src/childrenUtils.d.ts +12 -0
  228. package/lib/typescript/module/src/childrenUtils.d.ts.map +1 -0
  229. package/lib/typescript/module/src/commonTypes.d.ts +39 -3
  230. package/lib/typescript/module/src/commonTypes.d.ts.map +1 -1
  231. package/lib/typescript/module/src/index.d.ts +2 -1
  232. package/lib/typescript/module/src/index.d.ts.map +1 -1
  233. package/lib/typescript/module/src/math/environment.d.ts +7 -0
  234. package/lib/typescript/module/src/math/environment.d.ts.map +1 -0
  235. package/lib/typescript/module/src/math/index.d.ts +64 -0
  236. package/lib/typescript/module/src/math/index.d.ts.map +1 -0
  237. package/lib/typescript/module/src/math/mathjax.d.ts +63 -0
  238. package/lib/typescript/module/src/math/mathjax.d.ts.map +1 -0
  239. package/lib/typescript/module/src/metro.d.ts +59 -0
  240. package/lib/typescript/module/src/metro.d.ts.map +1 -0
  241. package/lib/typescript/module/src/parser/index.d.ts +3 -3
  242. package/lib/typescript/module/src/parser/index.d.ts.map +1 -1
  243. package/lib/typescript/module/src/parser/micromark-extension-mentions.d.ts.map +1 -1
  244. package/lib/typescript/module/src/rangeUtils.d.ts +1 -1
  245. package/lib/typescript/module/src/stripUtils.d.ts +108 -0
  246. package/lib/typescript/module/src/stripUtils.d.ts.map +1 -0
  247. package/lib/typescript/module/src/styleUtils.d.ts +62 -4
  248. package/lib/typescript/module/src/styleUtils.d.ts.map +1 -1
  249. package/lib/typescript/module/src/web/utils/blockLayout.d.ts +32 -4
  250. package/lib/typescript/module/src/web/utils/blockLayout.d.ts.map +1 -1
  251. package/lib/typescript/module/src/web/utils/blockUtils.d.ts +20 -8
  252. package/lib/typescript/module/src/web/utils/blockUtils.d.ts.map +1 -1
  253. package/lib/typescript/module/src/web/utils/elementUtils.d.ts +37 -0
  254. package/lib/typescript/module/src/web/utils/elementUtils.d.ts.map +1 -0
  255. package/lib/typescript/module/src/web/utils/parserUtils.d.ts +5 -5
  256. package/lib/typescript/module/src/web/utils/parserUtils.d.ts.map +1 -1
  257. package/lib/typescript/module/src/web/utils/treeUtils.d.ts +6 -1
  258. package/lib/typescript/module/src/web/utils/treeUtils.d.ts.map +1 -1
  259. package/lib/typescript/module/src/web/utils/webStyleUtils.d.ts +2 -2
  260. package/lib/typescript/module/src/web/utils/webStyleUtils.d.ts.map +1 -1
  261. package/package.json +29 -2
  262. package/react-native.config.js +8 -1
  263. package/src/MarcusTextDecoratorViewNativeComponent.ts +199 -0
  264. package/src/MarcusTextInputDecoratorViewNativeComponent.ts +145 -58
  265. package/src/MarkdownText.tsx +472 -0
  266. package/src/MarkdownText.web.tsx +668 -0
  267. package/src/MarkdownTextInput.tsx +42 -38
  268. package/src/MarkdownTextInput.web.tsx +36 -13
  269. package/src/atomUtils.ts +112 -0
  270. package/src/childrenUtils.ts +39 -0
  271. package/src/commonTypes.ts +69 -9
  272. package/src/index.tsx +2 -1
  273. package/src/math/environment.ts +68 -0
  274. package/src/math/index.ts +78 -0
  275. package/src/math/mathjax.ts +604 -0
  276. package/src/metro.ts +238 -0
  277. package/src/parser/index.ts +175 -10
  278. package/src/parser/micromark-extension-mentions.ts +104 -11
  279. package/src/stripUtils.ts +919 -0
  280. package/src/styleUtils.ts +290 -26
  281. package/src/web/MarkdownElements.css +67 -0
  282. package/src/web/MarkdownTextInput.css +9 -7
  283. package/src/web/utils/blockLayout.ts +124 -14
  284. package/src/web/utils/blockUtils.ts +365 -59
  285. package/src/web/utils/elementUtils.ts +87 -0
  286. package/src/web/utils/parserUtils.ts +119 -31
  287. package/src/web/utils/treeUtils.ts +6 -1
  288. package/src/web/utils/webStyleUtils.ts +32 -8
  289. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownBackgroundColorSpan.kt +0 -6
  290. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownBoldSpan.kt +0 -6
  291. package/android/src/main/java/app/getbullet/marcus/spans/MarkdownItalicSpan.kt +0 -6
  292. package/apple/RCTMarcusStyle+Codegen.mm +0 -64
  293. package/apple/RCTMarcusUtils.h +0 -26
  294. package/apple/RCTMarcusUtils.mm +0 -26
@@ -1,4 +1,14 @@
1
- export function parse(markdown) {
1
+ const __parsers = new Map();
2
+ export function createParser(options) {
3
+ const __marcusGfm = !!(options && options.gfm === true);
4
+ const __marcusMention = !!(options && options.mention === true);
5
+ const __marcusMath = !!(options && options.math === true);
6
+ const key = `${__marcusGfm}:${__marcusMention}:${__marcusMath}`;
7
+ const cached = __parsers.get(key);
8
+ if (cached !== undefined) {
9
+ return cached;
10
+ }
11
+ const parse = function parse(markdown) {
2
12
  "worklet";
3
13
  function TextDecoder() {
4
14
  throw new Error('TextDecoder is not available in the worklet runtime');
@@ -2319,7 +2329,7 @@ var content = {
2319
2329
  };
2320
2330
  function initializeContent(effects) {
2321
2331
  const contentStart = effects.attempt(this.parser.constructs.contentInitial, afterContentStartConstruct, paragraphInitial);
2322
- let previous2;
2332
+ let previous4;
2323
2333
  return contentStart;
2324
2334
  function afterContentStartConstruct(code2) {
2325
2335
  if (code2 === null) {
@@ -2338,12 +2348,12 @@ function initializeContent(effects) {
2338
2348
  function lineStart(code2) {
2339
2349
  const token = effects.enter("chunkText", {
2340
2350
  contentType: "text",
2341
- previous: previous2
2351
+ previous: previous4
2342
2352
  });
2343
- if (previous2) {
2344
- previous2.next = token;
2353
+ if (previous4) {
2354
+ previous4.next = token;
2345
2355
  }
2346
- previous2 = token;
2356
+ previous4 = token;
2347
2357
  return data(code2);
2348
2358
  }
2349
2359
  function data(code2) {
@@ -2671,8 +2681,8 @@ function resolveAllAttention(events, context) {
2671
2681
  }
2672
2682
  function tokenizeAttention(effects, ok) {
2673
2683
  const attentionMarkers2 = this.parser.constructs.attentionMarkers.null;
2674
- const previous2 = this.previous;
2675
- const before = classifyCharacter(previous2);
2684
+ const previous4 = this.previous;
2685
+ const before = classifyCharacter(previous4);
2676
2686
  let marker;
2677
2687
  return start;
2678
2688
  function start(code2) {
@@ -2688,7 +2698,7 @@ function tokenizeAttention(effects, ok) {
2688
2698
  const token = effects.exit("attentionSequence");
2689
2699
  const after = classifyCharacter(code2);
2690
2700
  const open = !after || after === 2 && before || attentionMarkers2.includes(code2);
2691
- const close = !before || before === 2 && after || attentionMarkers2.includes(previous2);
2701
+ const close = !before || before === 2 && after || attentionMarkers2.includes(previous4);
2692
2702
  token._open = Boolean(marker === 42 ? open : open && (before || !close));
2693
2703
  token._close = Boolean(marker === 42 ? close : close && (after || !open));
2694
2704
  return ok(code2);
@@ -3608,7 +3618,7 @@ function subcontent(events, eventIndex) {
3608
3618
  const jumps = [];
3609
3619
  const gaps = {};
3610
3620
  let stream;
3611
- let previous2;
3621
+ let previous4;
3612
3622
  let index = -1;
3613
3623
  let current = token;
3614
3624
  let adjust = 0;
@@ -3623,7 +3633,7 @@ function subcontent(events, eventIndex) {
3623
3633
  if (!current.next) {
3624
3634
  stream.push(null);
3625
3635
  }
3626
- if (previous2) {
3636
+ if (previous4) {
3627
3637
  tokenizer.defineSkip(current.start);
3628
3638
  }
3629
3639
  if (current._isInFirstContentOfListItem) {
@@ -3634,7 +3644,7 @@ function subcontent(events, eventIndex) {
3634
3644
  tokenizer._gfmTasklistFirstContentOfListItem = void 0;
3635
3645
  }
3636
3646
  }
3637
- previous2 = current;
3647
+ previous4 = current;
3638
3648
  current = current.next;
3639
3649
  }
3640
3650
  current = token;
@@ -3687,11 +3697,11 @@ function resolveContent(events) {
3687
3697
  return events;
3688
3698
  }
3689
3699
  function tokenizeContent(effects, ok) {
3690
- let previous2;
3700
+ let previous4;
3691
3701
  return chunkStart;
3692
3702
  function chunkStart(code2) {
3693
3703
  effects.enter("content");
3694
- previous2 = effects.enter("chunkContent", {
3704
+ previous4 = effects.enter("chunkContent", {
3695
3705
  contentType: "content"
3696
3706
  });
3697
3707
  return chunkInside(code2);
@@ -3714,11 +3724,11 @@ function tokenizeContent(effects, ok) {
3714
3724
  function contentContinue(code2) {
3715
3725
  effects.consume(code2);
3716
3726
  effects.exit("chunkContent");
3717
- previous2.next = effects.enter("chunkContent", {
3727
+ previous4.next = effects.enter("chunkContent", {
3718
3728
  contentType: "content",
3719
- previous: previous2
3729
+ previous: previous4
3720
3730
  });
3721
- previous2 = previous2.next;
3731
+ previous4 = previous4.next;
3722
3732
  return chunkInside;
3723
3733
  }
3724
3734
  }
@@ -6577,19 +6587,19 @@ function gfmStrikethrough(options) {
6577
6587
  return events;
6578
6588
  }
6579
6589
  function tokenizeStrikethrough(effects, ok, nok) {
6580
- const previous2 = this.previous;
6590
+ const previous4 = this.previous;
6581
6591
  const events = this.events;
6582
6592
  let size = 0;
6583
6593
  return start;
6584
6594
  function start(code2) {
6585
- if (previous2 === 126 && events[events.length - 1][1].type !== "characterEscape") {
6595
+ if (previous4 === 126 && events[events.length - 1][1].type !== "characterEscape") {
6586
6596
  return nok(code2);
6587
6597
  }
6588
6598
  effects.enter("strikethroughSequenceTemporary");
6589
6599
  return more(code2);
6590
6600
  }
6591
6601
  function more(code2) {
6592
- const before = classifyCharacter(previous2);
6602
+ const before = classifyCharacter(previous4);
6593
6603
  if (code2 === 126) {
6594
6604
  if (size > 1) return nok(code2);
6595
6605
  effects.consume(code2);
@@ -6606,14 +6616,296 @@ function gfmStrikethrough(options) {
6606
6616
  }
6607
6617
  }
6608
6618
 
6619
+ // node_modules/micromark-extension-math/lib/math-flow.js
6620
+ var mathFlow = {
6621
+ tokenize: tokenizeMathFenced,
6622
+ concrete: true,
6623
+ name: "mathFlow"
6624
+ };
6625
+ var nonLazyContinuation2 = {
6626
+ tokenize: tokenizeNonLazyContinuation2,
6627
+ partial: true
6628
+ };
6629
+ function tokenizeMathFenced(effects, ok, nok) {
6630
+ const self = this;
6631
+ const tail = self.events[self.events.length - 1];
6632
+ const initialSize = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], true).length : 0;
6633
+ let sizeOpen = 0;
6634
+ return start;
6635
+ function start(code2) {
6636
+ effects.enter("mathFlow");
6637
+ effects.enter("mathFlowFence");
6638
+ effects.enter("mathFlowFenceSequence");
6639
+ return sequenceOpen(code2);
6640
+ }
6641
+ function sequenceOpen(code2) {
6642
+ if (code2 === 36) {
6643
+ effects.consume(code2);
6644
+ sizeOpen++;
6645
+ return sequenceOpen;
6646
+ }
6647
+ if (sizeOpen < 2) {
6648
+ return nok(code2);
6649
+ }
6650
+ effects.exit("mathFlowFenceSequence");
6651
+ return factorySpace(effects, metaBefore, "whitespace")(code2);
6652
+ }
6653
+ function metaBefore(code2) {
6654
+ if (code2 === null || markdownLineEnding(code2)) {
6655
+ return metaAfter(code2);
6656
+ }
6657
+ effects.enter("mathFlowFenceMeta");
6658
+ effects.enter("chunkString", {
6659
+ contentType: "string"
6660
+ });
6661
+ return meta(code2);
6662
+ }
6663
+ function meta(code2) {
6664
+ if (code2 === null || markdownLineEnding(code2)) {
6665
+ effects.exit("chunkString");
6666
+ effects.exit("mathFlowFenceMeta");
6667
+ return metaAfter(code2);
6668
+ }
6669
+ if (code2 === 36) {
6670
+ return nok(code2);
6671
+ }
6672
+ effects.consume(code2);
6673
+ return meta;
6674
+ }
6675
+ function metaAfter(code2) {
6676
+ effects.exit("mathFlowFence");
6677
+ if (self.interrupt) {
6678
+ return ok(code2);
6679
+ }
6680
+ return effects.attempt(nonLazyContinuation2, beforeNonLazyContinuation, after)(code2);
6681
+ }
6682
+ function beforeNonLazyContinuation(code2) {
6683
+ return effects.attempt({
6684
+ tokenize: tokenizeClosingFence,
6685
+ partial: true
6686
+ }, after, contentStart)(code2);
6687
+ }
6688
+ function contentStart(code2) {
6689
+ return (initialSize ? factorySpace(effects, beforeContentChunk, "linePrefix", initialSize + 1) : beforeContentChunk)(code2);
6690
+ }
6691
+ function beforeContentChunk(code2) {
6692
+ if (code2 === null) {
6693
+ return after(code2);
6694
+ }
6695
+ if (markdownLineEnding(code2)) {
6696
+ return effects.attempt(nonLazyContinuation2, beforeNonLazyContinuation, after)(code2);
6697
+ }
6698
+ effects.enter("mathFlowValue");
6699
+ return contentChunk(code2);
6700
+ }
6701
+ function contentChunk(code2) {
6702
+ if (code2 === null || markdownLineEnding(code2)) {
6703
+ effects.exit("mathFlowValue");
6704
+ return beforeContentChunk(code2);
6705
+ }
6706
+ effects.consume(code2);
6707
+ return contentChunk;
6708
+ }
6709
+ function after(code2) {
6710
+ effects.exit("mathFlow");
6711
+ return ok(code2);
6712
+ }
6713
+ function tokenizeClosingFence(effects2, ok2, nok2) {
6714
+ let size = 0;
6715
+ return factorySpace(effects2, beforeSequenceClose, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4);
6716
+ function beforeSequenceClose(code2) {
6717
+ effects2.enter("mathFlowFence");
6718
+ effects2.enter("mathFlowFenceSequence");
6719
+ return sequenceClose(code2);
6720
+ }
6721
+ function sequenceClose(code2) {
6722
+ if (code2 === 36) {
6723
+ size++;
6724
+ effects2.consume(code2);
6725
+ return sequenceClose;
6726
+ }
6727
+ if (size < sizeOpen) {
6728
+ return nok2(code2);
6729
+ }
6730
+ effects2.exit("mathFlowFenceSequence");
6731
+ return factorySpace(effects2, afterSequenceClose, "whitespace")(code2);
6732
+ }
6733
+ function afterSequenceClose(code2) {
6734
+ if (code2 === null || markdownLineEnding(code2)) {
6735
+ effects2.exit("mathFlowFence");
6736
+ return ok2(code2);
6737
+ }
6738
+ return nok2(code2);
6739
+ }
6740
+ }
6741
+ }
6742
+ function tokenizeNonLazyContinuation2(effects, ok, nok) {
6743
+ const self = this;
6744
+ return start;
6745
+ function start(code2) {
6746
+ if (code2 === null) {
6747
+ return ok(code2);
6748
+ }
6749
+ effects.enter("lineEnding");
6750
+ effects.consume(code2);
6751
+ effects.exit("lineEnding");
6752
+ return lineStart;
6753
+ }
6754
+ function lineStart(code2) {
6755
+ return self.parser.lazy[self.now().line] ? nok(code2) : ok(code2);
6756
+ }
6757
+ }
6758
+
6759
+ // node_modules/micromark-extension-math/lib/math-text.js
6760
+ function mathText(options) {
6761
+ const options_ = options || {};
6762
+ let single = options_.singleDollarTextMath;
6763
+ if (single === null || single === void 0) {
6764
+ single = true;
6765
+ }
6766
+ return {
6767
+ tokenize: tokenizeMathText,
6768
+ resolve: resolveMathText,
6769
+ previous: previous2,
6770
+ name: "mathText"
6771
+ };
6772
+ function tokenizeMathText(effects, ok, nok) {
6773
+ const self = this;
6774
+ let sizeOpen = 0;
6775
+ let size;
6776
+ let token;
6777
+ return start;
6778
+ function start(code2) {
6779
+ effects.enter("mathText");
6780
+ effects.enter("mathTextSequence");
6781
+ return sequenceOpen(code2);
6782
+ }
6783
+ function sequenceOpen(code2) {
6784
+ if (code2 === 36) {
6785
+ effects.consume(code2);
6786
+ sizeOpen++;
6787
+ return sequenceOpen;
6788
+ }
6789
+ if (sizeOpen < 2 && !single) {
6790
+ return nok(code2);
6791
+ }
6792
+ effects.exit("mathTextSequence");
6793
+ return between(code2);
6794
+ }
6795
+ function between(code2) {
6796
+ if (code2 === null) {
6797
+ return nok(code2);
6798
+ }
6799
+ if (code2 === 36) {
6800
+ token = effects.enter("mathTextSequence");
6801
+ size = 0;
6802
+ return sequenceClose(code2);
6803
+ }
6804
+ if (code2 === 32) {
6805
+ effects.enter("space");
6806
+ effects.consume(code2);
6807
+ effects.exit("space");
6808
+ return between;
6809
+ }
6810
+ if (markdownLineEnding(code2)) {
6811
+ effects.enter("lineEnding");
6812
+ effects.consume(code2);
6813
+ effects.exit("lineEnding");
6814
+ return between;
6815
+ }
6816
+ effects.enter("mathTextData");
6817
+ return data(code2);
6818
+ }
6819
+ function data(code2) {
6820
+ if (code2 === null || code2 === 32 || code2 === 36 || markdownLineEnding(code2)) {
6821
+ effects.exit("mathTextData");
6822
+ return between(code2);
6823
+ }
6824
+ effects.consume(code2);
6825
+ return data;
6826
+ }
6827
+ function sequenceClose(code2) {
6828
+ if (code2 === 36) {
6829
+ effects.consume(code2);
6830
+ size++;
6831
+ return sequenceClose;
6832
+ }
6833
+ if (size === sizeOpen) {
6834
+ effects.exit("mathTextSequence");
6835
+ effects.exit("mathText");
6836
+ return ok(code2);
6837
+ }
6838
+ token.type = "mathTextData";
6839
+ return data(code2);
6840
+ }
6841
+ }
6842
+ }
6843
+ function resolveMathText(events) {
6844
+ let tailExitIndex = events.length - 4;
6845
+ let headEnterIndex = 3;
6846
+ let index;
6847
+ let enter;
6848
+ if ((events[headEnterIndex][1].type === "lineEnding" || events[headEnterIndex][1].type === "space") && (events[tailExitIndex][1].type === "lineEnding" || events[tailExitIndex][1].type === "space")) {
6849
+ index = headEnterIndex;
6850
+ while (++index < tailExitIndex) {
6851
+ if (events[index][1].type === "mathTextData") {
6852
+ events[tailExitIndex][1].type = "mathTextPadding";
6853
+ events[headEnterIndex][1].type = "mathTextPadding";
6854
+ headEnterIndex += 2;
6855
+ tailExitIndex -= 2;
6856
+ break;
6857
+ }
6858
+ }
6859
+ }
6860
+ index = headEnterIndex - 1;
6861
+ tailExitIndex++;
6862
+ while (++index <= tailExitIndex) {
6863
+ if (enter === void 0) {
6864
+ if (index !== tailExitIndex && events[index][1].type !== "lineEnding") {
6865
+ enter = index;
6866
+ }
6867
+ } else if (index === tailExitIndex || events[index][1].type === "lineEnding") {
6868
+ events[enter][1].type = "mathTextData";
6869
+ if (index !== enter + 2) {
6870
+ events[enter][1].end = events[index - 1][1].end;
6871
+ events.splice(enter + 2, index - enter - 2);
6872
+ tailExitIndex -= index - enter - 2;
6873
+ index = enter + 2;
6874
+ }
6875
+ enter = void 0;
6876
+ }
6877
+ }
6878
+ return events;
6879
+ }
6880
+ function previous2(code2) {
6881
+ return code2 !== 36 || this.events[this.events.length - 1][1].type === "characterEscape";
6882
+ }
6883
+
6884
+ // node_modules/micromark-extension-math/lib/syntax.js
6885
+ function math(options) {
6886
+ return {
6887
+ flow: {
6888
+ [36]: mathFlow
6889
+ },
6890
+ text: {
6891
+ [36]: mathText(options)
6892
+ }
6893
+ };
6894
+ }
6895
+
6609
6896
  // src/parser/micromark-extension-mentions.ts
6610
6897
  var LETTER = /^\p{L}$/u;
6611
- var WORD = /^[\p{L}\p{M}\p{N}_]$/u;
6612
6898
  var ALPHANUMERIC = /^[\p{L}\p{M}\p{N}]$/u;
6899
+ var AT = 64;
6900
+ var DOT = 46;
6901
+ var HYPHEN = 45;
6902
+ var UNDERSCORE = 95;
6613
6903
  var mention = {
6614
6904
  name: "mention",
6615
- tokenize
6905
+ tokenize,
6906
+ previous: previous3
6616
6907
  };
6908
+ var join = { tokenize: tokenizeJoin, partial: true };
6617
6909
  function mentions() {
6618
6910
  return {
6619
6911
  text: {
@@ -6622,6 +6914,9 @@ function mentions() {
6622
6914
  }
6623
6915
  };
6624
6916
  }
6917
+ function previous3(code2) {
6918
+ return code2 === null || code2 !== AT && !test(ALPHANUMERIC, code2);
6919
+ }
6625
6920
  function tokenize(effects, ok, nok) {
6626
6921
  return start;
6627
6922
  function start(code2) {
@@ -6637,25 +6932,52 @@ function tokenize(effects, ok, nok) {
6637
6932
  return nok(code2);
6638
6933
  }
6639
6934
  effects.consume(code2);
6640
- return body;
6935
+ return part;
6641
6936
  }
6642
- function body(code2) {
6643
- if (code2 !== null && test(WORD, code2)) {
6937
+ function part(code2) {
6938
+ if (code2 !== null && test(ALPHANUMERIC, code2)) {
6644
6939
  effects.consume(code2);
6645
- return body;
6940
+ return part;
6646
6941
  }
6647
- if (code2 === 45) {
6648
- return hyphen;
6942
+ if (code2 === DOT) {
6943
+ effects.consume(code2);
6944
+ return afterDot;
6945
+ }
6946
+ if (code2 === HYPHEN || code2 === UNDERSCORE || code2 === AT) {
6947
+ return effects.attempt(join, part, done);
6649
6948
  }
6949
+ return done(code2);
6950
+ }
6951
+ function afterDot(code2) {
6952
+ if (code2 === DOT) {
6953
+ return done(code2);
6954
+ }
6955
+ return part(code2);
6956
+ }
6957
+ function done(code2) {
6650
6958
  effects.exit("mention");
6651
6959
  return ok(code2);
6652
6960
  }
6653
- function hyphen(code2) {
6961
+ }
6962
+ function tokenizeJoin(effects, ok, nok) {
6963
+ return separator;
6964
+ function separator(code2) {
6965
+ effects.consume(code2);
6966
+ return code2 === AT ? afterAt : afterJoin;
6967
+ }
6968
+ function afterJoin(code2) {
6654
6969
  if (code2 === null || !test(ALPHANUMERIC, code2)) {
6655
6970
  return nok(code2);
6656
6971
  }
6657
6972
  effects.consume(code2);
6658
- return body;
6973
+ return ok;
6974
+ }
6975
+ function afterAt(code2) {
6976
+ if (code2 === null || !test(LETTER, code2)) {
6977
+ return nok(code2);
6978
+ }
6979
+ effects.consume(code2);
6980
+ return ok;
6659
6981
  }
6660
6982
  }
6661
6983
  function test(regex, code2) {
@@ -6668,6 +6990,8 @@ function test(regex, code2) {
6668
6990
  // src/parser/index.ts
6669
6991
  var EMOJI_TYPE = "emoji";
6670
6992
  var SYNTAX_TYPE = "syntax";
6993
+ var LABEL_TYPE = "label";
6994
+ var ALT_TYPE = "alt";
6671
6995
  var MAX_DEPTH = 6;
6672
6996
  var TOKENS = {
6673
6997
  syntax: /* @__PURE__ */ new Set([
@@ -6709,6 +7033,17 @@ var TOKENS = {
6709
7033
  // Code.
6710
7034
  "codeTextSequence",
6711
7035
  "codeFencedFenceSequence",
7036
+ // Maths. The padding is the space `$ x $` is written with, which is part of
7037
+ // the markup rather than of the TeX.
7038
+ "mathTextSequence",
7039
+ "mathTextPadding",
7040
+ "mathFlowFenceSequence",
7041
+ // Whatever follows the opening `$$`, which nothing reads.
7042
+ "mathFlowFenceMeta",
7043
+ // Whatever follows a fenced block's language. The language itself is
7044
+ // `language` -- something will want to read it -- but the rest of
7045
+ // that line is markup like any other fence.
7046
+ "codeFencedFenceMeta",
6712
7047
  // Character references.
6713
7048
  "characterReferenceMarker",
6714
7049
  "characterReferenceMarkerNumeric",
@@ -6725,19 +7060,39 @@ var TOKENS = {
6725
7060
  special: {
6726
7061
  codeFenced: "codeblock",
6727
7062
  codeIndented: "codeblock",
6728
- image: "inline-image"
7063
+ image: "image",
7064
+ // One range over the whole span, delimiters included, the way an image is
7065
+ // one range over `![alt](url)`. What is inside is TeX: a display strips it
7066
+ // whole and hands it to a renderer, and an input leaves it alone. Nothing
7067
+ // is emitted for the content itself -- there is nothing markdown-shaped in
7068
+ // there to style.
7069
+ mathText: "math",
7070
+ mathFlow: "math-block"
6729
7071
  },
6730
7072
  scope: {
6731
- emphasis: "italic",
6732
- strong: "bold",
7073
+ // Identities: these carry CommonMark's own names, so what micromark calls
7074
+ // a token and what a range is typed as are the same word.
7075
+ emphasis: "emphasis",
7076
+ strong: "strong",
6733
7077
  strikethrough: "strikethrough"
6734
7078
  // Headings are absent: their level is only known once the marker token
6735
7079
  // arrives, so they are emitted from emitHeading() instead.
6736
7080
  },
6737
7081
  content: {
6738
- mention: "mention-user",
7082
+ mention: "mention",
6739
7083
  codeTextData: "code",
6740
- codeFlowValue: "pre"
7084
+ codeFlowValue: "pre",
7085
+ // The language a fenced block declares. Its own type rather than `syntax`
7086
+ // because it is metadata something will want to read -- highlighting, at
7087
+ // least -- and no formatter styles it, so it stays plain text in an input
7088
+ // the way the rest of the fence line does not.
7089
+ codeFencedFenceInfo: "language",
7090
+ // The title after a destination -- `[a](b "title")`, on a link as much as on
7091
+ // an image. Metadata for the same reasons the language above is: a display
7092
+ // renderer removes it with the rest of the resource, and something that
7093
+ // renders an image wants to read it. Left unstyled in an input, where it is
7094
+ // text between two quotes.
7095
+ resourceTitleString: "title"
6741
7096
  // TODO:
6742
7097
  // htmlFlow: 'html',
6743
7098
  // htmlText: 'html',
@@ -6774,19 +7129,31 @@ var EMOJI = {
6774
7129
  "autolinkProtocol",
6775
7130
  "autolinkEmail"
6776
7131
  ]),
6777
- exclude: /* @__PURE__ */ new Set(["bold", "italic", "strikethrough"]),
7132
+ exclude: /* @__PURE__ */ new Set(["strong", "emphasis", "strikethrough"]),
6778
7133
  pattern: (0, import_emoji_regex.default)()
6779
7134
  };
6780
- globalThis.__parse__micromark = function(markdown) {
7135
+ globalThis.__parse__micromark = function(markdown, options) {
6781
7136
  const bomLength = markdown.charCodeAt(0) === 65279 ? 1 : 0;
6782
7137
  if (bomLength > 0) {
6783
7138
  markdown = markdown.slice(bomLength);
6784
7139
  }
6785
- const extensions = [gfmAutolinkLiteral(), gfmStrikethrough(), mentions()];
7140
+ const extensions = [];
7141
+ if (options?.gfm === true) {
7142
+ extensions.push(gfmAutolinkLiteral(), gfmStrikethrough());
7143
+ }
7144
+ if (options?.mention === true) {
7145
+ extensions.push(mentions());
7146
+ }
7147
+ if (options?.math === true) {
7148
+ extensions.push(math({ singleDollarTextMath: false }));
7149
+ }
6786
7150
  const ranges = [];
6787
7151
  const openBlocks = [];
6788
7152
  const countedBlocks = [];
6789
7153
  let pendingHeading = null;
7154
+ let openImages = 0;
7155
+ let altDepth = 0;
7156
+ let labelDepth = 0;
6790
7157
  const markers = [];
6791
7158
  const events = postprocess(
6792
7159
  parse({ extensions }).document().write(preprocess()(markdown, "utf-8", true))
@@ -6850,6 +7217,12 @@ globalThis.__parse__micromark = function(markdown) {
6850
7217
  return;
6851
7218
  }
6852
7219
  if (TOKENS.special[token.type]) {
7220
+ if (token.type === "image") {
7221
+ openImages++;
7222
+ if (altDepth > 0) {
7223
+ return;
7224
+ }
7225
+ }
6853
7226
  emit(token, TOKENS.special[token.type]);
6854
7227
  return;
6855
7228
  }
@@ -6857,6 +7230,23 @@ globalThis.__parse__micromark = function(markdown) {
6857
7230
  emit(token, SYNTAX_TYPE);
6858
7231
  return;
6859
7232
  }
7233
+ if (token.type === "labelText") {
7234
+ if (altDepth > 0) {
7235
+ altDepth++;
7236
+ return;
7237
+ }
7238
+ if (openImages > 0) {
7239
+ emit(token, ALT_TYPE);
7240
+ altDepth = 1;
7241
+ return;
7242
+ }
7243
+ emit(token, LABEL_TYPE);
7244
+ labelDepth++;
7245
+ return;
7246
+ }
7247
+ if (altDepth > 0) {
7248
+ return;
7249
+ }
6860
7250
  if (TOKENS.scope[token.type]) {
6861
7251
  emit(token, TOKENS.scope[token.type]);
6862
7252
  return;
@@ -6870,11 +7260,26 @@ globalThis.__parse__micromark = function(markdown) {
6870
7260
  return;
6871
7261
  }
6872
7262
  if (TOKENS.link[token.type]) {
7263
+ if (labelDepth > 0 && openImages === 0) {
7264
+ return;
7265
+ }
6873
7266
  emit(token, TOKENS.link[token.type]);
6874
7267
  return;
6875
7268
  }
6876
7269
  }
6877
7270
  function exit2(token) {
7271
+ if (token.type === "labelText") {
7272
+ if (altDepth > 0) {
7273
+ altDepth--;
7274
+ } else if (labelDepth > 0) {
7275
+ labelDepth--;
7276
+ }
7277
+ return;
7278
+ }
7279
+ if (token.type === "image") {
7280
+ openImages--;
7281
+ return;
7282
+ }
6878
7283
  if (!TOKENS.block[token.type]) {
6879
7284
  return;
6880
7285
  }
@@ -6963,7 +7368,7 @@ globalThis.__parse__micromark = function(markdown) {
6963
7368
  }
6964
7369
  function push2(start, end, type, depth) {
6965
7370
  if (start >= end) return;
6966
- const previous2 = ranges[ranges.length - 1];
7371
+ const previous4 = ranges[ranges.length - 1];
6967
7372
  if (depth === void 0 && // Two containers opening on one line put their prefixes back to back.
6968
7373
  // Merging them would lose which prefix belongs to which container.
6969
7374
  type !== BLOCK_PREFIX && // Adjacent syntax belongs to whatever encloses it, and neighbors often sit in different
@@ -6972,8 +7377,8 @@ globalThis.__parse__micromark = function(markdown) {
6972
7377
  // the first one's container -- overlapping it without containing it or being contained by
6973
7378
  // it, which is not a tree and renders the shared characters once per range. Runs that do
6974
7379
  // share an enclosure, like `>>`, cost only an extra span.
6975
- type !== SYNTAX_TYPE && previous2 && previous2.type === type && previous2.start + previous2.length === start) {
6976
- previous2.length = end - previous2.start;
7380
+ type !== SYNTAX_TYPE && previous4 && previous4.type === type && previous4.start + previous4.length === start) {
7381
+ previous4.length = end - previous4.start;
6977
7382
  return;
6978
7383
  }
6979
7384
  const range = {
@@ -7024,6 +7429,9 @@ globalThis.__parse__micromark = function(markdown) {
7024
7429
  ranges.push(...result);
7025
7430
  }
7026
7431
  };
7027
- return globalThis.__parse__micromark(markdown);
7432
+ return globalThis.__parse__micromark(markdown, { gfm: __marcusGfm, mention: __marcusMention, math: __marcusMath });
7433
+ };
7434
+ __parsers.set(key, parse);
7435
+ return parse;
7028
7436
  }
7029
7437
  //# sourceMappingURL=index.js.map