react-native-enriched-markdown-scaffold 1.0.2-scaffold.9 → 1.2.0-scaffold.2

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 (346) hide show
  1. package/ReactNativeEnrichedMarkdown.podspec +31 -10
  2. package/android/build.gradle +49 -12
  3. package/android/consumer-rules.pro +3 -0
  4. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerDelegate.java +18 -0
  5. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerInterface.java +6 -0
  6. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerDelegate.java +3 -0
  7. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerInterface.java +1 -0
  8. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerDelegate.java +18 -0
  9. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerInterface.java +6 -0
  10. package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.cpp +62 -0
  11. package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.h +44 -0
  12. package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.cpp +67 -2
  13. package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +929 -178
  14. package/android/src/main/baseline-prof.txt +21 -22
  15. package/android/src/main/cpp/jni-adapter.cpp +17 -5
  16. package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdown.kt +729 -768
  17. package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownInternalText.kt +1 -1
  18. package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownManager.kt +72 -3
  19. package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownText.kt +222 -8
  20. package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextManager.kt +65 -1
  21. package/android/src/main/java/com/swmansion/enriched/markdown/MeasurementStore.kt +191 -26
  22. package/android/src/main/java/com/swmansion/enriched/markdown/accessibility/AccessibleMarkdownTextView.kt +10 -0
  23. package/android/src/main/java/com/swmansion/enriched/markdown/accessibility/MarkdownAccessibilityHelper.kt +54 -6
  24. package/android/src/main/java/com/swmansion/enriched/markdown/events/CodeBlockPressEvent.kt +24 -0
  25. package/android/src/main/java/com/swmansion/enriched/markdown/events/ImagePressEvent.kt +25 -0
  26. package/android/src/main/java/com/swmansion/enriched/markdown/events/LatexErrorEvent.kt +29 -0
  27. package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputManager.kt +21 -0
  28. package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputView.kt +101 -9
  29. package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/EditPipeline.kt +48 -0
  30. package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/InputConnectionWrapper.kt +7 -0
  31. package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/MarkdownShortcutMatcher.kt +64 -0
  32. package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/InputRemend.kt +44 -6
  33. package/android/src/main/java/com/swmansion/enriched/markdown/input/layout/InputEventEmitter.kt +9 -8
  34. package/android/src/main/java/com/swmansion/enriched/markdown/math/LatexErrorReporter.kt +9 -0
  35. package/android/src/main/java/com/swmansion/enriched/markdown/parser/MarkdownASTNode.kt +6 -0
  36. package/android/src/main/java/com/swmansion/enriched/markdown/parser/Parser.kt +5 -1
  37. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlankLineRenderer.kt +38 -0
  38. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockStyleContext.kt +2 -2
  39. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockquoteRenderer.kt +3 -2
  40. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockquoteTextRenderer.kt +55 -0
  41. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/CodeBlockRenderer.kt +8 -1
  42. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/HighlightRenderer.kt +10 -1
  43. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/NodeRenderer.kt +31 -3
  44. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ParagraphRenderer.kt +17 -2
  45. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/Renderer.kt +40 -21
  46. package/android/src/main/java/com/swmansion/enriched/markdown/segments/AdmonitionIcons.kt +62 -0
  47. package/android/src/main/java/com/swmansion/enriched/markdown/{views → segments}/BlockSegmentView.kt +1 -1
  48. package/android/src/main/java/com/swmansion/enriched/markdown/segments/BlockquoteContainerView.kt +401 -0
  49. package/android/src/main/java/com/swmansion/enriched/markdown/{views → segments}/CodeBlockContainerView.kt +55 -16
  50. package/android/src/main/java/com/swmansion/enriched/markdown/segments/ContainerNodeView.kt +164 -0
  51. package/android/src/main/java/com/swmansion/enriched/markdown/{utils/common → segments}/MarkdownSegment.kt +21 -1
  52. package/android/src/main/java/com/swmansion/enriched/markdown/segments/RenderedSegment.kt +137 -0
  53. package/android/src/main/java/com/swmansion/enriched/markdown/segments/SegmentHeightMeasurer.kt +139 -0
  54. package/android/src/main/java/com/swmansion/enriched/markdown/{utils/common → segments}/SegmentReconciler.kt +1 -1
  55. package/android/src/main/java/com/swmansion/enriched/markdown/{utils/common → segments}/SegmentSignature.kt +3 -1
  56. package/android/src/main/java/com/swmansion/enriched/markdown/segments/SegmentViewCreators.kt +262 -0
  57. package/android/src/main/java/com/swmansion/enriched/markdown/segments/SegmentViewFactory.kt +29 -0
  58. package/android/src/main/java/com/swmansion/enriched/markdown/{views → segments}/TableContainerView.kt +100 -36
  59. package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeBackgroundSpan.kt +18 -17
  60. package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeBlockSpan.kt +3 -0
  61. package/android/src/main/java/com/swmansion/enriched/markdown/spans/HighlightSpan.kt +60 -6
  62. package/android/src/main/java/com/swmansion/enriched/markdown/spans/ImageSpan.kt +15 -5
  63. package/android/src/main/java/com/swmansion/enriched/markdown/spans/InlineBackgroundGeometry.kt +42 -0
  64. package/android/src/main/java/com/swmansion/enriched/markdown/spans/InlineChipPainter.kt +4 -27
  65. package/android/src/main/java/com/swmansion/enriched/markdown/spans/LineHeightSpan.kt +10 -0
  66. package/android/src/main/java/com/swmansion/enriched/markdown/spans/LinkSpan.kt +1 -1
  67. package/android/src/main/java/com/swmansion/enriched/markdown/spoiler/SpoilerDrawUtils.kt +11 -0
  68. package/android/src/main/java/com/swmansion/enriched/markdown/styles/BlockquoteStyle.kt +27 -0
  69. package/android/src/main/java/com/swmansion/enriched/markdown/styles/LinkVariantEntry.kt +2 -0
  70. package/android/src/main/java/com/swmansion/enriched/markdown/styles/StyleConfig.kt +10 -0
  71. package/android/src/main/java/com/swmansion/enriched/markdown/styles/VideoStyle.kt +31 -0
  72. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/BorderStyleUtils.kt +86 -0
  73. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/EllipsizeUtils.kt +27 -0
  74. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/EnrichedMarkdownAncestorUtils.kt +10 -0
  75. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/FeatureFlags.kt +1 -0
  76. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/MarkdownViewManagerUtils.kt +36 -0
  77. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/ReadableMapExtensions.kt +5 -0
  78. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/serialization/MarkdownASTSerializer.kt +227 -0
  79. package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/PasteTextUtils.kt +34 -2
  80. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/conversion/HTMLGenerator.kt +50 -28
  81. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/conversion/MarkdownExtractor.kt +16 -21
  82. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/extensions/SpannableExtensions.kt +4 -3
  83. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/span/BlockSpacing.kt +3 -2
  84. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/span/SpanFlags.kt +13 -0
  85. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/CodeBlockPressHost.kt +15 -0
  86. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/ImagePressHost.kt +19 -0
  87. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/LinkEvents.kt +11 -0
  88. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/LinkLongPressMovementMethod.kt +87 -2
  89. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/TextViewSetup.kt +79 -0
  90. package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/conversions.h +2 -0
  91. package/android/src/math/java/com/swmansion/enriched/markdown/renderer/MathInlineRenderer.kt +9 -3
  92. package/android/src/math/java/com/swmansion/enriched/markdown/{views → segments}/MathContainerView.kt +86 -29
  93. package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathInlineSpan.kt +33 -7
  94. package/android/src/video/java/com/swmansion/enriched/markdown/segments/VideoContainerView.kt +115 -0
  95. package/cpp/md4c/md4c.c +343 -236
  96. package/cpp/md4c/md4c.h +28 -11
  97. package/cpp/parser/MD4CParser.cpp +266 -4
  98. package/cpp/parser/MD4CParser.hpp +6 -2
  99. package/cpp/parser/MarkdownASTNode.hpp +4 -1
  100. package/cpp/wasm/ASTSerializer.cpp +6 -0
  101. package/cpp/wasm/md4c_wasm.cpp +5 -1
  102. package/docs/API_REFERENCE.md +199 -12
  103. package/docs/BREAKING_CHANGES.md +75 -0
  104. package/docs/CODE_HIGHLIGHT.md +4 -0
  105. package/docs/COPY_OPTIONS.md +52 -9
  106. package/docs/ELEMENTS_STRUCTURE.md +48 -1
  107. package/docs/INPUT.md +60 -3
  108. package/docs/LATEX_MATH.md +30 -0
  109. package/docs/MACOS.md +1 -1
  110. package/docs/MENTIONS.md +2 -2
  111. package/docs/STYLES.md +27 -0
  112. package/docs/TEXT.md +8 -0
  113. package/docs/WEB.md +44 -10
  114. package/ios/EnrichedMarkdown.mm +285 -43
  115. package/ios/EnrichedMarkdownText.mm +185 -23
  116. package/ios/attachments/ENRMImageAttachment.h +17 -2
  117. package/ios/attachments/ENRMImageAttachment.m +26 -28
  118. package/ios/attachments/ENRMMathInlineAttachment+macOS.m +10 -2
  119. package/ios/attachments/ENRMMathInlineAttachment.h +3 -1
  120. package/ios/attachments/ENRMMathInlineAttachment.m +17 -1
  121. package/ios/attachments/ENRMMathInlineAttachmentShared.h +3 -0
  122. package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.cpp +62 -0
  123. package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.h +44 -0
  124. package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.cpp +67 -2
  125. package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.h +929 -178
  126. package/ios/input/ENRMInputFormatter.mm +68 -12
  127. package/ios/input/ENRMInputFormatterStyle.mm +9 -2
  128. package/ios/input/ENRMInputParser.mm +18 -0
  129. package/ios/input/ENRMInputRemend.mm +40 -3
  130. package/ios/input/ENRMMarkdownShortcutMatcher.h +39 -0
  131. package/ios/input/ENRMMarkdownShortcutMatcher.mm +66 -0
  132. package/ios/input/EnrichedMarkdownTextInput.mm +129 -1
  133. package/ios/internals/ENRMViewFreeMeasurement.h +45 -6
  134. package/ios/internals/MeasurementCache.h +20 -4
  135. package/ios/internals/ShadowMeasurementUtils.h +2 -0
  136. package/ios/math/ENRMLatexErrorCoordinator.h +27 -0
  137. package/ios/math/ENRMLatexErrorCoordinator.mm +75 -0
  138. package/ios/math/ENRMLatexErrorReporting.h +13 -0
  139. package/ios/math/ENRMRaTeXBridge.swift +46 -3
  140. package/ios/parser/ENRMMarkdownParser.h +3 -0
  141. package/ios/parser/ENRMMarkdownParser.mm +11 -2
  142. package/ios/parser/MarkdownASTNode.h +8 -1
  143. package/ios/parser/MarkdownASTNode.m +20 -0
  144. package/ios/parser/MarkdownParserBridge.mm +13 -2
  145. package/ios/renderer/AttributedRenderer.h +13 -1
  146. package/ios/renderer/AttributedRenderer.m +24 -13
  147. package/ios/renderer/BaselineShiftTextAttributes.h +4 -0
  148. package/ios/renderer/BaselineShiftTextAttributes.m +4 -0
  149. package/ios/renderer/BlankLineRenderer.h +4 -0
  150. package/ios/renderer/BlankLineRenderer.m +51 -0
  151. package/ios/renderer/BlockquoteRenderer.m +1 -0
  152. package/ios/renderer/CodeBlockRenderer.m +8 -0
  153. package/ios/renderer/CodeRenderer.m +5 -2
  154. package/ios/renderer/ENRMBlockquoteTextRenderer.h +25 -0
  155. package/ios/renderer/ENRMBlockquoteTextRenderer.m +48 -0
  156. package/ios/renderer/ENRMImageRenderer.m +1 -1
  157. package/ios/renderer/ENRMMathInlineRenderer.m +9 -1
  158. package/ios/renderer/HeadingRenderer.m +1 -0
  159. package/ios/renderer/HighlightRenderer.m +6 -0
  160. package/ios/renderer/LinkRenderer.m +1 -1
  161. package/ios/renderer/ListItemRenderer.m +51 -2
  162. package/ios/renderer/ParagraphRenderer.m +10 -3
  163. package/ios/renderer/RenderContext.h +16 -0
  164. package/ios/renderer/RenderContext.m +16 -0
  165. package/ios/renderer/RendererFactory.m +6 -0
  166. package/ios/renderer/SubscriptRenderer.m +1 -0
  167. package/ios/renderer/SuperscriptRenderer.m +1 -0
  168. package/ios/segments/ENRMAdmonitionIcons.h +31 -0
  169. package/ios/segments/ENRMAdmonitionIcons.m +93 -0
  170. package/ios/segments/ENRMBlockquoteContainerView.h +90 -0
  171. package/ios/segments/ENRMBlockquoteContainerView.mm +551 -0
  172. package/ios/{views → segments}/ENRMCodeBlockContainerView.h +9 -4
  173. package/ios/{views → segments}/ENRMCodeBlockContainerView.m +147 -36
  174. package/ios/segments/ENRMContainerNodeView.h +52 -0
  175. package/ios/segments/ENRMContainerNodeView.mm +201 -0
  176. package/ios/segments/ENRMDynamicBlockProps.h +32 -0
  177. package/ios/segments/ENRMDynamicBlockProps.m +15 -0
  178. package/ios/{views → segments}/ENRMMathContainerView.h +13 -5
  179. package/ios/{views → segments}/ENRMMathContainerView.m +60 -9
  180. package/ios/segments/ENRMSVGPath.h +21 -0
  181. package/ios/segments/ENRMSVGPath.m +409 -0
  182. package/ios/segments/ENRMSegmentHeightMeasurer.h +33 -0
  183. package/ios/segments/ENRMSegmentHeightMeasurer.mm +94 -0
  184. package/ios/segments/ENRMVideoContainerView.h +40 -0
  185. package/ios/segments/ENRMVideoContainerView.m +421 -0
  186. package/ios/{utils → segments}/RenderedMarkdownSegment.h +19 -2
  187. package/ios/{utils → segments}/RenderedMarkdownSegment.m +42 -1
  188. package/ios/segments/SegmentRenderer.h +26 -0
  189. package/ios/{utils → segments}/SegmentRenderer.m +46 -9
  190. package/ios/{views → segments}/TableContainerView.h +5 -4
  191. package/ios/{views → segments}/TableContainerView.m +96 -12
  192. package/ios/styles/StyleConfig.h +17 -0
  193. package/ios/styles/StyleConfig.mm +90 -0
  194. package/ios/utils/ENRMCodeBlockContent.mm +13 -0
  195. package/ios/utils/ENRMFeatureFlags.h +6 -0
  196. package/ios/utils/ENRMTextRenderer.h +8 -0
  197. package/ios/utils/ENRMTextRenderer.m +26 -10
  198. package/ios/utils/ENRMUIKit.h +1 -0
  199. package/ios/utils/FontUtils.h +2 -1
  200. package/ios/utils/FontUtils.m +22 -6
  201. package/ios/utils/LinkTapUtils.h +17 -2
  202. package/ios/utils/LinkTapUtils.m +44 -2
  203. package/ios/utils/ListMarkerDrawer.m +25 -1
  204. package/ios/utils/MarkdownASTSerializer.h +7 -0
  205. package/ios/utils/MarkdownASTSerializer.m +243 -0
  206. package/ios/utils/MarkdownAccessibilityElementBuilder.m +9 -67
  207. package/ios/utils/MarkdownExtractor.m +6 -3
  208. package/ios/utils/ParagraphStyleUtils.h +25 -1
  209. package/ios/utils/ParagraphStyleUtils.m +51 -7
  210. package/ios/utils/StylePropsUtils.h +60 -1
  211. package/ios/utils/TextViewLayoutManager.mm +57 -0
  212. package/lib/module/EnrichedMarkdownNativeComponent.ts +110 -4
  213. package/lib/module/EnrichedMarkdownTextInput.js +60 -2
  214. package/lib/module/EnrichedMarkdownTextInput.js.map +1 -1
  215. package/lib/module/EnrichedMarkdownTextInputNativeComponent.ts +12 -0
  216. package/lib/module/EnrichedMarkdownTextNativeComponent.ts +115 -4
  217. package/lib/module/admonitionDefaults.js +34 -0
  218. package/lib/module/admonitionDefaults.js.map +1 -0
  219. package/lib/module/index.js.map +1 -1
  220. package/lib/module/jest/index.js +84 -4
  221. package/lib/module/jest/index.js.map +1 -1
  222. package/lib/module/native/EnrichedMarkdownText.js +58 -5
  223. package/lib/module/native/EnrichedMarkdownText.js.map +1 -1
  224. package/lib/module/normalizeMarkdownShortcuts.js +31 -0
  225. package/lib/module/normalizeMarkdownShortcuts.js.map +1 -0
  226. package/lib/module/normalizeMarkdownStyle.js +15 -1
  227. package/lib/module/normalizeMarkdownStyle.js.map +1 -1
  228. package/lib/module/normalizeMarkdownStyle.web.js +15 -1
  229. package/lib/module/normalizeMarkdownStyle.web.js.map +1 -1
  230. package/lib/module/styleUtils.js +15 -3
  231. package/lib/module/styleUtils.js.map +1 -1
  232. package/lib/module/utils/textInputState.js +4 -3
  233. package/lib/module/utils/textInputState.js.map +1 -1
  234. package/lib/module/utils/usePressability.js +28 -0
  235. package/lib/module/utils/usePressability.js.map +1 -0
  236. package/lib/module/web/EnrichedMarkdownText.js +19 -6
  237. package/lib/module/web/EnrichedMarkdownText.js.map +1 -1
  238. package/lib/module/web/globalStyles.js +7 -1
  239. package/lib/module/web/globalStyles.js.map +1 -1
  240. package/lib/module/web/nativeProps.js +70 -0
  241. package/lib/module/web/nativeProps.js.map +1 -0
  242. package/lib/module/web/parseMarkdown.js +5 -3
  243. package/lib/module/web/parseMarkdown.js.map +1 -1
  244. package/lib/module/web/renderers/BlockRenderers.js +164 -8
  245. package/lib/module/web/renderers/BlockRenderers.js.map +1 -1
  246. package/lib/module/web/renderers/admonitionIcons.js +34 -0
  247. package/lib/module/web/renderers/admonitionIcons.js.map +1 -0
  248. package/lib/module/web/styles.js +30 -8
  249. package/lib/module/web/styles.js.map +1 -1
  250. package/lib/module/web/wasm/md4c.js +0 -0
  251. package/lib/module/web/wasm/md4c.js.map +1 -1
  252. package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts +103 -3
  253. package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts.map +1 -1
  254. package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts +27 -3
  255. package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts.map +1 -1
  256. package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts +11 -0
  257. package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts.map +1 -1
  258. package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts +108 -3
  259. package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts.map +1 -1
  260. package/lib/typescript/src/admonitionDefaults.d.ts +10 -0
  261. package/lib/typescript/src/admonitionDefaults.d.ts.map +1 -0
  262. package/lib/typescript/src/index.d.ts +3 -2
  263. package/lib/typescript/src/index.d.ts.map +1 -1
  264. package/lib/typescript/src/index.web.d.ts +1 -1
  265. package/lib/typescript/src/index.web.d.ts.map +1 -1
  266. package/lib/typescript/src/jest/index.d.ts +2 -2
  267. package/lib/typescript/src/jest/index.d.ts.map +1 -1
  268. package/lib/typescript/src/native/EnrichedMarkdownText.d.ts +3 -3
  269. package/lib/typescript/src/native/EnrichedMarkdownText.d.ts.map +1 -1
  270. package/lib/typescript/src/normalizeMarkdownShortcuts.d.ts +7 -0
  271. package/lib/typescript/src/normalizeMarkdownShortcuts.d.ts.map +1 -0
  272. package/lib/typescript/src/normalizeMarkdownStyle.d.ts.map +1 -1
  273. package/lib/typescript/src/normalizeMarkdownStyle.web.d.ts.map +1 -1
  274. package/lib/typescript/src/styleUtils.d.ts.map +1 -1
  275. package/lib/typescript/src/types/MarkdownStyle.d.ts +59 -1
  276. package/lib/typescript/src/types/MarkdownStyle.d.ts.map +1 -1
  277. package/lib/typescript/src/types/MarkdownStyleInternal.d.ts +21 -0
  278. package/lib/typescript/src/types/MarkdownStyleInternal.d.ts.map +1 -1
  279. package/lib/typescript/src/types/MarkdownTextProps.d.ts +93 -8
  280. package/lib/typescript/src/types/MarkdownTextProps.d.ts.map +1 -1
  281. package/lib/typescript/src/types/MarkdownTextProps.web.d.ts +25 -1
  282. package/lib/typescript/src/types/MarkdownTextProps.web.d.ts.map +1 -1
  283. package/lib/typescript/src/types/events.d.ts +33 -5
  284. package/lib/typescript/src/types/events.d.ts.map +1 -1
  285. package/lib/typescript/src/utils/textInputState.d.ts +5 -3
  286. package/lib/typescript/src/utils/textInputState.d.ts.map +1 -1
  287. package/lib/typescript/src/utils/usePressability.d.ts +24 -0
  288. package/lib/typescript/src/utils/usePressability.d.ts.map +1 -0
  289. package/lib/typescript/src/web/EnrichedMarkdownText.d.ts +1 -1
  290. package/lib/typescript/src/web/EnrichedMarkdownText.d.ts.map +1 -1
  291. package/lib/typescript/src/web/globalStyles.d.ts +1 -0
  292. package/lib/typescript/src/web/globalStyles.d.ts.map +1 -1
  293. package/lib/typescript/src/web/nativeProps.d.ts +34 -0
  294. package/lib/typescript/src/web/nativeProps.d.ts.map +1 -0
  295. package/lib/typescript/src/web/parseMarkdown.d.ts +1 -1
  296. package/lib/typescript/src/web/parseMarkdown.d.ts.map +1 -1
  297. package/lib/typescript/src/web/renderers/BlockRenderers.d.ts.map +1 -1
  298. package/lib/typescript/src/web/renderers/admonitionIcons.d.ts +5 -0
  299. package/lib/typescript/src/web/renderers/admonitionIcons.d.ts.map +1 -0
  300. package/lib/typescript/src/web/styles.d.ts +1 -0
  301. package/lib/typescript/src/web/styles.d.ts.map +1 -1
  302. package/lib/typescript/src/web/types.d.ts +8 -2
  303. package/lib/typescript/src/web/types.d.ts.map +1 -1
  304. package/package.json +1 -1
  305. package/postinstall.mjs +7 -0
  306. package/src/EnrichedMarkdownNativeComponent.ts +110 -4
  307. package/src/EnrichedMarkdownTextInput.tsx +101 -4
  308. package/src/EnrichedMarkdownTextInputNativeComponent.ts +12 -0
  309. package/src/EnrichedMarkdownTextNativeComponent.ts +115 -4
  310. package/src/admonitionDefaults.ts +58 -0
  311. package/src/index.tsx +5 -0
  312. package/src/index.web.tsx +3 -0
  313. package/src/jest/index.tsx +138 -5
  314. package/src/native/EnrichedMarkdownText.tsx +55 -3
  315. package/src/normalizeMarkdownShortcuts.ts +38 -0
  316. package/src/normalizeMarkdownStyle.ts +17 -0
  317. package/src/normalizeMarkdownStyle.web.ts +17 -0
  318. package/src/styleUtils.ts +17 -6
  319. package/src/types/MarkdownStyle.ts +62 -1
  320. package/src/types/MarkdownStyleInternal.ts +24 -0
  321. package/src/types/MarkdownTextProps.ts +95 -7
  322. package/src/types/MarkdownTextProps.web.ts +26 -0
  323. package/src/types/events.ts +36 -5
  324. package/src/utils/textInputState.ts +5 -3
  325. package/src/utils/usePressability.ts +34 -0
  326. package/src/web/EnrichedMarkdownText.tsx +36 -3
  327. package/src/web/globalStyles.ts +10 -0
  328. package/src/web/nativeProps.ts +78 -0
  329. package/src/web/parseMarkdown.ts +10 -2
  330. package/src/web/renderers/BlockRenderers.tsx +175 -6
  331. package/src/web/renderers/admonitionIcons.ts +37 -0
  332. package/src/web/styles.ts +28 -3
  333. package/src/web/types.ts +12 -1
  334. package/src/web/wasm/md4c.js +0 -0
  335. package/vendor-ratex.mjs +86 -17
  336. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/DocumentRenderer.kt +0 -16
  337. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/RenderedSegment.kt +0 -88
  338. package/ios/utils/SegmentRenderer.h +0 -24
  339. /package/ios/{views → segments}/ENRMTableGridView.h +0 -0
  340. /package/ios/{views → segments}/ENRMTableGridView.m +0 -0
  341. /package/ios/{views → segments}/ENRMTableIOSGridView.h +0 -0
  342. /package/ios/{views → segments}/ENRMTableIOSGridView.m +0 -0
  343. /package/ios/{utils → segments}/SegmentReconciler.h +0 -0
  344. /package/ios/{utils → segments}/SegmentReconciler.m +0 -0
  345. /package/ios/{utils → segments}/SegmentViewRegistry.h +0 -0
  346. /package/ios/{utils → segments}/SegmentViewRegistry.m +0 -0
