JSPM

  • Created
  • Published
  • Downloads 5469781
  • Score
    100M100P100Q250588F
  • License MIT

Interprets markdown text and outputs a JSX equivalent.

Package Exports

  • markdown-to-jsx

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (markdown-to-jsx) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

markdown to jsx converter

Enables the safe parsing of markdown into proper React JSX objects, so you don't need to use a pattern like dangerouslySetInnerHTML and potentially open your application up to security issues.

The only exception is arbitrary HTML in the markdown (kind of an antipattern), which will still use the unsafe method.

Uses mdast under the hood to parse markdown into a consistent AST format.

Requires React >= 0.14.

Usage

import converter from 'markdown-to-jsx';
import React from 'react';
import {render} from 'react-dom';

render(converter('# Hello world!'), document.body);

mdast options can be passed as the second argument:

converter('# Hello world[^2]!\n\n[^2]: A beautiful place.', {footnotes: true});

Development Checklist

  • Base library
  • Unit testing
  • Ship 1.0.0 to npm
  • stretch goal - don't use dangerouslySetInnerHTML for arbitrary HTML in the markdown

Known Issues

  • mdast's handling of lists will sometimes add a child paragraph tag inside the <li> where it shouldn't exist - Bug Ticket

  • mdast does not currently have support for column-specific alignment in GFM tables - Bug Ticket

  • mdast incorrectly parses footnote definitions with only one word - Bug Ticket

MIT