<commit_before>var parser = require('yaml-js')

module.exports = function(string){
  var body = string
    , attributes = {}
    , match = matcher(string, '= yaml =') || matcher(string, '---')

  if (match){
    attributes = parser.load(match[2].replace(/^\s+|\s+$/g, ''))
    body = string.replace(match[0], '')
  }

  return { attributes: attributes, body: body }
}

function matcher(string, seperator){
  var seperator = seperator || '---'
    , pattern = '^('
      + seperator
      + '$([\\s\\S]*?)'
      + seperator+'$\\n)'
    , regex = new RegExp(pattern, 'm')
    , match = regex.exec(string)

  if (match && match.length > 0) return match
}<commit_msg>adding win32 support<commit_after>var parser = require('yaml-js')

module.exports = function(string){
  var body = string
    , attributes = {}
    , match = matcher(string, '= yaml =') || matcher(string, '---')

  if (match){
    attributes = parser.load(match[2].replace(/^\s+|\s+$/g, ''))
    body = string.replace(match[0], '')
  }

  return { attributes: attributes, body: body }
}

function matcher(string, seperator){
  if (process.platform === 'win32')
    var seperator = seperator || '---'
      , pattern = '^('
        + seperator
        + '$([\\s\\S]*?)'
        + seperator+'$\\r\\n)'
      , regex = new RegExp(pattern, 'm')
      , match = regex.exec(string)

  else
    var seperator = seperator || '---'
      , pattern = '^('
        + seperator
        + '$([\\s\\S]*?)'
        + seperator+'$\\n)'
      , regex = new RegExp(pattern, 'm')
      , match = regex.exec(string)

  if (match && match.length > 0) return match
}
{'fraction_non_alphanumeric': 0.20833333333333334, 'fraction_numerical': 0.006218905472636816, 'mean_word_length': 2.60762331838565, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '28355', 'n_tokens_mistral': 568, 'n_tokens_neox': 557, 'n_words': 111}