All Projects → tradle → rn-markdown

tradle / rn-markdown

Licence: MIT license
basic markdown renderer for react-native using the great https://github.com/chjj/marked parser

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to rn-markdown

React Code Input
React component for entering and validating PIN code.
Stars: ✭ 207 (+885.71%)
Mutual labels:  react-component
Virtual List
🧾 React Virtual List Component which worked with animation
Stars: ✭ 232 (+1004.76%)
Mutual labels:  react-component
Sweetalert React
Declarative SweetAlert in React
Stars: ✭ 244 (+1061.9%)
Mutual labels:  react-component
React Intl Tel Input
Rewrite International Telephone Input in React.js. (Looking for maintainers, and PRs & contributors are also welcomed!)
Stars: ✭ 212 (+909.52%)
Mutual labels:  react-component
React Native Htmlview
A React Native component which renders HTML content as native views
Stars: ✭ 2,546 (+12023.81%)
Mutual labels:  react-component
React Native demo
react-native实现网易新闻和美团,实现大部分页面。使用最新的react-navigation等组件,同时支持安卓和iOS设备。
Stars: ✭ 237 (+1028.57%)
Mutual labels:  react-component
React Input Color
React color picker
Stars: ✭ 208 (+890.48%)
Mutual labels:  react-component
React Emoji Render
Normalize and render emoji's the way your users expect.
Stars: ✭ 250 (+1090.48%)
Mutual labels:  react-component
React Kawaii
Cute SVG React Components
Stars: ✭ 2,709 (+12800%)
Mutual labels:  react-component
Boundless
✨ accessible, battle-tested React components with infinite composability
Stars: ✭ 242 (+1052.38%)
Mutual labels:  react-component
Yoshino
A themable React component library!Flexible Lightweight PC UI Components built on React! Anyone can generate easily all kinds of themes by it!
Stars: ✭ 216 (+928.57%)
Mutual labels:  react-component
React Photo View
一款精致的 React 图片预览组件
Stars: ✭ 218 (+938.1%)
Mutual labels:  react-component
React Sweet Progress
A way to quickly add a progress bar to react app 🌈
Stars: ✭ 239 (+1038.1%)
Mutual labels:  react-component
React Adsense
📽 a simple React-component for Google AdSense / Baidu advertisement.
Stars: ✭ 210 (+900%)
Mutual labels:  react-component
React Email Editor
Drag-n-Drop Email Editor Component for React.js
Stars: ✭ 3,131 (+14809.52%)
Mutual labels:  react-component
React Reorder
Drag & drop, touch enabled, reorderable / sortable list, React component
Stars: ✭ 209 (+895.24%)
Mutual labels:  react-component
React Sight
Visualization tool for React, with support for Fiber, Router (v4), and Redux
Stars: ✭ 2,716 (+12833.33%)
Mutual labels:  react-component
react-antd-formutil
Happy to use react-formutil in the project based on ant-design ^_^
Stars: ✭ 16 (-23.81%)
Mutual labels:  react-component
React Powerplug
🔌 Renderless Containers
Stars: ✭ 2,704 (+12776.19%)
Mutual labels:  react-component
React Css Grid
React layout component based on CSS Grid Layout and built with styled-components
Stars: ✭ 239 (+1038.1%)
Mutual labels:  react-component

rn-markdown

Markdown rendering component, using the parser from marked.

play with the react-native-web version

Install

npm install --save rn-markdown
# or
yarn add rn-markdown

Usage

The example below, and the component styles were adapted from react-native-simple-markdown.

import React, { Component } from 'react'
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Alert,
  TouchableHighlight
} from 'react-native'

import createMarkdownRenderer from 'rn-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, passThroughProps } = 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} passThroughProps={{ passMeThrough: 'to the child renderer components' }}>
        {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)

Contributing

This is a work in progress and contributions are welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].