@@ -0,0 +1,51 @@
1
+ #import "BlankLineRenderer.h"
2
+ #import "MarkdownASTNode.h"
3
+ #import "ParagraphStyleUtils.h"
4
+ #import "StyleConfig.h"
5
+
6
+ #pragma mark - Renderer Implementation
7
+
8
+ // Renders a run of consecutive blank lines emitted by the parser when the
9
+ // preserveBlankLines flag is enabled. Each blank line in the source is drawn as
10
+ // one empty line, so the rendered text keeps the exact line count that was typed
11
+ // (e.g. in EnrichedMarkdownTextInput). The empty lines use the paragraph font
12
+ // and line height so their vertical rhythm matches the surrounding paragraphs;
13
+ // any extra block spacing is left to the caller to configure via markdownStyle.
14
+ @implementation BlankLineRenderer
15
+
16
+ - (void)renderNodeContent:(MarkdownASTNode *)node
17
+ into:(NSMutableAttributedString *)output
18
+ context:(RenderContext *)context
19
+ {
20
+ NSInteger count = [node.attributes[@"count"] integerValue];
21
+ if (count <= 0) {
22
+ return;
23
+ }
24
+
25
+ [self ensureStartingNewline:output];
26
+
27
+ NSDictionary *attributes = @{NSFontAttributeName : _config.paragraphFont};
28
+
29
+ NSMutableString *blanks = [NSMutableString stringWithCapacity:(NSUInteger)count];
30
+ for (NSInteger i = 0; i < count; i++) {
31
+ [blanks appendString:@"\n"];
32
+ }
33
+
34
+ NSUInteger start = output.length;
35
+ [output appendAttributedString:[[NSAttributedString alloc] initWithString:blanks attributes:attributes]];
36
+
37
+ NSRange range = NSMakeRange(start, output.length - start);
38
+ applyLineHeight(output, range, _config.paragraphLineHeight);
39
+ applyTextAlignment(output, range, _config.paragraphTextAlign);
40
+ }
41
+
42
+ #pragma mark - Private Utilities
43
+
44
+ - (void)ensureStartingNewline:(NSMutableAttributedString *)output
45
+ {
46
+ if (output.length > 0 && ![output.string hasSuffix:@"\n"]) {
47
+ [output appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n"]];
48
+ }
49
+ }
50
+
51
+ @end
@@ -158,6 +158,7 @@ static NSString *const kNestedInfoRangeKey = @"range";
158
158
  }
