Added markdown definition, workin' on the editor

This commit is contained in:
Eston Bond
2010-10-27 16:47:30 -07:00
parent 0b1f1a5338
commit c9cc0d3d37
2 changed files with 69 additions and 3 deletions
+50 -1
View File
@@ -1 +1,50 @@
// meh
/**
* 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"
* }
*
**/
var MarkDown = {
'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"
},
'function-ul' : {
search: /(.+)([\n]?)/gi,
replace: "* $1$2"
}
};
// this is necessary for GollumEditor to pick this up
jQuery.GollumEditor.defineLanguage('markdown', MarkDown);
+19 -2
View File
@@ -50,6 +50,14 @@
}
};
$.GollumEditor.defineLanguage = function( language_name, languageObject ) {
if ( typeof languageObject == 'object' )
LanguageDefinition.define( language_name, languageObject );
else
debug('GollumEditor.defineLanguage: definition for ' + language_name
+ ' is not an object');
};
/**
@@ -75,7 +83,15 @@
**/
var LanguageDefinition = {
_LOADED_LANGS: [],
_LOADED_LANGS: [],
_LANG: {},
/**
* Defines a language
**/
define: function( name, definitionObject ) {
LanguageDefinition._LANG[name] = definitionObject;
},
/**
* loadFor
@@ -162,7 +178,8 @@
},
evtFunctionButtonClick: function(e) {
alert('eee');
e.preventDefault();
alert($(this).attr('id'));
}
};