Adding creole & asciidoc

This commit is contained in:
Eston Bond
2010-11-03 14:51:33 -07:00
parent 9ffa79e44e
commit 742ca5e6dc
4 changed files with 312 additions and 26 deletions
+108
View File
@@ -0,0 +1,108 @@
/**
* ASCIIDoc Language Definition
*
*/
(function() {
var ASCIIDoc = {
'function-bold' : {
search: /([^\n]+)([\n]*)/gi,
replace: "*$1*$2"
},
'function-italic' : {
search: /([^\n]+)([\n]*)/gi,
replace: "_$1_$2"
},
'function-code' : {
search: /([^\n]+)([\n]*)/gi,
replace: "+$1+$2"
},
'function-ul' : {
search: /(.+)([\n]?)/gi,
replace: "* $1$2"
},
/* This looks silly but is completely valid Markdown */
'function-ol' : {
search: /(.+)([\n]?)/gi,
replace: ". $1$2"
},
'function-blockquote' : {
search: /(.+)([\n]?)/gi,
replace: "----\n$1$2\n----\n"
},
'function-link' : {
exec: function( txt, selText, $field ) {
var results = null;
$.GollumEditor.Dialog({
title: 'Insert Link',
fields: [
{
id: 'text',
name: 'Link Text',
type: 'text',
help: 'The text to display to the user.'
},
{
id: 'href',
name: 'URL',
type: 'text',
help: 'The URL to link to.'
}
],
OK: function( res ) {
if ( res['text'] && res['href'] ) {
return res['href'] + '[' +
res['text'] + ']';
}
else
return '';
}
});
}
},
'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 ) {
if ( res['url'] && res['alt'] ) {
return 'image::' + res['url'] +
'[' + res['alt'] + ']';
} else
return '';
}
});
}
}
};
// this is necessary for GollumEditor to pick this up
jQuery.GollumEditor.defineLanguage('markdown', ASCIIDoc);
})();
+107
View File
@@ -0,0 +1,107 @@
/**
* Creole Language Definition
*
*/
(function() {
var Creole = {
'function-bold' : {
search: /([^\n]+)([\n]*)/gi,
replace: "**$1**$2"
},
'function-italic' : {
search: /([^\n]+)([\n]*)/gi,
replace: "//$1//$2"
},
'function-code' : {
search: /([^\n]+)([\n]*)/gi,
replace: "{{{$1}}}$2"
},
'function-hr' : {
append: "\n\n----\n\n";
},
'function-ul' : {
search: /(.+)([\n]?)/gi,
replace: "* $1$2"
},
/* This looks silly but is completely valid Markdown */
'function-ol' : {
search: /(.+)([\n]?)/gi,
replace: "# $1$2"
},
'function-link' : {
exec: function( txt, selText, $field ) {
var results = null;
$.GollumEditor.Dialog({
title: 'Insert Link',
fields: [
{
id: 'text',
name: 'Link Text',
type: 'text',
help: 'The text to display to the user.'
},
{
id: 'href',
name: 'URL',
type: 'text',
help: 'The URL to link to.'
}
],
OK: function( res ) {
if ( res['text'] && res['href'] ) {
return '[[' + res['href'] + '|' +
res['text'] + ']]';
}
else
return '';
}
});
}
},
'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 ) {
if ( res['url'] && res['alt'] ) {
var h = '{{' + res['url'];
if ( res['alt'] != '' ) {
h += '|' + res['alt'] + '}}';
}
return h;
} else
return '';
}
});
}
}
};
jQuery.GollumEditor.defineLanguage('creole', Creole);
})();
+30 -3
View File
@@ -17,6 +17,7 @@
* }
*
**/
(function() {
var MarkDown = {
@@ -59,7 +60,7 @@ var MarkDown = {
exec: function( txt, selText, $field ) {
var results = null;
$.GollumEditor.Dialog({
title: '',
title: 'Insert Link',
fields: [
{
id: 'text',
@@ -89,11 +90,37 @@ var MarkDown = {
},
'function-image' : {
/* Stub */
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 ) {
if ( res['url'] && res['alt'] ) {
return '![' + res['alt'] + ']' +
'(' + res['url'] + ')';
} else
return '';
}
});
}
}
};
// this is necessary for GollumEditor to pick this up
jQuery.GollumEditor.defineLanguage('markdown', MarkDown);
jQuery.GollumEditor.defineLanguage('markdown', MarkDown);
})();