Skip to content

Custom and code rules#13

Open
diegolmello wants to merge 5 commits intojuiceo:masterfrom
diegolmello:master
Open

Custom and code rules#13
diegolmello wants to merge 5 commits intojuiceo:masterfrom
diegolmello:master

Conversation

@diegolmello
Copy link

Custom rules allow to send components to react-native-easy-markdown.
A Twitter's username rule could be created like this:

<Markdown rules={{
    username: {
        order: 1,
        match: SimpleMarkdown.inlineRegex(/@[0-9a-zA-Z-_.]+/),
        parse: capture => ({ content: capture[0] }),
        react: (node, output, state) => ({
            type: 'custom',
            key: state.key,
            props: {
                children: (
                    <Text
                        key={state.key}
                        style={{ color: 'blue', fontWeight: 'bold' }}
                        onPress={() => alert('Works')}
                    >
                        {node.content}
                    </Text>
                )
            }
        })
    }
}}>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant