-
Notifications
You must be signed in to change notification settings - Fork 9
/
example.js
113 lines (90 loc) · 2.12 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import React, { Component } from 'react'
import {
AppRegistry,
StyleSheet,
Text,
View,
Alert,
TouchableHighlight
} from 'react-native'
import createMarkdownRenderer from './markdown'
// pass in `marked` opts, e.g. gfm: true for Github Flavored Markdown
const Markdown = createMarkdownRenderer({ gfm: false })
// define a custom renderer for links
Markdown.renderer.link = props => {
const { markdown } = props
const { href } = markdown
return (
<TouchableHighlight onPress={() => Alert.alert('check out this hot href', href)}>
<View>
{props.children}
</View>
</TouchableHighlight>
)
}
// example partially from react-native-simple-markdown
export default class MarkdownExample extends Component {
render() {
const text =
`
You can **emphasize**
You can even [**link your website**](http://carlito.ninja) or if you prefer: [email somebody](mailto:[email protected])
Spice it up with some GIFs 💃:
![Some GIF](https://media.giphy.com/media/dkGhBWE3SyzXW/giphy.gif)
And even add a cool video 😎!
[![A cool video from YT](https://img.youtube.com/vi/dQw4w9WgXcQ/0.jpg)](http://www.youtube.com/watch?v=dQw4w9WgXcQ)
[![Another one from Vimeo](https://i.vimeocdn.com/video/399486266_640.jpg)](https://vimeo.com/57580368)
# heading 1
content 1
## heading 2
### heading 3
#### heading 4
uh oh...numbered list coming up
1. a
1. b
- with an unnumbered list inside
- blah
- blah blah
more frakking lists
- blah
- blah1
- blah2
- blah2.1
- blah2.2
- blah2.2.1
- blah2.2.2
`
return (
<Markdown contentContainerStyle={styles.container} markdownStyles={markdownStyles}>
{text}
</Markdown>
)
}
}
const markdownStyles = {
container: {
paddingLeft: 10
},
heading1: {
fontSize: 24,
color: 'purple',
},
link: {
color: 'pink',
},
mail_to: {
color: 'orange',
},
text: {
color: '#555555',
},
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
}
})
AppRegistry.registerComponent('MarkdownExample', () => MarkdownExample)