-
Notifications
You must be signed in to change notification settings - Fork 464
Expand file tree
/
Copy pathCustomRulesExample.tsx
More file actions
53 lines (48 loc) · 1.65 KB
/
CustomRulesExample.tsx
File metadata and controls
53 lines (48 loc) · 1.65 KB
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
import { ScrollView, StyleSheet, SafeAreaView, Text } from 'react-native';
import Markdown from 'react-native-markdown-renderer';
import type { ASTNode, RenderRules, MarkdownStyles } from 'react-native-markdown-renderer';
import type { ReactNode } from 'react';
const rules: Partial<RenderRules> = {
heading1: (node: ASTNode, children: ReactNode[], _parent: ASTNode[], styles: MarkdownStyles) => (
<Text key={node.key} style={[styles.heading as any, styles.heading1 as any]}>
[{children}]
</Text>
),
heading2: (node: ASTNode, children: ReactNode[], _parent: ASTNode[], styles: MarkdownStyles) => (
<Text key={node.key} style={[styles.heading as any, styles.heading2 as any]}>
[{children}]
</Text>
),
heading3: (node: ASTNode, children: ReactNode[], _parent: ASTNode[], styles: MarkdownStyles) => (
<Text key={node.key} style={[styles.heading as any, styles.heading3 as any]}>
[{children}]
</Text>
),
};
const copy = `# h1 Heading 8-)
## h2 Heading 8-)
### h3 Heading 8-)
| Option | Description |
| ------ | ----------- |
| data | path to data files to supply the data that will be passed into templates. |
| engine | engine to be used for processing templates. Handlebars is the default. |
| ext | extension to be used for dest files. |
`;
export default function CustomRulesExample() {
return (
<SafeAreaView style={styles.safe}>
<ScrollView contentContainerStyle={styles.content}>
<Markdown rules={rules}>{copy}</Markdown>
</ScrollView>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
safe: {
flex: 1,
backgroundColor: '#fff',
},
content: {
padding: 16,
},
});