<commit_before>
var _saveButtonClickHandler = null;
var _titlesShownHandler = null;
var _saveForLaterString = null;
var _savedForLaterString = null;
var _saveButtonIDPrefix = 'readmore:save:';

var shownTitles = [];

const safelyRemoveEnclosures = (string, opener, closer) => {
  const enclosureRegex = new RegExp(`\\s?[${opener}][^${opener}${closer}]+[${closer}]`, 'g');
  var previousString = null;
  var counter = 0;
  const safeMaxTries = 30;
  do {
    previousString = string;
    string = string.replace(enclosureRegex, '');
    counter++;
  } while (previousString !== string && counter < safeMaxTries);
  return string;
};

const cleanExtract = (string) => {
  string = safelyRemoveEnclosures(string, '(', ')');
  string = safelyRemoveEnclosures(string, '/', '/');
  return string;
};

class WMFPage {
    constructor(title, thumbnail, terms, extract) {
        this.title = title;
        this.thumbnail = thumbnail;
        this.terms = terms;
        this.extract = extract;
    }
}

class WMFPageFragment {
    constructor(wmfPage, index) {
        var pageContainer = document.createElement('div');
        pageContainer.id = index;
        pageContainer.className = 'footer_readmore_page';

        var containerAnchor = document.createElement('a');
        containerAnchor.href = '/wiki/' + wmfPage.title;
        pageContainer.appendChild(containerAnchor);

        var bottomActions = document.createElement('div');
        bottomActions.id = index;
        bottomActions.className = 'footer_readmore_page_actions';
        pageContainer.appendChild(bottomActions);

        if(wmfPage.title){
            var title = document.createElement('h3');
            title.id = index;
            title.className = 'footer_readmore_page_title';
            title.innerHTML = wmfPage.title.replace(/_/g, ' ');
            containerAnchor.appendChild(title);
        }

        if(wmfPage.thumbnail){
            var img = document.createElement('img');
            img.id = index;
            img.className = 'footer_readmore_page_thumbnail';
            
//TODO: inject this class name<commit_msg>Fix read more URI encoding bug.<commit_after>
var _saveButtonClickHandler = null;
var _titlesShownHandler = null;
var _saveForLaterString = null;
var _savedForLaterString = null;
var _saveButtonIDPrefix = 'readmore:save:';

var shownTitles = [];

const safelyRemoveEnclosures = (string, opener, closer) => {
  const enclosureRegex = new RegExp(`\\s?[${opener}][^${opener}${closer}]+[${closer}]`, 'g');
  var previousString = null;
  var counter = 0;
  const safeMaxTries = 30;
  do {
    previousString = string;
    string = string.replace(enclosureRegex, '');
    counter++;
  } while (previousString !== string && counter < safeMaxTries);
  return string;
};

const cleanExtract = (string) => {
  string = safelyRemoveEnclosures(string, '(', ')');
  string = safelyRemoveEnclosures(string, '/', '/');
  return string;
};

class WMFPage {
    constructor(title, thumbnail, terms, extract) {
        this.title = title;
        this.thumbnail = thumbnail;
        this.terms = terms;
        this.extract = extract;
    }
}

class WMFPageFragment {
    constructor(wmfPage, index) {
        var pageContainer = document.createElement('div');
        pageContainer.id = index;
        pageContainer.className = 'footer_readmore_page';

        var containerAnchor = document.createElement('a');
        containerAnchor.href = '/wiki/' + encodeURI(wmfPage.title);
        pageContainer.appendChild(containerAnchor);

        var bottomActions = document.createElement('div');
        bottomActions.id = index;
        bottomActions.className = 'footer_readmore_page_actions';
        pageContainer.appendChild(bottomActions);

        if(wmfPage.title){
            var title = document.createElement('h3');
            title.id = index;
            title.className = 'footer_readmore_page_title';
            title.innerHTML = wmfPage.title.replace(/_/g, ' ');
            containerAnchor.appendChild(title);
        }

        if(wmfPage.thumbnail){
            var img = document.createElement('img');
            img.id = index;
            img.className = 'footer_readmore_page_thumbnail';
            
//TODO: inject this class name
{'fraction_non_alphanumeric': 0.1255594817432273, 'fraction_numerical': 0.001884570082449941, 'mean_word_length': 3.055396370582617, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '956474', 'n_tokens_mistral': 1227, 'n_tokens_neox': 1202, 'n_words': 250}