react-native-marked 1.6.14 → 2.0.0-rc.1

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 (78) hide show
  1. package/README.md +64 -8
  2. package/dist/commonjs/index.js +8 -0
  3. package/dist/commonjs/index.js.map +1 -1
  4. package/dist/commonjs/lib/Markdown.js +5 -1
  5. package/dist/commonjs/lib/Markdown.js.map +1 -1
  6. package/dist/commonjs/lib/Parser.js +50 -35
  7. package/dist/commonjs/lib/Parser.js.map +1 -1
  8. package/dist/commonjs/lib/Renderer.js +113 -45
  9. package/dist/commonjs/lib/Renderer.js.map +1 -1
  10. package/dist/commonjs/lib/__perf__/Markdown.perf-test.js +196 -0
  11. package/dist/commonjs/lib/__perf__/Markdown.perf-test.js.map +1 -0
  12. package/dist/module/index.js +2 -0
  13. package/dist/module/index.js.map +1 -1
  14. package/dist/module/lib/Markdown.js +4 -1
  15. package/dist/module/lib/Markdown.js.map +1 -1
  16. package/dist/module/lib/Parser.js +50 -32
  17. package/dist/module/lib/Parser.js.map +1 -1
  18. package/dist/module/lib/Renderer.js +112 -44
  19. package/dist/module/lib/Renderer.js.map +1 -1
  20. package/dist/module/lib/__perf__/Markdown.perf-test.js +188 -0
  21. package/dist/module/lib/__perf__/Markdown.perf-test.js.map +1 -0
  22. package/dist/typescript/components/MDImage.d.ts.map +1 -0
  23. package/dist/typescript/index.d.ts +7 -0
  24. package/dist/typescript/index.d.ts.map +1 -0
  25. package/dist/typescript/{src/lib → lib}/Markdown.d.ts +1 -1
  26. package/dist/typescript/lib/Markdown.d.ts.map +1 -0
  27. package/dist/typescript/lib/Parser.d.ts.map +1 -0
  28. package/dist/typescript/lib/Renderer.d.ts +32 -0
  29. package/dist/typescript/lib/Renderer.d.ts.map +1 -0
  30. package/dist/typescript/lib/__perf__/Markdown.perf-test.d.ts +2 -0
  31. package/dist/typescript/lib/__perf__/Markdown.perf-test.d.ts.map +1 -0
  32. package/dist/typescript/lib/types.d.ts +34 -0
  33. package/dist/typescript/lib/types.d.ts.map +1 -0
  34. package/dist/typescript/theme/colors.d.ts.map +1 -0
  35. package/dist/typescript/theme/spacing.d.ts.map +1 -0
  36. package/dist/typescript/theme/styles.d.ts.map +1 -0
  37. package/dist/typescript/theme/types.d.ts.map +1 -0
  38. package/dist/typescript/utils/handlers.d.ts.map +1 -0
  39. package/dist/typescript/utils/url.d.ts.map +1 -0
  40. package/package.json +2 -2
  41. package/src/index.ts +8 -0
  42. package/src/lib/Markdown.tsx +8 -1
  43. package/src/lib/Parser.tsx +50 -64
  44. package/src/lib/Renderer.tsx +135 -60
  45. package/src/lib/__perf__/Markdown.perf-test.tsx +186 -0
  46. package/src/lib/types.ts +48 -2
  47. package/dist/commonjs/utils/string.js +0 -17
  48. package/dist/commonjs/utils/string.js.map +0 -1
  49. package/dist/module/utils/string.js +0 -8
  50. package/dist/module/utils/string.js.map +0 -1
  51. package/dist/typescript/dangerfile.d.ts +0 -2
  52. package/dist/typescript/dangerfile.d.ts.map +0 -1
  53. package/dist/typescript/src/components/MDImage.d.ts.map +0 -1
  54. package/dist/typescript/src/index.d.ts +0 -3
  55. package/dist/typescript/src/index.d.ts.map +0 -1
  56. package/dist/typescript/src/lib/Markdown.d.ts.map +0 -1
  57. package/dist/typescript/src/lib/Parser.d.ts.map +0 -1
  58. package/dist/typescript/src/lib/Renderer.d.ts +0 -14
  59. package/dist/typescript/src/lib/Renderer.d.ts.map +0 -1
  60. package/dist/typescript/src/lib/types.d.ts +0 -13
  61. package/dist/typescript/src/lib/types.d.ts.map +0 -1
  62. package/dist/typescript/src/theme/colors.d.ts.map +0 -1
  63. package/dist/typescript/src/theme/spacing.d.ts.map +0 -1
  64. package/dist/typescript/src/theme/styles.d.ts.map +0 -1
  65. package/dist/typescript/src/theme/types.d.ts.map +0 -1
  66. package/dist/typescript/src/utils/handlers.d.ts.map +0 -1
  67. package/dist/typescript/src/utils/string.d.ts +0 -6
  68. package/dist/typescript/src/utils/string.d.ts.map +0 -1
  69. package/dist/typescript/src/utils/url.d.ts.map +0 -1
  70. package/src/utils/string.ts +0 -7
  71. /package/dist/typescript/{src/components → components}/MDImage.d.ts +0 -0
  72. /package/dist/typescript/{src/lib → lib}/Parser.d.ts +0 -0
  73. /package/dist/typescript/{src/theme → theme}/colors.d.ts +0 -0
  74. /package/dist/typescript/{src/theme → theme}/spacing.d.ts +0 -0
  75. /package/dist/typescript/{src/theme → theme}/styles.d.ts +0 -0
  76. /package/dist/typescript/{src/theme → theme}/types.d.ts +0 -0
  77. /package/dist/typescript/{src/utils → utils}/handlers.d.ts +0 -0
  78. /package/dist/typescript/{src/utils → utils}/url.d.ts +0 -0