159
159
  [output addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:nonListRange];
160
160
  applyLineHeight(output, nonListRange, lineHeight);
161
+ applyBaselineOffset(output, nonListRange);
161
162
  }];
162
163
 
163
164
  if (padding > 0) {
@@ -85,6 +85,14 @@
85
85
  [output addAttribute:CodeBlockIndentAttributeName value:@(listIndent) range:backgroundRange];
86
86
  }
87
87
 
88
+ // Recovered by a tap for onCodeBlockPress (the AST node is gone after render).
89
+ NSString *codeBlockText = ENRMCodeBlockExtractCode(node) ?: @"";
90
+ [output addAttribute:@"codeBlockText" value:codeBlockText range:backgroundRange];
91
+ NSString *codeBlockLanguage = ENRMCodeBlockLanguage(node);
92
+ if (codeBlockLanguage) {
93
+ [output addAttribute:@"codeBlockLanguage" value:codeBlockLanguage range:backgroundRange];
94
+ }
95
+
88
96
  // External Margin: Applied outside the background range
89
97
  if (marginBottom > 0) {
90
98
  applyBlockSpacingAfter(output, marginBottom);
@@ -26,6 +26,9 @@
26
26
 
27
27
  CGFloat codeFontSize = _config.codeFontSize > 0 ? _config.codeFontSize : blockStyle.fontSize;
28
28
 
29
+ // Both sizes above are unscaled; apply the same multiplier as the surrounding block font.
30
+ CGFloat fontScale = context.allowFontScaling ? RCTFontSizeMultiplierWithMax(context.maxFontSizeMultiplier) : 1.0;
31
+
29
32
  NSString *codeFontFamily = _config.codeFontFamily;
30
33
  UIFont *codeFont;
31
34
  if (codeFontFamily.length > 0) {
@@ -36,9 +39,9 @@
36
39
  weight:weightStr
37
40
  style:nil
38
41
  variant:nil
39
- scaleMultiplier:1.0];
42
+ scaleMultiplier:fontScale];
40
43
  } else {
41
- codeFont = [UIFont monospacedSystemFontOfSize:codeFontSize weight:weight];
44
+ codeFont = [UIFont monospacedSystemFontOfSize:codeFontSize * fontScale weight:weight];
42
45
  }
