lib/gollum/frontend/public/javascript/editor/langs/markdown.js in gollum-1.3.1 vs lib/gollum/frontend/public/javascript/editor/langs/markdown.js in gollum-1.4.2

- old
+ new

@@ -1,78 +1,78 @@ /** * Markdown Language Definition - * - * A language definition for string manipulation operations, in this case + * + * 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 + * 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() { +(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' : { + + 'function-ul' : { search: /(.+)([\n]?)/g, replace: "* $1$2" }, - - /* This looks silly but is completely valid Markdown */ + + /* This looks silly but is completely valid Markdown */ 'function-ol' : { search: /(.+)([\n]?)/g, replace: "1. $1$2" }, - + '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', @@ -89,19 +89,19 @@ } ], OK: function( res ) { var rep = ''; if ( res['text'] && res['href'] ) { - rep = '[' + res['text'] + '](' - + res['href'] + ')'; + rep = '[' + res['text'] + '](' + + res['href'] + ')'; } $.GollumEditor.replaceSelection( rep ); } - }); + }); } }, - + 'function-image' : { exec: function( txt, selText, $field ) { var results = null; $.GollumEditor.Dialog.init({ title: 'Insert Image', @@ -126,11 +126,11 @@ $.GollumEditor.replaceSelection( rep ); } }); } } - + }; var MarkDownHelp = [ { @@ -160,52 +160,52 @@ menuName: 'Horizontal Rules', data: 'Horizontal rules are created by placing three or more hyphens, asterisks or underscores on a line by themselves. Spaces are allowed between the hyphens, asterisks or underscores.' } ] }, - + { menuName: 'Span Elements', content: [ { menuName: 'Links', data: '<p>Markdown has two types of links: <strong>inline</strong> and <strong>reference</strong>. For both types of links, the text you want to display to the user is placed in square brackets. For example, if you want your link to display the text &ldquo;GitHub&rdquo;, you write <code>[GitHub]</code>.</p><p>To create an inline link, create a set of parentheses immediately after the brackets and write your URL within the parentheses. (e.g., <code>[GitHub](http://github.com/)</code>). Relative paths are allowed in inline links.</p><p>To create a reference link, use two sets of square brackets. <code>[my internal link][internal-ref]</code> will link to the internal reference <code>internal-ref</code>.</p>' }, - + { menuName: 'Emphasis', data: '<p>Asterisks (<code>*</code>) and underscores (<code>_</code>) are treated as emphasis and are wrapped with an <code>&lt;em&gt;</code> tag, which usually displays as italics in most browsers. Double asterisks (<code>**</code>) or double underscores (<code>__</code>) are treated as bold using the <code>&lt;strong&gt;</code> tag. To create italic or bold text, simply wrap your words in single/double asterisks/underscores. For example, <code>**My double emphasis text**</code> becomes <strong>My double emphasis text</strong>, and <code>*My single emphasis text*</code> becomes <em>My single emphasis text</em>.</p>' }, - + { menuName: 'Code', data: '<p>To create inline spans of code, simply wrap the code in backticks (<code>`</code>). Markdown will turn <code>`myFunction`</code> into <code>myFunction</code>.</p>' }, - + { menuName: 'Images', data: '<p>Markdown image syntax looks a lot like the syntax for links; it is essentially the same syntax preceded by an exclamation point (<code>!</code>). For example, if you want to link to an image at <code>http://github.com/unicorn.png</code> with the alternate text <code>My Unicorn</code>, you would write <code>![My Unicorn](http://github.com/unicorn.png)</code>.</p>' } ] }, - + { menuName: 'Miscellaneous', content: [ { menuName: 'Automatic Links', data: '<p>If you want to create a link that displays the actual URL, markdown allows you to quickly wrap the URL in <code>&lt;</code> and <code>&gt;</code> to do so. For example, the link <a href="javascript:void(0);">http://github.com/</a> is easily produced by writing <code>&lt;http://github.com/&gt;</code>.</p>' }, - + { menuName: 'Escaping', data: '<p>If you want to use a special Markdown character in your document (such as displaying literal asterisks), you can escape the character with the backslash (<code>\\</code>). Markdown will ignore the character directly after a backslash.' } ] } ]; -jQuery.GollumEditor.defineLanguage('markdown', MarkDown); -jQuery.GollumEditor.defineHelp('markdown', MarkDownHelp); +$.GollumEditor.defineLanguage('markdown', MarkDown); +$.GollumEditor.defineHelp('markdown', MarkDownHelp); -})(); +})(jQuery);