react-native-nitro-markdown 0.5.2 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/README.md +311 -669
  2. package/android/CMakeLists.txt +8 -1
  3. package/android/build.gradle +9 -2
  4. package/android/consumer-rules.pro +31 -0
  5. package/android/gradle.properties +2 -0
  6. package/android/src/main/java/com/margelo/nitro/com/nitromarkdown/HybridMarkdownSession.kt +68 -22
  7. package/android/src/main/java/com/nitromarkdown/NitroMarkdownPackage.kt +6 -18
  8. package/cpp/bindings/HybridMarkdownParser.cpp +40 -12
  9. package/cpp/bindings/HybridMarkdownParser.hpp +4 -4
  10. package/cpp/bindings/HybridMarkdownSession.cpp +2 -0
  11. package/cpp/core/MD4CParser.cpp +147 -86
  12. package/cpp/core/MarkdownSessionCore.cpp +2 -0
  13. package/cpp/core/MarkdownTypes.hpp +1 -1
  14. package/ios/HybridMarkdownSession.swift +89 -46
  15. package/lib/commonjs/headless.js +34 -8
  16. package/lib/commonjs/headless.js.map +1 -1
  17. package/lib/commonjs/index.js +48 -38
  18. package/lib/commonjs/index.js.map +1 -1
  19. package/lib/commonjs/markdown-stream.js +1 -1
  20. package/lib/commonjs/markdown-stream.js.map +1 -1
  21. package/lib/commonjs/markdown.js +57 -16
  22. package/lib/commonjs/markdown.js.map +1 -1
  23. package/lib/commonjs/renderers/blockquote.js +15 -13
  24. package/lib/commonjs/renderers/blockquote.js.map +1 -1
  25. package/lib/commonjs/renderers/code.js +58 -54
  26. package/lib/commonjs/renderers/code.js.map +1 -1
  27. package/lib/commonjs/renderers/heading.js +48 -46
  28. package/lib/commonjs/renderers/heading.js.map +1 -1
  29. package/lib/commonjs/renderers/horizontal-rule.js +10 -8
  30. package/lib/commonjs/renderers/horizontal-rule.js.map +1 -1
  31. package/lib/commonjs/renderers/image.js +18 -4
  32. package/lib/commonjs/renderers/image.js.map +1 -1
  33. package/lib/commonjs/renderers/link.js +7 -2
  34. package/lib/commonjs/renderers/link.js.map +1 -1
  35. package/lib/commonjs/renderers/list.js +75 -68
  36. package/lib/commonjs/renderers/list.js.map +1 -1
  37. package/lib/commonjs/renderers/math.js +8 -5
  38. package/lib/commonjs/renderers/math.js.map +1 -1
  39. package/lib/commonjs/renderers/paragraph.js +15 -13
  40. package/lib/commonjs/renderers/paragraph.js.map +1 -1
  41. package/lib/commonjs/renderers/style-cache.js +14 -0
  42. package/lib/commonjs/renderers/style-cache.js.map +1 -0
  43. package/lib/commonjs/renderers/table/cell-content.js +1 -1
  44. package/lib/commonjs/renderers/table/cell-content.js.map +1 -1
  45. package/lib/commonjs/renderers/table/index.js +17 -6
  46. package/lib/commonjs/renderers/table/index.js.map +1 -1
  47. package/lib/commonjs/theme.js +7 -7
  48. package/lib/commonjs/theme.js.map +1 -1
  49. package/lib/commonjs/utils/code-highlight.js +24 -25
  50. package/lib/commonjs/utils/code-highlight.js.map +1 -1
  51. package/lib/module/headless.js +35 -7
  52. package/lib/module/headless.js.map +1 -1
  53. package/lib/module/index.js +1 -1
  54. package/lib/module/index.js.map +1 -1
  55. package/lib/module/markdown-stream.js +1 -1
  56. package/lib/module/markdown-stream.js.map +1 -1
  57. package/lib/module/markdown.js +58 -17
  58. package/lib/module/markdown.js.map +1 -1
  59. package/lib/module/renderers/blockquote.js +15 -13
  60. package/lib/module/renderers/blockquote.js.map +1 -1
  61. package/lib/module/renderers/code.js +58 -54
  62. package/lib/module/renderers/code.js.map +1 -1
  63. package/lib/module/renderers/heading.js +48 -46
  64. package/lib/module/renderers/heading.js.map +1 -1
  65. package/lib/module/renderers/horizontal-rule.js +10 -8
  66. package/lib/module/renderers/horizontal-rule.js.map +1 -1
  67. package/lib/module/renderers/image.js +19 -5
  68. package/lib/module/renderers/image.js.map +1 -1
  69. package/lib/module/renderers/link.js +7 -2
  70. package/lib/module/renderers/link.js.map +1 -1
  71. package/lib/module/renderers/list.js +75 -68
  72. package/lib/module/renderers/list.js.map +1 -1
  73. package/lib/module/renderers/math.js +8 -5
  74. package/lib/module/renderers/math.js.map +1 -1
  75. package/lib/module/renderers/paragraph.js +15 -13
  76. package/lib/module/renderers/paragraph.js.map +1 -1
  77. package/lib/module/renderers/style-cache.js +10 -0
  78. package/lib/module/renderers/style-cache.js.map +1 -0
  79. package/lib/module/renderers/table/cell-content.js +1 -1
  80. package/lib/module/renderers/table/cell-content.js.map +1 -1
  81. package/lib/module/renderers/table/index.js +17 -6
  82. package/lib/module/renderers/table/index.js.map +1 -1
  83. package/lib/module/theme.js +7 -7
  84. package/lib/module/theme.js.map +1 -1
  85. package/lib/module/utils/code-highlight.js +24 -25
  86. package/lib/module/utils/code-highlight.js.map +1 -1
  87. package/lib/typescript/commonjs/Markdown.nitro.d.ts +1 -0
  88. package/lib/typescript/commonjs/Markdown.nitro.d.ts.map +1 -1
  89. package/lib/typescript/commonjs/headless.d.ts +10 -2
  90. package/lib/typescript/commonjs/headless.d.ts.map +1 -1
  91. package/lib/typescript/commonjs/index.d.ts +3 -2
  92. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  93. package/lib/typescript/commonjs/markdown-stream.d.ts.map +1 -1
  94. package/lib/typescript/commonjs/markdown.d.ts +8 -3
  95. package/lib/typescript/commonjs/markdown.d.ts.map +1 -1
  96. package/lib/typescript/commonjs/renderers/blockquote.d.ts +1 -1
  97. package/lib/typescript/commonjs/renderers/blockquote.d.ts.map +1 -1
  98. package/lib/typescript/commonjs/renderers/code.d.ts.map +1 -1
  99. package/lib/typescript/commonjs/renderers/heading.d.ts +1 -1
  100. package/lib/typescript/commonjs/renderers/heading.d.ts.map +1 -1
  101. package/lib/typescript/commonjs/renderers/horizontal-rule.d.ts +1 -1
  102. package/lib/typescript/commonjs/renderers/horizontal-rule.d.ts.map +1 -1
  103. package/lib/typescript/commonjs/renderers/image.d.ts.map +1 -1
  104. package/lib/typescript/commonjs/renderers/link.d.ts.map +1 -1
  105. package/lib/typescript/commonjs/renderers/list.d.ts +1 -1
  106. package/lib/typescript/commonjs/renderers/list.d.ts.map +1 -1
  107. package/lib/typescript/commonjs/renderers/math.d.ts +1 -1
  108. package/lib/typescript/commonjs/renderers/math.d.ts.map +1 -1
  109. package/lib/typescript/commonjs/renderers/paragraph.d.ts +1 -1
  110. package/lib/typescript/commonjs/renderers/paragraph.d.ts.map +1 -1
  111. package/lib/typescript/commonjs/renderers/style-cache.d.ts +3 -0
  112. package/lib/typescript/commonjs/renderers/style-cache.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/renderers/table/cell-content.d.ts +4 -3
  114. package/lib/typescript/commonjs/renderers/table/cell-content.d.ts.map +1 -1
  115. package/lib/typescript/commonjs/renderers/table/index.d.ts.map +1 -1
  116. package/lib/typescript/commonjs/theme.d.ts.map +1 -1
  117. package/lib/typescript/commonjs/utils/code-highlight.d.ts +1 -1
  118. package/lib/typescript/commonjs/utils/code-highlight.d.ts.map +1 -1
  119. package/lib/typescript/module/Markdown.nitro.d.ts +1 -0
  120. package/lib/typescript/module/Markdown.nitro.d.ts.map +1 -1
  121. package/lib/typescript/module/headless.d.ts +10 -2
  122. package/lib/typescript/module/headless.d.ts.map +1 -1
  123. package/lib/typescript/module/index.d.ts +3 -2
  124. package/lib/typescript/module/index.d.ts.map +1 -1
  125. package/lib/typescript/module/markdown-stream.d.ts.map +1 -1
  126. package/lib/typescript/module/markdown.d.ts +8 -3
  127. package/lib/typescript/module/markdown.d.ts.map +1 -1
  128. package/lib/typescript/module/renderers/blockquote.d.ts +1 -1
  129. package/lib/typescript/module/renderers/blockquote.d.ts.map +1 -1
  130. package/lib/typescript/module/renderers/code.d.ts.map +1 -1
  131. package/lib/typescript/module/renderers/heading.d.ts +1 -1
  132. package/lib/typescript/module/renderers/heading.d.ts.map +1 -1
  133. package/lib/typescript/module/renderers/horizontal-rule.d.ts +1 -1
  134. package/lib/typescript/module/renderers/horizontal-rule.d.ts.map +1 -1
  135. package/lib/typescript/module/renderers/image.d.ts.map +1 -1
  136. package/lib/typescript/module/renderers/link.d.ts.map +1 -1
  137. package/lib/typescript/module/renderers/list.d.ts +1 -1
  138. package/lib/typescript/module/renderers/list.d.ts.map +1 -1
  139. package/lib/typescript/module/renderers/math.d.ts +1 -1
  140. package/lib/typescript/module/renderers/math.d.ts.map +1 -1
  141. package/lib/typescript/module/renderers/paragraph.d.ts +1 -1
  142. package/lib/typescript/module/renderers/paragraph.d.ts.map +1 -1
  143. package/lib/typescript/module/renderers/style-cache.d.ts +3 -0
  144. package/lib/typescript/module/renderers/style-cache.d.ts.map +1 -0
  145. package/lib/typescript/module/renderers/table/cell-content.d.ts +4 -3
  146. package/lib/typescript/module/renderers/table/cell-content.d.ts.map +1 -1
  147. package/lib/typescript/module/renderers/table/index.d.ts.map +1 -1
  148. package/lib/typescript/module/theme.d.ts.map +1 -1
  149. package/lib/typescript/module/utils/code-highlight.d.ts +1 -1
  150. package/lib/typescript/module/utils/code-highlight.d.ts.map +1 -1
  151. package/nitro.json +12 -3
  152. package/nitrogen/generated/android/NitroMarkdownOnLoad.cpp +2 -2
  153. package/nitrogen/generated/android/c++/JFunc_void.hpp +2 -2
  154. package/nitrogen/generated/android/c++/JFunc_void_double_double.hpp +2 -2
  155. package/nitrogen/generated/android/c++/JHybridMarkdownSessionSpec.hpp +2 -2
  156. package/nitrogen/generated/ios/NitroMarkdown+autolinking.rb +2 -0
  157. package/nitrogen/generated/shared/c++/ParserOptions.hpp +6 -2
  158. package/package.json +8 -6
  159. package/react-native-nitro-markdown.podspec +3 -0
  160. package/src/Markdown.nitro.ts +1 -0
  161. package/src/headless.ts +58 -8
  162. package/src/index.ts +16 -2
  163. package/src/markdown-stream.tsx +1 -0
  164. package/src/markdown.tsx +108 -23
  165. package/src/renderers/blockquote.tsx +22 -17
  166. package/src/renderers/code.tsx +76 -57
  167. package/src/renderers/heading.tsx +60 -54
  168. package/src/renderers/horizontal-rule.tsx +17 -12
  169. package/src/renderers/image.tsx +24 -5
  170. package/src/renderers/link.tsx +8 -2
  171. package/src/renderers/list.tsx +93 -74
  172. package/src/renderers/math.tsx +14 -5
  173. package/src/renderers/paragraph.tsx +22 -17
  174. package/src/renderers/style-cache.ts +14 -0
  175. package/src/renderers/table/cell-content.tsx +15 -4
  176. package/src/renderers/table/index.tsx +30 -13
  177. package/src/theme.ts +34 -14
  178. package/src/utils/code-highlight.ts +133 -44