43
46
 
44
47
  NSUInteger start = output.length;
@@ -0,0 +1,25 @@
1
+ #pragma once
2
+ #import <Foundation/Foundation.h>
3
+
4
+ @class RenderContext;
5
+ @class StyleConfig;
6
+
7
+ NS_ASSUME_NONNULL_BEGIN
8
+
9
+ /**
10
+ * Renders a GFM blockquote's own prose content - the nodes left after nested quotes, code blocks and
11
+ * other block segments have been split out - as blockquote text.
12
+ *
13
+ * It decorates a generic AttributedRenderer pass rather than owning the render envelope itself:
14
+ * -pushOnContext: enters the blockquote baseline block style (+depth) so text picks up the quote's
15
+ * font/color and paragraphs render tight (currentBlockType == Blockquote), matching the commonmark
16
+ * path; -postProcess: applies the quote's line height once the string is complete. It draws no
17
+ * border/background/padding - the ENRMBlockquoteContainerView draws the box.
18
+ */
19
+ @interface ENRMBlockquoteTextRenderer : NSObject
20
+ - (instancetype)initWithConfig:(StyleConfig *)config;
21
+ - (void)pushOnContext:(RenderContext *)context;
22
+ - (void)postProcess:(NSMutableAttributedString *)text;
23
+ @end
24
+
25
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,48 @@
1
+ #import "ENRMBlockquoteTextRenderer.h"
2
+ #import "ParagraphStyleUtils.h"
3
+ #import "RenderContext.h"
4
+ #import "StyleConfig.h"
5
+
6
+ @implementation ENRMBlockquoteTextRenderer {
7
+ StyleConfig *_config;
8
+ }
9
+
10
+ - (instancetype)initWithConfig:(StyleConfig *)config
11
+ {
12
+ self = [super init];
13
+ if (self) {
14
+ _config = config;
15
+ }
16
+ return self;
17
+ }
18
+
19
+ - (void)pushOnContext:(RenderContext *)context
20
+ {
21
+ // Only set the blockquote baseline block style (tight paragraphs + the quote's font/color).
22
+ // Unlike the commonmark inline path we do NOT bump blockquoteDepth: the ENRMBlockquoteContainerView
23
+ // already insets its content by the quote's border/gap/padding, so bumping it here would make
24
+ // ListItemRenderer add a second blockquoteIndentForDepth on top and over-indent nested lists.
25
+ [context setBlockStyle:BlockTypeBlockquote font:_config.blockquoteFont color:_config.blockquoteColor headingLevel:0];
26
+ }
27
+
28
+ - (void)postProcess:(NSMutableAttributedString *)text
29
+ {
30
+ // Stamp the quote's line height per paragraph. applyLineHeight copies the paragraph style at the
31
+ // range start over the whole range, so applying it across the entire run would overwrite every
32
+ // paragraph with the first one's style - wiping each list item's firstLineHeadIndent/headIndent
33
+ // (the marker draws from a separate attribute, so it would then land on top of un-indented text).
34
+ CGFloat lineHeight = [_config blockquoteLineHeight];
35
+ if (text.length == 0 || lineHeight <= 0) {
36
+ return;
37
+ }
38
+ NSString *string = text.string;
39
+ NSUInteger location = 0;
40
+ while (location < text.length) {
41
+ NSRange paragraph = [string paragraphRangeForRange:NSMakeRange(location, 0)];
42
+ applyLineHeight(text, paragraph, lineHeight);
43
+ applyBaselineOffset(text, paragraph);
44
+ location = NSMaxRange(paragraph);
45
+ }
46
+ }
47
+
48
+ @end
@@ -40,7 +40,7 @@ static const unichar kZeroWidthSpace = 0x200B;
40
40
 
