🚀 Socket Launch Week 🚀 Day 2: Introducing Repository Labels and Security Policies.Learn More
Socket
Sign inDemoInstall
Socket

commonmark-react-renderer

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commonmark-react-renderer

React renderer for CommonMark (rationalized Markdown)

2.1.0
Source
npm
Version published
Weekly downloads
12K
5.12%
Maintainers
1
Weekly downloads
 
Created
Source

commonmark-react-renderer

npm versionBuild StatusCoverage StatusCode Climate

Renderer for CommonMark which returns an array of React elements, ready to be used in a React component. See react-markdown for such a component.

Installing

npm install --save commonmark-react-renderer

Basic usage

var CommonMark = require('commonmark');
var ReactRenderer = require('commonmark-react-renderer');

var parser = new CommonMark.Parser();
var renderer = new ReactRenderer();

var input = '# This is a header\n\nAnd this is a paragraph';
var ast = parser.parse(input);
var result = renderer.render(ast);

// `result`:
[
    <h1>This is a header</h1>,
    <p>And this is a paragraph</p>
]

Options

Pass an object of options to the renderer constructor to configure it. Available options:

  • sourcePos - boolean Setting to true will add data-sourcepos attributes to all elements, indicating where in the markdown source they were rendered from (default: false).
  • escapeHtml - boolean Setting to true will escape HTML blocks, rendering plain text instead of inserting the blocks as raw HTML (default: false).
  • skipHtml - boolean Setting to true will skip inlined and blocks of HTML (default: false).
  • softBreak - string Setting to br will create <br> tags instead of newlines (default: \n).
  • allowedTypes - array Defines which types of nodes should be allowed (rendered). (default: all types).
  • disallowedTypes - array Defines which types of nodes should be disallowed (not rendered). (default: none).

Testing

git clone git@github.com:rexxars/commonmark-react-renderer.git
cd commonmark-react-renderer
npm install
npm test

License

MIT-licensed. See LICENSE.

Keywords

commonmark

FAQs

Package last updated on 22 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts