<commit_before>'use strict'

module.exports = userscriptParser

/**
 * Userscript format:
 * http://wiki.greasespot.net/Metadata_Block
 */

function userscriptParser (userscriptText) {
  //
  let meta = {}

  try {
    const metaBlockPattern = /^[\S\s]+\/\/ ==\/UserScript==/
    const metaBlock = userscriptText.match(metaBlockPattern)[0]
    const cleanMeta = metaBlock.replace(/ +/, ' ')
    const metaArray = cleanMeta.match(/\/\/ @\w+ .+/g)

    metaArray.forEach(function (m) {
      const parts = m.match(/@(\w+)\s+(.+)/)
      meta[parts[1]] = meta[parts[1]] || []
      meta[parts[1]].push(parts[2])
    })

    meta.content = userscriptText.replace(metaBlockPattern, '')

  } catch(e) {
    if (console) console.log(e)
    return false
  }

  return meta
}
<commit_msg>(fix) allow whitespace in metadata, again.<commit_after>'use strict'

module.exports = userscriptParser

/**
 * Userscript format:
 * http://wiki.greasespot.net/Metadata_Block
 */

function userscriptParser (userscriptText) {
  //
  let meta = {}

  try {
    const metaBlockPattern = /^[\S\s]+\/\/ ==\/UserScript==/
    const metaBlock = userscriptText.match(metaBlockPattern)[0]
    const cleanMeta = metaBlock.replace(/ +/, ' ')
    const metaArray = cleanMeta.match(/\/\/\s+@\w+ .+/g)

    metaArray.forEach(function (m) {
      const parts = m.match(/@(\w+)\s+(.+)/)
      meta[parts[1]] = meta[parts[1]] || []
      meta[parts[1]].push(parts[2])
    })

    meta.content = userscriptText.replace(metaBlockPattern, '')

  } catch(e) {
    if (console) console.log(e)
    return false
  }

  return meta
}

{'fraction_non_alphanumeric': 0.18628067967275017, 'fraction_numerical': 0.0062932662051604785, 'mean_word_length': 2.9849624060150375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4052891', 'n_tokens_mistral': 557, 'n_tokens_neox': 542, 'n_words': 96}