<commit_before>/**
 *  Markdown Language Definition
 *
 *  A language definition for string manipulation operations, in this case
 *  for the Markdown, uh, markup language. Uses regexes for various functions
 *  by default. If regexes won't do and you need to do some serious
 *  manipulation, you can declare a function in the object instead.
 *
 *  Code example:
 *  'functionbar-id'  :   {
 *                          exec: function(text, selectedText) {
 *                                   functionStuffHere();
 *                                },
 *                          search: /somesearchregex/gi,
 *                          replace: 'replace text for RegExp.replace',
 *                          append: "just add this where the cursor is"
 *                         }
 *
**/
(function($) {

var MarkDown = {

  'function-bold' :         {
                              search: /([^\n]+)([\n\s]*)/g,
                              replace: "**$1**$2"
                            },

  'function-italic' :       {
                              search: /([^\n]+)([\n\s]*)/g,
                              replace: "_$1_$2"
                            },

  'function-code'   :       {
                              search: /([^\n]+)([\n\s]*)/g,
                              replace: "`$1`$2"
                            },

  'function-hr'     :       {
                              append: "\n***\n"
                            },

  'function-ul'     :       {
                              search: /(.+)([\n]?)/g,
                              replace: "* $1$2"
                            },
  /* based on rdoc.js */
  'function-ol'   :         {
                                exec: function( txt, selText, $field ) {
                                  var count = 1;
                                  // split into lines
                                  var repText = '';
                                  var lines = selText.split("\n");
                                  var hasContent = /[\w]+/;
                                  for ( var i = 0; i < lines.length; i++ ) {
                                    if ( hasContent.test(lines[i]) ) {
                                      repText += (i + 1).toString() + '. ' +
                                      lines[i] + "\n";
                                    }
                                  }
                                  $.GollumEditor.replaceSelection( repText );
                                }
                            },

  'function-blockquote' :   {
                              search: /(.+)([\n]?)/g,
                              replace: "> $1$2"
                            },

  'function-h1'         :   {
                              search: /(.+)([\n]?)/g,
                              replace: "# $1$2"
                            },

  'function-h2'         :   {
                              search: /(.+)([\n]?)/g,
                              replace: "## $1$2"
                            },

  'function-h3'         :   {
                              search: /(.+)([\n]?)/g,
                              replace: "### $1$2"
                            },

  'function-link'       :   {
                              exec: function( txt, selText, $field ) {
                                var results = null;
                                $.GollumEditor.Dialog.init({
                                  title: 'Insert Link',
                                  fields: [
                                    {
                                      id:   'text',
                                      name: 'Link Text',
                                      type: 'text',
                                      defaultValue: selText
                                    },
                                    {
                                      id:   'href',
                                      name: 'URL',
                                      type: 'text'
                                    }
                                  ],
                                  OK: function( res ) {
                                   var rep = '';
                                   if ( res['text'] && res['href'] ) {
                                      rep = '[' + res['text'] + '](' +
                                             res['href'] + ')';
                                    }
                                    $.GollumEditor.replaceSelection( rep );
                                  }
                                });
                              }
                            },

  'function-image'      :   {
                              exec: function( txt, selText, $field ) {
                                var results = null;
				                        var fields = [
                                  {
                                    id: 'url',
                                    name: 'Image URL',
                                    type: 'text'
                                  },
                                  {
                                    id: 'alt',
                                    name: 'Alt Text',
                                    type: 'text'
                                  }
                                ];
			                         	if (typeof(uploadDest) != undefined && filesApiSupported) {
				                          fields.push( 
				                          {
				                            id: 'image-upload',
				                            name: 'image-upload',
				                            type: 'file',
				                            target: '#gollum-editor-body',<commit_msg>Adding a better test for uploads enabled.<commit_after>/**
 *  Markdown Language Definition
 *
 *  A language definition for string manipulation operations, in this case
 *  for the Markdown, uh, markup language. Uses regexes for various functions
 *  by default. If regexes won't do and you need to do some serious
 *  manipulation, you can declare a function in the object instead.
 *
 *  Code example:
 *  'functionbar-id'  :   {
 *                          exec: function(text, selectedText) {
 *                                   functionStuffHere();
 *                                },
 *                          search: /somesearchregex/gi,
 *                          replace: 'replace text for RegExp.replace',
 *                          append: "just add this where the cursor is"
 *                         }
 *
**/
(function($) {

var MarkDown = {

  'function-bold' :         {
                              search: /([^\n]+)([\n\s]*)/g,
                              replace: "**$1**$2"
                            },

  'function-italic' :       {
                              search: /([^\n]+)([\n\s]*)/g,
                              replace: "_$1_$2"
                            },

  'function-code'   :       {
                              search: /([^\n]+)([\n\s]*)/g,
                              replace: "`$1`$2"
                            },

  'function-hr'     :       {
                              append: "\n***\n"
                            },

  'function-ul'     :       {
                              search: /(.+)([\n]?)/g,
                              replace: "* $1$2"
                            },
  /* based on rdoc.js */
  'function-ol'   :         {
                                exec: function( txt, selText, $field ) {
                                  var count = 1;
                                  // split into lines
                                  var repText = '';
                                  var lines = selText.split("\n");
                                  var hasContent = /[\w]+/;
                                  for ( var i = 0; i < lines.length; i++ ) {
                                    if ( hasContent.test(lines[i]) ) {
                                      repText += (i + 1).toString() + '. ' +
                                      lines[i] + "\n";
                                    }
                                  }
                                  $.GollumEditor.replaceSelection( repText );
                                }
                            },

  'function-blockquote' :   {
                              search: /(.+)([\n]?)/g,
                              replace: "> $1$2"
                            },

  'function-h1'         :   {
                              search: /(.+)([\n]?)/g,
                              replace: "# $1$2"
                            },

  'function-h2'         :   {
                              search: /(.+)([\n]?)/g,
                              replace: "## $1$2"
                            },

  'function-h3'         :   {
                              search: /(.+)([\n]?)/g,
                              replace: "### $1$2"
                            },

  'function-link'       :   {
                              exec: function( txt, selText, $field ) {
                                var results = null;
                                $.GollumEditor.Dialog.init({
                                  title: 'Insert Link',
                                  fields: [
                                    {
                                      id:   'text',
                                      name: 'Link Text',
                                      type: 'text',
                                      defaultValue: selText
                                    },
                                    {
                                      id:   'href',
                                      name: 'URL',
                                      type: 'text'
                                    }
                                  ],
                                  OK: function( res ) {
                                   var rep = '';
                                   if ( res['text'] && res['href'] ) {
                                      rep = '[' + res['text'] + '](' +
                                             res['href'] + ')';
                                    }
                                    $.GollumEditor.replaceSelection( rep );
                                  }
                                });
                              }
                            },

  'function-image'      :   {
                              exec: function( txt, selText, $field ) {
                                var results = null;
				                        var fields = [
                                  {
                                    id: 'url',
                                    name: 'Image URL',
                                    type: 'text'
                                  },
                                  {
                                    id: 'alt',
                                    name: 'Alt Text',
                                    type: 'text'
                                  }
                                ];
			                         	if ($('#gollum-editor.uploads-allowed').length) {
				                          fields.push( 
				                          {
				                            id: 'image-upload',
				                            name: 'image-upload',
				                            type: 'file',
				                            target: '#gollum-editor-body',
{'fraction_non_alphanumeric': 0.1063586861057439, 'fraction_numerical': 0.0038643948708940805, 'mean_word_length': 0.5086115527291998, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 96, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5449752', 'n_tokens_mistral': 2595, 'n_tokens_neox': 2370, 'n_words': 473}