Fix invalid syntax, leaky vars and trailing whitespace in lang JS

This commit is contained in:
Joshua Peek
2011-09-26 17:35:39 -05:00
parent fced891975
commit 7829e17c27
7 changed files with 146 additions and 146 deletions
+18 -19
View File
@@ -3,40 +3,40 @@
* *
*/ */
(function() { (function($) {
var ASCIIDoc = { var ASCIIDoc = {
'function-bold' : { 'function-bold' : {
search: /(^[\n]+)([\n\s]*)/g, search: /(^[\n]+)([\n\s]*)/g,
replace: "*$1*$2" replace: "*$1*$2"
}, },
'function-italic' : { 'function-italic' : {
search: /(^[\n]+)([\n\s]*)/g, search: /(^[\n]+)([\n\s]*)/g,
replace: "_$1_$2" replace: "_$1_$2"
}, },
'function-code' : { 'function-code' : {
search: /(^[\n]+)([\n\s]*)/g, search: /(^[\n]+)([\n\s]*)/g,
replace: "+$1+$2" replace: "+$1+$2"
}, },
'function-ul' : { 'function-ul' : {
search: /(^[\n]+)([\n\s]*)/g, search: /(^[\n]+)([\n\s]*)/g,
replace: "* $1$2" replace: "* $1$2"
}, },
'function-ol' : { 'function-ol' : {
search: /(.+)([\n]?)/g, search: /(.+)([\n]?)/g,
replace: ". $1$2" replace: ". $1$2"
}, },
'function-blockquote' : { 'function-blockquote' : {
search: /(.+)([\n]?)/g, search: /(.+)([\n]?)/g,
replace: "----\n$1$2\n----\n" replace: "----\n$1$2\n----\n"
}, },
'function-link' : { 'function-link' : {
exec: function( txt, selText, $field ) { exec: function( txt, selText, $field ) {
var results = null; var results = null;
@@ -59,17 +59,17 @@ var ASCIIDoc = {
OK: function( res ) { OK: function( res ) {
var h = ''; var h = '';
if ( res['text'] && res['href'] ) { if ( res['text'] && res['href'] ) {
h = res['href'] + '[' + h = res['href'] + '[' +
res['text'] + ']'; res['text'] + ']';
} }
$.GollumEditor.replaceSelection( h ); $.GollumEditor.replaceSelection( h );
} }
}); });
} }
}, },
'function-image' : { 'function-image' : {
exec: function( txt, selText, $field ) { exec: function( txt, selText, $field ) {
var results = null; var results = null;
@@ -98,10 +98,10 @@ var ASCIIDoc = {
}); });
} }
} }
}; };
jQuery.GollumEditor.defineLanguage('asciidoc', ASCIIDoc); $.GollumEditor.defineLanguage('asciidoc', ASCIIDoc);
var ASCIIDocHelp = [ var ASCIIDocHelp = [
@@ -158,11 +158,10 @@ var ASCIIDocHelp = [
menuName: 'Images', menuName: 'Images',
data: '<p>Images in ASCIIDoc work much like hyperlinks, but image URLs are prefixed with <code>image:</code>. For example, to link to an image at <code>images/icons/home.png</code>, write <code>image:images/icons/home.png</code>. Alt text can be added by appending the text to the URI in <code>[</code> (brackets).</p>' data: '<p>Images in ASCIIDoc work much like hyperlinks, but image URLs are prefixed with <code>image:</code>. For example, to link to an image at <code>images/icons/home.png</code>, write <code>image:images/icons/home.png</code>. Alt text can be added by appending the text to the URI in <code>[</code> (brackets).</p>'
} }
] ]
} }
]; ];
jQuery.GollumEditor.defineHelp('asciidoc', ASCIIDocHelp); $.GollumEditor.defineHelp('asciidoc', ASCIIDocHelp);
})();
})(jQuery);
@@ -2,40 +2,40 @@
* Creole Language Definition * Creole Language Definition
* *
*/ */
(function() { (function($) {
var Creole = { var Creole = {
'function-bold' : { 'function-bold' : {
search: /([^\n]+)([\n]*)/gi, search: /([^\n]+)([\n]*)/gi,
replace: "**$1**$2" replace: "**$1**$2"
}, },
'function-italic' : { 'function-italic' : {
search: /([^\n]+)([\n]*)/gi, search: /([^\n]+)([\n]*)/gi,
replace: "//$1//$2" replace: "//$1//$2"
}, },
'function-code' : { 'function-code' : {
search: /([^\n]+)([\n]*)/gi, search: /([^\n]+)([\n]*)/gi,
replace: "{{{$1}}}$2" replace: "{{{$1}}}$2"
}, },
'function-hr' : { 'function-hr' : {
append: "\n\n----\n\n"; append: "\n\n----\n\n"
}, },
'function-ul' : { 'function-ul' : {
search: /(.+)([\n]?)/gi, search: /(.+)([\n]?)/gi,
replace: "* $1$2" replace: "* $1$2"
}, },
/* This looks silly but is completely valid Markdown */ /* This looks silly but is completely valid Markdown */
'function-ol' : { 'function-ol' : {
search: /(.+)([\n]?)/gi, search: /(.+)([\n]?)/gi,
replace: "# $1$2" replace: "# $1$2"
}, },
'function-link' : { 'function-link' : {
exec: function( txt, selText, $field ) { exec: function( txt, selText, $field ) {
var results = null; var results = null;
@@ -56,16 +56,16 @@ var Creole = {
} }
], ],
OK: function( res ) { OK: function( res ) {
var h = '[[' + res['href'] + '|' + var h = '[[' + res['href'] + '|' +
res['text'] + ']]'; res['text'] + ']]';
$.GollumEditor.replaceSelection( h ); $.GollumEditor.replaceSelection( h );
} }
}); });
} }
}, },
'function-image' : { 'function-image' : {
exec: function( txt, selText, $field ) { exec: function( txt, selText, $field ) {
var results = null; var results = null;
@@ -84,8 +84,9 @@ var Creole = {
} }
], ],
OK: function( res ) { OK: function( res ) {
var h = '';
if ( res['url'] && res['alt'] ) { if ( res['url'] && res['alt'] ) {
var h = '{{' + res['url']; h = '{{' + res['url'];
if ( res['alt'] != '' ) { if ( res['alt'] != '' ) {
h += '|' + res['alt'] + '}}'; h += '|' + res['alt'] + '}}';
} }
@@ -95,9 +96,9 @@ var Creole = {
}); });
} }
} }
}; };
jQuery.GollumEditor.defineLanguage('creole', Creole); $.GollumEditor.defineLanguage('creole', Creole);
})(); })(jQuery);
+33 -33
View File
@@ -1,9 +1,9 @@
/** /**
* Markdown Language Definition * 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 * 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. * manipulation, you can declare a function in the object instead.
* *
* Code example: * Code example:
@@ -14,63 +14,63 @@
* search: /somesearchregex/gi, * search: /somesearchregex/gi,
* replace: 'replace text for RegExp.replace', * replace: 'replace text for RegExp.replace',
* append: "just add this where the cursor is" * append: "just add this where the cursor is"
* } * }
* *
**/ **/
(function() { (function($) {
var MarkDown = { var MarkDown = {
'function-bold' : { 'function-bold' : {
search: /([^\n]+)([\n\s]*)/g, search: /([^\n]+)([\n\s]*)/g,
replace: "**$1**$2" replace: "**$1**$2"
}, },
'function-italic' : { 'function-italic' : {
search: /([^\n]+)([\n\s]*)/g, search: /([^\n]+)([\n\s]*)/g,
replace: "_$1_$2" replace: "_$1_$2"
}, },
'function-code' : { 'function-code' : {
search: /(^[\n]+)([\n\s]*)/g, search: /(^[\n]+)([\n\s]*)/g,
replace: "`$1`$2" replace: "`$1`$2"
}, },
'function-hr' : { 'function-hr' : {
append: "\n***\n" append: "\n***\n"
}, },
'function-ul' : { 'function-ul' : {
search: /(.+)([\n]?)/g, search: /(.+)([\n]?)/g,
replace: "* $1$2" replace: "* $1$2"
}, },
/* This looks silly but is completely valid Markdown */ /* This looks silly but is completely valid Markdown */
'function-ol' : { 'function-ol' : {
search: /(.+)([\n]?)/g, search: /(.+)([\n]?)/g,
replace: "1. $1$2" replace: "1. $1$2"
}, },
'function-blockquote' : { 'function-blockquote' : {
search: /(.+)([\n]?)/g, search: /(.+)([\n]?)/g,
replace: "> $1$2" replace: "> $1$2"
}, },
'function-h1' : { 'function-h1' : {
search: /(.+)([\n]?)/g, search: /(.+)([\n]?)/g,
replace: "# $1$2" replace: "# $1$2"
}, },
'function-h2' : { 'function-h2' : {
search: /(.+)([\n]?)/g, search: /(.+)([\n]?)/g,
replace: "## $1$2" replace: "## $1$2"
}, },
'function-h3' : { 'function-h3' : {
search: /(.+)([\n]?)/g, search: /(.+)([\n]?)/g,
replace: "### $1$2" replace: "### $1$2"
}, },
'function-link' : { 'function-link' : {
exec: function( txt, selText, $field ) { exec: function( txt, selText, $field ) {
var results = null; var results = null;
@@ -91,15 +91,15 @@ var MarkDown = {
OK: function( res ) { OK: function( res ) {
var rep = ''; var rep = '';
if ( res['text'] && res['href'] ) { if ( res['text'] && res['href'] ) {
rep = '[' + res['text'] + '](' rep = '[' + res['text'] + '](' +
+ res['href'] + ')'; res['href'] + ')';
} }
$.GollumEditor.replaceSelection( rep ); $.GollumEditor.replaceSelection( rep );
} }
}); });
} }
}, },
'function-image' : { 'function-image' : {
exec: function( txt, selText, $field ) { exec: function( txt, selText, $field ) {
var results = null; var results = null;
@@ -128,7 +128,7 @@ var MarkDown = {
}); });
} }
} }
}; };
var MarkDownHelp = [ var MarkDownHelp = [
@@ -162,7 +162,7 @@ var MarkDownHelp = [
} }
] ]
}, },
{ {
menuName: 'Span Elements', menuName: 'Span Elements',
content: [ content: [
@@ -170,24 +170,24 @@ var MarkDownHelp = [
menuName: 'Links', 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>' 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', 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>' 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', 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>' 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', 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>' 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', menuName: 'Miscellaneous',
content: [ content: [
@@ -195,7 +195,7 @@ var MarkDownHelp = [
menuName: 'Automatic Links', 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>' 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', 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.' 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.'
@@ -205,7 +205,7 @@ var MarkDownHelp = [
]; ];
jQuery.GollumEditor.defineLanguage('markdown', MarkDown); $.GollumEditor.defineLanguage('markdown', MarkDown);
jQuery.GollumEditor.defineHelp('markdown', MarkDownHelp); $.GollumEditor.defineHelp('markdown', MarkDownHelp);
})(); })(jQuery);
@@ -1,36 +1,36 @@
/** /**
* Org-mode Language Definition * Org-mode Language Definition
**/ **/
(function() { (function($) {
var OrgMode = { var OrgMode = {
'function-bold' : { 'function-bold' : {
search: /([^\n]+)([\n\s]*)/g, search: /([^\n]+)([\n\s]*)/g,
replace: "*$1*$2" replace: "*$1*$2"
}, },
'function-italic' : { 'function-italic' : {
search: /([^\n]+)([\n\s]*)/g, search: /([^\n]+)([\n\s]*)/g,
replace: "/$1/$2" replace: "/$1/$2"
}, },
'function-code' : { 'function-code' : {
search: /(^[\n]+)([\n\s]*)/g, search: /(^[\n]+)([\n\s]*)/g,
replace: "=$1=$2" replace: "=$1=$2"
}, },
'function-ul' : { 'function-ul' : {
search: /(.+)([\n]?)/g, search: /(.+)([\n]?)/g,
replace: "* $1$2" replace: "* $1$2"
}, },
/* This works, just like it works for Markdown */ /* This works, just like it works for Markdown */
'function-ol' : { 'function-ol' : {
search: /(.+)([\n]?)/g, search: /(.+)([\n]?)/g,
replace: "1. $1$2" replace: "1. $1$2"
}, },
'function-blockquote' : { 'function-blockquote' : {
search: /(.+)([\n]?)/g, search: /(.+)([\n]?)/g,
replace: "#+BEGIN_QUOTE\n$1$2\n#+END_QUOTE\n" replace: "#+BEGIN_QUOTE\n$1$2\n#+END_QUOTE\n"
@@ -40,17 +40,17 @@ var OrgMode = {
search: /(.+)([\n]?)/g, search: /(.+)([\n]?)/g,
replace: "* $1$2" replace: "* $1$2"
}, },
'function-h2' : { 'function-h2' : {
search: /(.+)([\n]?)/g, search: /(.+)([\n]?)/g,
replace: "** $1$2" replace: "** $1$2"
}, },
'function-h3' : { 'function-h3' : {
search: /(.+)([\n]?)/g, search: /(.+)([\n]?)/g,
replace: "*** $1$2" replace: "*** $1$2"
}, },
'function-link' : { 'function-link' : {
exec: function( txt, selText, $field ) { exec: function( txt, selText, $field ) {
var results = null; var results = null;
@@ -71,18 +71,18 @@ var OrgMode = {
OK: function( res ) { OK: function( res ) {
var rep = ''; var rep = '';
if ( res['text'] && res['href'] ) { if ( res['text'] && res['href'] ) {
rep = '[[' + res['href'] + '][' rep = '[[' + res['href'] + '][' +
+ res['text'] + ']]'; res['text'] + ']]';
} }
else if ( res['href'] ) { else if ( res['href'] ) {
rep = '[[' + res['href'] + ']]'; rep = '[[' + res['href'] + ']]';
} }
$.GollumEditor.replaceSelection( rep ); $.GollumEditor.replaceSelection( rep );
} }
}); });
} }
}, },
'function-image' : { 'function-image' : {
exec: function( txt, selText, $field ) { exec: function( txt, selText, $field ) {
var results = null; var results = null;
@@ -93,7 +93,7 @@ var OrgMode = {
id: 'url', id: 'url',
name: 'Image URL', name: 'Image URL',
type: 'text' type: 'text'
}, }
], ],
OK: function( res ) { OK: function( res ) {
var rep = ''; var rep = '';
@@ -105,7 +105,7 @@ var OrgMode = {
}); });
} }
} }
}; };
var OrgModeHelp = [ var OrgModeHelp = [
@@ -136,10 +136,10 @@ var OrgModeHelp = [
{ {
menuName: 'Tables', menuName: 'Tables',
data: '<p>Org-mode supports simple tables (tables with equal number of cells in each row). To create a simple table, just separate the contents of each cell with a <code>|</code> character. For example, <br><br><code>|one|two|three|<br>|four|five|six|</code><br><br> will appear as a table with two rows and three columns. Additionally, <br><br><code>|one|two|three|<br>|---+---+-----|<br>|four|five|six|</code><br><br> will also appear as a table, but the first row will be interpreted as a header row and the <code>&lt;th&gt;</code> tag will be used to render it. </p>' data: '<p>Org-mode supports simple tables (tables with equal number of cells in each row). To create a simple table, just separate the contents of each cell with a <code>|</code> character. For example, <br><br><code>|one|two|three|<br>|four|five|six|</code><br><br> will appear as a table with two rows and three columns. Additionally, <br><br><code>|one|two|three|<br>|---+---+-----|<br>|four|five|six|</code><br><br> will also appear as a table, but the first row will be interpreted as a header row and the <code>&lt;th&gt;</code> tag will be used to render it. </p>'
}, }
] ]
}, },
{ {
menuName: 'Span Elements', menuName: 'Span Elements',
content: [ content: [
@@ -147,27 +147,27 @@ var OrgModeHelp = [
menuName: 'Links', menuName: 'Links',
data: '<p>To create links to external pages, you need to enclose the URI in double square brackets. (i.e., <code>[[http://github.com/]]</code> will automatically be parsed to <a href="javascript:void(0);">http://github.com/</a>)If you want to add text, to be displayed to the user, you write the URI and the text next to each other, both enclosed in square brackets and both of them together enclosed in another pair of square brackets. For example, if you want your link to display the text &ldquo;GitHub&rdquo;, you write <code>[[http://github.com][GitHub]]</code>.</p>' data: '<p>To create links to external pages, you need to enclose the URI in double square brackets. (i.e., <code>[[http://github.com/]]</code> will automatically be parsed to <a href="javascript:void(0);">http://github.com/</a>)If you want to add text, to be displayed to the user, you write the URI and the text next to each other, both enclosed in square brackets and both of them together enclosed in another pair of square brackets. For example, if you want your link to display the text &ldquo;GitHub&rdquo;, you write <code>[[http://github.com][GitHub]]</code>.</p>'
}, },
{ {
menuName: 'Emphasis', menuName: 'Emphasis',
data: '<p>Forward slashes (<code>/</code>) are treated as emphasis and are wrapped with an <code>&lt;i&gt;</code> tag. Asterisks (<code>*</code>) are treated as bold using the <code>&lt;b&gt;</code> tag.</p>' data: '<p>Forward slashes (<code>/</code>) are treated as emphasis and are wrapped with an <code>&lt;i&gt;</code> tag. Asterisks (<code>*</code>) are treated as bold using the <code>&lt;b&gt;</code> tag.</p>'
}, },
{ {
menuName: 'Code', menuName: 'Code',
data: '<p>To create inline spans of code, simply wrap the code in equal signs (<code>=</code>). Orgmode will turn <code>=myFunction=</code> into <code>myFunction</code>.</p>' data: '<p>To create inline spans of code, simply wrap the code in equal signs (<code>=</code>). Orgmode will turn <code>=myFunction=</code> into <code>myFunction</code>.</p>'
}, },
{ {
menuName: 'Images', menuName: 'Images',
data: "<p>Org-mode image syntax is exactly same as the syntax that you would use for a URI to link to itself. The image URI is enclosed in double square brackets. Alt text on images is not currently supported by Gollum's Org-mode parser.</p>" data: "<p>Org-mode image syntax is exactly same as the syntax that you would use for a URI to link to itself. The image URI is enclosed in double square brackets. Alt text on images is not currently supported by Gollum's Org-mode parser.</p>"
} }
] ]
}, }
]; ];
jQuery.GollumEditor.defineLanguage('org', OrgMode); $.GollumEditor.defineLanguage('org', OrgMode);
jQuery.GollumEditor.defineHelp('org', OrgModeHelp); $.GollumEditor.defineHelp('org', OrgModeHelp);
})(); })(jQuery);
+15 -15
View File
@@ -1,40 +1,40 @@
/** /**
* Pod Language Definition * Pod Language Definition
**/ **/
(function() { (function($) {
var Pod = { var Pod = {
'function-bold' : { 'function-bold' : {
search: /(^[\n]+)([\n\s]*)/g, search: /(^[\n]+)([\n\s]*)/g,
replace: "B<$1>$2" replace: "B<$1>$2"
}, },
'function-italic' : { 'function-italic' : {
search: /(^[\n]+)([\n\s]*)/g, search: /(^[\n]+)([\n\s]*)/g,
replace: "I<$1>$2" replace: "I<$1>$2"
}, },
'function-code' : { 'function-code' : {
search: /(^[\n]+)([\n\s]*)/g, search: /(^[\n]+)([\n\s]*)/g,
replace: "C<$1>$2" replace: "C<$1>$2"
}, },
'function-h1' : { 'function-h1' : {
search: /(.+)([\n]?)/gi, search: /(.+)([\n]?)/gi,
replace: "=head1 $1$2" replace: "=head1 $1$2"
}, },
'function-h2' : { 'function-h2' : {
search: /(.+)([\n]?)/gi, search: /(.+)([\n]?)/gi,
replace: "=head2 $1$2" replace: "=head2 $1$2"
}, },
'function-h3' : { 'function-h3' : {
search: /(.+)([\n]?)/gi, search: /(.+)([\n]?)/gi,
replace: "=head3 $1$2" replace: "=head3 $1$2"
}, },
'function-link' : { 'function-link' : {
exec: function( txt, selText, $field ) { exec: function( txt, selText, $field ) {
var results = null; var results = null;
@@ -55,18 +55,18 @@ var Pod = {
OK: function( res ) { OK: function( res ) {
var rep = ''; var rep = '';
if ( res['text'] && res['href'] ) { if ( res['text'] && res['href'] ) {
rep = 'L<' + res['text'] + '|' rep = 'L<' + res['text'] + '|' +
+ res['href'] + '>'; res['href'] + '>';
} }
$.GollumEditor.replaceSelection( rep ); $.GollumEditor.replaceSelection( rep );
} }
}); });
} }
} }
}; };
jQuery.GollumEditor.defineLanguage('pod', Pod); $.GollumEditor.defineLanguage('pod', Pod);
var PodHelp = [ var PodHelp = [
@@ -106,6 +106,6 @@ var PodHelp = [
} }
]; ];
jQuery.GollumEditor.defineHelp('pod', PodHelp); $.GollumEditor.defineHelp('pod', PodHelp);
})(); })(jQuery);
+16 -16
View File
@@ -1,9 +1,9 @@
/** /**
* Markdown Language Definition * 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 * 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. * manipulation, you can declare a function in the object instead.
* *
* Code example: * Code example:
@@ -14,27 +14,27 @@
* search: /somesearchregex/gi, * search: /somesearchregex/gi,
* replace: 'replace text for RegExp.replace', * replace: 'replace text for RegExp.replace',
* append: "just add this where the cursor is" * append: "just add this where the cursor is"
* } * }
* *
**/ **/
(function() { (function($) {
var RDoc = { var RDoc = {
'function-bold' : { 'function-bold' : {
search: /([^\n]+)([\n\s]*)/g, search: /([^\n]+)([\n\s]*)/g,
replace: "((*$1*))$2" replace: "((*$1*))$2"
} },
'function-code' : { 'function-code' : {
search: /([^\n]+)([\n\s]*)/g, search: /([^\n]+)([\n\s]*)/g,
replace: "(({$1}))$2" replace: "(({$1}))$2"
}, },
'function-ul' : { 'function-ul' : {
search: /(.+)([\n]?)/gi, search: /(.+)([\n]?)/gi,
replace: "* $1$2" replace: "* $1$2"
}, },
'function-ol' : { 'function-ol' : {
exec: function( txt, selText, $field ) { exec: function( txt, selText, $field ) {
var count = 1; var count = 1;
@@ -51,24 +51,24 @@ var RDoc = {
$.GollumEditor.replaceSelection( repText ); $.GollumEditor.replaceSelection( repText );
} }
}, },
'function-h1' : { 'function-h1' : {
search: /(.+)([\n]?)/gi, search: /(.+)([\n]?)/gi,
replace: "= $1$2" replace: "= $1$2"
}, },
'function-h2' : { 'function-h2' : {
search: /(.+)([\n]?)/gi, search: /(.+)([\n]?)/gi,
replace: "== $1$2" replace: "== $1$2"
}, },
'function-h3' : { 'function-h3' : {
search: /(.+)([\n]?)/gi, search: /(.+)([\n]?)/gi,
replace: "=== $1$2" replace: "=== $1$2"
} }
}; };
jQuery.GollumEditor.defineLanguage('rdoc', RDoc); $.GollumEditor.defineLanguage('rdoc', RDoc);
})(); })(jQuery);
+17 -17
View File
@@ -1,44 +1,44 @@
/** /**
* Textile Language Definition * Textile Language Definition
*/ */
(function() { (function($) {
var Textile = { var Textile = {
'function-bold' : { 'function-bold' : {
search: /(^[\n]+)([\n\s]*)/g, search: /(^[\n]+)([\n\s]*)/g,
replace: "*$1*$2" replace: "*$1*$2"
}, },
'function-italic' : { 'function-italic' : {
search: /(^[\n]+)([\n\s]*)/g, search: /(^[\n]+)([\n\s]*)/g,
replace: "_$1_$2" replace: "_$1_$2"
}, },
'function-hr' : { 'function-hr' : {
append: "\n***\n" append: "\n***\n"
}, },
'function-code' : { 'function-code' : {
search: /(^[\n]+)([\n\s]*)/g, search: /(^[\n]+)([\n\s]*)/g,
replace: "<pre><code>$1</code></pre>$2" replace: "<pre><code>$1</code></pre>$2"
}, },
'function-ul' : { 'function-ul' : {
search: /(.+)([\n]?)/gi, search: /(.+)([\n]?)/gi,
replace: "* $1$2" replace: "* $1$2"
}, },
'function-ol' : { 'function-ol' : {
search: /(.+)([\n]?)/gi, search: /(.+)([\n]?)/gi,
replace: "# $1$2" replace: "# $1$2"
}, },
'function-blockquote' : { 'function-blockquote' : {
search: /(.+)([\n]?)/gi, search: /(.+)([\n]?)/gi,
replace: "bq. $1$2" replace: "bq. $1$2"
}, },
'function-link' : { 'function-link' : {
exec: function( txt, selText, $field ) { exec: function( txt, selText, $field ) {
var results = null; var results = null;
@@ -67,11 +67,11 @@ var Textile = {
$.GollumEditor.replaceSelection( h ); $.GollumEditor.replaceSelection( h );
} }
}); });
} }
}, },
'function-image' : { 'function-image' : {
exec: function( txt, selText, $field ) { exec: function( txt, selText, $field ) {
var results = null; var results = null;
@@ -102,10 +102,10 @@ var Textile = {
}); });
} }
} }
}; };
jQuery.GollumEditor.defineLanguage('textile', Textile); $.GollumEditor.defineLanguage('textile', Textile);
var TextileHelp = [ var TextileHelp = [
@@ -170,6 +170,6 @@ var TextileHelp = [
} }
]; ];
jQuery.GollumEditor.defineHelp('textile', TextileHelp); $.GollumEditor.defineHelp('textile', TextileHelp);
})(); })(jQuery);