<commit_before>/**
 * Created by Estevao on 15-01-2015.
 */

(function () {
  'use strict';

  require('source-map-support').install();
  require('chai').should();

  var fs = require('fs'),
      showdown = require('../../../dist/showdown.js'),
      cases = fs.readdirSync('test/cases/')
        .filter(filter())
        .map(map('test/cases/')),
      issues = fs.readdirSync('test/issues/')
        .filter(filter())
        .map(map('test/issues/'));

  //Tests
  describe('Converter.makeHtml() simple testcases', function () {
    var converter = new showdown.Converter();
    for (var i = 0; i < cases.length; ++i) {
      if (cases[i].name === 'github-style-at-start') {
        console.log(showdown.getOptions());
      }
      it(cases[i].name, assertion(cases[i], converter));
    }
  });

  describe('Converter.makeHtml() issues testcase', function () {
    var converter = new showdown.Converter();
    for (var i = 0; i < issues.length; ++i) {
      it(issues[i].name, assertion(issues[i], converter));
    }
  });

  describe('Converter.options omitExtraWLInCodeBlocks', function () {
    var converter = new showdown.Converter({omitExtraWLInCodeBlocks: true}),
        text = 'var foo = bar;',
        html = converter.makeHtml('    ' + text);
    it('should omit extra line after code tag', function () {
      var expectedHtml = '<pre><code>' + text + '</code></pre>';
      html.should.equal(expectedHtml);
    });
  });

  describe('Converter.options prefixHeaderId', function () {
    var converter = new showdown.Converter(),
        text = 'foo header';

    it('should prefix header id with "section"', function () {
      converter.setOption('prefixHeaderId', true);
      var html = converter.makeHtml('# ' + text),
          expectedHtml = '<h1 id="sectionfooheader">' + text + '</h1>';
      html.should.equal(expectedHtml);
    });

    it('should prefix header id with custom string', function () {
      converter.setOption('prefixHeaderId', 'blabla');
      var html = converter.makeHtml('# ' + text),
          expectedHtml = '<h1 id="blablafooheader">' + text + '</h1>';
      html.should.equal(expectedHtml);
    });
  });

  function filter() {
    return function (file) {
      var ext = file.slice(-3);
      return (ext === '.md');
    };
  }

  function map(dir) {
    return function (file) {
      var name = file.replace('.md', ''),
          htmlPath = dir + name + '.html',
          html = fs.readFileSync(htmlPath, 'utf8'),
          mdPath = dir + name + '.md',
          md = fs.readFileSync(mdPath, 'utf8');
<commit_msg>Add test to reproduce the bug<commit_after>/**
 * Created by Estevao on 15-01-2015.
 */

(function () {
  'use strict';

  require('source-map-support').install();
  require('chai').should();

  var fs = require('fs'),
      showdown = require('../../../dist/showdown.js'),
      cases = fs.readdirSync('test/cases/')
        .filter(filter())
        .map(map('test/cases/')),
      issues = fs.readdirSync('test/issues/')
        .filter(filter())
        .map(map('test/issues/'));

  //Tests
  describe('Converter.makeHtml() simple testcases', function () {
    var converter = new showdown.Converter();
    for (var i = 0; i < cases.length; ++i) {
      if (cases[i].name === 'github-style-at-start') {
        console.log(showdown.getOptions());
      }
      it(cases[i].name, assertion(cases[i], converter));
    }
  });

  describe('Converter.makeHtml() issues testcase', function () {
    var converter = new showdown.Converter();
    for (var i = 0; i < issues.length; ++i) {
      it(issues[i].name, assertion(issues[i], converter));
    }
  });

  describe('Converter.options omitExtraWLInCodeBlocks', function () {
    var converter = new showdown.Converter({omitExtraWLInCodeBlocks: true}),
        text = 'var foo = bar;',
        html = converter.makeHtml('    ' + text);
    it('should omit extra line after code tag', function () {
      var expectedHtml = '<pre><code>' + text + '</code></pre>';
      html.should.equal(expectedHtml);
    });
  });

  describe('Converter.options prefixHeaderId', function () {
    var converter = new showdown.Converter(),
        text = 'foo header';

    it('should prefix header id with "section"', function () {
      converter.setOption('prefixHeaderId', true);
      var html = converter.makeHtml('# ' + text),
          expectedHtml = '<h1 id="sectionfooheader">' + text + '</h1>';
      html.should.equal(expectedHtml);
    });

    it('should prefix header id with custom string', function () {
      converter.setOption('prefixHeaderId', 'blabla');
      var html = converter.makeHtml('# ' + text),
          expectedHtml = '<h1 id="blablafooheader">' + text + '</h1>';
      html.should.equal(expectedHtml);
    });
  });

  describe('Converter.options extensions', function () {
    showdown.extensions.testext = function () {
      return [{
        type: 'output',
        filter: function (text) {
          runCount = runCount + 1;
          return text;
        }
      }];
    };
    var runCount,
        converter = new showdown.Converter({extensions: ['testext']});

    it('output extensions should run once', function () {
      runCount = 0;
      converter.makeHtml('# testext');
      runCount.should.equal(1);
    });
  });

  function filter() {
    return function (file) {
      var ext = file.slice(-3);
      return (ext === '.md');
    };
  }

  function map(dir) {
    return function (file) {
      var name = file.replace('.md', ''),
          htmlPath = dir + name + '.html',
          html = fs.readFileSync(htmlPath, 'utf8'),
          mdPath = dir + name + '.md',
          md = fs.readFileSync(mdPath, 'utf8');

{'fraction_non_alphanumeric': 0.1775272983444875, 'fraction_numerical': 0.006516379006692497, 'mean_word_length': 2.6828793774319064, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 19, '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': '4920898', 'n_tokens_mistral': 1760, 'n_tokens_neox': 1689, 'n_words': 390}