41
41
  NSMutableString *buffer = [NSMutableString string];
42
42
  [self _appendChildTextFromNode:node toBuffer:buffer];
43
- return [buffer copy];
43
+ return [buffer stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
44
44
  }
45
45
 
46
46
  - (void)_appendChildTextFromNode:(MarkdownASTNode *)node toBuffer:(NSMutableString *)buffer
@@ -27,10 +27,18 @@
27
27
  ENRMMathInlineAttachment *attachment = [[ENRMMathInlineAttachment alloc] init];
28
28
  attachment.latex = latex;
29
29
  attachment.fontSize = currentFont ? currentFont.pointSize : [_config paragraphFontSize];
30
- attachment.mathTextColor = [_config inlineMathColor];
30
+ RCTUIColor *mathColor = [_config inlineMathColor];
31
+ if (context.inHighlight) {
32
+ mathColor = [RenderContext calculateHighlightColor:[_config highlightColor]
33
+ paragraphColor:[_config paragraphColor]
34
+ blockColor:mathColor]
35
+ ?: mathColor;
36
+ }
37
+ attachment.mathTextColor = mathColor;
31
38
  attachment.containerPaddingVertical = [_config inlineMathPaddingVertical];
32
39
  attachment.bold = ENRMMathFontWeightIsBold([_config inlineMathFontWeight]);
33
40
  attachment.glyphOverflow = [_config inlineMathGlyphOverflow];
41
+ [context.mathReporters addObject:attachment];
34
42
 
35
43
  #if TARGET_OS_OSX
36
44
  // On macOS, NSLayoutManager uses self.image/self.bounds rather than calling
