Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/pladaria/react-mark-ii

Ultra small and fast text formatter (markdown-ish) for React
https://github.com/pladaria/react-mark-ii

Last synced: about 2 months ago
JSON representation

Ultra small and fast text formatter (markdown-ish) for React

Awesome Lists containing this project

README

        


react-mark-ii



react-mark-ii

Ultra small and fast text formatter for React



Build Status
Coverage Status

## Features

- Very small (parser is just **50 lines of code**!)
- Super fast!
- Dependency free
- Configurable

## Live demo

[Demo!](https://runkit.com/pladaria/react-mark-ii-demo)

## Install

npm install --save react-mark-ii

## Simple example

```javascript
import Mark from 'react-mark-ii';
//...
const str = '*bold* _emphasis_ ~strike~ `code` ```code\nblock```';
//...
{str}
```

Render result:

``` html


bold
emphasis
strike
code

code
block


```

## Custom options

With the `options` prop you can define your own markup:

Available mark options:

- `renderer`: _React component_ or _tag name string_
- `raw`: (default `false`) if `true`, inner marks will be ignored (useful for code marks)
- `multiline`: (default `false`) if `true` marks can be used across multiple lines
- `alwaysOpen`: (default `false`) by default, marks must be set after a break character (space or punctuation) and
joined to an alphanumeric string). With `alwaysOpen` set to `true` you can ignore these checks. This is useful, for
example, for multiline code blocks which may contain spaces after the mark.

```javascript
import Mark from 'react-mark-ii';
//...
const options = {
'**': {renderer: 'b'},
'_': {renderer: 'u'},
'~': {renderer: ({children}) => {children}},
'`': {renderer: 'kbd', raw: true},
'```': {renderer: 'pre', raw: true, multiline: true, alwaysOpen: true},
};

const str = '**bold** _underline_ ~strike~ `code` ```code\nblock```';
//...
{str}
```

Render result:

```html


bold
underline
strike
code

code
block


```

## Custom wrapper

By default your children will be wrapped with a `div`. Use the `wrap` prop to have a different wrapper. You can use a React component or a tag name string.

```javascript
*text*
```

Render result:

```html

text

```

## Other props

All other props are passed to the wrapper

```javascript
*text*
```

Render result:

```html


text

```

## License

MIT

[Logo font](http://www.iconian.com/a.html)