DRY language definitions (#1411)

* Dryer language defs
* Fix markup modes after move to Primer
* Fix rest function buttons
This commit is contained in:
Dawa Ometto
2019-09-03 11:58:17 +02:00
committed by GitHub
parent 77aaeef5ff
commit 3740a7f6ff
12 changed files with 591 additions and 1257 deletions
@@ -6,6 +6,7 @@
//= require gollum.dialog
//= require gollum.placeholder
//= require editor/gollum.editor
//= require editor/langs/default
//= require_tree ./editor/langs
//= require ace/ace
//= require ace/mode-markdown
@@ -162,7 +162,6 @@
$(this).parent().toggleClass('collapsed');
buttons = $(this).parent().children("button");
console.log(buttons);
hidden_button = buttons.filter(':hidden')[0];
shown_button = buttons.not(':hidden')[0];
hidden_button.hidden = false;
@@ -623,7 +622,6 @@
isActive: false,
/**
* FunctionBar.activate
* Activates the function bar, attaching all click events
@@ -638,9 +636,11 @@
if ( LanguageDefinition.getDefinitionFor( $(this).attr('id') ) ) {
$(this).click( FunctionBar.evtFunctionButtonClick );
$(this).removeClass('disabled');
$(this).attr('disabled', false);
}
else if ( !['function-help', 'function-text-direction'].includes( $(this).attr('id') ) ) {
$(this).addClass('disabled');
$(this).attr('disabled', true);
}
});
@@ -651,7 +651,7 @@
deactivate: function() {
$('#gollum-editor-function-bar a.function-button').unbind('click');
$('#gollum-editor-function-bar button.function-button').unbind('click');
$('#gollum-editor-function-bar').removeClass( 'active' );
FunctionBar.isActive = false;
},
@@ -713,7 +713,7 @@
// the text area, but on the editor. But since a lot functions
// does not use the third args, this works in these cases. But
// we shall fix it.
definitionObject.exec( txt, selText, $('#gollum-editor-body') );
definitionObject.exec( txt, selText, $('#gollum-editor-body'), selRange );
return;
}
@@ -786,7 +786,7 @@
if ( EditorHas.functionBar() ) {
debug('Refreshing function bar');
if ( LanguageDefinition.isValid() ) {
$('#gollum-editor-function-bar a.function-button').unbind('click');
$('#gollum-editor-function-bar button.function-button').unbind('click');
FunctionBar.activate();
if ( Help ) {
Help.setActiveHelp( LanguageDefinition.getActiveLanguage() );
@@ -1,172 +1,58 @@
/**
* AsciiDoc Language Definition
* See default.js for documentation
*
*/
(function($) {
// No need to set all the replacements, only those different from the default language (Markdown).
var AsciiDoc = {
'function-bold': {
search: /([^\n]+)([\n\s]*)/g,
replace: "*$1*$2"
'replace': "*$1*$2"
},
'function-italic' : {
search: /([^\n]+)([\n\s]*)/g,
replace: "_$1_$2"
},
'function-code' : {
search: /([^\n]+)([\n\s]*)/g,
replace: "`$1`$2"
},
'function-ul' : {
exec: function( txt, selText, $field ) {
var repText = '';
var lines = selText.split("\n");
for ( var i = 0; i < lines.length; i++ ) {
repText += '* ' + lines[i] + "\n";
}
repText = repText.substring(0, repText.length-1)
$.GollumEditor.replaceSelection( repText, true, true );
},
},
'function-ol' : {
exec: function( txt, selText, $field ) {
var repText = '';
var lines = selText.split("\n");
for ( var i = 0; i < lines.length; i++ ) {
repText += '. ' + lines[i] + "\n";
}
repText = repText.substring(0, repText.length-1)
$.GollumEditor.replaceSelection( repText, true, true );
},
},
'function-hr': undefined,
'function-blockquote': {
search: /(.+)([\n]?)/g,
replace: "----\n$1$2\n----",
break_line: true,
'replace': "----\n$1$2\n----"
},
'function-h1': {
search: /(.+)([\n]?)/g,
replace: "= $1$2",
break_line: true,
whole_line: true
'replace': "= $1$2"
},
'function-h2': {
search: /(.+)([\n]?)/g,
replace: "== $1$2",
break_line: true,
whole_line: true
'replace': "== $1$2"
},
'function-h3': {
search: /(.+)([\n]?)/g,
replace: "=== $1$2",
break_line: true,
whole_line: true
'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',
help: 'The text to display to the user.',
defaultValue: selText
},
{
id: 'href',
name: 'URL',
type: 'text',
help: 'The URL to link to.'
}
],
OK: function( res ) {
var h = '';
'replace': function ( res ) {
var rep = '';
if ( res['text'] && res['href'] ) {
h = res['href'] + '[' +
res['text'] + ']';
rep = res['href'] + '[' + res['text'] + ']';
}
$.GollumEditor.replaceSelection( h );
}
});
return rep;
}
},
'function-image': {
exec: function( txt, selText, $field ) {
var results = null;
$.GollumEditor.Dialog.init({
title: 'Insert Image',
fields: [
{
id: 'url',
name: 'Image URL',
type: 'text'
},
{
id: 'alt',
name: 'Alt Text',
type: 'text'
}
],
OK: function( res ) {
var h = '';
'replace': function ( res ) {
var rep = '';
if ( res['url'] && res['alt'] ) {
h = 'image::' + res['url'] +
'[' + res['alt'] + ']';
rep = 'image::' + res['url'] + '[' + res['alt'] + ']';
}
$.GollumEditor.replaceSelection( h );
return rep;
}
});
}
},
'function-critic-accept' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
},
'function-critic-reject' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
}
};
$.GollumEditor.defineLanguage('asciidoc', AsciiDoc);
$.GollumEditor.defineLanguage('asciidoc', $.constructLanguageDefinition(AsciiDoc));
var AsciiDocHelp = [
{
@@ -1,145 +1,70 @@
/**
* Creole Language Definition
* See default.js for documentation
*
*/
(function($) {
// No need to set all the replacements, only those different from the default language (Markdown).
var Creole = {
'function-bold' : {
search: /([^\n]+)([\n]*)/gi,
replace: "**$1**$2"
},
'function-italic': {
search: /([^\n]+)([\n]*)/gi,
replace: "//$1//$2"
'replace': "//$1//$2"
},
'function-code': {
search: /([^\n]+)([\n]*)/gi,
replace: "{{{$1}}}$2"
'replace': "{{{$1}}}$2"
},
'function-hr': {
append: "\n\n----\n\n"
'append': "\n\n----\n\n"
},
'function-ul' : {
exec: function( txt, selText, $field ) {
var repText = '';
var lines = selText.split("\n");
for ( var i = 0; i < lines.length; i++ ) {
repText += '* ' + lines[i] + "\n";
}
repText = repText.substring(0, repText.length-1)
$.GollumEditor.replaceSelection( repText, true, true );
},
},
'function-blockquote': undefined,
/* This looks silly but is completely valid Markdown */
'function-ol': {
exec: function( txt, selText, $field ) {
var repText = '';
var lines = selText.split("\n");
for ( var i = 0; i < lines.length; i++ ) {
repText += '# ' + lines[i] + "\n";
'line': function ( index, line) {
return '# ' + line + "\n";
}
repText = repText.substring(0, repText.length-1)
$.GollumEditor.replaceSelection( repText, true, true );
},
'function-h1': {
'replace': "== $1$2"
},
'function-h2': {
'replace': "=== $1$2"
},
'function-h3': {
'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',
help: 'The text to display to the user.',
defaultValue: selText
},
{
id: 'href',
name: 'URL',
type: 'text',
help: 'The URL to link to.'
'replace': function ( res ) {
var rep = '';
if ( res['text'] && res['href'] ) {
rep = '[[' + res['href'] + '|' + res['text'] + ']]';
}
],
OK: function( res ) {
var h = '[[' + res['href'] + '|' +
res['text'] + ']]';
$.GollumEditor.replaceSelection( h );
}
});
return rep;
}
},
'function-image': {
exec: function( txt, selText, $field ) {
var results = null;
$.GollumEditor.Dialog.init({
title: 'Insert Image',
fields: [
{
id: 'url',
name: 'Image URL',
type: 'text'
},
{
id: 'alt',
name: 'Alt Text',
type: 'text'
}
],
OK: function( res ) {
var h = '';
'replace': function ( res ) {
var rep = '';
if ( res['url'] && res['alt'] ) {
h = '{{' + res['url'];
rep = '{{' + res['url'];
if ( res['alt'] != '' ) {
h += '|' + res['alt'] + '}}';
rep += '|' + res['alt'];
}
rep = rep + '}}';
}
return rep;
}
}
$.GollumEditor.replaceSelection( h );
}
});
}
},
'function-critic-accept' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
},
'function-critic-reject' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
}
};
$.GollumEditor.defineLanguage('creole', Creole);
$.GollumEditor.defineLanguage('creole', $.constructLanguageDefinition(Creole));
})(jQuery);
@@ -0,0 +1,201 @@
/**
* Default Language Definition
*
* Standard language definition for string manipulation operations which can be used
* to generate others language definition. The default rules below describe
* the Markdown markup language. (The Markdown definition is therefore just a
* deep clone of $.DefaultLanguage.)
*
* Language definitions use 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.
*
* If the 'append' property is set for a function, its value will be appended at the cursor position.
*
* Some functions have the 'break_line' and 'whole_line' boolean properties set.
* You can use these to indicate whether a function inserts a newline (break_line),
* and whether just the selection or the whole line should be replaced (whole_line).
* These also influence cursor placement after text in the editor has been replaced.
*
**/
(function($) {
$.constructLanguageDefinition = function (newLang) {
var result = $.extend(true, {}, $.DefaultLang, newLang);
Object.keys(newLang).forEach(function (key) {
if(typeof newLang[key] === 'undefined'){
delete result[key];
}
});
return result;
};
var initDialog = function( title, fields, onResult) {
$.GollumEditor.Dialog.init({
title: title,
fields: fields,
OK: function( res ) {
$.GollumEditor.replaceSelection( onResult(res) );
}
});
};
$.DefaultLang = {
'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' : {
exec: function( txt, selText, $field ) {
var repText = '';
var lines = selText.split("\n");
for ( var i = 0; i < lines.length; i++ ) {
repText += '* ' + lines[i] + "\n";
}
repText = repText.substring(0, repText.length-1)
$.GollumEditor.replaceSelection( repText, true, true );
},
},
/* based on rdoc.js */
'function-ol' : {
line: function ( index, line) {
// This function generates the markup for a line of the ol, based on the line number (index) and the content of the line (line).
// Override this function for alternative markups when needed.
return index.toString() + '. ' + line + "\n"; // result e.g. "1. Previously existing text\n"
},
exec: function( txt, selText, $field ) {
var repText = '';
var lines = selText.split("\n");
for ( var i = 0; i < lines.length; i++ ) {
repText += this.line(i+1, lines[i]);
}
repText = repText.substring(0, repText.length-1)
$.GollumEditor.replaceSelection( repText, true, true );
},
},
'function-blockquote' : {
search: /(.+)([\n]?)/g,
replace: "> $1$2",
break_line: true,
},
'function-h1' : {
search: /(.+)([\n]?)/g,
replace: "# $1$2",
break_line: true,
whole_line: true
},
'function-h2' : {
search: /(.+)([\n]?)/g,
replace: "## $1$2",
break_line: true,
whole_line: true
},
'function-h3' : {
search: /(.+)([\n]?)/g,
replace: "### $1$2",
break_line: true,
whole_line: true
},
'function-link' : {
replace: function ( res ) {
// The replace function generates the markup to be inserted from the result of the Dialog (res).
// Set a different replace function if your markup requires it.
var rep = '';
if ( res['text'] && res['href'] ) {
rep = '[' + res['text'] + '](' + res['href'] + ')';
}
return rep;
},
exec: function (txt, selText, $field) {
initDialog('Insert Link', [
{
id: 'text',
name: 'Link Text',
type: 'text',
defaultValue: selText
},
{
id: 'href',
name: 'URL',
type: 'text'
}
], this.replace)
}
},
'function-image' : {
replace: function( res ) {
// The replace function generates the markup to be inserted from the result of the Dialog (res).
// Set a different replace function if your markup requires it.
var rep = '';
if ( res['url'] && res['alt'] ) {
rep = '![' + res['alt'] + ']' + '(' + res['url'] + ')';
}
return rep;
},
exec: function (txt, selText, $field) {
initDialog('Insert Image', [
{
id: 'url',
name: 'Image Url',
type: 'text',
defaultValue: selText
},
{
id: 'alt',
name: 'Alt Text',
type: 'text'
}
], this.replace)
}
},
'function-critic-accept' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
},
'function-critic-reject' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
}
};
})(jQuery);
@@ -1,183 +1,13 @@
/**
* 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"
* }
* See default.js for documentation
*
**/
(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' : {
exec: function( txt, selText, $field ) {
var repText = '';
var lines = selText.split("\n");
for ( var i = 0; i < lines.length; i++ ) {
repText += '* ' + lines[i] + "\n";
}
repText = repText.substring(0, repText.length-1)
$.GollumEditor.replaceSelection( repText, true, true );
},
},
/* based on rdoc.js */
'function-ol' : {
exec: function( txt, selText, $field ) {
var repText = '';
var lines = selText.split("\n");
for ( var i = 0; i < lines.length; i++ ) {
repText += (i+1).toString() + '. ' +
lines[i] + "\n";
}
repText = repText.substring(0, repText.length-1)
$.GollumEditor.replaceSelection( repText, true, true );
},
},
'function-blockquote' : {
search: /(.+)([\n]?)/g,
replace: "> $1$2",
break_line: true,
},
'function-h1' : {
search: /(.+)([\n]?)/g,
replace: "# $1$2",
break_line: true,
whole_line: true
},
'function-h2' : {
search: /(.+)([\n]?)/g,
replace: "## $1$2",
break_line: true,
whole_line: true
},
'function-h3' : {
search: /(.+)([\n]?)/g,
replace: "### $1$2",
break_line: true,
whole_line: true
},
'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;
$.GollumEditor.Dialog.init({
title: 'Insert Image',
fields: [
{
id: 'url',
name: 'Image URL',
type: 'text'
},
{
id: 'alt',
name: 'Alt Text',
type: 'text'
}
],
OK: function( res ) {
var rep = '';
if ( res['url'] && res['alt'] ) {
rep = '![' + res['alt'] + ']' +
'(' + res['url'] + ')';
}
$.GollumEditor.replaceSelection( rep );
}
});
}
},
'function-critic-accept' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
},
'function-critic-reject' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
}
};
var MarkDown = $.extend(true, {}, $.DefaultLang); // The default language definition is markdown, so copy it into a new variable.
$.GollumEditor.defineLanguage('markdown', MarkDown);
var MarkDownHelp = [
@@ -257,8 +87,6 @@ var MarkDownHelp = [
}
];
$.GollumEditor.defineLanguage('markdown', MarkDown);
$.GollumEditor.defineHelp('markdown', MarkDownHelp);
})(jQuery);
@@ -1,19 +1,19 @@
/**
* MediaWiki Language Definition
* See default.js for documentation
*
*/
(function($) {
// No need to set all the replacements, only those different from the default language (Markdown).
var MediaWiki = {
'function-bold' : {
search: /([^\n]+)([\n\s]*)/g,
replace: "'''$1'''$2"
},
'function-italic' : {
search: /([^\n]+)([\n\s]*)/g,
replace: "''$1''$2"
},
'function-hr' : {
@@ -21,125 +21,41 @@ var MediaWiki = {
},
'function-code' : {
search: /([^\n]+)([\n\s]*)/g,
replace: "<code>$1</code>$2"
},
'function-ul' : {
exec: function( txt, selText, $field ) {
var repText = '';
var lines = selText.split("\n");
for ( var i = 0; i < lines.length; i++ ) {
repText += '* ' + lines[i] + "\n";
}
repText = repText.substring(0, repText.length-1)
$.GollumEditor.replaceSelection( repText, true, true );
},
},
'function-ol' : {
exec: function( txt, selText, $field ) {
var repText = '';
var lines = selText.split("\n");
for ( var i = 0; i < lines.length; i++ ) {
repText += '# ' + lines[i] + "\n";
link: function ( index, line) {
return '# ' + line + "\n";
}
repText = repText.substring(0, repText.length-1)
$.GollumEditor.replaceSelection( repText, true, true );
},
},
'function-blockquote' : {
search: /(.+)([\n]?)/g,
replace: "<blockquote>\n$1$2\n</blockquote>",
break_line: true,
},
'function-h1' : {
search: /(.+)([\n]?)/g,
replace: "= $1$2 =",
break_line: true,
whole_line: true
},
'function-h2' : {
search: /(.+)([\n]?)/g,
replace: "== $1$2 ==",
break_line: true,
whole_line: true
},
'function-h3' : {
search: /(.+)([\n]?)/g,
replace: "=== $1$2 ===",
break_line: true,
whole_line: true
},
'function-link' : {
exec: function( txt, selText, $field ) {
var results = null;
$.GollumEditor.Dialog.init({
title: 'Insert Link',
fields: [
{
id: 'text',
name: 'Link Text',
type: 'text',
help: 'The text to display to the user.',
defaultValue: selText
},
{
id: 'href',
name: 'URL',
type: 'text',
help: 'The URL to link to.'
}
],
OK: function( res ) {
var h = '';
replace: function( res ) {
var rep = '';
if ( res['text'] && res['href'] ) {
h = '[' + res['href'] + ' | ' +
res['text'] + ']';
rep = '[' + res['href'] + ' | ' + res['text'] + ']';
}
$.GollumEditor.replaceSelection( h );
return rep;
}
});
}
},
'function-critic-accept' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
},
'function-critic-reject' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
}
};
$.GollumEditor.defineLanguage('mediawiki', MediaWiki);
$.GollumEditor.defineLanguage('mediawiki', $.constructLanguageDefinition(MediaWiki));
var MediaWikiHelp = [
@@ -1,162 +1,69 @@
/**
* Org-mode Language Definition
* See default.js for documentation
**/
(function($) {
// No need to set all the replacements, only those different from the default language (Markdown).
var OrgMode = {
'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-ul' : {
exec: function( txt, selText, $field ) {
var repText = '';
var lines = selText.split("\n");
for ( var i = 0; i < lines.length; i++ ) {
repText += '* ' + lines[i] + "\n";
}
repText = repText.substring(0, repText.length-1)
$.GollumEditor.replaceSelection( repText, true, true );
},
},
'function-ol' : {
exec: function( txt, selText, $field ) {
var repText = '';
var lines = selText.split("\n");
for ( var i = 0; i < lines.length; i++ ) {
repText += (i+1).toString() + '. ' +
lines[i] + "\n";
}
repText = repText.substring(0, repText.length-1)
$.GollumEditor.replaceSelection( repText, true, true );
},
},
'function-hr': undefined,
'function-blockquote' : {
search: /(.+)([\n]?)/g,
replace: "#+BEGIN_QUOTE\n$1$2\n#+END_QUOTE",
break_line: true,
replace: "#+BEGIN_QUOTE\n$1$2\n#+END_QUOTE"
},
'function-h1' : {
search: /(.+)([\n]?)/g,
replace: "* $1$2",
break_line: true,
whole_line: true
replace: "* $1$2"
},
'function-h2' : {
search: /(.+)([\n]?)/g,
replace: "** $1$2",
break_line: true,
whole_line: true
replace: "** $1$2"
},
'function-h3' : {
search: /(.+)([\n]?)/g,
replace: "*** $1$2",
break_line: true,
whole_line: true
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 ) {
replace: function ( res ) {
var rep = '';
if ( res['text'] && res['href'] ) {
rep = '[[' + res['href'] + '][' +
res['text'] + ']]';
rep = '[[' + res['href'] + '][' + res['text'] + ']]';
}
else if ( res['href'] ) {
rep = '[[' + res['href'] + ']]';
}
$.GollumEditor.replaceSelection( rep );
}
});
return rep;
}
},
'function-image' : {
exec: function( txt, selText, $field ) {
var results = null;
$.GollumEditor.Dialog.init({
title: 'Insert Image',
fields: [
{
id: 'url',
name: 'Image URL',
type: 'text'
}
],
OK: function( res ) {
replace: function ( res ) {
var rep = '';
if ( res['url'] ) {
rep = '[[' + res['url'] + ']]';
}
$.GollumEditor.replaceSelection( rep );
return rep;
}
});
}
},
'function-critic-accept' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
},
'function-critic-reject' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
}
};
$.GollumEditor.defineLanguage('org', $.constructLanguageDefinition(OrgMode));
var OrgModeHelp = [
{
@@ -216,7 +123,6 @@ var OrgModeHelp = [
];
$.GollumEditor.defineLanguage('org', OrgMode);
$.GollumEditor.defineHelp('org', OrgModeHelp);
})(jQuery);
@@ -1,106 +1,54 @@
/**
* Pod Language Definition
* See default.js for documentation
**/
(function($) {
// No need to set all the replacements, only those different from the default language (Markdown).
var Pod = {
'function-bold' : {
search: /([^\n]+)([\n\s]*)/g,
replace: "B<$1>$2"
},
'function-italic' : {
search: /([^\n]+)([\n\s]*)/g,
replace: "I<$1>$2"
},
'function-hr' : undefined,
'function-code' : {
search: /([^\n]+)([\n\s]*)/g,
replace: "C<$1>$2"
},
'function-h1' : {
search: /(.+)([\n]?)/gi,
replace: "=head1 $1$2",
break_line: true,
whole_line: true
replace: "=head1 $1$2"
},
'function-h2' : {
search: /(.+)([\n]?)/gi,
replace: "=head2 $1$2",
break_line: true,
whole_line: true
replace: "=head2 $1$2"
},
'function-h3' : {
search: /(.+)([\n]?)/gi,
replace: "=head3 $1$2",
break_line: true,
whole_line: true
replace: "=head3 $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 ) {
replace: function ( res ) {
var rep = '';
if ( res['text'] && res['href'] ) {
rep = 'L<' + res['text'] + '|' +
res['href'] + '>';
rep = 'L<' + res['text'] + '|' + res['href'] + '>';
}
$.GollumEditor.replaceSelection( rep );
}
});
return rep;
}
},
'function-critic-accept' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
},
'function-critic-reject' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
}
'function-image' : undefined,
'function-ul' : undefined,
'function-ol' : undefined,
'function-blockquote' : undefined
};
$.GollumEditor.defineLanguage('pod', Pod);
$.GollumEditor.defineLanguage('pod', $.constructLanguageDefinition(Pod));
var PodHelp = [
@@ -1,110 +1,23 @@
/**
* 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"
* }
* Rdoc Language Definition
* See default.js for documentation
*
**/
(function($) {
// No need to set all the replacements, only those different from the default language (Markdown).
// RDoc is pretty bare bones, so we only need to unset some functions.
var RDoc = {
'function-bold' : {
search: /([^\n]+)([\n\s]*)/g,
replace: "((*$1*))$2"
},
'function-code' : {
search: /([^\n]+)([\n\s]*)/g,
replace: "(({$1}))$2"
},
'function-ul' : {
exec: function( txt, selText, $field ) {
var repText = '';
var lines = selText.split("\n");
for ( var i = 0; i < lines.length; i++ ) {
repText += '* ' + lines[i] + "\n";
}
repText = repText.substring(0, repText.length-1)
$.GollumEditor.replaceSelection( repText, true, true );
},
},
'function-ol' : {
exec: function( txt, selText, $field ) {
var repText = '';
var lines = selText.split("\n");
for ( var i = 0; i < lines.length; i++ ) {
repText += (i+1).toString() + '. ' +
lines[i] + "\n";
}
repText = repText.substring(0, repText.length-1)
$.GollumEditor.replaceSelection( repText, true, true );
},
},
'function-h1' : {
search: /(.+)([\n]?)/gi,
replace: "= $1$2",
break_line: true,
whole_line: true
},
'function-h2' : {
search: /(.+)([\n]?)/gi,
replace: "== $1$2",
break_line: true,
whole_line: true
},
'function-h3' : {
search: /(.+)([\n]?)/gi,
replace: "=== $1$2",
break_line: true,
whole_line: true,
},
'function-critic-accept' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
},
'function-critic-reject' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
}
'function-code' : undefined,
'function-h1' : undefined,
'function-h2' : undefined,
'function-h3' : undefined,
'function-link' : undefined,
'function-image' : undefined,
'function-hr' : undefined,
'function-blockquote' : undefined,
};
$.GollumEditor.defineLanguage('rdoc', RDoc);
$.GollumEditor.defineLanguage('rdoc', $.constructLanguageDefinition(RDoc));
})(jQuery);
@@ -1,38 +1,29 @@
/**
* reStructuredText Language Definition
*
* A language definition for string manipulation operations, in this case
* for the reStructuredText 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"
* }
* See default.js for documentation
*
**/
(function($) {
var headerFunc = function (selText, selectedRange, symbol) {
adornment = symbol.repeat(selText.length);
repText = selText + "\n" + adornment + "\n";
$.GollumEditor.replaceSelection(repText, false, false, selectedRange);
};
// No need to set all the replacements, only those different from the default language (Markdown).
var reStructuredText = {
'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"
},
@@ -40,30 +31,6 @@ var reStructuredText = {
append: "\n\n----\n\n"
},
'function-ul' : {
exec: function(txt, selText, $field) {
var pfx = "* ";
var lines = selText.split("\n");
for ( var i = 0; i < lines.length; i++ ) {
lines[i] = pfx + lines[i];
}
var repText = lines.join("\n");
$.GollumEditor.replaceSelection(repText);
}
},
'function-ol' : {
exec: function( txt, selText, $field) {
var lines = selText.split("\n");
for ( var i = 0; i < lines.length; i++ ) {
pfx = (i + 1).toString() + ". ";
lines[i] = pfx + lines[i];
}
var repText = lines.join("\n");
$.GollumEditor.replaceSelection(repText);
}
},
'function-blockquote' : {
exec: function( txt, selText, $field) {
var pfx = " ";
@@ -77,121 +44,51 @@ var reStructuredText = {
},
'function-h1' : {
exec: function( txt, selText, $field) {
var lines = selText.split("\n");
title = lines.shift();
subtitle = lines.join(' ');
title_adornment = "=".repeat(title.length);
subtitle_adornment = "~".repeat(subtitle.length);
if (title != "" && subtitle != "") {
repText = title_adornment + "\n" + title + "\n" + title_adornment + "\n" +
subtitle_adornment + "\n" + subtitle + "\n" + subtitle_adornment;
} else if (title != ""){
repText = title_adornment + "\n" + title + "\n" + title_adornment;
}
$.GollumEditor.replaceSelection(repText);
symbol: '=',
exec: function( txt, selText, $field, selectedRange) {
headerFunc(selText, selectedRange, this.symbol);
}
},
'function-h2' : {
exec: function( txt, selText, $field) {
var lines = selText.split("\n");
header = lines.shift();
tail = lines.join("\n");
adornment = "=".repeat(header.length);
repText = header + "\n" + adornment + "\n" + tail;
$.GollumEditor.replaceSelection(repText);
}
},
'function-critic-accept' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
symbol: '-',
exec: function( txt, selText, $field, selectedRange) {
headerFunc(selText, selectedRange, this.symbol);
}
},
'function-critic-reject' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
'function-h3' : {
symbol: '~',
exec: function( txt, selText, $field, selectedRange) {
headerFunc(selText, selectedRange, this.symbol);
}
},
'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 ) {
replace: function( res ) {
var rep = '';
if ( res['text'] && res['href'] ) {
rep = '`' + res['text'] + ' ' +
'<' + res['href'] + '>`_';
rep = '`' + res['text'] + ' ' + '<' + res['href'] + '>`_';
}
$.GollumEditor.replaceSelection( rep );
}
});
return rep;
}
},
'function-image' : {
exec: function( txt, selText, $field ) {
var results = null;
$.GollumEditor.Dialog.init({
title: 'Insert Image',
fields: [
{
id: 'url',
name: 'Image URL',
type: 'text'
},
{
id: 'alt',
name: 'Alt Text',
type: 'text'
}
],
OK: function( res ) {
var rep = "";
replace: function( res ) {
var rep = '';
if ( res['url'] && res['alt'] ) {
rep = ".. image:: " + res['url'] + "\n" +
' :alt: ' + res['alt'];
rep = '.. image:: ' + res['url'] + "\n" + ' :alt: ' + res['alt'];
}
$.GollumEditor.replaceSelection( rep );
}
});
return rep;
}
}
};
$.GollumEditor.defineLanguage('rst', $.constructLanguageDefinition(reStructuredText));
var reStructuredTextHelp = [
{
@@ -260,8 +157,6 @@ var reStructuredTextHelp = [
}
];
$.GollumEditor.defineLanguage('rest', reStructuredText);
$.GollumEditor.defineHelp('rest', reStructuredTextHelp);
})(jQuery);
@@ -1,154 +1,69 @@
/**
* Textile Language Definition
* See default.js for documentation
*
*/
(function($) {
// No need to set all the replacements, only those different from the default language (Markdown).
var Textile = {
'function-bold' : {
search: /([^\n]+)([\n\s]*)/g,
replace: "*$1*$2"
},
'function-italic' : {
search: /([^\n]+)([\n\s]*)/g,
replace: "_$1_$2"
},
'function-hr' : {
append: "\n***\n"
},
'function-hr' : undefined,
'function-code' : {
search: /([^\n]+)([\n\s]*)/g,
replace: "<pre><code>$1</code></pre>$2"
},
'function-ul' : {
exec: function( txt, selText, $field ) {
var repText = '';
var lines = selText.split("\n");
for ( var i = 0; i < lines.length; i++ ) {
repText += '* ' + lines[i] + "\n";
}
repText = repText.substring(0, repText.length-1)
$.GollumEditor.replaceSelection( repText, true, true );
},
replace: "bc. $1$2",
whole_line: true
},
'function-ol' : {
exec: function( txt, selText, $field ) {
var repText = '';
var lines = selText.split("\n");
for ( var i = 0; i < lines.length; i++ ) {
repText += '# ' + lines[i] + "\n";
'line': function ( index, line) {
return '# ' + line + "\n";
}
repText = repText.substring(0, repText.length-1)
$.GollumEditor.replaceSelection( repText, true, true );
},
},
'function-blockquote' : {
search: /(.+)([\n]?)/gi,
replace: "bq. $1$2",
break_line: true,
},
'function-h1' : {
replace: "h1. $1$2"
},
'function-h2' : {
replace: "h2. $1$2"
},
'function-h3' : {
replace: "h3. $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',
help: 'The text to display to the user.',
defaultValue: selText
},
{
id: 'href',
name: 'URL',
type: 'text',
help: 'The URL to link to.'
}
],
OK: function( res ) {
var h = '';
replace: function( res ) {
var rep = '';
if ( res['text'] && res['href'] ) {
h = '"' + res['text'] + '":' +
res['href'];
rep = '"' + res['text'] + '":' + res['href'];
}
$.GollumEditor.replaceSelection( h );
}
});
return rep;
}
},
'function-image' : {
exec: function( txt, selText, $field ) {
var results = null;
$.GollumEditor.Dialog.init({
title: 'Insert Image',
fields: [
{
id: 'url',
name: 'Image URL',
type: 'text'
},
{
id: 'alt',
name: 'Alt Text',
type: 'text'
}
],
OK: function( res ) {
replace: function( res ) {
var rep = '';
if ( res['url'] ) {
var h = '!' + res['url'];
var rep = '!' + res['url'];
if ( res['alt'] != '' ) {
h += '(' + res['alt'] + ')';
rep += '(' + res['alt'] + ')';
}
h += '!';
$.GollumEditor.replaceSelection( h );
rep += '!';
return rep;
}
}
});
}
},
'function-critic-accept' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
},
'function-critic-reject' : {
exec: function( txt, selText, $field) {
var toReplace = selText.
replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
replace(/\{>>(.*?)<<\}/gm, "")
$.GollumEditor.replaceSelection( toReplace );
}
}
};
$.GollumEditor.defineLanguage('textile', Textile);
$.GollumEditor.defineLanguage('textile', $.constructLanguageDefinition(Textile));
var TextileHelp = [