@@ -65,6 +65,7 @@ static NSString *const kHeadingTypes[] = {nil, @"heading-1", @"heading-
65
65
  [output addAttribute:MarkdownTypeAttributeName value:kHeadingTypes[level] range:range];
66
66
 
67
67
  applyLineHeight(output, range, style.lineHeight);
68
+ applyBaselineOffset(output, range);
68
69
  applyTextAlignment(output, range, style.textAlign);
69
70
 
70
71
  // Skip marginTop for the first block — already handled by applyBlockSpacingBefore above
@@ -10,11 +10,17 @@ NSString *const HighlightAttributeName = @"EnrichedMarkdownHighlight";
10
10
 
11
11
  #pragma mark - Rendering
12
12
 
13
+ - (id)takeContextSnapshot:(RenderContext *)context
14
+ {
15
+ return [context snapshotScope];
16
+ }
17
+
13
18
  - (void)renderNodeContent:(MarkdownASTNode *)node
14
19
  into:(NSMutableAttributedString *)output
15
20
  context:(RenderContext *)context
16
21
  {
17
22
  NSUInteger start = output.length;
23
+ context.inHighlight = YES;
18
24
  [_rendererFactory renderChildrenOfNode:node into:output context:context];
19
25
 
20
26
  NSRange range = NSMakeRange(start, output.length - start);
@@ -20,7 +20,7 @@
20
20
 
21
21
  RCTUIColor *linkColor = variant.color ?: [_config linkColor];
22
22
  BOOL linkUnderline = variant ? variant.underline : [_config linkUnderline];
23
- NSString *linkFontFamily = [_config linkFontFamily];
23
+ NSString *linkFontFamily = variant.fontFamily.length > 0 ? variant.fontFamily : [_config linkFontFamily];
24
24
  // Chip ("box") properties never fall back to the base link style.
25
25
  ENRMLinkChip *chip = [[ENRMLinkChip alloc] init];
26
26
  chip.backgroundColor = variant ? variant.backgroundColor : [_config linkBackgroundColor];
@@ -19,6 +19,41 @@ NSString *const TaskIndexAttribute = @"TaskIndex";
19
19
  @implementation ENRMListMarkerDescriptor
20
20
  @end
21
21
 
22
+ // NSArray's -hash is its count, so plain one-marker arrays all collide in the
23
+ // table that uniques attribute dictionaries, and each list item probes past
24
+ // every earlier one. Hashing by the item's own marker keeps rendering linear.
25
+ @interface ENRMListMarkerArray : NSArray
26
+ @end
27
+
28
+ @implementation ENRMListMarkerArray {
29
+ NSArray<ENRMListMarkerDescriptor *> *_markers;
30
+ }
31
+
32
+ - (instancetype)initWithMarkers:(NSArray<ENRMListMarkerDescriptor *> *)markers
33
+ {
34
+ if (self = [super init]) {
35
+ _markers = [markers copy];
36
+ }
37
+ return self;
38
+ }
39
+
40
+ - (NSUInteger)count
41
+ {
42
+ return _markers.count;
43
+ }
44
+
45
+ - (id)objectAtIndex:(NSUInteger)index
46
+ {
47
+ return _markers[index];
48
+ }
49
+
50
+ - (NSUInteger)hash
51
+ {
52
+ return _markers.lastObject.hash;
53
+ }
54
+
55
+ @end
56
+
22
57
  @interface ListItemRenderer ()
23
58
  - (void)applyCheckedDecorationsTo:(NSMutableAttributedString *)output
24
59
  range:(NSRange)range
@@ -134,12 +169,18 @@ NSString *const TaskIndexAttribute = @"TaskIndex";
134
169
  attributesToApply[NSParagraphStyleAttributeName] = style;
135
170
  [output addAttributes:attributesToApply range:range];
136
171
  // Line height goes through the shared helper so list items get the same carve-out as
137
- // paragraphs — inline math AND block images. Clamping maximumLineHeight here directly
172
+ // paragraphs — inline math AND block images keep maximumLineHeight = 0, text-only lines are
173
+ // clamped (fork D7 option b, see applyLineHeight). Clamping maximumLineHeight here directly
138
174
  // would push the line fragment below the height an inline math attachment draws at, and
139
175
  // the overflow paints over the neighbouring lines. applyLineHeight reads the paragraph
140
176
  // style back via getOrCreateParagraphStyle, so it must run AFTER addAttributes: for the
141
177
  // indents above to survive; it early-returns on a non-positive line height.
142
178
  applyLineHeight(output, range, lineHeightConfig);
179
+ // Upstream #785: centre the glyphs within the line height. Must run after applyLineHeight,
180
+ // since it reads minimumLineHeight back from the paragraph style.
181
+ if (lineHeightConfig > 0) {
182
+ applyBaselineOffset(output, range);
183
+ }
143
184
  };
144
185
 
145
186
  NSUInteger pos = itemRange.location;
@@ -176,10 +217,18 @@ NSString *const TaskIndexAttribute = @"TaskIndex";
176
217
  }
177
218
  }
178
219
 
220
+ // Cover the whole grapheme cluster: anchoring on a single UTF-16 code unit
221
+ // splits multi-unit graphemes (emoji surrogate pairs, ZWJ sequences) across
222
+ // two attribute runs, which drops the glyph and hides the marker for every
223
+ // item but the last.
224
+ const NSRange anchorRange = [string rangeOfComposedCharacterSequenceAtIndex:anchorLocation];
225
+
179
226
  NSArray *existingMarkers = [output attribute:ListItemMarkerStartAttribute atIndex:anchorLocation effectiveRange:NULL];
180
227
  NSArray *markers =
181
228
  [existingMarkers isKindOfClass:[NSArray class]] ? [existingMarkers arrayByAddingObject:marker] : @[ marker ];
182
- [output addAttribute:ListItemMarkerStartAttribute value:markers range:NSMakeRange(anchorLocation, 1)];
229
+ [output addAttribute:ListItemMarkerStartAttribute
230
+ value:[[ENRMListMarkerArray alloc] initWithMarkers:markers]
231
+ range:anchorRange];
183
232
 
184
233
  if (isTask && isChecked) {
185
234
  [self applyCheckedDecorationsTo:output range:itemRange nestingLevel:nestingLevel];
@@ -31,8 +31,13 @@
31
31
  }
32
32
 
33
33
  NSUInteger start = output.length;
34
+ // Paragraphs directly inside a blockquote keep their block margins so spacing
35
+ // between blocks matches the top-level document (a heading defaults to
36
+ // marginTop 0, so the gap before it comes from the preceding paragraph's
37
+ // marginBottom). List content stays tight - lists own their item spacing.
34
38
  BOOL shouldApplyMargin =
35
- (context.currentBlockType == BlockTypeNone || context.currentBlockType == BlockTypeParagraph);
39
+ (context.currentBlockType == BlockTypeNone || context.currentBlockType == BlockTypeParagraph ||
40
+ context.currentBlockType == BlockTypeBlockquote);
36
41
 
37
42
  // Detect if the paragraph is a wrapper for a standalone image to use image-specific spacing
38
43
  BOOL isBlockImage = (node.children.count == 1 && ((MarkdownASTNode *)node.children[0]).type == MarkdownNodeTypeImage);
