import React, { PropTypes } from 'react';
import markdownIt from 'markdown-it';
import ast from './util/ast';
import renderTokens from './util/renderTokens';
import components from './components';

const md = new markdownIt();

/**
 * Renders React components from a Markdown string.
 * @todo Allow for custom markdown-it instance.
 * @todo Allow for custom components.
 */
export default function Markdown({ input }) {
  const { nodes } = ast(md.parse(input));

  return (
    <div>
      {renderTokens(nodes, components)}
    </div>
  );
}

/**
 * Props that can be passed to `<Markdown />`.
 * @type Object
 * @prop {String} input - Markdown string.
 */
Markdown.propTypes = {
  input: PropTypes.string.isRequired,
}

@@ -195,38 +195,8 @@
 ';%0A%0A
-const md = new markdownIt();%0A%0A
 /**%0A
@@ -251,56 +251,8 @@
 ng.%0A
- * @todo Allow for custom markdown-it instance.%0A
  * @
@@ -329,16 +329,26 @@
 (%7B input
+, renderer
  %7D) %7B%0A  
@@ -373,10 +373,16 @@
 ast(
-md
+renderer
 .par
@@ -584,16 +584,69 @@
 string.%0A
+ * @prop %7BObject%7D %5Brenderer%5D - markdown-it instance.%0A
  */%0AMark
@@ -702,10 +702,156 @@
 quired,%0A
+  renderer: PropTypes.object,%0A%7D%0A%0A/**%0A * Default props for %60%3CMarkdown /%3E%60.%0A * @type Object%0A */%0AMarkdown.defaultProps = %7B%0A  renderer: markdownIt(),%0A
 %7D%0A

Allow custom markdown-it instance to be passed to the <Markdown /> component