<commit_before>(function () {
    if (typeof tinymce !== 'undefined') {

        tinymce.create('tinymce.plugins.shortcodable', {
            getInfo: function () {
                return {
                    longname: 'Shortcodable - Shortcode UI plugin for SilverStripe',
                    author: '<NAME>',
                    authorurl: 'http://www.livesource.co.nz/',
                    infourl: 'http://www.livesource.co.nz/',
                    version: "1.0"
                };
            },

            init: function (ed, url) {
                var me = tinyMCE.activeEditor.plugins.shortcodable;

                ed.addButton('shortcodable', {
                    title: 'Insert Shortcode',
                    cmd: 'shortcodable',
                    'class': 'mce_shortcode'
                });

                ed.addCommand('shortcodable', function (ed) {
                    jQuery('#' + this.id).entwine('ss').openShortcodeDialog();
                });

                // On load replace shorcode with placeholder.
                ed.onLoadContent.add(function (ed, o) {
                    var newContent = me.replaceShortcodesWithPlaceholders(o.content, ed);
                    ed.execCommand('mceSetContent', false, newContent, false);
                });

                ed.onDblClick.add(function (ed, e) {
                    var dom = ed.dom, node = e.target;
                    if (node.nodeName === 'IMG' && dom.hasClass(node, 'shortcode-placeholder') && e.button !== 2) {
                        ed.execCommand('shortcodable');
                    }
                });
            },

            // replace shortcode strings with placeholder images
            replaceShortcodesWithPlaceholders: function (content, editor) {
                var plugin = tinyMCE.activeEditor.plugins.shortcodable;
                var placeholderClasses = jQuery('#' + editor.id).entwine('ss').getPlaceholderClasses();

                if (placeholderClasses) {
                    return content.replace(/\[([a-z]+)\s*([^\]]*)\]/gi, function (found, name, params) {
                        var id = plugin.getAttribute(params, 'id');
                        if (placeholderClasses.indexOf(name) != -1) {
                            var src = encodeURI('ShortcodableController/shortcodePlaceHolder/' + name + '/' + id + '?Shortcode=[' + name + ' ' + params + ']');
                            var img = jQuery('<img/>')
                                .attr('class', 'shortcode-placeholder mceItem')
                                .attr('title', name + ' ' + params)
                                .attr('src', src);
                            return img.prop('outerHTML');
                        }

                        return found;<commit_msg>Allow _ (underscores) in shortcode tags<commit_after>(function () {
    if (typeof tinymce !== 'undefined') {

        tinymce.create('tinymce.plugins.shortcodable', {
            getInfo: function () {
                return {
                    longname: 'Shortcodable - Shortcode UI plugin for SilverStripe',
                    author: '<NAME>',
                    authorurl: 'http://www.livesource.co.nz/',
                    infourl: 'http://www.livesource.co.nz/',
                    version: "1.0"
                };
            },

            init: function (ed, url) {
                var me = tinyMCE.activeEditor.plugins.shortcodable;

                ed.addButton('shortcodable', {
                    title: 'Insert Shortcode',
                    cmd: 'shortcodable',
                    'class': 'mce_shortcode'
                });

                ed.addCommand('shortcodable', function (ed) {
                    jQuery('#' + this.id).entwine('ss').openShortcodeDialog();
                });

                // On load replace shorcode with placeholder.
                ed.onLoadContent.add(function (ed, o) {
                    var newContent = me.replaceShortcodesWithPlaceholders(o.content, ed);
                    ed.execCommand('mceSetContent', false, newContent, false);
                });

                ed.onDblClick.add(function (ed, e) {
                    var dom = ed.dom, node = e.target;
                    if (node.nodeName === 'IMG' && dom.hasClass(node, 'shortcode-placeholder') && e.button !== 2) {
                        ed.execCommand('shortcodable');
                    }
                });
            },

            // replace shortcode strings with placeholder images
            replaceShortcodesWithPlaceholders: function (content, editor) {
                var plugin = tinyMCE.activeEditor.plugins.shortcodable;
                var placeholderClasses = jQuery('#' + editor.id).entwine('ss').getPlaceholderClasses();

                if (placeholderClasses) {
                    return content.replace(/\[([a-z_]+)\s*([^\]]*)\]/gi, function (found, name, params) {
                        var id = plugin.getAttribute(params, 'id');
                        if (placeholderClasses.indexOf(name) != -1) {
                            var src = encodeURI('ShortcodableController/shortcodePlaceHolder/' + name + '/' + id + '?Shortcode=[' + name + ' ' + params + ']');
                            var img = jQuery('<img/>')
                                .attr('class', 'shortcode-placeholder mceItem')
                                .attr('title', name + ' ' + params)
                                .attr('src', src);
                            return img.prop('outerHTML');
                        }

                        return found;
{'fraction_non_alphanumeric': 0.12802582033351265, 'fraction_numerical': 0.0014344629729245114, 'mean_word_length': 1.3261050875729774, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1524414', 'n_tokens_mistral': 1449, 'n_tokens_neox': 1341, 'n_words': 267}