@@ -56,7 +61,9 @@
56
61
  // Avoid standard line height on block images to prevent vertical alignment issues
57
62
  if (!isBlockImage) {
58
63
  applyLineHeight(output, range, _config.paragraphLineHeight);
59
- applyBaselineOffset(output, range);
64
+ if (!ENRMBlockTypeReappliesBaselineOffset(context.currentBlockType)) {
65
+ applyBaselineOffset(output, range);
66
+ }
60
67
  }
61
68
 
62
69
  applyTextAlignment(output, range, _config.paragraphTextAlign);
@@ -75,4 +82,4 @@
75
82
  applyParagraphSpacingAfter(output, start, marginBottom);
76
83
  }
77
84
 
78
- @end
85
+ @end
@@ -1,3 +1,4 @@
1
+ #import "ENRMLatexErrorReporting.h"
1
2
  #import "ENRMUIKit.h"
2
3
  #import <Foundation/Foundation.h>
3
4
 
@@ -11,6 +12,16 @@ typedef NS_ENUM(NSInteger, BlockType) {
11
12
  BlockTypeCodeBlock
12
13
  };
13
14
 
15
+ /// YES when the enclosing block re-stamps its own line height over paragraph content and applies the
16
+ /// matching baseline offset itself, so a paragraph nested inside it must not apply its own (the outer
17
+ /// block's line height wins, and applyBaselineOffset skips ranges that already carry an offset).
18
+ /// TODO: loose list items have the same shape (ParagraphRenderer runs, then the list re-stamps its
19
+ /// line height); add BlockTypeUnorderedList/BlockTypeOrderedList here once lists own their offset too.
20
+ static inline BOOL ENRMBlockTypeReappliesBaselineOffset(BlockType type)
21
+ {
22
+ return type == BlockTypeBlockquote;
23
+ }
24
+
14
25
  typedef NS_ENUM(NSInteger, ListType) { ListTypeUnordered, ListTypeOrdered };
15
26
 
16
27
  @interface BlockStyle : NSObject
@@ -45,6 +56,10 @@ typedef NS_ENUM(NSInteger, ListType) { ListTypeUnordered, ListTypeOrdered };
45
56
  @property (nonatomic, assign) BOOL allowFontScaling;
46
57
  @property (nonatomic, assign) CGFloat maxFontSizeMultiplier;
47
58
  @property (nonatomic, assign) NSInteger taskItemCount;
59
+ @property (nonatomic, strong) NSMutableArray<id<ENRMLatexErrorReporting>> *mathReporters;
60
+ /// Rendering inside a `==…==` span: a formula there takes the highlight colour,
61
+ /// which the attributed string's foreground cannot give an attachment.
62
+ @property (nonatomic, assign) BOOL inHighlight;
48
63
 
49
64
  - (instancetype)init;
50
65
  - (void)reset;
@@ -55,6 +70,7 @@ typedef NS_ENUM(NSInteger, ListType) { ListTypeUnordered, ListTypeOrdered };
55
70
  - (void)registerLinkRange:(NSRange)range url:(NSString *)url;
56
71
 
57
72
  - (void)applyLinkAttributesToString:(NSMutableAttributedString *)attributedString;
73
+ - (void)applyImageAttributesToString:(NSMutableAttributedString *)attributedString;
58
74
  - (void)registerHeadingRange:(NSRange)range level:(NSInteger)level text:(NSString *)text;
59
75
  - (void)registerImageRange:(NSRange)range altText:(NSString *)altText url:(NSString *)url;
60
76
  - (void)registerListItemRange:(NSRange)range
@@ -25,6 +25,7 @@ static NSArray<NSString *> *ENRMScopedKeyPaths(void)
25
25
  @"listType",
26
26
  @"listItemNumber",
27
27
  @"accumulatedIndent",
28
+ @"inHighlight",
28
29
  ];
29
30
  });
30
31
  return keyPaths;
@@ -50,6 +51,7 @@ static NSArray<NSString *> *ENRMScopedKeyPaths(void)
50
51
  _listItemPositions = [NSMutableArray array];
51
52
  _listItemDepths = [NSMutableArray array];
52
53
  _listItemOrdered = [NSMutableArray array];
54
+ _mathReporters = [NSMutableArray array];
53
55
  _fontCache = [NSMutableDictionary dictionary];
54
56
  _currentBlockStyle = [[BlockStyle alloc] init];
55
57
  _allowFontScaling = YES;
@@ -138,6 +140,18 @@ static NSArray<NSString *> *ENRMScopedKeyPaths(void)
138
140
  }
139
141
  }
140
142
 
143
+ - (void)applyImageAttributesToString:(NSMutableAttributedString *)attributedString
144
+ {
145
+ NSUInteger length = attributedString.length;
146
+ for (NSUInteger i = 0; i < self.imageRanges.count; i++) {
147
+ NSRange range = [self.imageRanges[i] rangeValue];
148
+ if (NSMaxRange(range) > length)
149
+ continue;
150
+ [attributedString addAttribute:@"imageURL" value:self.imageURLs[i] range:range];
151
+ [attributedString addAttribute:@"imageAltText" value:self.imageAltTexts[i] range:range];
152
+ }
153
+ }
154
+
141
155
  - (void)registerHeadingRange:(NSRange)range level:(NSInteger)level text:(NSString *)text
142
156
  {
143
157
  if (range.length == 0)
@@ -293,6 +307,7 @@ static NSArray<NSString *> *ENRMScopedKeyPaths(void)
293
307
  [_listItemPositions removeAllObjects];
294
308
  [_listItemDepths removeAllObjects];
295
309
  [_listItemOrdered removeAllObjects];
310
+ [_mathReporters removeAllObjects];
296
311
  [self clearBlockStyle];
297
312
 
298
313
  _blockquoteDepth = 0;
@@ -301,6 +316,7 @@ static NSArray<NSString *> *ENRMScopedKeyPaths(void)
301
316
  _listItemNumber = 0;
302
317
  _accumulatedIndent = 0;
303
318
  _taskItemCount = 0;
319
+ _inHighlight = NO;
304
320
 
305
321
  // Revert shared style object to baseline defaults
306
322
  _currentBlockStyle.fontSize = 0;
@@ -1,4 +1,5 @@
1
1
  #import "RendererFactory.h"
2
+ #import "BlankLineRenderer.h"
2
3
  #import "BlockquoteRenderer.h"
3
4
  #import "CodeBlockRenderer.h"
4
5
  #import "CodeRenderer.h"
@@ -98,6 +99,9 @@
98
99
  case MarkdownNodeTypeImage:
99
100
  return [[ENRMImageRenderer alloc] initWithRendererFactory:self config:_config];
100
101
  case MarkdownNodeTypeBlockquote:
102
+ // A list-nested admonition falls back to the inline blockquote renderer
103
+ // (no themed header); top-level admonitions use the segment container path.
104
+ case MarkdownNodeTypeAdmonition:
101
105
  return [[BlockquoteRenderer alloc] initWithRendererFactory:self config:_config];
102
106
  case MarkdownNodeTypeListItem:
103
107
  return [[ListItemRenderer alloc] initWithRendererFactory:self config:_config];
@@ -109,6 +113,8 @@
109
113
  return [[CodeBlockRenderer alloc] initWithRendererFactory:self config:_config];
110
114
  case MarkdownNodeTypeThematicBreak:
111
115
  return [[ThematicBreakRenderer alloc] initWithRendererFactory:self config:_config];
116
+ case MarkdownNodeTypeBlankLine:
117
+ return [[BlankLineRenderer alloc] initWithRendererFactory:self config:_config];
112
118
  #if ENRICHED_MARKDOWN_MATH
113
119
  case MarkdownNodeTypeLatexMathInline:
114
120
  return [[ENRMMathInlineRenderer alloc] initWithRendererFactory:self config:_config];
@@ -18,6 +18,7 @@
18
18
  if (range.length == 0)
19
19
  return;
20
20
 
21
+ [output addAttribute:ENRMScriptAttributeName value:ENRMScriptValueSubscript range:range];
21
22
  ENRMApplyBaselineShift(output, range, _config.subscriptFontScale, -_config.subscriptBaselineOffsetScale);
22
23
  }
