<commit_before>"use strict";
var md = require("html-md");
var _ = require("lodash");

module.exports = function ($) {

  var makrdown = md($(".mw-content-ltr").html(), {
    inline: true
  });

  return getDestinations(makrdown);
};

var re = "\\[([^\\[]+)\\]\\(([^\\)]+)\\)";
var linksRe = new RegExp(re, "g");
var linksInfoRe = new RegExp(re);


function getLinkStrings(line) {
  return line.match(linksRe) || [];
}

function getLinkInfo(linkString) {
  var info = linkString.match(linksInfoRe) || [];

  if (info[2]) {
    info[2] = info[2].substring(0, info[2].indexOf(" "));
  }
  return info;
}

function hasValidLinks(links) {
  return links.length === 2 && links[0][1] && links[0][2] && links[1][1] && links[1][2];
}

function getDestination(line) {
  var links = getLinkStrings(line).map(getLinkInfo);<commit_msg>moving variables inside functions to avoid globals and use them on test<commit_after>"use strict";
var md = require("html-md");
var _ = require("lodash");

module.exports = function ($) {

  var makrdown = md($(".mw-content-ltr").html(), {
    inline: true
  });

  return getDestinations(makrdown);
};

var re = "\\[([^\\[]+)\\]\\(([^\\)]+)\\)";


function getLinkStrings(line) {
  var linksRe = new RegExp(re, "g");

  return line.match(linksRe) || [];
}

function getLinkInfo(linkString) {
  console.log(linkString);
  var linksInfoRe = new RegExp(re);
  var info = linkString.match(linksInfoRe) || [];

  if (info[2]) {
    info[2] = info[2].substring(0, info[2].indexOf(" "));
  }
  return info;
}

function hasValidLinks(links) {
  return links.length === 2 && links[0][1] && links[0][2] && links[1][1] && links[1][2];
}

function getDestination(line) {
  var links = getLinkStrings(line).map(getLinkInfo);
{'fraction_non_alphanumeric': 0.21683967704728951, 'fraction_numerical': 0.016147635524798153, 'mean_word_length': 4.27355623100304, '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': '7444564', 'n_tokens_mistral': 642, 'n_tokens_neox': 619, 'n_words': 125}