/* eslint no-unused-vars: 0 */
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import marked from 'marked';

const Markdown = ({ markdown, options }) => {
  marked.setOptions(Object.assign({
    renderer: new marked.Renderer(),
    gfm: true,
    tables: true,
    breaks: false,
    pedantic: false,
    sanitize: true,
    smartLists: false,
    smartypants: false,
  }, options));
  const renderMarkdown = markdown => { return {__html: marked(markdown)}; };
  // sanitized with marked
  return <div dangerouslySetInnerHTML={renderMarkdown(markdown)} />;
};

Markdown.propTypes = {
  markdown: PropTypes.string,
  options: PropTypes.object,
};

Markdown.defaultProps = {
  markdown: '',
  options: {},
};

export default Markdown;