23
24
 
@@ -18,6 +18,7 @@
18
18
  if (range.length == 0)
19
19
  return;
20
20
 
21
+ [output addAttribute:ENRMScriptAttributeName value:ENRMScriptValueSuperscript range:range];
21
22
  ENRMApplyBaselineShift(output, range, _config.superscriptFontScale, _config.superscriptBaselineOffsetScale);
22
23
  }
23
24
 
@@ -0,0 +1,31 @@
1
+ #import <CoreGraphics/CoreGraphics.h>
2
+ #import <Foundation/Foundation.h>
3
+
4
+ NS_ASSUME_NONNULL_BEGIN
5
+
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ // GitHub admonition/alert header assets shared with Android and web.
11
+ //
12
+ // The `d` path strings live in ENRMAdmonitionIcons.m and are taken verbatim from
13
+ // @primer/octicons (16x16 viewBox); they MUST stay byte-identical across:
14
+ // - iOS: this file
15
+ // - Android: android/.../segments/AdmonitionIcons.kt
16
+ // - Web: src/web/renderers/admonitionIcons.ts
17
+ extern const CGFloat ENRMAdmonitionIconViewBox;
18
+
19
+ // CGPath for the octicon of the given admonition type ("note", "tip",
20
+ // "important", "warning", "caution"), in the 16x16 icon space. NULL for unknown
21
+ // types. The returned path is cached and owned by the module; do not release.
22
+ CGPathRef _Nullable ENRMAdmonitionIconPath(NSString *type);
23
+
24
+ // Capitalized header title for the type (e.g. "note" -> "Note").
25
+ NSString *ENRMAdmonitionTitle(NSString *type);
26
+
27
+ #ifdef __cplusplus
28
+ }
29
+ #endif
30
+
31
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,93 @@
1
+ #import "ENRMAdmonitionIcons.h"
2
+ #import "ENRMSVGPath.h"
3
+
4
+ const CGFloat ENRMAdmonitionIconViewBox = 16.0;
5
+
6
+ // note=info, tip=light-bulb, important=report, warning=alert, caution=stop.
7
+ // Keep byte-identical with AdmonitionIcons.kt / admonitionIcons.ts (the web file
8
+ // is the source of truth). Parity is enforced by
9
+ // __tests__/admonition-icons-parity.test.ts (jest, run in CI), which reads all
10
+ // three files and fails on any drift. That guard only works while all three
11
+ // copies live under packages/react-native-enriched-markdown/**; moving a copy
12
+ // out of this package requires re-homing the guard (or adding a native-side
13
+ // check) so the copies can't silently diverge.
14
+ static NSDictionary<NSString *, NSString *> *ENRMAdmonitionIconPathData(void)
15
+ {
16
+ static NSDictionary<NSString *, NSString *> *data;
17
+ static dispatch_once_t once;
18
+ dispatch_once(&once, ^{
19
+ data = @{
20
+ @"note" :
21
+ @"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 "
22
+ @"7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 "
23
+ @"0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z",
24
+ @"tip" :
25
+ @"M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284."
26
+ @"411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 "
27
+ @"0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 "
28
+ @"5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-."
29
+ @"33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848."
30
+ @"075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 "
31
+ @"0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 "
32
+ @"0 0 1-.75-.75Z",
33
+ @"important" :
34
+ @"M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0 1 14.25 "
35
+ @"13H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25Zm1.75-.25a.25."
36
+ @"25 0 0 0-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 "
37
+ @".53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25Zm7 2.25v2.5a.75.75 0 0 1-1.5 "
38
+ @"0v-2.5a.75.75 0 0 1 1.5 0ZM9 9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",
39
+ @"warning" :
40
+ @"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 "
41
+ @"1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a."
42
+ @"25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 "
43
+ @"0 1 1 0 0 1 2 0Z",
44
+ @"caution" :
45
+ @"M4.47.22A.749.749 0 0 1 5 0h6c.199 0 .389.079.53.22l4.25 4.25c.141.14.22.331.22.53v6a.749.749 0 "
46
+ @"0 1-.22.53l-4.25 4.25A.749.749 0 0 1 11 16H5a.749.749 0 0 1-.53-.22L.22 11.53A.749.749 0 0 1 0 "
47
+ @"11V5c0-.199.079-.389.22-.53Zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5ZM8 "
48
+ @"4a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 1 0-2 1 1 0 0 1 0 "
49
+ @"2Z",
50
+ };
51
+ });
52
+ return data;
53
+ }
54
+
55
+ static NSDictionary<NSString *, id> *ENRMAdmonitionIconPaths(void)
56
+ {
57
+ static NSDictionary<NSString *, id> *paths;
58
+ static dispatch_once_t once;
59
+ dispatch_once(&once, ^{
60
+ NSDictionary<NSString *, NSString *> *data = ENRMAdmonitionIconPathData();
61
+ NSMutableDictionary<NSString *, id> *parsed = [NSMutableDictionary dictionaryWithCapacity:data.count];
62
+ for (NSString *key in data) {
63
+ CGPathRef path = ENRMCreateCGPathFromSVGPath(data[key]);
64
+ if (path) {
65
+ parsed[key] = (__bridge_transfer id)path;
66
+ }
67
+ }
68
+ paths = parsed;
69
+ });
70
+ return paths;
71
+ }
72
+
73
+ CGPathRef ENRMAdmonitionIconPath(NSString *type)
74
+ {
75
+ return (__bridge CGPathRef)ENRMAdmonitionIconPaths()[type];
76
+ }
77
+
78
+ NSString *ENRMAdmonitionTitle(NSString *type)
79
+ {
80
+ static NSDictionary<NSString *, NSString *> *titles;
81
+ static dispatch_once_t once;
82
+ dispatch_once(&once, ^{
83
+ titles = @{
84
+ @"note" : @"Note",
85
+ @"tip" : @"Tip",
86
+ @"important" : @"Important",
87
+ @"warning" : @"Warning",
88
+ @"caution" : @"Caution",
89
+ };
90
+ });
91
+ NSString *title = titles[type];
92
+ return title ?: type.capitalizedString;
93
+ }