An open API service indexing awesome lists of open source software.

https://github.com/iddan/react-universal-markdown

Markdown component for Web and Native powered by CommonMark
https://github.com/iddan/react-universal-markdown

Last synced: 10 months ago
JSON representation

Markdown component for Web and Native powered by CommonMark

Awesome Lists containing this project

README

          




NPM Version


Known Vulnerabilities





Coverage Status





Markdown Logo
React Logo

react-universal-markdown


Markdown component for Web and Native powered by CommonMark

```bash
npm install react-universal-markdown
```

### Usage

*With React DOM*
```jsx
import React, { Component } from 'react'
import Markdown from 'react-universal-markdown/dom'

export default class App extends Component {
render() {
return (
{`
Your markdown text
`}
)
}
}
```

*With React Native*
```jsx
import React, { Component } from 'react'
import Markdown from 'react-universal-markdown/native'

export default class App extends Component {
render() {
return (
{`
Your markdown text
`}
)
}
}
```

### API

#### DOMMarkdown

##### Props

...Markdown Props

- **className** to be added to the Document element. Other elements should be styled by CSS descendent selector. `string`]

#### DOMComponents

DOMMarkdown default components prop value

#### NativeMarkdown

##### Props

...Markdown Props

- **styles** styles to be applied to each element by type
```
{
Text : number | Object,
Em : number | Object,
Strong : number | Object,
Link : number | Object,
Image : number | Object,
Code : number | Object,
Paragraph : number | Object,
BlockQuote : number | Object,
Item : number | Object,
List : number | Object,
Heading : number | Object,
CodeBlock : number | Object,
ThematicBreak : number | Object,
Document : number | Object,
}
```

#### NativeComponents

NativeComponents default components prop value

#### Markdown

##### Props

- **customizer** a function to modify the parsed elements tree (AST). Executed for each level of the tree. `(children, render) => renderedChildren`
- **children** a markdown `string`
- **components** to be used for rendering markdown.
```
{
Text : Class | (props) => ReactElement,
Em : Class | (props) => ReactElement,
Strong : Class | (props) => ReactElement,
Link : Class | (props) => ReactElement,
Image : Class | (props) => ReactElement,
Code : Class | (props) => ReactElement,
Paragraph : Class | (props) => ReactElement,
BlockQuote : Class | (props) => ReactElement,
Item : Class | (props) => ReactElement,
List : Class | (props) => ReactElement,
Heading : Class | (props) => ReactElement,
CodeBlock : Class | (props) => ReactElement,
ThematicBreak : Class | (props) => ReactElement,
Document : Class | (props) => ReactElement,
}
```