react-native-marked 2.0.0 → 3.0.0-rc.0

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 (41) hide show
  1. package/README.md +10 -1
  2. package/dist/commonjs/lib/Parser.js +16 -1
  3. package/dist/commonjs/lib/Parser.js.map +1 -1
  4. package/dist/commonjs/lib/Renderer.js +54 -2
  5. package/dist/commonjs/lib/Renderer.js.map +1 -1
  6. package/dist/commonjs/theme/styles.js +10 -0
  7. package/dist/commonjs/theme/styles.js.map +1 -1
  8. package/dist/commonjs/utils/table.js +45 -0
  9. package/dist/commonjs/utils/table.js.map +1 -0
  10. package/dist/module/lib/Parser.js +15 -1
  11. package/dist/module/lib/Parser.js.map +1 -1
  12. package/dist/module/lib/Renderer.js +51 -3
  13. package/dist/module/lib/Renderer.js.map +1 -1
  14. package/dist/module/theme/styles.js +10 -0
  15. package/dist/module/theme/styles.js.map +1 -1
  16. package/dist/module/utils/table.js +33 -0
  17. package/dist/module/utils/table.js.map +1 -0
  18. package/dist/typescript/lib/Parser.d.ts.map +1 -1
  19. package/dist/typescript/lib/Renderer.d.ts +4 -2
  20. package/dist/typescript/lib/Renderer.d.ts.map +1 -1
  21. package/dist/typescript/lib/types.d.ts +3 -1
  22. package/dist/typescript/lib/types.d.ts.map +1 -1
  23. package/dist/typescript/theme/styles.d.ts.map +1 -1
  24. package/dist/typescript/theme/types.d.ts +3 -0
  25. package/dist/typescript/theme/types.d.ts.map +1 -1
  26. package/dist/typescript/utils/table.d.ts +5 -0
  27. package/dist/typescript/utils/table.d.ts.map +1 -0
  28. package/package.json +30 -20
  29. package/src/lib/Parser.tsx +28 -0
  30. package/src/lib/Renderer.tsx +54 -0
  31. package/src/lib/types.ts +10 -0
  32. package/src/theme/styles.ts +10 -0
  33. package/src/theme/types.ts +3 -0
  34. package/src/utils/table.ts +29 -0
  35. package/dist/commonjs/lib/__perf__/Markdown.perf-test.js +0 -196
  36. package/dist/commonjs/lib/__perf__/Markdown.perf-test.js.map +0 -1
  37. package/dist/module/lib/__perf__/Markdown.perf-test.js +0 -188
  38. package/dist/module/lib/__perf__/Markdown.perf-test.js.map +0 -1
  39. package/dist/typescript/lib/__perf__/Markdown.perf-test.d.ts +0 -2
  40. package/dist/typescript/lib/__perf__/Markdown.perf-test.d.ts.map +0 -1
  41. package/src/lib/__perf__/Markdown.perf-test.tsx +0 -186
