<commit_before>/* global $ */
/* jshint asi:true */

var md = window.markdownit({ html: true, typographer: true })
var attr = window.markdownItAttrs
var anchor = window.markdownItAnchor
var sub = window.markdownitSub
var sup = window.markdownitSup
md.use(attr)
md.use(anchor, {permalink: true, permalinkBefore: true})
md.use(sub)
md.use(sup)

function convert (markdown) {
  var html = md.render(markdown)
  $('.container').append(html)
}

function floats () {
  $('p img').each(function () {
    var img = $(this)
    var p = img.parent()
    var div = $('<div class="figure"></div>')
    var caption = $('<p class="caption">' +
                    img.attr('alt') + '</p>')
    div.insertBefore(p)
    div.addClass('figure')
    var width = parseInt(img.attr('width'))
    div.addClass(img.attr('class'))
    div.css('width', (width + 9) + 'px')
    div.append(img)
    div.append(caption)
    p.remove()
  })
}

function headers () {
  var show = '\u25bc'
  var hide = '\u25b2'
  for (var i = 6; i >= 1; i--) {
    var stop = [];
    for (var j = 1; j <= i; j++) {
      stop.push('h' + j);
    }
    var next = stop.join(',')
    $('h' + i).each(function () {
      var header = $(this)
      var section = header.nextUntil(next)
      var div = section.wrapAll('<div></div>')
      var button = $('<span aria-hidden="true" class="collapse-button" title="Collapse">' + hide + '</span>')
      header.append(button)
      button.click(function () {
        var button = $(this)
        var header = button.parent()
        if (button.text() === show) {
          button.text(hide)
          button.attr('title', 'Collapse')
          header.removeClass('collapsed')
        } else {
          button.text(show)
          button.attr('title', 'Expand')
          header.addClass('collapsed')
        }
        div.toggle()
      })
    })
  }
}

// https://github.com/kellym/smartquotesjs
function smartquotes () {
  var root = document.body
  var node = root.childNodes[0]
  while (node !== null) {
    if (node.nodeType === 3 && node.nodeName !== 'TEXTAREA') {
      node.nodeValue = node.nodeValue
        .replace(/([-([«\s]|^)"(\S)/g, '$1\u201c$2') // beginning "
        .replace(/"/g, '\u201d') // ending "
      // .replace(/([^0-9])"/g,'$1\u201d') // remaining " at end of word
        .replace(/([0-9])('|\u2019)([0-9])/g, '$1\u2032$3') // prime
        .replace(/([-([«\u201c\s]|^)('|\u2019)(\S)/g, '$1\u2018$3') // beginning '
        .replace(/'/ig, '\u2019') // ending '
      // .replace(/((\u2018[^']*)|[a-z])'([^0-9]|$)/ig, '$1\u2019$3') // conjunction's possession
      // .replace(/(\u2018)([0-9]{2}[^\u2019]*)(\u2018([^0-9]|$)|$|\u2019[a-z])/ig, '\u2019$2$3') // abbrev. years like '93
      // .replace(/(\B|^)\u2018(?=([^\u2019]*\u2019\b)*([^\u2019\u2018]*\W[\u2019\u2018]\b|[^\u2019\u2018]*$))/ig, '$1\u2019') // backwards apostrophe
        .replace(/<-+>/g, '\u2194') // double arrow
        .replace(/<=+>/g, '\u21D4')
        .replace(/-+>/g, '\u2192') // right arrow
        .replace(/==+>/g, '\u21D2')
        .replace(/<-+?/g, '\u2190') // left arrow
        .replace(/<==+/g, '\u21D0')<commit_msg>Add support for pre-collapsed headers<commit_after>/* global $ */
/* jshint asi:true */

var md = window.markdownit({ html: true, typographer: true })
var attr = window.markdownItAttrs
var anchor = window.markdownItAnchor
var sub = window.markdownitSub
var sup = window.markdownitSup
md.use(attr)
md.use(anchor, {permalink: true, permalinkBefore: true})
md.use(sub)
md.use(sup)

function convert (markdown) {
  var html = md.render(markdown)
  $('.container').append(html)
}

function floats () {
  $('p img').each(function () {
    var img = $(this)
    var p = img.parent()
    var div = $('<div class="figure"></div>')
    var caption = $('<p class="caption">' +
                    img.attr('alt') + '</p>')
    div.insertBefore(p)
    div.addClass('figure')
    var width = parseInt(img.attr('width'))
    div.addClass(img.attr('class'))
    div.css('width', (width + 9) + 'px')
    div.append(img)
    div.append(caption)
    p.remove()
  })
}

function headers () {
  var show = '\u25bc'
  var hide = '\u25b2'
  for (var i = 6; i >= 1; i--) {
    var stop = [];
    for (var j = 1; j <= i; j++) {
      stop.push('h' + j);
    }
    var next = stop.join(',')
    $('h' + i).each(function () {
      var header = $(this)
      var section = header.nextUntil(next)
      var div = section.wrapAll('<div></div>')
      var button = $('<span aria-hidden="true" class="collapse-button" title="Collapse">' + hide + '</span>')
      header.append(button)
      button.click(function () {
        var button = $(this)
        var header = button.parent()
        if (button.text() === show) {
          button.text(hide)
          button.attr('title', 'Collapse')
          header.removeClass('collapsed')
        } else {
          button.text(show)
          button.attr('title', 'Expand')
          header.addClass('collapsed')
        }
        div.toggle()
      })
      if (header.hasClass('collapsed')) {
        button.click()
      }
    })
  }
}

// https://github.com/kellym/smartquotesjs
function smartquotes () {
  var root = document.body
  var node = root.childNodes[0]
  while (node !== null) {
    if (node.nodeType === 3 && node.nodeName !== 'TEXTAREA') {
      node.nodeValue = node.nodeValue
        .replace(/([-([«\s]|^)"(\S)/g, '$1\u201c$2') // beginning "
        .replace(/"/g, '\u201d') // ending "
      // .replace(/([^0-9])"/g,'$1\u201d') // remaining " at end of word
        .replace(/([0-9])('|\u2019)([0-9])/g, '$1\u2032$3') // prime
        .replace(/([-([«\u201c\s]|^)('|\u2019)(\S)/g, '$1\u2018$3') // beginning '
        .replace(/'/ig, '\u2019') // ending '
      // .replace(/((\u2018[^']*)|[a-z])'([^0-9]|$)/ig, '$1\u2019$3') // conjunction's possession
      // .replace(/(\u2018)([0-9]{2}[^\u2019]*)(\u2018([^0-9]|$)|$|\u2019[a-z])/ig, '\u2019$2$3') // abbrev. years like '93
      // .replace(/(\B|^)\u2018(?=([^\u2019]*\u2019\b)*([^\u2019\u2018]*\W[\u2019\u2018]\b|[^\u2019\u2018]*$))/ig, '$1\u2019') // backwards apostrophe
        .replace(/<-+>/g, '\u2194') // double arrow
        .replace(/<=+>/g, '\u21D4')
        .replace(/-+>/g, '\u2192') // right arrow
        .replace(/==+>/g, '\u21D2')
        .replace(/<-+?/g, '\u2190') // left arrow
        .replace(/<==+/g, '\u21D0')
{'fraction_non_alphanumeric': 0.23918855165906588, 'fraction_numerical': 0.05000786287152068, 'mean_word_length': 2.454644215100489, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 2, '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': '856947', 'n_tokens_mistral': 2534, 'n_tokens_neox': 2309, 'n_words': 438}