@novastera-oss/react-native-markdown-display 8.0.1 → 8.0.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.
package/README.md CHANGED
@@ -1,10 +1,6 @@
1
1
  # React Native Markdown Display
2
2
 
3
- It a 100% compatible CommonMark renderer, a react-native markdown renderer done right. This is __not__ a web-view markdown renderer but a renderer that uses native components for all its elements. These components can be overwritten and styled as needed.
4
-
5
- ### Compatibility with react-native-markdown-renderer
6
-
7
- This is intended to be a replacement for react-native-markdown-renderer, with a variety of bug fixes and enhancements - **Due to how the new style rules work, there may be some tweaking needed**, [see how to style stuff section below](#How-to-style-stuff)
3
+ It is a CommonMark-compatible React Native markdown renderer that uses native components rather than a web view. Maintained by Novastera, an open-source CRM/ERP platform, it is designed to be easy to theme and extend.
8
4
 
9
5
  ### Install
10
6
 
@@ -37,7 +33,7 @@ const copy = `# h1 Heading 8-)
37
33
  This is normal text
38
34
  `;
39
35
 
40
- const App: () => React$Node = () => {
36
+ const App: () => React.ReactNode = () => {
41
37
  return (
42
38
  <>
43
39
  <StatusBar barStyle="dark-content" />
@@ -66,9 +62,9 @@ The `<Markdown>` object takes the following common props:
66
62
  | Property | Default | Required | Description
67
63
  | --- | --- | --- | ---
68
64
  | `children` | N/A | `true` | The markdown string to render, or the [pre-processed tree](#pre-processing)
69
- | `style` | [source](https://github.com/iamacup/react-native-markdown-display/blob/master/src/lib/styles.js) | `false` | An object to override the styling for the various rules, [see style section below](#rules-and-styles) for more info
65
+ | `style` | [source](https://github.com/novastera/react-native-markdown-display/blob/master/src/lib/styles.ts) | `false` | An object to override the styling for the various rules, [see style section below](#rules-and-styles) for more info
70
66
  | `mergeStyle` | `true` | `false` | If true, when a style is supplied, the individual items are merged with the default styles instead of overwriting them
71
- | `rules` | [source](https://github.com/iamacup/react-native-markdown-display/blob/master/src/lib/renderRules.js) | `false` | An object of rules that specify how to render each markdown item, [see rules section below](#rules) for more info
67
+ | `rules` | [source](https://github.com/novastera/react-native-markdown-display/blob/master/src/lib/renderRules.tsx) | `false` | An object of rules that specify how to render each markdown item, [see rules section below](#rules) for more info
72
68
  | `onLinkPress` | `import { Linking } from 'react-native';` and `Linking.openURL(url);` | `false` | A handler function to change click behaviour, [see handling links section below](#handling-links) for more info
73
69
  | `debugPrintTree` | `false` | `false` | Will print the AST tree to the console to help you see what the markdown is being translated to
74
70
 
@@ -101,7 +97,7 @@ And some additional, less used options:
101
97
 
102
98
  | iOS | Android
103
99
  | --- | ---
104
- | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-1.png"/> | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-1.png"/>
100
+ | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/ios-1.png"/> | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/android-1.png"/>
105
101
 
106
102
  </p>
107
103
  </details>
@@ -123,7 +119,7 @@ And some additional, less used options:
123
119
 
124
120
  | iOS | Android
125
121
  | --- | ---
126
- | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-2.png"/> | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-2.png"/>
122
+ | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/ios-2.png"/> | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/android-2.png"/>
127
123
 
128
124
 
129
125
  </p>
@@ -148,7 +144,7 @@ And some additional, less used options:
148
144
 
149
145
  | iOS | Android
150
146
  | --- | ---
151
- | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-4.png"/> | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-4.png"/>
147
+ | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/ios-4.png"/> | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/android-4.png"/>
152
148
 
153
149
  </p>
154
150
  </details>
@@ -165,7 +161,7 @@ And some additional, less used options:
165
161
 
166
162
  | iOS | Android
167
163
  | --- | ---
168
- | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-5.png"/> | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-5.png"/>
164
+ | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/ios-5.png"/> | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/android-5.png"/>
169
165
 
170
166
  </p>
171
167
  </details>
@@ -199,7 +195,7 @@ And some additional, less used options:
199
195
 
200
196
  | iOS | Android
201
197
  | --- | ---
202
- | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-6.png"/> | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-6.png"/>
198
+ | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/ios-6.png"/> | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/android-6.png"/>
203
199
 
204
200
  </p>
205
201
  </details>
@@ -238,7 +234,7 @@ And some additional, less used options:
238
234
 
239
235
  | iOS | Android
240
236
  | --- | ---
241
- | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-7.png"/> | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-7.png"/>
237
+ | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/ios-7.png"/> | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/android-7.png"/>
242
238
 
243
239
  </p>
244
240
  </details>
@@ -265,7 +261,7 @@ And some additional, less used options:
265
261
 
266
262
  | iOS | Android
267
263
  | --- | ---
268
- | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-8.png"/> | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-8.png"/>
264
+ | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/ios-8.png"/> | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/android-8.png"/>
269
265
 
270
266
  </p>
271
267
  </details>
@@ -283,7 +279,7 @@ And some additional, less used options:
283
279
 
284
280
  | iOS | Android
285
281
  | --- | ---
286
- | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-9.png"/> | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-9.png"/>
282
+ | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/ios-9.png"/> | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/android-9.png"/>
287
283
 
288
284
  </p>
289
285
  </details>
@@ -306,7 +302,7 @@ And some additional, less used options:
306
302
 
307
303
  | iOS | Android
308
304
  | --- | ---
309
- | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-10.png"/> | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-10.png"/>
305
+ | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/ios-10.png"/> | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/android-10.png"/>
310
306
 
311
307
  </p>
312
308
  </details>
@@ -329,7 +325,7 @@ And some additional, less used options:
329
325
 
330
326
  | iOS | Android
331
327
  | --- | ---
332
- | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-3.png"/> | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-3.png"/>
328
+ | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/ios-3.png"/> | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/android-3.png"/>
333
329
 
334
330
  </p>
335
331
  </details>
@@ -365,7 +361,7 @@ const copy = `
365
361
  @[youtube](lJIrF4YjHfQ)
366
362
  `;
367
363
 
368
- const App: () => React$Node = () => {
364
+ const App: () => React.ReactNode = () => {
369
365
  return (
370
366
  <>
371
367
  <StatusBar barStyle="dark-content" />
@@ -431,7 +427,7 @@ const copy = `
431
427
  @[youtube](lJIrF4YjHfQ)
432
428
  `;
433
429
 
434
- const App: () => React$Node = () => {
430
+ const App: () => React.ReactNode = () => {
435
431
  return (
436
432
  <>
437
433
  <StatusBar barStyle="dark-content" />
@@ -729,7 +725,7 @@ Think of the implementation like applying styles in CSS. changes to the `body` e
729
725
  <details><summary>Example</summary>
730
726
  <p>
731
727
 
732
- <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/style-example.png"/>
728
+ <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/style-example.png"/>
733
729
 
734
730
  ```jsx
735
731
  import React from 'react';
@@ -755,7 +751,7 @@ and some more small text
755
751
  ### this is a h3
756
752
  `;
757
753
 
758
- const App: () => React$Node = () => {
754
+ const App: () => React.ReactNode = () => {
759
755
  return (
760
756
  <>
761
757
  <StatusBar barStyle="dark-content" />
@@ -844,7 +840,7 @@ const copy = `
844
840
  | ext | extension to be used for dest files. |
845
841
  `;
846
842
 
847
- const App: () => React$Node = () => {
843
+ const App: () => React.ReactNode = () => {
848
844
  return (
849
845
  <>
850
846
  <StatusBar barStyle="dark-content" />
@@ -872,7 +868,7 @@ export default App;
872
868
 
873
869
  ### Rules
874
870
 
875
- Rules are used to specify how you want certain elements to be displayed. The existing implementation is [here](https://github.com/iamacup/react-native-markdown-display/blob/master/src/lib/renderRules.js)
871
+ Rules are used to specify how you want certain elements to be displayed. The existing implementation is here: https://github.com/novastera/react-native-markdown-display/blob/master/src/lib/renderRules.tsx
876
872
 
877
873
  <details><summary>Example Implementation</summary>
878
874
  <p>
@@ -910,7 +906,7 @@ const copy = `
910
906
  | ext | extension to be used for dest files. |
911
907
  `;
912
908
 
913
- const App: () => React$Node = () => {
909
+ const App: () => React.ReactNode = () => {
914
910
  return (
915
911
  <>
916
912
  <StatusBar barStyle="dark-content" />
@@ -992,7 +988,7 @@ import { SafeAreaView, ScrollView, StatusBar } from 'react-native';
992
988
 
993
989
  import Markdown from '@novastera-oss/react-native-markdown-display';
994
990
 
995
- const copy = `[This is a link!](https://github.com/iamacup/react-native-markdown-display/)`;
991
+ const copy = `[This is a link!](https://novastera.com)`;
996
992
 
997
993
  const onLinkPress = (url) => {
998
994
  if (url) {
@@ -1005,7 +1001,7 @@ const onLinkPress = (url) => {
1005
1001
  return true
1006
1002
  }
1007
1003
 
1008
- const App: () => React$Node = () => {
1004
+ const App: () => React.ReactNode = () => {
1009
1005
  return (
1010
1006
  <>
1011
1007
  <StatusBar barStyle="dark-content" />
@@ -1034,7 +1030,7 @@ export default App;
1034
1030
  <details><summary>Using a Custom Rule</summary>
1035
1031
  <p>
1036
1032
 
1037
- You will need to overwrite one or both of `link` and `blocklink`, the original defenitions can be [found here](https://github.com/iamacup/react-native-markdown-display/blob/master/src/lib/renderRules.js)
1033
+ You will need to overwrite one or both of `link` and `blocklink`, the original definitions can be found here: https://github.com/novastera/react-native-markdown-display/blob/master/src/lib/renderRules.tsx
1038
1034
 
1039
1035
  Something like this with `yourCustomHandlerFunctionOrLogicHere`:
1040
1036
 
@@ -1044,7 +1040,7 @@ import { SafeAreaView, ScrollView, StatusBar, Text } from 'react-native';
1044
1040
 
1045
1041
  import Markdown from '@novastera-oss/react-native-markdown-display';
1046
1042
 
1047
- const copy = `[This is a link!](https://github.com/iamacup/react-native-markdown-display/)`;
1043
+ const copy = `[This is a link!](https://novastera.com)`;
1048
1044
 
1049
1045
  const rules = {
1050
1046
  link: (node, children, parent, styles) => {
@@ -1056,7 +1052,7 @@ const rules = {
1056
1052
  },
1057
1053
  };
1058
1054
 
1059
- const App: () => React$Node = () => {
1055
+ const App: () => React.ReactNode = () => {
1060
1056
  return (
1061
1057
  <>
1062
1058
  <StatusBar barStyle="dark-content" />
@@ -1085,7 +1081,7 @@ export default App;
1085
1081
 
1086
1082
  # Disabling Specific Types of Markdown
1087
1083
 
1088
- You can dissable any type of markdown you want, which is very useful in a mobile environment, by passing the markdownit property like below. Note that for convenience we also export the `MarkdownIt` instance so you don't have to include it as a project dependency directly just to remove some types of markdown.
1084
+ You can disable any type of markdown you want, which is very useful in a mobile environment, by passing the markdownit property like below. Note that for convenience we also export the `MarkdownIt` instance so you don't have to include it as a project dependency directly just to remove some types of markdown.
1089
1085
 
1090
1086
  This example will stop images and links.
1091
1087
 
@@ -1101,7 +1097,7 @@ const copy = `
1101
1097
  [but this link will just](be displayed as this text)
1102
1098
  `;
1103
1099
 
1104
- const App: () => React$Node = () => {
1100
+ const App: () => React.ReactNode = () => {
1105
1101
  return (
1106
1102
  <>
1107
1103
  <StatusBar barStyle="dark-content" />
@@ -1126,12 +1122,12 @@ const App: () => React$Node = () => {
1126
1122
  export default App;
1127
1123
  ```
1128
1124
 
1129
- A full list of things you can turn off is [here](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/commonmark.js)
1125
+ A full list of things you can turn off lives in the markdown-it CommonMark preset (the preset list may move across releases). You can also configure this renderer by supplying your own markdown-it instance; see the markdown-it docs for preset and rule options: https://github.com/markdown-it/markdown-it
1130
1126
 
1131
1127
 
1132
1128
  ### Pre Processing
1133
1129
 
1134
- It is possible to need to pre-process the data outside of this library ([related discussion here](https://github.com/iamacup/react-native-markdown-display/issues/79)). As a result, you can pass an AST tree directly as the children like this:
1130
+ It is possible to need to pre-process the data outside of this library. As a result, you can pass an AST tree directly as the children like this:
1135
1131
 
1136
1132
  ```jsx
1137
1133
  import React from 'react';
@@ -1149,7 +1145,7 @@ This is some text with **BOLD!**
1149
1145
 
1150
1146
  const ast = tokensToAST(stringToTokens(copy, markdownItInstance))
1151
1147
 
1152
- const App: () => React$Node = () => {
1148
+ const App: () => React.ReactNode = () => {
1153
1149
  return (
1154
1150
  <>
1155
1151
  <StatusBar barStyle="dark-content" />
@@ -1174,11 +1170,11 @@ export default App;
1174
1170
 
1175
1171
  ### Other Notes
1176
1172
 
1177
- This is a fork of [react-native-markdown-renderer](https://github.com/mientjan/react-native-markdown-renderer), a library that unfortunately has not been updated for some time so i took all of the outstanding pull requests from that library and tested + merged as necessary.
1173
+ See [iamacup/react-native-markdown-display](https://github.com/iamacup/react-native-markdown-display) for the legacy fork lineage. This project removes unmaintained libraries and uses TypeScript.
1178
1174
 
1179
1175
  ## About Novastera
1180
1176
 
1181
- This library is part of the Novastera open-source ecosystem, a modern CRM/ERP
1177
+ This library is part of the Novastera CRM/ERP open-source ecosystem, a modern
1182
1178
  platform designed for the next generation of business applications. Novastera
1183
1179
  combines AI capabilities with comprehensive business management tools, enabling
1184
1180
  organizations to leverage on-device AI for enhanced productivity and data
@@ -22,10 +22,7 @@ class AstRenderer {
22
22
  const renderFunction = this.getRenderFunction(node.type);
23
23
  const parents = [...parentNodes];
24
24
  if (this._debugPrintTree === true) {
25
- let str = '';
26
- for (let a = 0; a < parents.length; a++) {
27
- str = str + '-';
28
- }
25
+ const str = '-'.repeat(parents.length);
29
26
  console.log(`${str}${node.type}`);
30
27
  }
31
28
  parents.unshift(node);
@@ -17,10 +17,7 @@ export default class AstRenderer {
17
17
  const renderFunction = this.getRenderFunction(node.type);
18
18
  const parents = [...parentNodes];
19
19
  if (this._debugPrintTree === true) {
20
- let str = '';
21
- for (let a = 0; a < parents.length; a++) {
22
- str = str + '-';
23
- }
20
+ const str = '-'.repeat(parents.length);
24
21
  console.log(`${str}${node.type}`);
25
22
  }
26
23
  parents.unshift(node);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novastera-oss/react-native-markdown-display",
3
- "version": "8.0.1",
3
+ "version": "8.0.2",
4
4
  "description": "Markdown renderer for react-native, with CommonMark spec support. Maintained by Novastera.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",