@@ -1,188 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=Markdown.perf-test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Markdown.perf-test.d.ts","sourceRoot":"","sources":["../../../../src/lib/__perf__/Markdown.perf-test.tsx"],"names":[],"mappings":""}
@@ -1,186 +0,0 @@
1
- import React from "react";
2
- import { screen } from "@testing-library/react-native";
3
- import { measurePerformance } from "reassure";
4
- import Markdown from "../Markdown";
5
-
6
- const mdString = `Markdown Quick Reference
7
- ========================
8
-
9
- 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*.
10
-
11
- [Markdown]: http://daringfireball.net/projects/markdown/
12
-
13
-
14
- Simple Text Formatting
15
- ======================
16
-
17
- First thing is first. You can use *stars* or _underscores_ for italics. **Double stars** and __double underscores__ for bold. ***Three together*** for ___both___.
18
-
19
- Paragraphs are pretty easy too. Just have a blank line between chunks of text.
20
-
21
- > This chunk of text is in a block quote. Its multiple lines will all be
22
- > indented a bit from the rest of the text.
23
- >
24
- > > Multiple levels of block quotes also work.
25
-
26
- 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()\`.
27
-
28
- If you want to include code and have new
29
- lines preserved, indent the line with a tab
30
- or at least four spaces:
31
-
32
- Extra spaces work here too.
33
- This is also called preformatted text and it is useful for showing examples.
34
- The text will stay as text, so any *markdown* or <u>HTML</u> you add will
35
- not show up formatted. This way you can show markdown examples in a
36
- markdown document.
37
-
38
- > You can also use preformatted text with your blockquotes
39
- > as long as you add at least five spaces.
40
-
41
-
42
- Headings
43
- ========
44
-
45
- 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:
46
-
47
- This is H1
48
- ==========
49
-
50
- This is H2
51
- ----------
52
-
53
- # This is H1
54
- ## This is H2
55
- ### This is H3 with some extra pounds ###
56
- #### You get the idea ####
57
- ##### I don't need extra pounds at the end
58
- ###### H6 is the max
59
-
60
-
61
- Links
62
- =====
63
-
64
- 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.
65
- Next is an inline link to [Google](https://www.google.com). A little nicer.
66
- This is a reference-style link to [Wikipedia] [1].
67
- 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.
68
-
69
- [1]: https://www.wikipedia.org
70
- [Yahoo]: https://www.yahoo.com
71
-
72
- Title attributes may be added to links by adding text after a link.
73
- This is the [inline link](https://www.bing.com "Bing") with a "Bing" title.
74
- You can also go to [W3C] [2] and maybe visit a [friend].
75
-
76
- [2]: https://w3c.org (The W3C puts out specs for web-based things)
77
- [Friend]: https://facebook.com "Facebook!"
78
-
79
- Email addresses in plain text are not linked: test@example.com.
80
- Email addresses wrapped in angle brackets are linked: <test@example.com>.
81
- They are also obfuscated so that email harvesting spam robots hopefully won't get them.
82
-
83
-
84
- Lists
85
- =====
86
-
87
- * This is a bulleted list
88
- * Great for shopping lists
89
- - You can also use hyphens
90
- + Or plus symbols
91
-
92
- The above is an "unordered" list. Now, on for a bit of order.
93
-
94
- 1. Numbered lists are also easy
95
- 2. Just start with a number
96
- 3738762. However, the actual number doesn't matter when converted to HTML.
97
- 1. This will still show up as 4.
98
-
99
- You might want a few advanced lists:
100
-
101
- - This top-level list is wrapped in paragraph tags
102
- - This generates an extra space between each top-level item.
103
-
104
- - You do it by adding a blank line
105
-
106
- - This nested list also has blank lines between the list items.
107
-
108
- - How to create nested lists
109
- 1. Start your regular list
110
- 2. Indent nested lists with two spaces
111
- 3. Further nesting means you should indent with two more spaces
112
- * This line is indented with four spaces.
113
-
114
- - List items can be quite lengthy. You can keep typing and either continue
115
- them on the next line with no indentation.
116
-
117
- - Alternately, if that looks ugly, you can also
118
- indent the next line a bit for a prettier look.
119
-
120
- - You can put large blocks of text in your list by just indenting with two spaces.
121
-
122
- 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.
123
-
124
- 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.
125
-
126
- You really only need to indent the first line,
127
- but that looks ugly.
128
-
129
- - Lists support blockquotes
130
-
131
- > Just like this example here. By the way, you can
132
- > nest lists inside blockquotes!
133
- > - Fantastic!
134
-
135
- - Lists support preformatted text
136
-
137
- You just need to indent an additional four spaces.
138
-
139
-
140
- Even More
141
- =========
142
-
143
- Horizontal Rule
144
- ---------------
145
-
146
- 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.
147
-
148
- ---
149
- ****************************
150
- _ _ _ _ _ _ _
151
-
152
- 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.
153
-
154
- Images
155
- ------
156
-
157
- Images work exactly like links, but they have exclamation points in front. They work with references and titles too.
158
-
159
- ![Google Logo](https://www.google.com/images/errors/logo_sm.gif) and ![Happy].
160
-
161
- [Happy]: https://wpclipart.com/smiley/happy/simple_colors/smiley_face_simple_green_small.png ("Smiley face")
162
-
163
-
164
- Inline HTML
165
- -----------
166
-
167
- 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.
168
-
169
- <div style='font-family: "Comic Sans MS", "Comic Sans", cursive;'>
170
- It is a pity, but markdown does **not** work in here for most markdown parsers.
171
- [Marked] handles it pretty well.
172
- </div>
173
- `;
174
-
175
- describe("Perf test", () => {
176
- it("Renders markdown", async () => {
177
- const scenario = async () => {
178
- await screen.queryByText("Markdown Quick Reference");
179
- await screen.queryByText("Inline HTML");
180
- await screen.queryByText(
181
- "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.",
182
- );
183
- };
184
- measurePerformance(<Markdown value={mdString} />, { scenario });
185
- });
186
- });