<commit_before>function (template, lang, sax, fest_ns){
    "use strict";
    var parser = sax.parser(true, {trim:false, xmlns:true}),
        opennode = false,
        lang = 0,
        lang_stack = [],
        result = '';

    function closetag(){
        if (opennode){
            opennode = false;
            result += '>';
        }
    }

    parser.onprocessinginstruction = function(instruction){
        result += '<?' + instruction.name + ' ' + instruction.body + '?>';
    }
    parser.onopentag = function(node){
        var i, l;
        closetag();
        if (node.ns[node.prefix] === fest_ns && node.local === 'lang'){
            lang++;
            return;
        }
        result += '<' + node.name;
        opennode = true;
        for (i in node.attributes){
            result += ' ' + i + '="' + node.attributes[i].value + '"';
        }
    }
    parser.ontext = parser.oncdata = function(text){
        if (lang){
            lang_stack.push(text);
            return;
        }
        closetag();
        result += text;
    }
    parser.onclosetag = function(node){
        node = this.tag;
        closetag();
        if (node.ns[node.prefix] === fest_ns && node.local === 'lang'){
            lang--;
            return;
        }
        result += '</' + node.name + '>'
    }
    parser.onend = function(){
        console.log(1111)
        closetag();
    }
    parser.onerror = function(){
        console.log(222222222222);
    }
    parser.write(template);
    //console.log(result);
    return result;
}
<commit_msg>improve langs<commit_after>function (template, lang, sax, fest_ns){
    "use strict";
    var parser = sax.parser(true, {trim:false, xmlns:true}),
        opennode = false,
        lang = 0,
        lang_stack = [],
        result = '';

    function closetag(){
        if (opennode){
            opennode = false;
            result += '>';
        }
    }

    parser.onprocessinginstruction = function(instruction){
        result += '<?' + instruction.name + ' ' + instruction.body + '?>';
    }
    parser.onopentag = function(node){
        var i, l;
        closetag();
        if (node.ns[node.prefix] === fest_ns && node.local === 'lang'){
            lang++;
            return;
        }
        result += '<' + node.name;
        opennode = true;
        for (i in node.attributes){
            result += ' ' + i + '="' + node.attributes[i].value + '"';
        }
    }
    parser.ontext = parser.oncdata = function(text){
        if (lang){
            lang_stack.push(text);
            return;
        }
        closetag();
        result += text;
    }
    parser.onclosetag = function(node){
        node = this.tag;
        closetag();
        if (node.ns[node.prefix] === fest_ns && node.local === 'lang'){
            lang--;
            return;
        }
        result += '</' + node.name + '>'
    }
    parser.write(template);
    //console.log(result);
    return result;
}

{'fraction_non_alphanumeric': 0.16097396009469056, 'fraction_numerical': 0.00608725059181603, 'mean_word_length': 1.6340160284951024, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 1, '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': '6463413', 'n_tokens_mistral': 910, 'n_tokens_neox': 890, 'n_words': 172}