@@ -3,76 +3,144 @@ import { ScrollView, View, Text, TouchableHighlight } from "react-native";
3
3
  import MarkedList from "@jsamr/react-native-li";
4
4
  import Disc from "@jsamr/counter-style/presets/disc";
5
5
  import Decimal from "@jsamr/counter-style/presets/decimal";
6
+ import { Slugger } from "marked";
6
7
  import MDImage from "./../components/MDImage";
7
- import { generateRandomString } from "../utils/string";
8
8
  import { onLinkPress } from "../utils/handlers";
9
9
 
10
10
  class Renderer {
11
- getTextNode = (children, styles) => {
12
- return /*#__PURE__*/React.createElement(Text, {
13
- key: generateRandomString(),
14
- style: styles
15
- }, children);
16
- };
17
- getTextLinkNode = (children, href, styles) => {
18
- return /*#__PURE__*/React.createElement(Text, {
19
- accessibilityRole: "link",
20
- accessibilityHint: "Opens in a new window",
21
- key: generateRandomString(),
22
- onPress: onLinkPress(href),
23
- style: styles
24
- }, children);
25
- };
26
- getImageLinkNode = (href, imageUrl, alt, style) => {
27
- const imageNode = this.getImageNode(imageUrl, alt, style);
28
- return /*#__PURE__*/React.createElement(TouchableHighlight, {
29
- accessibilityRole: "link",
30
- accessibilityHint: "Opens in a new window",
31
- onPress: onLinkPress(href),
32
- key: generateRandomString()
33
- }, imageNode);
34
- };
11
+ slugPrefix = "react-native-marked-ele";
35
12
 
36
- getViewNode(children, styles) {
37
- return /*#__PURE__*/React.createElement(View, {
38
- key: generateRandomString(),
39
- style: styles
40
- }, children);
13
+ constructor() {
14
+ this.slugger = new Slugger();
41
15
  }
42
16
 
43
- getCodeBlockNode(text, containerStyle, textStyle) {
17
+ paragraph(children, styles) {
18
+ return this.getViewNode(children, styles);
19
+ }
20
+
21
+ blockquote(children, styles) {
22
+ return this.getBlockquoteNode(children, styles);
23
+ }
24
+
25
+ heading(text, styles) {
26
+ return this.getTextNode(text, styles);
27
+ }
28
+
29
+ code(text, _language, containerStyle, textStyle) {
44
30
  return /*#__PURE__*/React.createElement(ScrollView, {
45
31
  horizontal: true,
46
- key: generateRandomString(),
32
+ key: this.getKey(),
47
33
  contentContainerStyle: containerStyle
48
34
  }, /*#__PURE__*/React.createElement(Text, {
49
35
  style: textStyle
50
36
  }, text));
51
37
  }
52
38
 
53
- getBlockquoteNode(children, styles) {
54
- return /*#__PURE__*/React.createElement(View, {
55
- key: generateRandomString(),
39
+ hr(styles) {
40
+ return this.getViewNode(null, styles);
41
+ }
42
+
43
+ listItem(children, styles) {
44
+ return this.getViewNode(children, styles);
45
+ }
46
+
47
+ list(ordered, li, listStyle, textStyle) {
48
+ return /*#__PURE__*/React.createElement(MarkedList, {
49
+ counterRenderer: ordered ? Decimal : Disc,
50
+ markerTextStyle: textStyle,
51
+ markerBoxStyle: listStyle,
52
+ key: this.getKey()
53
+ }, li.map(node => node));
54
+ }
55
+
56
+ escape(text, styles) {
57
+ return this.getTextNode(text, styles);
58
+ }
59
+
60
+ link(children, href, styles) {
61
+ return /*#__PURE__*/React.createElement(Text, {
62
+ accessibilityRole: "link",
63
+ accessibilityHint: "Opens in a new window",
64
+ key: this.getKey(),
65
+ onPress: onLinkPress(href),
56
66
  style: styles
57
67
  }, children);
58
68
  }
59
69
 
60
- getImageNode(uri, alt, style) {
70
+ image(uri, alt, style) {
61
71
  return /*#__PURE__*/React.createElement(MDImage, {
62
- key: generateRandomString(),
72
+ key: this.getKey(),
63
73
  uri: uri,
64
74
  alt: alt,
65
75
  style: style
66
76
  });
67
77
  }
68
78
 
69
- getListNode(ordered, li, listStyle, textStyle) {
70
- return /*#__PURE__*/React.createElement(MarkedList, {
71
- counterRenderer: ordered ? Decimal : Disc,
72
- markerTextStyle: textStyle,
73
- markerBoxStyle: listStyle,
74
- key: generateRandomString()
75
- }, li.map(node => node));
79
+ strong(children, styles) {
80
+ return this.getTextNode(children, styles);
81
+ }
82
+
83
+ em(children, styles) {
84
+ return this.getTextNode(children, styles);
85
+ }
86
+
87
+ codespan(text, styles) {
88
+ return this.getTextNode(text, styles);
89
+ }
90
+
91
+ br() {
92
+ return this.getTextNode("\n", {});
93
+ }
94
+
95
+ del(children, styles) {
96
+ return this.getTextNode(children, styles);
97
+ }
98
+
99
+ text(text, styles) {
100
+ return this.getTextNode(text, styles);
101
+ }
102
+
103
+ html(text, styles) {
104
+ return this.getTextNode(text, styles);
105
+ }
106
+
107
+ linkImage(href, imageUrl, alt, style) {
108
+ const imageNode = this.image(imageUrl, alt, style);
109
+ return /*#__PURE__*/React.createElement(TouchableHighlight, {
110
+ accessibilityRole: "link",
111
+ accessibilityHint: "Opens in a new window",
112
+ onPress: onLinkPress(href),
113
+ key: this.getKey()
114
+ }, imageNode);
115
+ }
116
+
117
+ getKey() {
118
+ return this.slugger.slug(this.slugPrefix);
119
+ }
120
+
121
+ getTextNode(children, styles) {
122
+ return /*#__PURE__*/React.createElement(Text, {
123
+ key: this.getKey(),
124
+ style: styles
125
+ }, children);
126
+ }
127
+
128
+ getViewNode(children, styles) {
129
+ {
130
+ return /*#__PURE__*/React.createElement(View, {
131
+ key: this.getKey(),
132
+ style: styles
133
+ }, children);
134
+ }
135
+ }
136
+
137
+ getBlockquoteNode(children, styles) {
138
+ {
139
+ return /*#__PURE__*/React.createElement(View, {
140
+ key: this.getKey(),
141
+ style: styles
142
+ }, children);
143
+ }
76
144
  }
77
145
 
78
146
  }
@@ -1 +1 @@
1
- {"version":3,"names":["React","ScrollView","View","Text","TouchableHighlight","MarkedList","Disc","Decimal","MDImage","generateRandomString","onLinkPress","Renderer","getTextNode","children","styles","getTextLinkNode","href","getImageLinkNode","imageUrl","alt","style","imageNode","getImageNode","getViewNode","getCodeBlockNode","text","containerStyle","textStyle","getBlockquoteNode","uri","getListNode","ordered","li","listStyle","map","node"],"sourceRoot":"../../../src","sources":["lib/Renderer.tsx"],"mappings":"AAAA,OAAOA,KAAP,MAAsC,OAAtC;AACA,SACCC,UADD,EAECC,IAFD,EAGCC,IAHD,EAICC,kBAJD,QAQO,cARP;AASA,OAAOC,UAAP,MAAuB,wBAAvB;AACA,OAAOC,IAAP,MAAiB,mCAAjB;AACA,OAAOC,OAAP,MAAoB,sCAApB;AACA,OAAOC,OAAP,MAAoB,yBAApB;AACA,SAASC,oBAAT,QAAqC,iBAArC;AACA,SAASC,WAAT,QAA4B,mBAA5B;;AAEA,MAAMC,QAAN,CAAe;EACdC,WAAW,GAAG,CAACC,QAAD,EAAiCC,MAAjC,KAAwD;IACrE,oBACC,oBAAC,IAAD;MAAM,GAAG,EAAEL,oBAAoB,EAA/B;MAAmC,KAAK,EAAEK;IAA1C,GACED,QADF,CADD;EAKA,CANU;EAQXE,eAAe,GAAG,CACjBF,QADiB,EAEjBG,IAFiB,EAGjBF,MAHiB,KAIb;IACJ,oBACC,oBAAC,IAAD;MACC,iBAAiB,EAAC,MADnB;MAEC,iBAAiB,EAAC,uBAFnB;MAGC,GAAG,EAAEL,oBAAoB,EAH1B;MAIC,OAAO,EAAEC,WAAW,CAACM,IAAD,CAJrB;MAKC,KAAK,EAAEF;IALR,GAOED,QAPF,CADD;EAWA,CAhBc;EAkBfI,gBAAgB,GAAG,CAClBD,IADkB,EAElBE,QAFkB,EAGlBC,GAHkB,EAIlBC,KAJkB,KAKd;IACJ,MAAMC,SAAS,GAAG,KAAKC,YAAL,CAAkBJ,QAAlB,EAA4BC,GAA5B,EAAiCC,KAAjC,CAAlB;IACA,oBACC,oBAAC,kBAAD;MACC,iBAAiB,EAAC,MADnB;MAEC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uGf,eAAexB,QAAf"}
1
+ {"version":3,"names":["React","ScrollView","View","Text","TouchableHighlight","MarkedList","Disc","Decimal","Slugger","MDImage","onLinkPress","Renderer","slugPrefix","constructor","slugger","paragraph","children","styles","getViewNode","blockquote","getBlockquoteNode","heading","text","getTextNode","code","_language","containerStyle","textStyle","getKey","hr","listItem","list","ordered","li","listStyle","map","node","escape","link","href","image","uri","alt","style","strong","em","codespan","br","del","html","linkImage","imageUrl","imageNode","slug"],"sourceRoot":"../../../src","sources":["lib/Renderer.tsx"],"mappings":"AAAA,OAAOA,KAAP,MAAsC,OAAtC;AACA,SACCC,UADD,EAECC,IAFD,EAGCC,IAHD,EAICC,kBAJD,QAQO,cARP;AASA,OAAOC,UAAP,MAAuB,wBAAvB;AACA,OAAOC,IAAP,MAAiB,mCAAjB;AACA,OAAOC,OAAP,MAAoB,sCAApB;AACA,SAASC,OAAT,QAAwB,QAAxB;AACA,OAAOC,OAAP,MAAoB,yBAApB;AACA,SAASC,WAAT,QAA4B,mBAA5B;;AAGA,MAAMC,QAAN,CAA4C;EACnCC,UAAU,GAAG,yBAAH;;EAElBC,WAAW,GAAG;IACb,KAAKC,OAAL,GAAe,IAAIN,OAAJ,EAAf;EACA;;EAEDO,SAAS,CAACC,QAAD,EAAwBC,MAAxB,EAAuD;IAC/D,OAAO,KAAKC,WAAL,CAAiBF,QAAjB,EAA2BC,MAA3B,CAAP;EACA;;EAEDE,UAAU,CAACH,QAAD,EAAwBC,MAAxB,EAAuD;IAChE,OAAO,KAAKG,iBAAL,CAAuBJ,QAAvB,EAAiCC,MAAjC,CAAP;EACA;;EAEDI,OAAO,CAACC,IAAD,EAA6BL,MAA7B,EAA4D;IAClE,OAAO,KAAKM,WAAL,CAAiBD,IAAjB,EAAuBL,MAAvB,CAAP;EACA;;EAEDO,IAAI,CACHF,IADG,EAEHG,SAFG,EAGHC,cAHG,EAIHC,SAJG,EAKS;IACZ,oBACC,oBAAC,UAAD;MACC,UAAU,MADX;MAEC,GAAG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d,OAAL,CAAauC,IAAb,CAAkB,KAAKzC,UAAvB,CAAP;EACA;;EAEOW,WAAW,CAClBP,QADkB,EAElBC,MAFkB,EAGN;IACZ,oBACC,oBAAC,IAAD;MAAM,GAAG,EAAE,KAAKW,MAAL,EAAX;MAA0B,KAAK,EAAEX;IAAjC,GACED,QADF,CADD;EAKA;;EAEOE,WAAW,CAClBF,QADkB,EAElBC,MAFkB,EAGN;IACZ;MACC,oBACC,oBAAC,IAAD;QAAM,GAAG,EAAE,KAAKW,MAAL,EAAX;QAA0B,KAAK,EAAEX;MAAjC,GACED,QADF,CADD;IAKA;EACD;;EAEOI,iBAAiB,CACxBJ,QADwB,EAExBC,MAFwB,EAGZ;IACZ;MACC,oBACC,oBAAC,IAAD;QAAM,GAAG,EAAE,KAAKW,MAAL,EAAX;QAA0B,KAAK,EAAEX;MAAjC,GACED,QADF,CADD;IAKA;EACD;;AA9K0C;;AAiL5C,eAAeL,QAAf"}
@@ -0,0 +1,188 @@
1
+ import React from "react";
2
+ import { screen } from "@testing-library/react-native";
3
+ import { measurePerformance } from "reassure";
4
+ import Markdown from "../Markdown";
5
+ const mdString = `Markdown Quick Reference
6
+ ========================
7
+
8
+ This guide is a very brief overview, with examples, of the syntax that [Markdown] supports. It is itself written in Markdown and you can copy the samples over to the left-hand pane for experimentation. It's shown as *text* and not *rendered HTML*.
9
+
10
+ [Markdown]: http://daringfireball.net/projects/markdown/
11
+
12
+
13
+ Simple Text Formatting
14
+ ======================
15
+
16
+ First thing is first. You can use *stars* or _underscores_ for italics. **Double stars** and __double underscores__ for bold. ***Three together*** for ___both___.
17
+
18
+ Paragraphs are pretty easy too. Just have a blank line between chunks of text.
19
+
20
+ > This chunk of text is in a block quote. Its multiple lines will all be
21
+ > indented a bit from the rest of the text.
22
+ >
23
+ > > Multiple levels of block quotes also work.
24
+
25
+ Sometimes you want to include code, such as when you are explaining how \`<h1>\` HTML tags work, or maybe you are a programmer and you are discussing \`someMethod()\`.
26
+
27
+ If you want to include code and have new
28
+ lines preserved, indent the line with a tab
29
+ or at least four spaces:
30
+
31
+ Extra spaces work here too.
32
+ This is also called preformatted text and it is useful for showing examples.
33
+ The text will stay as text, so any *markdown* or <u>HTML</u> you add will
34
+ not show up formatted. This way you can show markdown examples in a
35
+ markdown document.
36
+
37
+ > You can also use preformatted text with your blockquotes
38
+ > as long as you add at least five spaces.
39
+
40
+
41
+ Headings
42
+ ========
43
+
44
+ There are a couple of ways to make headings. Using three or more equals signs on a line under a heading makes it into an "h1" style. Three or more hyphens under a line makes it "h2" (slightly smaller). You can also use multiple pound symbols (\`#\`) before and after a heading. Pounds after the title are ignored. Here are some examples:
45
+
46
+ This is H1
47
+ ==========
48
+
49
+ This is H2
50
+ ----------
51
+
52
+ # This is H1
53
+ ## This is H2
54
+ ### This is H3 with some extra pounds ###
55
+ #### You get the idea ####
56
+ ##### I don't need extra pounds at the end
57
+ ###### H6 is the max
58
+
59
+
60
+ Links
61
+ =====
62
+
63
+ Let's link to a few sites. First, let's use the bare URL, like <https://www.github.com>. Great for text, but ugly for HTML.
64
+ Next is an inline link to [Google](https://www.google.com). A little nicer.
65
+ This is a reference-style link to [Wikipedia] [1].
66
+ Lastly, here's a pretty link to [Yahoo]. The reference-style and pretty links both automatically use the links defined below, but they could be defined *anywhere* in the markdown and are removed from the HTML. The names are also case insensitive, so you can use [YaHoO] and have it link properly.
67
+
68
+ [1]: https://www.wikipedia.org
69
+ [Yahoo]: https://www.yahoo.com
70
+
71
+ Title attributes may be added to links by adding text after a link.
72
+ This is the [inline link](https://www.bing.com "Bing") with a "Bing" title.
73
+ You can also go to [W3C] [2] and maybe visit a [friend].
74
+
75
+ [2]: https://w3c.org (The W3C puts out specs for web-based things)
76
+ [Friend]: https://facebook.com "Facebook!"
77
+
78
+ Email addresses in plain text are not linked: test@example.com.
79
+ Email addresses wrapped in angle brackets are linked: <test@example.com>.
80
+ They are also obfuscated so that email harvesting spam robots hopefully won't get them.
81
+
82
+
83
+ Lists
84
+ =====
85
+
86
+ * This is a bulleted list
87
+ * Great for shopping lists
88
+ - You can also use hyphens
89
+ + Or plus symbols
90
+
91
+ The above is an "unordered" list. Now, on for a bit of order.
92
+
93
+ 1. Numbered lists are also easy
94
+ 2. Just start with a number
95
+ 3738762. However, the actual number doesn't matter when converted to HTML.
96
+ 1. This will still show up as 4.
97
+
98
+ You might want a few advanced lists:
99
+
100
+ - This top-level list is wrapped in paragraph tags
101
+ - This generates an extra space between each top-level item.
102
+
103
+ - You do it by adding a blank line
104
+
105
+ - This nested list also has blank lines between the list items.
106
+
107
+ - How to create nested lists
108
+ 1. Start your regular list
109
+ 2. Indent nested lists with two spaces
110
+ 3. Further nesting means you should indent with two more spaces
111
+ * This line is indented with four spaces.
112
+
113
+ - List items can be quite lengthy. You can keep typing and either continue
114
+ them on the next line with no indentation.
115
+
116
+ - Alternately, if that looks ugly, you can also
117
+ indent the next line a bit for a prettier look.
118
+
119
+ - You can put large blocks of text in your list by just indenting with two spaces.
120
+
121
+ This is formatted the same as code, but you can inspect the HTML and find that it's just wrapped in a \`<p>\` tag and *won't* be shown as preformatted text.
122
+
123
+ You can keep adding more and more paragraphs to a single list item by adding the traditional blank line and then keep on indenting the paragraphs with two spaces.
124
+
125
+ You really only need to indent the first line,
126
+ but that looks ugly.
127
+
128
+ - Lists support blockquotes
129
+
130
+ > Just like this example here. By the way, you can
131
+ > nest lists inside blockquotes!
132
+ > - Fantastic!
133
+
134
+ - Lists support preformatted text
135
+
136
+ You just need to indent an additional four spaces.
137
+
138
+
139
+ Even More
140
+ =========
141
+
142
+ Horizontal Rule
143
+ ---------------
144
+
145
+ If you need a horizontal rule you just need to put at least three hyphens, asterisks, or underscores on a line by themselves. You can also even put spaces between the characters.
146
+
147
+ ---
148
+ ****************************
149
+ _ _ _ _ _ _ _
150
+
151
+ Those three all produced horizontal lines. Keep in mind that three hyphens under any text turns that text into a heading, so add a blank like if you use hyphens.
152
+
153
+ Images
154
+ ------
155
+
156
+ Images work exactly like links, but they have exclamation points in front. They work with references and titles too.
157
+
158
+ ![Google Logo](https://www.google.com/images/errors/logo_sm.gif) and ![Happy].
159
+
160
+ [Happy]: https://wpclipart.com/smiley/happy/simple_colors/smiley_face_simple_green_small.png ("Smiley face")
161
+
162
+
163
+ Inline HTML
164
+ -----------
165
+
166
+ If markdown is too limiting, you can just insert your own <strike>crazy</strike> HTML. Span-level HTML <u>can *still* use markdown</u>. Block level elements must be separated from text by a blank line and must not have any spaces before the opening and closing HTML.
167
+
168
+ <div style='font-family: "Comic Sans MS", "Comic Sans", cursive;'>
169
+ It is a pity, but markdown does **not** work in here for most markdown parsers.
170
+ [Marked] handles it pretty well.
171
+ </div>
172
+ `;
173
+ describe("Perf test", () => {
174
+ it("Renders markdown", async () => {
175
+ const scenario = async () => {
176
+ await screen.queryByText("Markdown Quick Reference");
177
+ await screen.queryByText("Inline HTML");
178
+ await screen.queryByText("If markdown is too limiting, you can just insert your own <strike>crazy</strike> HTML. Span-level HTML <u>can *still* use markdown</u>. Block level elements must be separated from text by a blank line and must not have any spaces before the opening and closing HTML.");
179
+ };
180
+
181
+ measurePerformance( /*#__PURE__*/React.createElement(Markdown, {
182
+ value: mdString
183
+ }), {
184
+ scenario
185
+ });
186
+ });
187
+ });
188
+ //# sourceMappingURL=Markdown.perf-test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","screen","measurePerformance","Markdown","mdString","describe","it","scenario","queryByText"],"sourceRoot":"../../../../src","sources":["lib/__perf__/Markdown.perf-test.tsx"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,MAAT,QAAuB,+BAAvB;AACA,SAASC,kBAAT,QAAmC,UAAnC;AACA,OAAOC,QAAP,MAAqB,aAArB;AAEA,MAAMC,QAAQ,GAAI;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAvKA;AAyKAC,QAAQ,CAAC,WAAD,EAAc,MAAM;EAC3BC,EAAE,CAAC,kBAAD,EAAqB,YAAY;IAClC,MAAMC,QAAQ,GAAG,YAAY;MAC5B,MAAMN,MAAM,CAACO,WAAP,CAAmB,0BAAnB,CAAN;MACA,MAAMP,MAAM,CAACO,WAAP,CAAmB,aAAnB,CAAN;MACA,MAAMP,MAAM,CAACO,WAAP,CACL,4QADK,CAAN;IAGA,CAND;;IAOAN,kBAAkB,eAAC,oBAAC,QAAD;MAAU,KAAK,EAAEE;IAAjB,EAAD,EAAgC;MAAEG;IAAF,CAAhC,CAAlB;EACA,CATC,CAAF;AAUA,CAXO,CAAR"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MDImage.d.ts","sourceRoot":"","sources":["../../../src/components/MDImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAGtD,UAAU,YAAY;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,UAAU,CAAC;CACnB;;AAmBD,wBAA6B"}
@@ -0,0 +1,7 @@
1
+ import Markdown from "./lib/Markdown";
2
+ import Renderer from "./lib/Renderer";
3
+ import type { MarkdownProps, ParserOptions, RendererInterface } from "./lib/types";
4
+ export type { MarkdownProps, ParserOptions, RendererInterface };
5
+ export { Renderer };
6
+ export default Markdown;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,EACX,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,MAAM,aAAa,CAAC;AAErB,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,eAAe,QAAQ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
2
  import type { MarkdownProps } from "./types";
3
- declare const _default: React.MemoExoticComponent<({ value, flatListProps, theme, baseUrl, styles: userStyles, }: MarkdownProps) => JSX.Element>;
3
+ declare const _default: React.MemoExoticComponent<({ value, flatListProps, theme, baseUrl, renderer, styles: userStyles, }: MarkdownProps) => JSX.Element>;
4
4
  export default _default;
5
5
  //# sourceMappingURL=Markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Markdown.d.ts","sourceRoot":"","sources":["../../../src/lib/Markdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AAMf,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;;AAsD7C,wBAA8B"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Parser.d.ts","sourceRoot":"","sources":["../../../src/lib/Parser.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAqB,aAAa,EAAE,MAAM,SAAS,CAAC;AAGhE,cAAM,MAAM;IACX,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,gBAAgB,CAAwC;IAChE,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,aAAa;IAclC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE;IAI5B,OAAO,CAAC,MAAM;IAUd,OAAO,CAAC,WAAW;IAiJnB,OAAO,CAAC,gDAAgD;CAsDxD;AAED,eAAe,MAAM,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { type ReactNode } from "react";
2
+ import { type TextStyle, type ViewStyle, type ImageStyle } from "react-native";
3
+ import type { RendererInterface } from "./types";
4
+ declare class Renderer implements RendererInterface {
5
+ private slugPrefix;
6
+ private slugger;
7
+ constructor();
8
+ paragraph(children: ReactNode[], styles?: ViewStyle): ReactNode;
9
+ blockquote(children: ReactNode[], styles?: ViewStyle): ReactNode;
10
+ heading(text: string | ReactNode[], styles?: TextStyle): ReactNode;
11
+ code(text: string, _language?: string, containerStyle?: ViewStyle, textStyle?: TextStyle): ReactNode;
12
+ hr(styles?: ViewStyle): ReactNode;
13
+ listItem(children: ReactNode[], styles?: ViewStyle): ReactNode;
14
+ list(ordered: boolean, li: ReactNode[], listStyle?: ViewStyle, textStyle?: TextStyle): ReactNode;
15
+ escape(text: string, styles?: TextStyle): ReactNode;
16
+ link(children: string | ReactNode[], href: string, styles?: TextStyle): ReactNode;
17
+ image(uri: string, alt?: string, style?: ImageStyle): ReactNode;
18
+ strong(children: ReactNode[], styles?: TextStyle): ReactNode;
19
+ em(children: ReactNode[], styles?: TextStyle): ReactNode;
20
+ codespan(text: string, styles?: TextStyle): ReactNode;
21
+ br(): ReactNode;
22
+ del(children: ReactNode[], styles?: TextStyle): ReactNode;
23
+ text(text: string | ReactNode[], styles?: TextStyle): ReactNode;
24
+ html(text: string | ReactNode[], styles?: TextStyle): ReactNode;
25
+ linkImage(href: string, imageUrl: string, alt?: string, style?: ImageStyle): ReactNode;
26
+ getKey(): string;
27
+ private getTextNode;
28
+ private getViewNode;
29
+ private getBlockquoteNode;
30
+ }
31
+ export default Renderer;
32
+ //# sourceMappingURL=Renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Renderer.d.ts","sourceRoot":"","sources":["../../../src/lib/Renderer.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAKN,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,UAAU,EACf,MAAM,cAAc,CAAC;AAOtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,cAAM,QAAS,YAAW,iBAAiB;IAC1C,OAAO,CAAC,UAAU,CAA6B;IAC/C,OAAO,CAAC,OAAO,CAAU;;IAKzB,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS;IAI/D,UAAU,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS;IAIhE,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS;IAIlE,IAAI,CACH,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,MAAM,EAClB,cAAc,CAAC,EAAE,SAAS,EAC1B,SAAS,CAAC,EAAE,SAAS,GACnB,SAAS;IAYZ,E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,EACZ,KAAK,CAAC,EAAE,UAAU,GAChB,SAAS;IAcZ,MAAM,IAAI,MAAM;IAIhB,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,WAAW;IAanB,OAAO,CAAC,iBAAiB;CAYzB;AAED,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Markdown.perf-test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Markdown.perf-test.d.ts","sourceRoot":"","sources":["../../../../src/lib/__perf__/Markdown.perf-test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,34 @@
1
+ import type { ReactNode } from "react";
2
+ import type { FlatListProps, ViewStyle, TextStyle, ImageStyle } from "react-native";
3
+ import type { MarkedStyles, UserTheme } from "./../theme/types";
4
+ export interface ParserOptions {
5
+ styles?: MarkedStyles;
6
+ baseUrl?: string;
7
+ renderer: RendererInterface;
8
+ }
9
+ export interface MarkdownProps extends Partial<ParserOptions> {
10
+ value: string;
11
+ flatListProps?: Omit<FlatListProps<ReactNode>, "data" | "renderItem" | "horizontal">;
12
+ theme?: UserTheme;
13
+ }
14
+ export interface RendererInterface {
15
+ paragraph(children: ReactNode[], styles?: ViewStyle): ReactNode;
16
+ blockquote(children: ReactNode[], styles?: ViewStyle): ReactNode;
17
+ heading(text: string | ReactNode[], styles?: TextStyle): ReactNode;
18
+ code(text: string, language?: string, containerStyle?: ViewStyle, textStyle?: TextStyle): ReactNode;
19
+ hr(styles?: ViewStyle): ReactNode;
20
+ listItem(children: ReactNode[], styles?: ViewStyle): ReactNode;
21
+ list(ordered: boolean, li: ReactNode[], listStyle?: ViewStyle, textStyle?: TextStyle): ReactNode;
22
+ escape(text: string, styles?: TextStyle): ReactNode;
23
+ link(children: string | ReactNode[], href: string, styles?: TextStyle): ReactNode;
24
+ image(uri: string, alt?: string, style?: ImageStyle): ReactNode;
25
+ strong(children: ReactNode[], styles?: TextStyle): ReactNode;
26
+ em(children: ReactNode[], styles?: TextStyle): ReactNode;
27
+ codespan(text: string, styles?: TextStyle): ReactNode;
28
+ br(): ReactNode;
29
+ del(children: ReactNode[], styles?: TextStyle): ReactNode;
30
+ text(text: string | ReactNode[], styles?: TextStyle): ReactNode;
31
+ html(text: string | ReactNode[], styles?: TextStyle): ReactNode;
32
+ linkImage(href: string, imageUrl: string, alt?: string, style?: ImageStyle): ReactNode;
33
+ }
34
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EACX,aAAa,EACb,SAAS,EACT,SAAS,EACT,UAAU,EACV,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEhE,MAAM,WAAW,aAAa;IAC7B,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,iBAAiB,CAAC;CAC5B;AAED,MAAM,WAAW,aAAc,SAAQ,OAAO,CAAC,aAAa,CAAC;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,IAAI,CACnB,aAAa,CAAC,SAAS,CAAC,EACxB,MAAM,GAAG,YAAY,GAAG,YAAY,CACpC,CAAC;IACF,KAAK,CAAC,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IACjC,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAChE,UAAU,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IACjE,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,EAAE,MAAM,CAAC,EAAE,SAAS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AE,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAChE,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAChE,SAAS,CACR,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,UAAU,GAChB,SAAS,CAAC;CACb"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../src/theme/colors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AAC/E,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;AAE3D,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,MAAM,EAAE,cAAc,CAepD,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spacing.d.ts","sourceRoot":"","sources":["../../../src/theme/spacing.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAErD,QAAA,MAAM,OAAO,EAAE,MAAM,CAAC,eAAe,EAAE,MAAM,CAK5C,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/theme/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAGhE,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAgBvD,QAAA,MAAM,SAAS,gBACD,YAAY,gBACX,eAAe,cACjB,SAAS,KACnB,YA+GF,CAAC;AAEF,e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3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/utils/handlers.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,QAAS,MAAM,eAMtC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/utils/url.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,WAAY,MAAM,QAAQ,MAAM,WAkBvD,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "react-native-marked",
3
- "version": "1.6.14",
3
+ "version": "2.0.0-rc.1",
4
4
  "description": "Markdown renderer for React Native powered by marked.js",
5
5
  "main": "dist/commonjs/index",
6
6
  "module": "dist/module/index",
7
- "types": "dist/typescript/src/index.d.ts",
7
+ "types": "dist/typescript/index.d.ts",
8
8
  "react-native": "src/index",
9
9
  "source": "src/index",
10
10
  "files": [
package/src/index.ts CHANGED
@@ -1,3 +1,11 @@
1
1
  import Markdown from "./lib/Markdown";
2
+ import Renderer from "./lib/Renderer";
3
+ import type {
4
+ MarkdownProps,
5
+ ParserOptions,
6
+ RendererInterface,
7
+ } from "./lib/types";
2
8
 
9
+ export type { MarkdownProps, ParserOptions, RendererInterface };
10
+ export { Renderer };
3
11
  export default Markdown;
@@ -8,6 +8,7 @@ import React, {
8
8
  import { FlatList, useColorScheme } from "react-native";
9
9
  import { marked } from "marked";
10
10
  import Parser from "./Parser";
11
+ import Renderer from "./Renderer";
11
12
  import getStyles from "../theme/styles";
12
13
  import type { MarkdownProps } from "./types";
13
14
 
@@ -16,6 +17,7 @@ const Markdown = ({
16
17
  flatListProps,
17
18
  theme,
18
19
  baseUrl,
20
+ renderer,
19
21
  styles: userStyles,
20
22
  }: MarkdownProps) => {
21
23
  const colorScheme = useColorScheme();
@@ -25,7 +27,12 @@ const Markdown = ({
25
27
  );
26
28
 
27
29
  const parser = useMemo(
28
- () => new Parser({ styles, baseUrl }),
30
+ () =>
31
+ new Parser({
32
+ styles,
33
+ baseUrl,
34
+ renderer: renderer ?? new Renderer(),
35
+ }),
29
36
  [styles, baseUrl],
30
37
  );
31
38