<commit_before>// Known spoiler "emotes" to avoid expanding alt-text on. Not all of these are
// known to BPM, and it's not really worth moving this to a data file somewhere.
// - /spoiler is from r/mylittlepony (and copied around like mad)
// - /s is from r/falloutequestria (and r/mylittleanime has a variant)
// - #s is from r/doctorwho
// - /b and /g are from r/dresdenfiles
var spoiler_links = ["/spoiler", "/s", "#s", "/b", "/g"];

/*
 * Sets the sourceinfo hover on an emote element.
 */
function add_sourceinfo(element, state, is_emote, is_unknown) {
    var name = element.getAttribute("data-bpm_emotename");
    var title = "";

    if(is_emote) {
        var subreddit = element.getAttribute("data-bpm_srname");

        if(state.indexOf("d") > -1) {
            title = "Disabled ";
            if(state.indexOf("n") > -1) {
                title += "NSFW ";
            }
            title += "emote ";
        }
        title += name + " from " + subreddit;
    } else if(is_unknown) {
        title = "Unknown emote " + name;
    }

    element.title = title;
}

/*
 * Decides whether or not the alt-text on this element needs to be processed.
 * Returns bpm_state if yes, null if no.
 */
function should_convert_alt_text(element, state, is_emote) {
    // Already processed? Avoid doing silly things like expanding things again
    // (or our sourceinfo hover)
    if(state.indexOf("a") > -1) {
        return false;
    }

    if(is_emote) {
        // Emotes require a sourceinfo hover, no matter what
        return true;
    }

    if(!element.title) {
        // Note, we don't bother setting state="a" in this case
        return false;
    }

    // Avoid spoiler links. We can't rely on any emote data to exist, as
    // of them aren't known as emotes
    var href = element.getAttribute("href");
    if(href && spoiler_links.indexOf(href.split("-")[0]) > -1) {
        return false;
    }

    // Work around RES putting tag links and other things with alt-text on
    // them in the middle of posts- we don't want to expand those.
    if(element.classList.contains("userTagLink") ||<commit_msg>Fix alt-text AGAIN: spoiler links were being incorrectly expanded<commit_after>// Known spoiler "emotes" to avoid expanding alt-text on. Not all of these are
// known to BPM, and it's not really worth moving this to a data file somewhere.
// - /spoiler is from r/mylittlepony (and copied around like mad)
// - /s is from r/falloutequestria (and r/mylittleanime has a variant)
// - #s is from r/doctorwho
// - /b and /g are from r/dresdenfiles
var spoiler_links = ["/spoiler", "/s", "#s", "/b", "/g"];

/*
 * Sets the sourceinfo hover on an emote element.
 */
function add_sourceinfo(element, state, is_emote, is_unknown) {
    var name = element.getAttribute("data-bpm_emotename");
    var title = "";

    if(is_emote) {
        var subreddit = element.getAttribute("data-bpm_srname");

        if(state.indexOf("d") > -1) {
            title = "Disabled ";
            if(state.indexOf("n") > -1) {
                title += "NSFW ";
            }
            title += "emote ";
        }
        title += name + " from " + subreddit;
    } else if(is_unknown) {
        title = "Unknown emote " + name;
    }

    element.title = title;
}

/*
 * Decides whether or not the alt-text on this element needs to be processed.
 * Returns bpm_state if yes, null if no.
 */
function should_convert_alt_text(element, state, is_emote) {
    // Already processed? Avoid doing silly things like expanding things again
    // (or our sourceinfo hover)
    if(state.indexOf("a") > -1) {
        return false;
    }

    // Avoid spoiler links. We can't rely on any emote data to exist, as
    // of them aren't known as emotes
    var href = element.getAttribute("href");
    if(href && spoiler_links.indexOf(href.split("-")[0]) > -1) {
        return false;
    }

    if(is_emote) {
        // Emotes require a sourceinfo hover, no matter what
        return true;
    }

    if(!element.title) {
        // Note, we don't bother setting state="a" in this case
        return false;
    }

    // Work around RES putting tag links and other things with alt-text on
    // them in the middle of posts- we don't want to expand those.
    if(element.classList.contains("userTagLink") ||
{'fraction_non_alphanumeric': 0.12296227293898462, 'fraction_numerical': 0.002328830926874709, 'mean_word_length': 2.3979430379746836, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4398699', 'n_tokens_mistral': 1346, 'n_tokens_neox': 1323, 'n_words': 458}