<commit_before>'use strict';
var fs = require('fs');
var path = require('path');
var marked = require('marked');
var setCase = require('case')
var Renderer = require('./JsxRenderer');

marked.setOptions({
  xhtml: true,
  highlight: function(code, lang) {
    let prism = require('./prism-jsx');
    lang = lang && lang.indexOf('language-') === 0 ? lang.replace('language-', '') : lang;
    return prism.highlight(code, prism.languages[lang]);
  }
});

function defaultRender(contents, resourcePath, options) {
  let prefix = setCase.pascal(path.basename(resourcePath, '.md').toLowerCase() + '/');

  return `
var React = require('react');
${options.preamble || ''}

module.exports = React.createClass({
  displayName: '${prefix}',
  render: function() {
    return (
      <div {...this.props}>
        ${contents}
      </div>
    )
 }
});

${options.postamble || ''}
`;
}

module.exports = function(contents) {
  var options = this.options.markdownJsxLoader || {}

  this.cacheable();

  Renderer = options.renderer || this.options.renderer || Renderer;

  var render = options.render || defaultRender

  return render(marked(contents, {
    renderer: new Renderer()
  }), this.resourcePath, options)
}

module.exports.Renderer = Renderer<commit_msg>Use functional JSX component. Update to `loaderUtils` to support options.<commit_after>'use strict';

const setCase = require('case');
const fs = require('fs');
const loaderUtils = require('loader-utils');
const marked = require('marked');
const path = require('path');
const Renderer = require('./JsxRenderer');

marked.setOptions({
  highlight: function(code, lang) {
    const prism = require('./prism-jsx');
    lang = lang && lang.indexOf('language-') === 0 ? lang.replace('language-', '') : lang;
    return prism.highlight(code, prism.languages[lang]);
  }
});

function defaultRender(contents, resourcePath, options) {
  const prefix = setCase.pascal(path.basename(resourcePath, '.md').toLowerCase() + '/');

  return `
var React = require('react');
${options.preamble || ''}

module.exports = function () {
  return (<div>${contents}</div>)
});

module.exports.displayName = '${prefix}';

${options.postamble || ''}
`;
}

module.exports = function(contents) {
  const options = loaderUtils.getOptions(this) || {};

  this.cacheable();

  const renderer = options.renderer || new Renderer();
  const render = options.render || defaultRender;

  return render(marked(contents, { renderer }), this.resourcePath, options)
}

module.exports.Renderer = Renderer
{'fraction_non_alphanumeric': 0.17759237187127533, 'fraction_numerical': 0.0007945967421533572, 'mean_word_length': 4.485838779956427, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '290460', 'n_tokens_mistral': 775, 'n_tokens_neox': 752, 'n_words': 169}