@@ -5,43 +5,50 @@ class HybridMarkdownSession: HybridMarkdownSessionSpec {
5
5
  private var buffer = ""
6
6
  private var listeners: [UUID: (Double, Double) -> Void] = [:]
7
7
  private let lock = NSLock()
8
-
9
- private(set) var version: Int = 0
10
-
11
- var highlightPosition: Double = 0
12
-
13
8
 
14
-
9
+ var highlightPosition: Double {
10
+ get { lock.lock(); defer { lock.unlock() }; return _highlightPosition }
11
+ set { lock.lock(); defer { lock.unlock() }; _highlightPosition = newValue }
12
+ }
13
+ private var _highlightPosition: Double = 0
14
+
15
15
  var memorySize: Int {
16
- return buffer.utf8.count + MemoryLayout<HybridMarkdownSession>.size
16
+ return buffer.utf8.count
17
+ + MemoryLayout<HybridMarkdownSession>.size
18
+ + MemoryLayout<NSLock>.size
19
+ + listeners.count * 128 // UUID key (16 bytes) + closure overhead estimate
17
20
  }
18
21
 
19
22
  private func utf16Length(_ value: String) -> Int {
20
23
  return (value as NSString).length
21
24
  }
22
-
25
+
23
26
  func append(chunk: String) throws -> Double {
24
- let from: Int
25
- let to: Int
26
- lock.lock()
27
- from = utf16Length(buffer)
28
- buffer += chunk
29
- to = utf16Length(buffer)
30
- version += 1
31
- lock.unlock()
32
- notifyListeners(from: Double(from), to: Double(to))
33
- return Double(to)
27
+ let notifyFrom: Double
28
+ let notifyTo: Double
29
+ do {
30
+ lock.lock()
31
+ defer { lock.unlock() }
32
+ let fromInt = utf16Length(buffer)
33
+ buffer += chunk
34
+ let toInt = utf16Length(buffer)
35
+ notifyFrom = Double(fromInt)
36
+ notifyTo = Double(toInt)
37
+ }
38
+ notifyListeners(from: notifyFrom, to: notifyTo)
39
+ return notifyTo
34
40
  }
35
-
41
+
36
42
  func clear() throws {
37
- lock.lock()
38
- buffer = ""
39
- highlightPosition = 0
40
- version += 1
41
- lock.unlock()
43
+ do {
44
+ lock.lock()
45
+ defer { lock.unlock() }
46
+ buffer = ""
47
+ _highlightPosition = 0
48
+ }
42
49
  notifyListeners(from: 0, to: 0)
43
50
  }
44
-
51
+
45
52
  func getAllText() throws -> String {
46
53
  lock.lock()
47
54
  defer { lock.unlock() }
@@ -55,6 +62,9 @@ class HybridMarkdownSession: HybridMarkdownSessionSpec {
55
62
  }
56
63
 
57
64
  func getTextRange(from: Double, to: Double) throws -> String {
65
+ guard from.isFinite && to.isFinite && from >= 0 && to >= 0 && from <= to else {
66
+ return ""
67
+ }
58
68
  lock.lock()
59
69
  defer { lock.unlock() }
60
70
 
@@ -64,43 +74,76 @@ class HybridMarkdownSession: HybridMarkdownSessionSpec {
64
74
  let end = max(start, min(Int(to), length))
65
75
  return text.substring(with: NSRange(location: start, length: end - start))
66
76
  }
67
-
77
+
78
+ /// Adds a change listener. The listener closure is held strongly.
79
+ /// To avoid retain cycles, ensure the listener does not capture a strong
80
+ /// reference to the object that owns this HybridMarkdownSession.
81
+ /// Always call the returned cleanup closure when done to unregister.
68
82
  func addListener(listener: @escaping (Double, Double) -> Void) throws -> () -> Void {
69
83
  let id = UUID()
70
84
  lock.lock()
71
85
  listeners[id] = listener
72
86
  lock.unlock()
73
-
87
+
74
88
  return { [weak self] in
75
- self?.lock.lock()
76
- self?.listeners.removeValue(forKey: id)
77
- self?.lock.unlock()
89
+ guard let self else { return }
90
+ self.lock.lock()
91
+ defer { self.lock.unlock() }
92
+ self.listeners.removeValue(forKey: id)
78
93
  }
79
94
  }
80
-
81
- func reset(text: String) -> Void {
82
- lock.lock()
83
- buffer = text
84
- lock.unlock()
85
- notifyListeners(from: 0, to: Double((text as NSString).length))
95
+
96
+ func reset(text: String) throws -> Void {
97
+ let notifyTo: Double
98
+ do {
99
+ lock.lock()
100
+ defer { lock.unlock() }
101
+ buffer = text
102
+ _highlightPosition = 0
103
+ notifyTo = Double((text as NSString).length)
104
+ }
105
+ notifyListeners(from: 0, to: notifyTo)
86
106
  }
87
107
 
88
- func replace(from: Double, to: Double, text: String) -> Double {
89
- lock.lock()
90
- let startIdx = buffer.index(buffer.startIndex, offsetBy: Int(from), limitedBy: buffer.endIndex) ?? buffer.endIndex
91
- let endIdx = buffer.index(buffer.startIndex, offsetBy: Int(to), limitedBy: buffer.endIndex) ?? buffer.endIndex
92
- buffer.replaceSubrange(startIdx..<endIdx, with: text)
93
- let newLength = Double((buffer as NSString).length)
94
- lock.unlock()
95
- notifyListeners(from: from, to: from + Double((text as NSString).length))
96
- return newLength
108
+ func replace(from: Double, to: Double, text: String) throws -> Double {
109
+ let notifyFrom: Double
110
+ let notifyTo: Double
111
+ let newLength: Double
112
+ let start: Int
113
+ let end: Int
114
+ do {
115
+ lock.lock()
116
+ defer { lock.unlock() }
117
+ guard from.isFinite && to.isFinite && from >= 0 && to >= 0 && from <= to else {
118
+ return Double(utf16Length(buffer))
119
+ }
120
+ let nsBuffer = NSMutableString(string: buffer)
121
+ let length = nsBuffer.length
122
+ start = max(0, min(Int(from), length))
123
+ end = max(start, min(Int(to), length))
124
+ nsBuffer.replaceCharacters(in: NSRange(location: start, length: end - start), with: text)
125
+ buffer = nsBuffer as String
126
+ newLength = Double((buffer as NSString).length)
127
+ notifyFrom = from
128
+ notifyTo = from + Double((text as NSString).length)
129
+ }
130
+ if start == end && text.isEmpty {
131
+ return newLength
132
+ }
133
+ notifyListeners(from: notifyFrom, to: notifyTo)
134
+ return newLength
97
135
  }
98
136
 
137
+ /// Notifies all registered listeners about a buffer change.
138
+ /// Called OUTSIDE the lock to prevent deadlock (listeners may call back into this session).
139
+ /// The `from`/`to` values reflect the buffer state AT THE TIME OF MUTATION.
140
+ /// The buffer may have been further modified by the time listener callbacks execute.
141
+ /// Listeners MUST NOT assume the buffer is stable; they should only use the index parameters.
99
142
  private func notifyListeners(from: Double, to: Double) {
100
143
  lock.lock()
101
144
  let currentListeners = Array(listeners.values)
102
145
  lock.unlock()
103
-
146
+
104
147
  for listener in currentListeners {
105
148
  listener(from, to)
106
149
  }
@@ -29,18 +29,40 @@ var _reactNativeNitroModules = require("react-native-nitro-modules");
29
29
  * Each node has a type and optional properties depending on the node type.
30
30
  */
31
31
 
32
- const MarkdownParserModule = exports.MarkdownParserModule = _reactNativeNitroModules.NitroModules.createHybridObject("MarkdownParser");
33
-
32
+ let MarkdownParserModule = exports.MarkdownParserModule = null;
33
+ try {
34
+ exports.MarkdownParserModule = MarkdownParserModule = _reactNativeNitroModules.NitroModules.createHybridObject("MarkdownParser");
35
+ } catch (e) {
36
+ if (__DEV__) {
37
+ // eslint-disable-next-line no-console
38
+ console.error("[NitroMarkdown] Failed to create native MarkdownParser:", e);
39
+ }
40
+ }
34
41
  /**
35
42
  * Parse markdown text into an AST.
36
43
  * @param text - The markdown text to parse
37
44
  * @returns The root node of the parsed AST
38
45
  */
39
- function parseMarkdown(text) {
40
- if (typeof MarkdownParserModule.parse === "function") {
46
+
47
+ /**
48
+ * Parse markdown text with custom options.
49
+ * @param text - The markdown text to parse
50
+ * @param options - Parser options (gfm, math, html)
51
+ * @returns The root node of the parsed AST
52
+ */
53
+
54
+ function parseMarkdown(text, options) {
55
+ if (options != null) {
56
+ return parseMarkdownWithOptions(text, options);
57
+ }
58
+ if (MarkdownParserModule != null && typeof MarkdownParserModule.parse === "function") {
41
59
  const jsonStr = MarkdownParserModule.parse(text);
42
60
  return JSON.parse(jsonStr);
43
61
  }
62
+ if (__DEV__) {
63
+ // eslint-disable-next-line no-console
64
+ console.error("[NitroMarkdown] parseMarkdown: native parser unavailable — check installation.");
65
+ }
44
66
  return {
45
67
  type: "document",
46
68
  children: []
@@ -50,14 +72,18 @@ function parseMarkdown(text) {
50
72
  /**
51
73
  * Parse markdown text with custom options.
52
74
  * @param text - The markdown text to parse
53
- * @param options - Parser options (gfm, math)
75
+ * @param options - Parser options (gfm, math, html)
54
76
  * @returns The root node of the parsed AST
55
77
  */
56
78
  function parseMarkdownWithOptions(text, options) {
57
- if (typeof MarkdownParserModule.parseWithOptions === "function") {
79
+ if (MarkdownParserModule != null && typeof MarkdownParserModule.parseWithOptions === "function") {
58
80
  const jsonStr = MarkdownParserModule.parseWithOptions(text, options);
59
81
  return JSON.parse(jsonStr);
60
82
  }
83
+ if (__DEV__) {
84
+ // eslint-disable-next-line no-console
85
+ console.error("[NitroMarkdown] parseMarkdownWithOptions: native parser unavailable — check installation.");
86
+ }
61
87
  return {
62
88
  type: "document",
63
89
  children: []
@@ -69,7 +95,7 @@ function parseMarkdownWithOptions(text, options) {
69
95
  * Useful for search/indexing flows that don't need full AST rendering.
70
96
  */
71
97
  function extractPlainText(text) {
72
- if (typeof MarkdownParserModule.extractPlainText === "function") {
98
+ if (MarkdownParserModule != null && typeof MarkdownParserModule.extractPlainText === "function") {
73
99
  return MarkdownParserModule.extractPlainText(text);
74
100
  }
75
101
  return getFlattenedText(parseMarkdown(text));
@@ -79,7 +105,7 @@ function extractPlainText(text) {
79
105
  * Parse markdown with options and return flattened plain text from native parser.
80
106
  */
81
107
  function extractPlainTextWithOptions(text, options) {
82
- if (typeof MarkdownParserModule.extractPlainTextWithOptions === "function") {
108
+ if (MarkdownParserModule != null && typeof MarkdownParserModule.extractPlainTextWithOptions === "function") {
83
109
  return MarkdownParserModule.extractPlainTextWithOptions(text, options);
84
110
  }
85
111
  return getFlattenedText(parseMarkdownWithOptions(text, options));
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNativeNitroModules","require","MarkdownParserModule","exports","NitroModules","createHybridObject","parseMarkdown","text","parse","jsonStr","JSON","type","children","parseMarkdownWithOptions","options","parseWithOptions","extractPlainText","getFlattenedText","extractPlainTextWithOptions","getTextContent","node","content","map","join","trim","alt","title","childrenText","stripSourceOffsets","beg","_beg","end","_end","rest"],"sourceRoot":"../../src","sources":["headless.ts"],"mappings":";;;;;;;;;;;;AAYA,IAAAA,wBAAA,GAAAC,OAAA;AAZA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,KAAK,IAAI,EAAE;EACrC;EAEA,MAAMC,YAAY,GAAGP,IAAI,CAACR,QAAQ,EAAEU,GAAG,CAACL,gBAAgB,CAAC,CAACM,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE;EAExE,QAAQH,IAAI,CAACT,IAAI;IACf,KAAK,WAAW;IAChB,KAAK,SAAS;IACd,KAAK,YAAY;MACf,OAAOgB,YAAY,CAACH,IAAI,CAAC,CAAC,GAAG,MAAM;IAErC,KAAK,WAAW;IAChB,KAAK,gBAAgB;MACnB,OAAOG,YAAY,CAACH,IAAI,CAAC,CAAC,GAAG,IAAI;IAEnC,KAAK,MAAM;MACT,OAAOG,YAAY,GAAG,IAAI;IAE5B,KAAK,WAAW;MACd,OAAOA,YAAY,GAAG,IAAI;IAE5B,KAAK,YAAY;MACf,OAAOA,YAAY,GAAG,KAAK;IAE7B;MACE,OAAOA,YAAY;EACvB;AACF,CAAC;;AAED;AACA;AACA;AACA;AAHAxB,OAAA,CAAAc,gBAAA,GAAAA,gBAAA;AAIO,SAASW,kBAAkBA,CAACR,IAAkB,EAAgB;EACnE,MAAM;IAAES,GAAG,EAAEC,IAAI;IAAEC,GAAG,EAAEC,IAAI;IAAEpB,QAAQ;IAAE,GAAGqB;EAAK,CAAC,GAAGb,IAAI;EACxD,OAAO;IACL,GAAGa,IAAI;IACP,IAAIrB,QAAQ,GAAG;MAAEA,QAAQ,EAAEA,QAAQ,CAACU,GAAG,CAACM,kBAAkB;IAAE,CAAC,GAAG,CAAC,CAAC;EACpE,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["_reactNativeNitroModules","require","MarkdownParserModule","exports","NitroModules","createHybridObject","e","__DEV__","console","error","parseMarkdown","text","options","parseMarkdownWithOptions","parse","jsonStr","JSON","type","children","parseWithOptions","extractPlainText","getFlattenedText","extractPlainTextWithOptions","getTextContent","node","content","map","join","trim","alt","title","childrenText","stripSourceOffsets","beg","_beg","end","_end","rest"],"sourceRoot":"../../src","sources":["headless.ts"],"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AACA;AACA;AACA;AAHA5B,OAAA,CAAAkB,gBAAA,GAAAA,gBAAA;AAIO,SAASW,kBAAkBA,CAACR,IAAkB,EAAgB;EACnE,MAAM;IAAES,GAAG,EAAEC,IAAI;IAAEC,GAAG,EAAEC,IAAI;IAAElB,QAAQ;IAAE,GAAGmB;EAAK,CAAC,GAAGb,IAAI;EACxD,OAAO;IACL,GAAGa,IAAI;IACP,IAAInB,QAAQ,GAAG;MAAEA,QAAQ,EAAEA,QAAQ,CAACQ,GAAG,CAACM,kBAAkB;IAAE,CAAC,GAAG,CAAC,CAAC;EACpE,CAAC;AACH","ignoreList":[]}
@@ -3,33 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- var _exportNames = {
7
- Markdown: true,
8
- MarkdownStream: true,
9
- useMarkdownContext: true,
10
- MarkdownContext: true,
11
- defaultMarkdownTheme: true,
12
- minimalMarkdownTheme: true,
13
- mergeThemes: true,
14
- Heading: true,
15
- Paragraph: true,
16
- Link: true,
17
- Blockquote: true,
18
- HorizontalRule: true,
19
- CodeBlock: true,
20
- InlineCode: true,
21
- List: true,
22
- ListItem: true,
23
- TaskListItem: true,
24
- TableRenderer: true,
25
- Image: true,
26
- MathInline: true,
27
- MathBlock: true,
28
- createMarkdownSession: true,
29
- useMarkdownSession: true,
30
- useStream: true,
31
- defaultHighlighter: true
32
- };
33
6
  Object.defineProperty(exports, "Blockquote", {
34
7
  enumerable: true,
35
8
  get: function () {
@@ -96,6 +69,12 @@ Object.defineProperty(exports, "MarkdownContext", {
96
69
  return _MarkdownContext.MarkdownContext;
97
70
  }
98
71
  });
72
+ Object.defineProperty(exports, "MarkdownParserModule", {
73
+ enumerable: true,
74
+ get: function () {
75
+ return _headless.MarkdownParserModule;
76
+ }
77
+ });
99
78
  Object.defineProperty(exports, "MarkdownStream", {
100
79
  enumerable: true,
101
80
  get: function () {
@@ -150,6 +129,30 @@ Object.defineProperty(exports, "defaultMarkdownTheme", {
150
129
  return _theme.defaultMarkdownTheme;
151
130
  }
152
131
  });
132
+ Object.defineProperty(exports, "extractPlainText", {
133
+ enumerable: true,
134
+ get: function () {
135
+ return _headless.extractPlainText;
136
+ }
137
+ });
138
+ Object.defineProperty(exports, "extractPlainTextWithOptions", {
139
+ enumerable: true,
140
+ get: function () {
141
+ return _headless.extractPlainTextWithOptions;
142
+ }
143
+ });
144
+ Object.defineProperty(exports, "getFlattenedText", {
145
+ enumerable: true,
146
+ get: function () {
147
+ return _headless.getFlattenedText;
148
+ }
149
+ });
150
+ Object.defineProperty(exports, "getTextContent", {
151
+ enumerable: true,
152
+ get: function () {
153
+ return _headless.getTextContent;
154
+ }
155
+ });
153
156
  Object.defineProperty(exports, "mergeThemes", {
154
157
  enumerable: true,
155
158
  get: function () {
@@ -162,6 +165,24 @@ Object.defineProperty(exports, "minimalMarkdownTheme", {
162
165
  return _theme.minimalMarkdownTheme;
163
166
  }
164
167
  });
168
+ Object.defineProperty(exports, "parseMarkdown", {
169
+ enumerable: true,
170
+ get: function () {
171
+ return _headless.parseMarkdown;
172
+ }
173
+ });
174
+ Object.defineProperty(exports, "parseMarkdownWithOptions", {
175
+ enumerable: true,
176
+ get: function () {
177
+ return _headless.parseMarkdownWithOptions;
178
+ }
179
+ });
180
+ Object.defineProperty(exports, "stripSourceOffsets", {
181
+ enumerable: true,
182
+ get: function () {
183
+ return _headless.stripSourceOffsets;
184
+ }
185
+ });
165
186
  Object.defineProperty(exports, "useMarkdownContext", {
166
187
  enumerable: true,
167
188
  get: function () {
@@ -181,17 +202,6 @@ Object.defineProperty(exports, "useStream", {
181
202
  }
182
203
  });
183
204
  var _headless = require("./headless.js");
184
- Object.keys(_headless).forEach(function (key) {
185
- if (key === "default" || key === "__esModule") return;
186
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
187
- if (key in exports && exports[key] === _headless[key]) return;
188
- Object.defineProperty(exports, key, {
189
- enumerable: true,
190
- get: function () {
191
- return _headless[key];
192
- }
193
- });
194
- });
195
205
  var _markdown = require("./markdown.js");
196
206
  var _markdownStream = require("./markdown-stream.js");
197
207
  var _MarkdownContext = require("./MarkdownContext.js");
@@ -1 +1 @@
1
- {"version":3,"names":["_headless","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_markdown","_markdownStream","_MarkdownContext","_theme","_heading","_paragraph","_link","_blockquote","_horizontalRule","_code","_list","_table","_image","_math","_MarkdownSession","_useMarkdownStream","_codeHighlight"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,SAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,SAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,SAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AAEA,IAAAS,SAAA,GAAAb,OAAA;AAOA,IAAAc,eAAA,GAAAd,OAAA;AAGA,IAAAe,gBAAA,GAAAf,OAAA;AAmBA,IAAAgB,MAAA,GAAAhB,OAAA;AAYA,IAAAiB,QAAA,GAAAjB,OAAA;AACA,IAAAkB,UAAA,GAAAlB,OAAA;AACA,IAAAmB,KAAA,GAAAnB,OAAA;AACA,IAAAoB,WAAA,GAAApB,OAAA;AACA,IAAAqB,eAAA,GAAArB,OAAA;AACA,IAAAsB,KAAA,GAAAtB,OAAA;AACA,IAAAuB,KAAA,GAAAvB,OAAA;AACA,IAAAwB,MAAA,GAAAxB,OAAA;AACA,IAAAyB,MAAA,GAAAzB,OAAA;AACA,IAAA0B,KAAA,GAAA1B,OAAA;AAEA,IAAA2B,gBAAA,GAAA3B,OAAA;AAEA,IAAA4B,kBAAA,GAAA5B,OAAA;AAGA,IAAA6B,cAAA,GAAA7B,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_headless","require","_markdown","_markdownStream","_MarkdownContext","_theme","_heading","_paragraph","_link","_blockquote","_horizontalRule","_code","_list","_table","_image","_math","_MarkdownSession","_useMarkdownStream","_codeHighlight"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAYA,IAAAC,SAAA,GAAAD,OAAA;AAOA,IAAAE,eAAA,GAAAF,OAAA;AAGA,IAAAG,gBAAA,GAAAH,OAAA;AAmBA,IAAAI,MAAA,GAAAJ,OAAA;AAYA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AACA,IAAAS,eAAA,GAAAT,OAAA;AACA,IAAAU,KAAA,GAAAV,OAAA;AACA,IAAAW,KAAA,GAAAX,OAAA;AACA,IAAAY,MAAA,GAAAZ,OAAA;AACA,IAAAa,MAAA,GAAAb,OAAA;AACA,IAAAc,KAAA,GAAAd,OAAA;AAEA,IAAAe,gBAAA,GAAAf,OAAA;AAEA,IAAAgB,kBAAA,GAAAhB,OAAA;AAOA,IAAAiB,cAAA,GAAAjB,OAAA","ignoreList":[]}
@@ -164,7 +164,7 @@ const MarkdownStream = ({
164
164
  rafRef.current = null;
165
165
  }
166
166
  };
167
- }, [allowIncremental, hasBeforeParsePlugins, options, session, updateIntervalMs, updateStrategy, useTransitionUpdates]);
167
+ }, [allowIncremental, hasBeforeParsePlugins, options, plugins, session, updateIntervalMs, updateStrategy, useTransitionUpdates]);
168
168
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_markdown.Markdown, {
169
169
  ...props,
170
170
  options: options,
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_markdown","_incrementalAst","_jsxRuntime","normalizeOffset","value","Number","isFinite","Math","floor","resolveStreamText","forceFullSync","pendingFrom","pendingTo","previousText","session","getAllText","length","appendedChunk","getTextRange","MarkdownStream","updateIntervalMs","updateStrategy","useTransitionUpdates","incrementalParsing","options","plugins","props","parseText","useCallback","text","parseMarkdownAst","createEmptyAst","type","children","initialText","hasBeforeParsePlugins","some","plugin","beforeParse","renderState","setRenderState","useState","ast","renderStateRef","useRef","pendingUpdateRef","pendingFromRef","pendingToRef","forceFullSyncRef","updateTimerRef","rafRef","allowIncremental","useEffect","current","initialState","flushUpdate","cancelAnimationFrame","previousState","latest","nextAst","getNextStreamAst","nextText","previousAst","nextState","startTransition","scheduleFlush","requestAnimationFrame","setTimeout","unsubscribe","addListener","from","to","nextFrom","nextTo","currentFrom","currentTo","min","max","clearTimeout","jsx","Markdown","sourceAst","undefined","exports"],"sourceRoot":"../../src","sources":["markdown-stream.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AASA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,eAAA,GAAAF,OAAA;AAA6E,IAAAG,WAAA,GAAAH,OAAA;AAE7E,MAAMI,eAAe,GAAIC,KA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3,"names":["_react","require","_markdown","_incrementalAst","_jsxRuntime","normalizeOffset","value","Number","isFinite","Math","floor","resolveStreamText","forceFullSync","pendingFrom","pendingTo","previousText","session","getAllText","length","appendedChunk","getTextRange","MarkdownStream","updateIntervalMs","updateStrategy","useTransitionUpdates","incrementalParsing","options","plugins","props","parseText","useCallback","text","parseMarkdownAst","createEmptyAst","type","children","initialText","hasBeforeParsePlugins","some","plugin","beforeParse","renderState","setRenderState","useState","ast","renderStateRef","useRef","pendingUpdateRef","pendingFromRef","pendingToRef","forceFullSyncRef","updateTimerRef","rafRef","allowIncremental","useEffect","current","initialState","flushUpdate","cancelAnimationFrame","previousState","latest","nextAst","getNextStreamAst","nextText","previousAst","nextState","startTransition","scheduleFlush","requestAnimationFrame","setTimeout","unsubscribe","addListener","from","to","nextFrom","nextTo","currentFrom","currentTo","min","max","clearTimeout","jsx","Markdown","sourceAst","undefined","exports"],"sourceRoot":"../../src","sources":["markdown-stream.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AASA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,eAAA,GAAAF,OAAA;AAA6E,IAAAG,WAAA,GAAAH,OAAA;AAE7E,MAAMI,eAAe,GAAIC,KAAa,IAAoB;EACxD,IAAI,CAACC,MAAM,CAACC,QAAQ,CAACF,KAAK,CAAC,EAAE,OAAO,IAAI;EACxC,IAAIA,KAAK,IAAI,CAAC,EAAE,OAAO,CAAC;EACxB,OAAOG,IAAI,CAACC,KAAK,CAACJ,KAAK,CAAC;AAC1B,CAAC;AAED,MAAMK,iBAAiB,GAAGA,CAAC;EACzBC,aAAa;EACbC,WAAW;EACXC,SAAS;EACTC,YAAY;EACZC;AAOF,CAAC,KAAa;EACZ,IAAIJ,aAAa,IAAIC,WAAW,KAAK,IAAI,IAAIC,SAAS,KAAK,IAAI,EAAE;IAC/D,OAAOE,OAAO,CAACC,UAAU,CAAC,CAAC;EAC7B;EAEA,IAAIH,SAAS,GAAGD,W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MACXG,WAAW,CAAC,CAAC;MACb,IAAInB,cAAc,CAACI,OAAO,EAAE;QAC1ByB,YAAY,CAAC7B,cAAc,CAACI,OAAO,CAAC;QACpCJ,cAAc,CAACI,OAAO,GAAG,IAAI;MAC/B;MACA,IAAIH,MAAM,CAACG,OAAO,KAAK,IAAI,EAAE;QAC3BG,oBAAoB,CAACN,MAAM,CAACG,OAAO,CAAC;QACpCH,MAAM,CAACG,OAAO,GAAG,IAAI;MACvB;IACF,CAAC;EACH,CAAC,EAAE,CACDF,gBAAgB,EAChBhB,qBAAqB,EACrBX,OAAO,EACPC,OAAO,EACPX,OAAO,EACPM,gBAAgB,EAChBC,cAAc,EACdC,oBAAoB,CACrB,CAAC;EAEF,oBACE,IAAApB,WAAA,CAAA6E,GAAA,EAAC/E,SAAA,CAAAgF,QAAQ;IAAA,GACHtD,KAAK;IACTF,OAAO,EAAEA,OAAQ;IACjBC,OAAO,EAAEA,OAAQ;IACjBwD,SAAS,EAAE9C,qBAAqB,GAAG+C,SAAS,GAAG3C,WAAW,CAACG,GAAI;IAAAT,QAAA,EAE9DM,WAAW,CAACV;EAAI,CACT,CAAC;AAEf,CAAC;AAACsD,OAAA,CAAAhE,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -20,10 +20,40 @@ var _paragraph = require("./renderers/paragraph.js");
20
20
  var _table = require("./renderers/table.js");
21
21
  var _theme = require("./theme.js");
22
22
  var _jsxRuntime = require("react/jsx-runtime");
23
+ function hashString(str) {
24
+ let hash = 0;
25
+ for (let i = 0; i < str.length; i++) {
26
+ const char = str.charCodeAt(i);
27
+ hash = (hash << 5) - hash + char;
28
+ hash = hash & hash; // Convert to 32bit int
29
+ }
30
+ return hash;
31
+ }
32
+ const ERROR_PHASE = {
33
+ PARSE: "parse",
34
+ BEFORE_PLUGIN: "before-plugin",
35
+ AFTER_PLUGIN: "after-plugin"
36
+ };
37
+
38
+ /**
39
+ * Safely invoke the onError callback, preventing callback exceptions from
40
+ * propagating and breaking the render cycle.
41
+ */
42
+ function safeOnError(onError, error, phase, pluginName) {
43
+ try {
44
+ onError?.(error instanceof Error ? error : new Error(String(error)), phase, pluginName);
45
+ } catch (callbackError) {
46
+ if (__DEV__) {
47
+ // eslint-disable-next-line no-console
48
+ console.warn("[NitroMarkdown] onError callback threw an exception:", callbackError);
49
+ }
50
+ }
51
+ }
23
52
  const baseStylesCache = new WeakMap();
24
53
  const parseAstCache = new Map();
25
54
  const MAX_PARSE_CACHE_ENTRIES = 32;
26
55
  const MAX_CACHEABLE_TEXT_LENGTH = 24_000;
56
+ const EMPTY_RENDERERS = {};
27
57
  const isMarkdownNode = value => {
28
58
  if (typeof value !== "object" || value === null) return false;
29
59
  return typeof Reflect.get(value, "type") === "string";
@@ -42,21 +72,24 @@ const cloneMarkdownNode = node => {
42
72
  };
43
73
  };
44
74
  const getParserOptionsKey = options => {
45
- if (!options) return "gfm:default|math:default";
75
+ if (!options) return "gfm:default|math:default|html:default";
46
76
  const gfm = options.gfm === undefined ? "default" : options.gfm ? "1" : "0";
47
77
  const math = options.math === undefined ? "default" : options.math ? "1" : "0";
48
- return `gfm:${gfm}|math:${math}`;
78
+ const html = options.html === undefined ? "default" : options.html ? "1" : "0";
79
+ return `gfm:${gfm}|math:${math}|html:${html}`;
49
80
  };
50
81
  const normalizeParserOptions = options => {
51
82
  if (!options) return undefined;
52
83
  const gfm = options.gfm;
53
84
  const math = options.math;
54
- if (gfm === undefined && math === undefined) {
85
+ const html = options.html;
86
+ if (gfm === undefined && math === undefined && html === undefined) {
55
87
  return undefined;
56
88
  }
57
89
  return {
58
90
  gfm,
59
- math
91
+ math,
92
+ html
60
93
  };
61
94
  };
62
95
  const parseWithNativeParser = (text, options) => {
@@ -69,7 +102,7 @@ const getCachedParsedAst = (text, options) => {
69
102
  if (text.length > MAX_CACHEABLE_TEXT_LENGTH) {
70
103
  return parseWithNativeParser(text, options);
71
104
  }
72
- const cacheKey = `${getParserOptionsKey(options)}|${text}`;
105
+ const cacheKey = `${getParserOptionsKey(options)}|${text.length}|${hashString(text)}`;
73
106
  const cachedNode = parseAstCache.get(cacheKey);
74
107
  if (cachedNode) {
75
108
  parseAstCache.delete(cacheKey);
@@ -102,7 +135,7 @@ const applyBeforeParsePlugins = (markdown, plugins, onError) => {
102
135
  } catch (error) {
103
136
  const pluginLabel = plugin.name ? ` (${plugin.name})` : "";
104
137
  warnInDev(`[react-native-nitro-markdown] plugin beforeParse${pluginLabel} threw; using previous markdown.`, error);
105
- onError?.(error instanceof Error ? error : new Error(String(error)), 'before-plugin', plugin.name);
138
+ safeOnError(onError, error, ERROR_PHASE.BEFORE_PLUGIN, plugin.name);
106
139
  }
107
140
  }
108
141
  return nextMarkdown;
@@ -123,7 +156,7 @@ const applyAfterParsePlugins = (ast, plugins, onError) => {
123
156
  } catch (error) {
124
157
  const pluginLabel = plugin.name ? ` (${plugin.name})` : "";
125
158
  warnInDev(`[react-native-nitro-markdown] plugin afterParse${pluginLabel} threw; using previous AST.`, error);
126
- onError?.(error instanceof Error ? error : new Error(String(error)), 'after-plugin', plugin.name);
159
+ safeOnError(onError, error, ERROR_PHASE.AFTER_PLUGIN, plugin.name);
127
160
  }
128
161
  }
129
162
  return nextAst;
@@ -134,7 +167,7 @@ const Markdown = ({
134
167
  plugins,
135
168
  sourceAst,
136
169
  astTransform,
137
- renderers = {},
170
+ renderers = EMPTY_RENDERERS,
138
171
  theme: userTheme,
139
172
  styles: nodeStyles,
140
173
  stylingStrategy = "opinionated",
@@ -151,15 +184,21 @@ const Markdown = ({
151
184
  }) => {
152
185
  const parserOptionGfm = options?.gfm;
153
186
  const parserOptionMath = options?.math;
187
+ const parserOptionHtml = options?.html;
188
+
189
+ /* eslint-disable react-hooks/refs -- Refs updated/read intentionally to avoid re-parsing on callback identity changes */
190
+ const onErrorRef = (0, _react.useRef)(onError);
191
+ onErrorRef.current = onError;
154
192
  const parseResult = (0, _react.useMemo)(() => {
155
193
  try {
156
- const markdownToParse = applyBeforeParsePlugins(children, plugins, onError ? (e, phase, name) => onError(e, phase, name) : undefined);
194
+ const markdownToParse = applyBeforeParsePlugins(children, plugins, onErrorRef.current);
157
195
  const parserOptions = normalizeParserOptions({
158
196
  gfm: parserOptionGfm,
159
- math: parserOptionMath
197
+ math: parserOptionMath,
198
+ html: parserOptionHtml
160
199
  });
161
200
  let parsedAst = sourceAst ? cloneMarkdownNode(sourceAst) : getCachedParsedAst(markdownToParse, parserOptions);
162
- parsedAst = applyAfterParsePlugins(parsedAst, plugins, onError ? (e, phase, name) => onError(e, phase, name) : undefined);
201
+ parsedAst = applyAfterParsePlugins(parsedAst, plugins, onErrorRef.current);
163
202
  let ast = parsedAst;
164
203
  if (astTransform) {
165
204
  try {
@@ -176,15 +215,17 @@ const Markdown = ({
176
215
  ast
177
216
  };
178
217
  } catch (parseError) {
179
- onError?.(parseError instanceof Error ? parseError : new Error(String(parseError)), 'parse');
218
+ safeOnError(onErrorRef.current, parseError, ERROR_PHASE.PARSE);
180
219
  return {
181
220
  ast: null
182
221
  };
183
222
  }
184
- }, [children, parserOptionGfm, parserOptionMath, plugins, sourceAst, astTransform, onError]);
223
+ }, [children, parserOptionGfm, parserOptionMath, parserOptionHtml, sourceAst, astTransform, plugins]);
224
+ /* eslint-enable react-hooks/refs */
225
+
185
226
  (0, _react.useEffect)(() => {
186
227
  onParsingInProgress?.();
187
- }, [children, parserOptionGfm, parserOptionMath, plugins, onParsingInProgress]);
228
+ }, [children, parserOptionGfm, parserOptionMath, parserOptionHtml, onParsingInProgress]);
188
229
  (0, _react.useEffect)(() => {
189
230
  if (!parseResult.ast || !onParseComplete) return;
190
231
  onParseComplete({
@@ -534,13 +575,13 @@ const getBaseStyles = theme => {
534
575
  };
535
576
  const createBaseStyles = theme => _reactNative.StyleSheet.create({
536
577
  container: {
537
- flex: 1
578
+ flexShrink: 1
538
579
  },
539
580
  virtualizedList: {
540
581
  flex: 1
541
582
  },
542
583
  document: {
543
- flex: 1
584
+ flexShrink: 1
544
585
  },
545
586
  errorText: {
546
587
  color: "#f87171",