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.
- package/README.md +311 -669
- package/android/CMakeLists.txt +8 -1
- package/android/build.gradle +9 -2
- package/android/consumer-rules.pro +31 -0
- package/android/gradle.properties +2 -0
- package/android/src/main/java/com/margelo/nitro/com/nitromarkdown/HybridMarkdownSession.kt +68 -22
- package/android/src/main/java/com/nitromarkdown/NitroMarkdownPackage.kt +6 -18
- package/cpp/bindings/HybridMarkdownParser.cpp +40 -12
- package/cpp/bindings/HybridMarkdownParser.hpp +4 -4
- package/cpp/bindings/HybridMarkdownSession.cpp +2 -0
- package/cpp/core/MD4CParser.cpp +147 -86
- package/cpp/core/MarkdownSessionCore.cpp +2 -0
- package/cpp/core/MarkdownTypes.hpp +1 -1
- package/ios/HybridMarkdownSession.swift +89 -46
- package/lib/commonjs/headless.js +34 -8
- package/lib/commonjs/headless.js.map +1 -1
- package/lib/commonjs/index.js +48 -38
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/markdown-stream.js +1 -1
- package/lib/commonjs/markdown-stream.js.map +1 -1
- package/lib/commonjs/markdown.js +57 -16
- package/lib/commonjs/markdown.js.map +1 -1
- package/lib/commonjs/renderers/blockquote.js +15 -13
- package/lib/commonjs/renderers/blockquote.js.map +1 -1
- package/lib/commonjs/renderers/code.js +58 -54
- package/lib/commonjs/renderers/code.js.map +1 -1
- package/lib/commonjs/renderers/heading.js +48 -46
- package/lib/commonjs/renderers/heading.js.map +1 -1
- package/lib/commonjs/renderers/horizontal-rule.js +10 -8
- package/lib/commonjs/renderers/horizontal-rule.js.map +1 -1
- package/lib/commonjs/renderers/image.js +18 -4
- package/lib/commonjs/renderers/image.js.map +1 -1
- package/lib/commonjs/renderers/link.js +7 -2
- package/lib/commonjs/renderers/link.js.map +1 -1
- package/lib/commonjs/renderers/list.js +75 -68
- package/lib/commonjs/renderers/list.js.map +1 -1
- package/lib/commonjs/renderers/math.js +8 -5
- package/lib/commonjs/renderers/math.js.map +1 -1
- package/lib/commonjs/renderers/paragraph.js +15 -13
- package/lib/commonjs/renderers/paragraph.js.map +1 -1
- package/lib/commonjs/renderers/style-cache.js +14 -0
- package/lib/commonjs/renderers/style-cache.js.map +1 -0
- package/lib/commonjs/renderers/table/cell-content.js +1 -1
- package/lib/commonjs/renderers/table/cell-content.js.map +1 -1
- package/lib/commonjs/renderers/table/index.js +17 -6
- package/lib/commonjs/renderers/table/index.js.map +1 -1
- package/lib/commonjs/theme.js +7 -7
- package/lib/commonjs/theme.js.map +1 -1
- package/lib/commonjs/utils/code-highlight.js +24 -25
- package/lib/commonjs/utils/code-highlight.js.map +1 -1
- package/lib/module/headless.js +35 -7
- package/lib/module/headless.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/markdown-stream.js +1 -1
- package/lib/module/markdown-stream.js.map +1 -1
- package/lib/module/markdown.js +58 -17
- package/lib/module/markdown.js.map +1 -1
- package/lib/module/renderers/blockquote.js +15 -13
- package/lib/module/renderers/blockquote.js.map +1 -1
- package/lib/module/renderers/code.js +58 -54
- package/lib/module/renderers/code.js.map +1 -1
- package/lib/module/renderers/heading.js +48 -46
- package/lib/module/renderers/heading.js.map +1 -1
- package/lib/module/renderers/horizontal-rule.js +10 -8
- package/lib/module/renderers/horizontal-rule.js.map +1 -1
- package/lib/module/renderers/image.js +19 -5
- package/lib/module/renderers/image.js.map +1 -1
- package/lib/module/renderers/link.js +7 -2
- package/lib/module/renderers/link.js.map +1 -1
- package/lib/module/renderers/list.js +75 -68
- package/lib/module/renderers/list.js.map +1 -1
- package/lib/module/renderers/math.js +8 -5
- package/lib/module/renderers/math.js.map +1 -1
- package/lib/module/renderers/paragraph.js +15 -13
- package/lib/module/renderers/paragraph.js.map +1 -1
- package/lib/module/renderers/style-cache.js +10 -0
- package/lib/module/renderers/style-cache.js.map +1 -0
- package/lib/module/renderers/table/cell-content.js +1 -1
- package/lib/module/renderers/table/cell-content.js.map +1 -1
- package/lib/module/renderers/table/index.js +17 -6
- package/lib/module/renderers/table/index.js.map +1 -1
- package/lib/module/theme.js +7 -7
- package/lib/module/theme.js.map +1 -1
- package/lib/module/utils/code-highlight.js +24 -25
- package/lib/module/utils/code-highlight.js.map +1 -1
- package/lib/typescript/commonjs/Markdown.nitro.d.ts +1 -0
- package/lib/typescript/commonjs/Markdown.nitro.d.ts.map +1 -1
- package/lib/typescript/commonjs/headless.d.ts +10 -2
- package/lib/typescript/commonjs/headless.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +3 -2
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/markdown-stream.d.ts.map +1 -1
- package/lib/typescript/commonjs/markdown.d.ts +8 -3
- package/lib/typescript/commonjs/markdown.d.ts.map +1 -1
- package/lib/typescript/commonjs/renderers/blockquote.d.ts +1 -1
- package/lib/typescript/commonjs/renderers/blockquote.d.ts.map +1 -1
- package/lib/typescript/commonjs/renderers/code.d.ts.map +1 -1
- package/lib/typescript/commonjs/renderers/heading.d.ts +1 -1
- package/lib/typescript/commonjs/renderers/heading.d.ts.map +1 -1
- package/lib/typescript/commonjs/renderers/horizontal-rule.d.ts +1 -1
- package/lib/typescript/commonjs/renderers/horizontal-rule.d.ts.map +1 -1
- package/lib/typescript/commonjs/renderers/image.d.ts.map +1 -1
- package/lib/typescript/commonjs/renderers/link.d.ts.map +1 -1
- package/lib/typescript/commonjs/renderers/list.d.ts +1 -1
- package/lib/typescript/commonjs/renderers/list.d.ts.map +1 -1
- package/lib/typescript/commonjs/renderers/math.d.ts +1 -1
- package/lib/typescript/commonjs/renderers/math.d.ts.map +1 -1
- package/lib/typescript/commonjs/renderers/paragraph.d.ts +1 -1
- package/lib/typescript/commonjs/renderers/paragraph.d.ts.map +1 -1
- package/lib/typescript/commonjs/renderers/style-cache.d.ts +3 -0
- package/lib/typescript/commonjs/renderers/style-cache.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/table/cell-content.d.ts +4 -3
- package/lib/typescript/commonjs/renderers/table/cell-content.d.ts.map +1 -1
- package/lib/typescript/commonjs/renderers/table/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme.d.ts.map +1 -1
- package/lib/typescript/commonjs/utils/code-highlight.d.ts +1 -1
- package/lib/typescript/commonjs/utils/code-highlight.d.ts.map +1 -1
- package/lib/typescript/module/Markdown.nitro.d.ts +1 -0
- package/lib/typescript/module/Markdown.nitro.d.ts.map +1 -1
- package/lib/typescript/module/headless.d.ts +10 -2
- package/lib/typescript/module/headless.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +3 -2
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/markdown-stream.d.ts.map +1 -1
- package/lib/typescript/module/markdown.d.ts +8 -3
- package/lib/typescript/module/markdown.d.ts.map +1 -1
- package/lib/typescript/module/renderers/blockquote.d.ts +1 -1
- package/lib/typescript/module/renderers/blockquote.d.ts.map +1 -1
- package/lib/typescript/module/renderers/code.d.ts.map +1 -1
- package/lib/typescript/module/renderers/heading.d.ts +1 -1
- package/lib/typescript/module/renderers/heading.d.ts.map +1 -1
- package/lib/typescript/module/renderers/horizontal-rule.d.ts +1 -1
- package/lib/typescript/module/renderers/horizontal-rule.d.ts.map +1 -1
- package/lib/typescript/module/renderers/image.d.ts.map +1 -1
- package/lib/typescript/module/renderers/link.d.ts.map +1 -1
- package/lib/typescript/module/renderers/list.d.ts +1 -1
- package/lib/typescript/module/renderers/list.d.ts.map +1 -1
- package/lib/typescript/module/renderers/math.d.ts +1 -1
- package/lib/typescript/module/renderers/math.d.ts.map +1 -1
- package/lib/typescript/module/renderers/paragraph.d.ts +1 -1
- package/lib/typescript/module/renderers/paragraph.d.ts.map +1 -1
- package/lib/typescript/module/renderers/style-cache.d.ts +3 -0
- package/lib/typescript/module/renderers/style-cache.d.ts.map +1 -0
- package/lib/typescript/module/renderers/table/cell-content.d.ts +4 -3
- package/lib/typescript/module/renderers/table/cell-content.d.ts.map +1 -1
- package/lib/typescript/module/renderers/table/index.d.ts.map +1 -1
- package/lib/typescript/module/theme.d.ts.map +1 -1
- package/lib/typescript/module/utils/code-highlight.d.ts +1 -1
- package/lib/typescript/module/utils/code-highlight.d.ts.map +1 -1
- package/nitro.json +12 -3
- package/nitrogen/generated/android/NitroMarkdownOnLoad.cpp +2 -2
- package/nitrogen/generated/android/c++/JFunc_void.hpp +2 -2
- package/nitrogen/generated/android/c++/JFunc_void_double_double.hpp +2 -2
- package/nitrogen/generated/android/c++/JHybridMarkdownSessionSpec.hpp +2 -2
- package/nitrogen/generated/ios/NitroMarkdown+autolinking.rb +2 -0
- package/nitrogen/generated/shared/c++/ParserOptions.hpp +6 -2
- package/package.json +8 -6
- package/react-native-nitro-markdown.podspec +3 -0
- package/src/Markdown.nitro.ts +1 -0
- package/src/headless.ts +58 -8
- package/src/index.ts +16 -2
- package/src/markdown-stream.tsx +1 -0
- package/src/markdown.tsx +108 -23
- package/src/renderers/blockquote.tsx +22 -17
- package/src/renderers/code.tsx +76 -57
- package/src/renderers/heading.tsx +60 -54
- package/src/renderers/horizontal-rule.tsx +17 -12
- package/src/renderers/image.tsx +24 -5
- package/src/renderers/link.tsx +8 -2
- package/src/renderers/list.tsx +93 -74
- package/src/renderers/math.tsx +14 -5
- package/src/renderers/paragraph.tsx +22 -17
- package/src/renderers/style-cache.ts +14 -0
- package/src/renderers/table/cell-content.tsx +15 -4
- package/src/renderers/table/index.tsx +30 -13
- package/src/theme.ts +34 -14
- package/src/utils/code-highlight.ts +133 -44
|
@@ -36,7 +36,7 @@ export type MarkdownProps = {
|
|
|
36
36
|
*/
|
|
37
37
|
children: string;
|
|
38
38
|
/**
|
|
39
|
-
* Parser options to enable GFM or
|
|
39
|
+
* Parser options to enable GFM, math, or raw HTML AST support.
|
|
40
40
|
*/
|
|
41
41
|
options?: ParserOptions;
|
|
42
42
|
/**
|
|
@@ -54,7 +54,12 @@ export type MarkdownProps = {
|
|
|
54
54
|
*/
|
|
55
55
|
astTransform?: AstTransform;
|
|
56
56
|
/**
|
|
57
|
-
* Callback fired
|
|
57
|
+
* Callback fired after the current parse cycle completes and the component
|
|
58
|
+
* has re-rendered with new content. Because the native parser runs
|
|
59
|
+
* synchronously inside `useMemo`, there is no observable "in-progress"
|
|
60
|
+
* window — this callback fires in the `useEffect` commit phase, after the
|
|
61
|
+
* new AST is already rendered. Use `onParseComplete` for post-parse
|
|
62
|
+
* inspection of results.
|
|
58
63
|
*/
|
|
59
64
|
onParsingInProgress?: () => void;
|
|
60
65
|
/**
|
|
@@ -71,7 +76,7 @@ export type MarkdownProps = {
|
|
|
71
76
|
* @param phase - Where the error occurred.
|
|
72
77
|
* @param pluginName - The plugin name, if applicable.
|
|
73
78
|
*/
|
|
74
|
-
onError?: (error: Error, phase:
|
|
79
|
+
onError?: (error: Error, phase: "parse" | "before-plugin" | "after-plugin", pluginName?: string) => void;
|
|
75
80
|
/**
|
|
76
81
|
* Custom renderers for specific markdown node types.
|
|
77
82
|
* Each renderer receives { node, children, Renderer } plus type-specific props.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/markdown.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/markdown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,EAAE,EAIR,MAAM,OAAO,CAAC;AACf,OAAO,EAOL,KAAK,aAAa,EAClB,KAAK,SAAS,EAEd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EAEtB,MAAM,mBAAmB,CAAC;AAW3B,OAAO,EAKL,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AAC,EAAE,CACR,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,cAAc,EACjD,UAAU,CAAC,EAAE,MAAM,KAChB,IAAI,CAAC;IACV;;;OAGG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B;;;;OAIG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC9B;;;OAGG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC;;OAEG;IACH,cAAc,CAAC,EAAE,6BAA6B,CAAC;IAC/C;;OAEG;IACH,YAAY,CAAC,EAAE;QACb,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,sBAAsB,CAAC,EAAE,MAAM,CAAC;KACjC,CAAC;IACF;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,GAAG,eAAe,CAAC;CAC3C,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CAmMtC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blockquote.d.ts","sourceRoot":"","sources":["../../../../src/renderers/blockquote.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"blockquote.d.ts","sourceRoot":"","sources":["../../../../src/renderers/blockquote.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAKhE,KAAK,eAAe,GAAG;IACrB,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAK1C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../../../src/renderers/code.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAML,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../../../src/renderers/code.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAML,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAQtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CA0DxC,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAiB1C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../../../src/renderers/heading.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../../../src/renderers/heading.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAA8B,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAK1E,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAYF,eAAO,MAAM,OAAO,EAAE,EAAE,CAAC,YAAY,CAepC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"horizontal-rule.d.ts","sourceRoot":"","sources":["../../../../src/renderers/horizontal-rule.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"horizontal-rule.d.ts","sourceRoot":"","sources":["../../../../src/renderers/horizontal-rule.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAKhE,KAAK,mBAAmB,GAAG;IACzB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAIlD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../../src/renderers/image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,EAAE,EACP,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AACf,OAAO,EAML,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAkB5D,KAAK,UAAU,GAAG;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC5C,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,EAAE,CAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../../src/renderers/image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,EAAE,EACP,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AACf,OAAO,EAML,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAkB5D,KAAK,UAAU,GAAG;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC5C,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,EAAE,CAAC,UAAU,CAwLhC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../../src/renderers/link.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAOtB,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../../src/renderers/link.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAOtB,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CA6C9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../src/renderers/list.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../src/renderers/list.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAoC,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAKhF,KAAK,SAAS,GAAG;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAGF,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAQ9B,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CAoBtC,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAqB9C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../../src/renderers/math.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../../src/renderers/math.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAiB,MAAM,OAAO,CAAC;AAC/C,OAAO,EAML,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AA0BtB,KAAK,eAAe,GAAG;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AA4DF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA2B1C,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CA0BxC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paragraph.d.ts","sourceRoot":"","sources":["../../../../src/renderers/paragraph.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"paragraph.d.ts","sourceRoot":"","sources":["../../../../src/renderers/paragraph.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAoB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAKhF,KAAK,cAAc,GAAG;IACpB,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAmBxC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-cache.d.ts","sourceRoot":"","sources":["../../../../src/renderers/style-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,eAAe,CAAC,CAAC,EAC/B,KAAK,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,EAChC,KAAK,EAAE,aAAa,EACpB,YAAY,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,CAAC,GACxC,CAAC,CAOH"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type StyleProp, type TextStyle } from "react-native";
|
|
1
|
+
import type { FC, ComponentType } from "react";
|
|
2
|
+
import { type StyleProp, type TextStyle, type ViewStyle } from "react-native";
|
|
3
3
|
import type { MarkdownNode } from "../../headless";
|
|
4
4
|
import type { NodeRendererProps } from "../../MarkdownContext";
|
|
5
5
|
type CellContentProps = {
|
|
6
6
|
node: MarkdownNode;
|
|
7
7
|
Renderer: ComponentType<NodeRendererProps>;
|
|
8
8
|
styles: {
|
|
9
|
-
cellContentWrapper:
|
|
9
|
+
cellContentWrapper: StyleProp<ViewStyle>;
|
|
10
|
+
[key: string]: StyleProp<ViewStyle | TextStyle> | undefined;
|
|
10
11
|
};
|
|
11
12
|
textStyle?: StyleProp<TextStyle>;
|
|
12
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell-content.d.ts","sourceRoot":"","sources":["../../../../../src/renderers/table/cell-content.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"cell-content.d.ts","sourceRoot":"","sources":["../../../../../src/renderers/table/cell-content.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC3C,MAAM,EAAE;QACN,kBAAkB,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QACzC,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,SAAS,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;KAC7D,CAAC;IACF,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAClC,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CA2B5C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/renderers/table/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,EAAE,EACP,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AACf,OAAO,EAKL,KAAK,SAAS,EAEf,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/renderers/table/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,EAAE,EACP,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AACf,OAAO,EAKL,KAAK,SAAS,EAEf,MAAM,cAAc,CAAC;AAQtB,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAI/B,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,OAAO,gBAAgB,EAAE,YAAY,CAAC;IAC5C,QAAQ,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC3C,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAQF,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAwShD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAExE,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QACzB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QACzB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QACzB,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;QACnC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;QACjC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;QAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;QACjC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;QAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;QAChC,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
export type TokenType = "keyword" | "string" | "comment" | "number" | "operator" | "punctuation" | "type" | "default";
|
|
2
2
|
export type HighlightedToken = {
|
|
3
3
|
text: string;
|
|
4
4
|
type: TokenType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-highlight.d.ts","sourceRoot":"","sources":["../../../../src/utils/code-highlight.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,UAAU,GACV,aAAa,GACb,MAAM,GACN,SAAS,CAAC;AAEd,MAAM,MAAM,gBAAgB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AACjE,MAAM,MAAM,eAAe,GAAG,
|
|
1
|
+
{"version":3,"file":"code-highlight.d.ts","sourceRoot":"","sources":["../../../../src/utils/code-highlight.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,UAAU,GACV,aAAa,GACb,MAAM,GACN,SAAS,CAAC;AAEd,MAAM,MAAM,gBAAgB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AACjE,MAAM,MAAM,eAAe,GAAG,CAC5B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,KACT,gBAAgB,EAAE,CAAC;AA8JxB,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GACX,gBAAgB,EAAE,CAepB"}
|
package/nitro.json
CHANGED
|
@@ -9,11 +9,20 @@
|
|
|
9
9
|
},
|
|
10
10
|
"autolinking": {
|
|
11
11
|
"MarkdownParser": {
|
|
12
|
-
"
|
|
12
|
+
"all": {
|
|
13
|
+
"language": "c++",
|
|
14
|
+
"implementationClassName": "HybridMarkdownParser"
|
|
15
|
+
}
|
|
13
16
|
},
|
|
14
17
|
"MarkdownSession": {
|
|
15
|
-
"
|
|
16
|
-
|
|
18
|
+
"ios": {
|
|
19
|
+
"language": "swift",
|
|
20
|
+
"implementationClassName": "HybridMarkdownSession"
|
|
21
|
+
},
|
|
22
|
+
"android": {
|
|
23
|
+
"language": "kotlin",
|
|
24
|
+
"implementationClassName": "HybridMarkdownSession"
|
|
25
|
+
}
|
|
17
26
|
}
|
|
18
27
|
}
|
|
19
28
|
}
|
|
@@ -30,9 +30,9 @@ int initialize(JavaVM* vm) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
struct JHybridMarkdownSessionSpecImpl: public jni::JavaClass<JHybridMarkdownSessionSpecImpl, JHybridMarkdownSessionSpec::JavaPart> {
|
|
33
|
-
static auto
|
|
33
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/com/nitromarkdown/HybridMarkdownSession;";
|
|
34
34
|
static std::shared_ptr<JHybridMarkdownSessionSpec> create() {
|
|
35
|
-
static auto constructorFn = javaClassStatic()->getConstructor<JHybridMarkdownSessionSpecImpl::javaobject()>();
|
|
35
|
+
static const auto constructorFn = javaClassStatic()->getConstructor<JHybridMarkdownSessionSpecImpl::javaobject()>();
|
|
36
36
|
jni::local_ref<JHybridMarkdownSessionSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
|
|
37
37
|
return javaPart->getJHybridMarkdownSessionSpec();
|
|
38
38
|
}
|
|
@@ -23,7 +23,7 @@ namespace margelo::nitro::Markdown {
|
|
|
23
23
|
*/
|
|
24
24
|
struct JFunc_void: public jni::JavaClass<JFunc_void> {
|
|
25
25
|
public:
|
|
26
|
-
static auto
|
|
26
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/com/nitromarkdown/Func_void;";
|
|
27
27
|
|
|
28
28
|
public:
|
|
29
29
|
/**
|
|
@@ -59,7 +59,7 @@ namespace margelo::nitro::Markdown {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
public:
|
|
62
|
-
static auto
|
|
62
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/com/nitromarkdown/Func_void_cxx;";
|
|
63
63
|
static void registerNatives() {
|
|
64
64
|
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_cxx::invoke_cxx)});
|
|
65
65
|
}
|
|
@@ -23,7 +23,7 @@ namespace margelo::nitro::Markdown {
|
|
|
23
23
|
*/
|
|
24
24
|
struct JFunc_void_double_double: public jni::JavaClass<JFunc_void_double_double> {
|
|
25
25
|
public:
|
|
26
|
-
static auto
|
|
26
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/com/nitromarkdown/Func_void_double_double;";
|
|
27
27
|
|
|
28
28
|
public:
|
|
29
29
|
/**
|
|
@@ -59,7 +59,7 @@ namespace margelo::nitro::Markdown {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
public:
|
|
62
|
-
static auto
|
|
62
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/com/nitromarkdown/Func_void_double_double_cxx;";
|
|
63
63
|
static void registerNatives() {
|
|
64
64
|
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_double_double_cxx::invoke_cxx)});
|
|
65
65
|
}
|
|
@@ -21,11 +21,11 @@ namespace margelo::nitro::Markdown {
|
|
|
21
21
|
class JHybridMarkdownSessionSpec: public virtual HybridMarkdownSessionSpec, public virtual JHybridObject {
|
|
22
22
|
public:
|
|
23
23
|
struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
|
|
24
|
-
static auto
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/com/nitromarkdown/HybridMarkdownSessionSpec;";
|
|
25
25
|
std::shared_ptr<JHybridMarkdownSessionSpec> getJHybridMarkdownSessionSpec();
|
|
26
26
|
};
|
|
27
27
|
struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
|
|
28
|
-
static auto
|
|
28
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/com/nitromarkdown/HybridMarkdownSessionSpec$CxxPart;";
|
|
29
29
|
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
30
30
|
static void registerNatives();
|
|
31
31
|
using HybridBase::HybridBase;
|
|
@@ -56,5 +56,7 @@ def add_nitrogen_files(spec)
|
|
|
56
56
|
"SWIFT_OBJC_INTEROP_MODE" => "objcxx",
|
|
57
57
|
# Enables stricter modular headers
|
|
58
58
|
"DEFINES_MODULE" => "YES",
|
|
59
|
+
# Disable auto-generated ObjC header for Swift (Static linkage on Xcode 26.4 breaks here)
|
|
60
|
+
"SWIFT_INSTALL_OBJC_HEADER" => "NO",
|
|
59
61
|
})
|
|
60
62
|
end
|
|
@@ -41,10 +41,11 @@ namespace margelo::nitro::Markdown {
|
|
|
41
41
|
public:
|
|
42
42
|
std::optional<bool> gfm SWIFT_PRIVATE;
|
|
43
43
|
std::optional<bool> math SWIFT_PRIVATE;
|
|
44
|
+
std::optional<bool> html SWIFT_PRIVATE;
|
|
44
45
|
|
|
45
46
|
public:
|
|
46
47
|
ParserOptions() = default;
|
|
47
|
-
explicit ParserOptions(std::optional<bool> gfm, std::optional<bool> math): gfm(gfm), math(math) {}
|
|
48
|
+
explicit ParserOptions(std::optional<bool> gfm, std::optional<bool> math, std::optional<bool> html): gfm(gfm), math(math), html(html) {}
|
|
48
49
|
|
|
49
50
|
public:
|
|
50
51
|
friend bool operator==(const ParserOptions& lhs, const ParserOptions& rhs) = default;
|
|
@@ -61,13 +62,15 @@ namespace margelo::nitro {
|
|
|
61
62
|
jsi::Object obj = arg.asObject(runtime);
|
|
62
63
|
return margelo::nitro::Markdown::ParserOptions(
|
|
63
64
|
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "gfm"))),
|
|
64
|
-
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "math")))
|
|
65
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "math"))),
|
|
66
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "html")))
|
|
65
67
|
);
|
|
66
68
|
}
|
|
67
69
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::Markdown::ParserOptions& arg) {
|
|
68
70
|
jsi::Object obj(runtime);
|
|
69
71
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "gfm"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.gfm));
|
|
70
72
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "math"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.math));
|
|
73
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "html"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.html));
|
|
71
74
|
return obj;
|
|
72
75
|
}
|
|
73
76
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -80,6 +83,7 @@ namespace margelo::nitro {
|
|
|
80
83
|
}
|
|
81
84
|
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "gfm")))) return false;
|
|
82
85
|
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "math")))) return false;
|
|
86
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "html")))) return false;
|
|
83
87
|
return true;
|
|
84
88
|
}
|
|
85
89
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-markdown",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "High-performance Markdown parser for React Native using Nitro Modules and md4c",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"!cpp/build",
|
|
48
48
|
"!android/build",
|
|
49
49
|
"!android/.cxx",
|
|
50
|
+
"!ios/build",
|
|
50
51
|
"!scripts"
|
|
51
52
|
],
|
|
52
53
|
"scripts": {
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
"build": "bob build",
|
|
55
56
|
"clean": "rimraf lib nitrogen/generated",
|
|
56
57
|
"codegen": "nitrogen --logLevel=\"debug\"",
|
|
57
|
-
"lint": "eslint src --max-warnings=0 --ignore-pattern 'src/**/__tests__/**' --ignore-pattern 'src/**/*.nitro.ts'",
|
|
58
|
+
"lint": "bunx eslint src --max-warnings=0 --ignore-pattern 'src/**/__tests__/**' --ignore-pattern 'src/**/*.nitro.ts'",
|
|
58
59
|
"typecheck": "tsc --noEmit",
|
|
59
60
|
"test": "jest",
|
|
60
61
|
"test:coverage": "jest --coverage",
|
|
@@ -80,6 +81,7 @@
|
|
|
80
81
|
},
|
|
81
82
|
"author": "João Paulo C. Marra <joaopaulocmarra@gmail.com>",
|
|
82
83
|
"license": "MIT",
|
|
84
|
+
"sideEffects": false,
|
|
83
85
|
"bugs": {
|
|
84
86
|
"url": "https://github.com/JoaoPauloCMarra/react-native-nitro-markdown/issues"
|
|
85
87
|
},
|
|
@@ -89,18 +91,18 @@
|
|
|
89
91
|
},
|
|
90
92
|
"devDependencies": {
|
|
91
93
|
"@size-limit/preset-small-lib": "^11.0.0",
|
|
92
|
-
"@types/react": "
|
|
94
|
+
"@types/react": "~19.2.14",
|
|
93
95
|
"@types/react-native": "^0.73.0",
|
|
94
96
|
"@types/react-test-renderer": "^19.1.0",
|
|
95
|
-
"react-native-builder-bob": "^0.
|
|
96
|
-
"react-test-renderer": "
|
|
97
|
+
"react-native-builder-bob": "^0.41.0",
|
|
98
|
+
"react-test-renderer": "19.2.0",
|
|
97
99
|
"size-limit": "^11.0.0",
|
|
98
100
|
"typescript": "^5.9.3"
|
|
99
101
|
},
|
|
100
102
|
"peerDependencies": {
|
|
101
103
|
"react": "*",
|
|
102
104
|
"react-native": ">=0.75.0",
|
|
103
|
-
"react-native-nitro-modules": ">=0.35.
|
|
105
|
+
"react-native-nitro-modules": ">=0.35.4",
|
|
104
106
|
"react-native-mathjax-svg": ">=0.9.0",
|
|
105
107
|
"react-native-svg": ">=13.0.0"
|
|
106
108
|
},
|
package/src/Markdown.nitro.ts
CHANGED
package/src/headless.ts
CHANGED
|
@@ -79,38 +79,82 @@ export type MarkdownNode = {
|
|
|
79
79
|
children?: MarkdownNode[];
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
let MarkdownParserModule: MarkdownParser | null = null;
|
|
83
|
+
try {
|
|
84
|
+
MarkdownParserModule =
|
|
85
|
+
NitroModules.createHybridObject<MarkdownParser>("MarkdownParser");
|
|
86
|
+
} catch (e) {
|
|
87
|
+
if (__DEV__) {
|
|
88
|
+
// eslint-disable-next-line no-console
|
|
89
|
+
console.error("[NitroMarkdown] Failed to create native MarkdownParser:", e);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export { MarkdownParserModule };
|
|
84
93
|
|
|
85
94
|
/**
|
|
86
95
|
* Parse markdown text into an AST.
|
|
87
96
|
* @param text - The markdown text to parse
|
|
88
97
|
* @returns The root node of the parsed AST
|
|
89
98
|
*/
|
|
90
|
-
export function parseMarkdown(text: string): MarkdownNode
|
|
91
|
-
|
|
99
|
+
export function parseMarkdown(text: string): MarkdownNode;
|
|
100
|
+
/**
|
|
101
|
+
* Parse markdown text with custom options.
|
|
102
|
+
* @param text - The markdown text to parse
|
|
103
|
+
* @param options - Parser options (gfm, math, html)
|
|
104
|
+
* @returns The root node of the parsed AST
|
|
105
|
+
*/
|
|
106
|
+
export function parseMarkdown(
|
|
107
|
+
text: string,
|
|
108
|
+
options: ParserOptions,
|
|
109
|
+
): MarkdownNode;
|
|
110
|
+
export function parseMarkdown(
|
|
111
|
+
text: string,
|
|
112
|
+
options?: ParserOptions,
|
|
113
|
+
): MarkdownNode {
|
|
114
|
+
if (options != null) {
|
|
115
|
+
return parseMarkdownWithOptions(text, options);
|
|
116
|
+
}
|
|
117
|
+
if (
|
|
118
|
+
MarkdownParserModule != null &&
|
|
119
|
+
typeof MarkdownParserModule.parse === "function"
|
|
120
|
+
) {
|
|
92
121
|
const jsonStr = MarkdownParserModule.parse(text);
|
|
93
122
|
return JSON.parse(jsonStr) as MarkdownNode;
|
|
94
123
|
}
|
|
95
124
|
|
|
125
|
+
if (__DEV__) {
|
|
126
|
+
// eslint-disable-next-line no-console
|
|
127
|
+
console.error(
|
|
128
|
+
"[NitroMarkdown] parseMarkdown: native parser unavailable — check installation.",
|
|
129
|
+
);
|
|
130
|
+
}
|
|
96
131
|
return { type: "document", children: [] };
|
|
97
132
|
}
|
|
98
133
|
|
|
99
134
|
/**
|
|
100
135
|
* Parse markdown text with custom options.
|
|
101
136
|
* @param text - The markdown text to parse
|
|
102
|
-
* @param options - Parser options (gfm, math)
|
|
137
|
+
* @param options - Parser options (gfm, math, html)
|
|
103
138
|
* @returns The root node of the parsed AST
|
|
104
139
|
*/
|
|
105
140
|
export function parseMarkdownWithOptions(
|
|
106
141
|
text: string,
|
|
107
142
|
options: ParserOptions,
|
|
108
143
|
): MarkdownNode {
|
|
109
|
-
if (
|
|
144
|
+
if (
|
|
145
|
+
MarkdownParserModule != null &&
|
|
146
|
+
typeof MarkdownParserModule.parseWithOptions === "function"
|
|
147
|
+
) {
|
|
110
148
|
const jsonStr = MarkdownParserModule.parseWithOptions(text, options);
|
|
111
149
|
return JSON.parse(jsonStr) as MarkdownNode;
|
|
112
150
|
}
|
|
113
151
|
|
|
152
|
+
if (__DEV__) {
|
|
153
|
+
// eslint-disable-next-line no-console
|
|
154
|
+
console.error(
|
|
155
|
+
"[NitroMarkdown] parseMarkdownWithOptions: native parser unavailable — check installation.",
|
|
156
|
+
);
|
|
157
|
+
}
|
|
114
158
|
return { type: "document", children: [] };
|
|
115
159
|
}
|
|
116
160
|
|
|
@@ -119,7 +163,10 @@ export function parseMarkdownWithOptions(
|
|
|
119
163
|
* Useful for search/indexing flows that don't need full AST rendering.
|
|
120
164
|
*/
|
|
121
165
|
export function extractPlainText(text: string): string {
|
|
122
|
-
if (
|
|
166
|
+
if (
|
|
167
|
+
MarkdownParserModule != null &&
|
|
168
|
+
typeof MarkdownParserModule.extractPlainText === "function"
|
|
169
|
+
) {
|
|
123
170
|
return MarkdownParserModule.extractPlainText(text);
|
|
124
171
|
}
|
|
125
172
|
|
|
@@ -133,7 +180,10 @@ export function extractPlainTextWithOptions(
|
|
|
133
180
|
text: string,
|
|
134
181
|
options: ParserOptions,
|
|
135
182
|
): string {
|
|
136
|
-
if (
|
|
183
|
+
if (
|
|
184
|
+
MarkdownParserModule != null &&
|
|
185
|
+
typeof MarkdownParserModule.extractPlainTextWithOptions === "function"
|
|
186
|
+
) {
|
|
137
187
|
return MarkdownParserModule.extractPlainTextWithOptions(text, options);
|
|
138
188
|
}
|
|
139
189
|
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {
|
|
2
|
+
MarkdownParserModule,
|
|
3
|
+
parseMarkdown,
|
|
4
|
+
parseMarkdownWithOptions,
|
|
5
|
+
extractPlainText,
|
|
6
|
+
extractPlainTextWithOptions,
|
|
7
|
+
getTextContent,
|
|
8
|
+
getFlattenedText,
|
|
9
|
+
stripSourceOffsets,
|
|
10
|
+
} from "./headless";
|
|
11
|
+
export type { MarkdownNode, ParserOptions, MarkdownParser } from "./headless";
|
|
2
12
|
|
|
3
13
|
export { Markdown } from "./markdown";
|
|
4
14
|
export type {
|
|
@@ -56,5 +66,9 @@ export { createMarkdownSession } from "./MarkdownSession";
|
|
|
56
66
|
export type { MarkdownSession } from "./MarkdownSession";
|
|
57
67
|
export { useMarkdownSession, useStream } from "./use-markdown-stream";
|
|
58
68
|
|
|
59
|
-
export type {
|
|
69
|
+
export type {
|
|
70
|
+
HighlightedToken,
|
|
71
|
+
TokenType,
|
|
72
|
+
CodeHighlighter,
|
|
73
|
+
} from "./utils/code-highlight";
|
|
60
74
|
export { defaultHighlighter } from "./utils/code-highlight";
|