Skip to content

Commit 83d1d61

Browse files
committed
Merge branch 'master' into develop
# Conflicts: # example/App.js # example/package.json # package.json
2 parents c26e370 + fcf4a2f commit 83d1d61

25 files changed

+1275
-589
lines changed

README.md

Lines changed: 49 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
1-
# React Native Markdown Renderer [![npm version](https://badge.fury.io/js/react-native-markdown-renderer.svg)](https://badge.fury.io/js/react-native-markdown-renderer)
1+
# React Native Markdown Renderer [![npm version](https://badge.fury.io/js/react-native-markdown-renderer.svg)](https://badge.fury.io/js/react-native-markdown-renderer) [![Known Vulnerabilities](https://snyk.io/test/github/mientjan/react-native-markdown-renderer/badge.svg)](https://snyk.io/test/github/mientjan/react-native-markdown-renderer)
22

33
Is a 100% compatible CommonMark renderer, a react-native markdown renderer done right. This is __not__
44
a web-view markdown renderer but a renderer that uses native components for all its elements. These components can be overwritten when needed as seen in the examples.
55

6-
To give a summary of the supported syntax react-native-markdown-renderer supports.
6+
### Future releases
7+
##### v2.1.0
8+
- We are going to switch to a type based rule system instead of a html tags. Rules are currently
9+
based off html tags "a,h1,h2,h3,h4,ul,li etc." this will change to "anchor, heading1, bullet_list, bullet_list_item"
10+
This makes it a lot easier to add extra syntax features through plugins.
11+
12+
13+
### Quick links
14+
- [Documentation](https://github.com/mientjan/react-native-markdown-renderer/wiki/)
15+
- [Examples](https://github.com/mientjan/react-native-markdown-renderer/wiki/Examples)
16+
- [Example App](https://github.com/mientjan/react-native-markdown-renderer/wiki/ExampleApp)
17+
18+
19+
### Syntax Support
720

21+
To give a summary of the supported syntax react-native-markdown-renderer supports.
22+
823
- Tables
924
- Heading 1 > 6
1025
- Horizontal Rules
11-
- Typographic replacements
26+
- Typographic Replacements
1227
- Emphasis ( **bold**, *italic*, ~~strikethrough~~ )
1328
- Blockquotes
1429
- Lists
@@ -20,21 +35,45 @@ To give a summary of the supported syntax react-native-markdown-renderer support
2035
- Syntax highlighting
2136
- Links
2237
- Images
23-
- Plugins for extra syntax support, [see plugins](https://www.npmjs.com/browse/keyword/markdown-it-plugin). Because this markdown-renderer uses markdown-it as its base it also supports all its plugins and subsequent extra language support.
38+
- Plugins for **extra** syntax support, [see plugins](https://www.npmjs.com/browse/keyword/markdown-it-plugin).
39+
Because this markdown-renderer uses markdown-it as its base it also supports all its plugins and
40+
subsequent extra language support.
41+
42+
### Plugins, Extending Markdown (common mark A+) language support
43+
This renderer, supports the ability extend the current CommonMark A+ spec.
44+
45+
For example:
2446

47+
- checkboxes: [ ] Not Checked [x] Checked https://www.npmjs.com/package/markdown-it-checkbox
48+
- Video Embeds: ```@[youtube](dQw4w9WgXcQ)``` https://www.npmjs.com/package/markdown-it-video
49+
50+
And a lot more, the list of community created plugins to extends the language are endless. But be
51+
**carefull** add a plugin is easy, creating a rule for it is not. Currently the astRenderer and rules
52+
are based off html tags. This makes it especially hard when adding stuff like checkbox or Video Embeds
53+
that are grouped under input, label and a tag.
2554

26-
### tested on:
55+
**Version 2.1.0** will switch this around and move the rules from tags to type. So a ```* list``` was a "li"
56+
in the rules becomes a "bullet_list_item".
57+
58+
Checkbox was a "input" with no wrapper and will now move to "checkbox". This change will help to make support
59+
for plugins a lot easier
60+
61+
62+
### Tested on:
2763

2864
| [] | react | react-native |
2965
| ---- | ---- | ------- |
3066
| v | 16.0.0-alpha.12 | 0.45.1 |
3167
| v | 16.0.0-alpha.6 | 0.44.0 |
32-
| v | ^15.6.1 | ^0.46.4 |
68+
| x | 15.x | ^0.46.4 |
69+
70+
``` // react 15 seems to break with expo.```
3371

34-
### todo
35-
- add styleSheet support
72+
### Todo
73+
- ~~add styleSheet support~~
74+
- ~~add plugin support~~
75+
- ~~add support for seperate rules~~
3676
- add styleSheet inheritance support
37-
- ~~adding plugin support~~
3877

3978
### How to:
4079

@@ -47,92 +86,10 @@ npm install -S react-native-markdown-renderer
4786
yarn add react-native-markdown-renderer
4887
```
4988

50-
### Example:
51-
##### Simple example
52-
```js
53-
54-
import react from 'react';
55-
import {View, PureComponent} from 'react-native';
56-
import Markdown from 'react-native-markdown-renderer';
57-
58-
const copy = `# h1 Heading 8-)
59-
60-
| Option | Description |
61-
| ------ | ----------- |
62-
| data | path to data files to supply the data that will be passed into templates. |
63-
| engine | engine to be used for processing templates. Handlebars is the default. |
64-
| ext | extension to be used for dest files. |
65-
`;
66-
67-
export default class Page extends PureComponent {
68-
69-
static propTypes = {};
70-
static defaultProps = {};
71-
72-
render() {
73-
74-
return (
75-
<Markdown>{copy}</Markdown>
76-
);
77-
}
78-
}
79-
```
80-
81-
##### If you want to use your own native elements and styling, and want to add extra plugins:
82-
```js
83-
84-
import react from 'react';
85-
import {View, PureComponent, Text} from 'react-native';
86-
import Markdown, { AstRenderer, defaultRenderFunctions, PluginContainer, blockPlugin} from 'react-native-markdown-renderer';
87-
88-
const copy = `# h1 Heading 8-)
89-
90-
| Option | Description |
91-
| ------ | ----------- |
92-
| data | path to data files to supply the data that will be passed into templates. |
93-
| engine | engine to be used for processing templates. Handlebars is the default. |
94-
| ext | extension to be used for dest files. |
95-
96-
[block]
97-
I'm in a block
98-
[/block]
99-
`;
100-
101-
/**
102-
* i'm overriding the default h1 render function.
103-
*/
104-
const renderer = new AstRenderer({
105-
...defaultRenderFunctions,
106-
h1: (node, children, parents) => {
107-
return <Text style={{backgroundColor: 'red'}}>{children}</Text>;
108-
},
109-
// added custom block element defined by plugin
110-
block: (node, children, parents) => {
111-
return <Text style={{backgroundColor: 'green'}}>{children}</Text>;
112-
}
113-
});
114-
115-
export default class Page extends PureComponent {
116-
117-
static propTypes = {};
118-
static defaultProps = {};
119-
120-
render() {
121-
122-
const plugins = [
123-
new PluginContainer(blockPlugin, 'block', {})
124-
];
125-
126-
return (
127-
<Markdown renderer={renderer} plugins={plugins}>{copy}</Markdown>
128-
);
129-
}
130-
}
131-
```
89+
See [WIKI](https://github.com/mientjan/react-native-markdown-renderer/wiki/) for examples and documentation
13290

13391
---
13492

135-
13693
# Syntax Support
13794

13895
__Advertisement :)__

0 commit comments

Comments
 (0)