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

marked.setOptions({
  renderer: new marked.Renderer(),
  gfm: true,
  tables: true,
  breaks: false,
  pedantic: false,
  sanitize: true,
  smartLists: false,
  smartypants: false,
});

const Markdown = ({ markdown }) => {
  const renderMarkdown = markdown => { return {__html: marked(markdown)}; };
  // sanitized with marked
  return <div dangerouslySetInnerHTML={renderMarkdown(markdown)} />;
};

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

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

export default Markdown;
