Skip to content
This repository has been archived by the owner on Apr 29, 2019. It is now read-only.

Commit

Permalink
added more docs to ep_linkify
Browse files Browse the repository at this point in the history
  • Loading branch information
fourplusone committed Apr 20, 2012
1 parent 18b0813 commit 648aa57
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions ep_linkify/static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ var Security = require('ep_etherpad-lite/static/js/security.js');

/* Define the regular expressions we will use to detect if a string looks like a reference to a pad IE [[foo]] */
var internalHrefRegexp = new RegExp(/\[\[([^\]]+)\]\]/g);

// Define a regexp to detect if we are in timeslider
var timesliderRegexp = new RegExp(/p\/[^\/]*\/timeslider/g);

/* Take the string and remove the first and last 2 characters IE [[foo]] returns foo */
Expand All @@ -17,24 +19,32 @@ var linkSanitizingFn = function(result){
};


/* Define a custom regular expression object */
/* CustomRegexp provides a wrapper around a RegExp Object which applies a given function to the result of the Regexp
@param regexp the regexp to be wrapped
@param sanitizeResultFn the function to be applied to the result.
*/
var CustomRegexp = function(regexp, sanitizeResultFn){
this.regexp = regexp;
this.sanitizeResultFn = sanitizeResultFn;
};


CustomRegexp.prototype.exec = function(text){
var result = this.regexp.exec(text);
return this.sanitizeResultFn(result);
}

var getCustomRegexpFilter = function(regExp, tag, sanitizeFn, linestylefilter)

/* getCustomRegexpFilter returns a linestylefilter compatible filter for a CustomRegexp
@param customRegexp the CustomRegexp Object
@param tag the tag to be filtered
@param linestylefilter reference to linestylefilter module
*/
var getCustomRegexpFilter = function(customRegexp, tag, linestylefilter)
{
var customRegexp = new CustomRegexp(regExp, sanitizeFn);
var filter = linestylefilter.getRegexpFilter(customRegexp, tag);
return filter;
}
/* End of defining a custom regular expression object */


exports.aceCreateDomLine = function(name, context){
Expand Down Expand Up @@ -70,9 +80,8 @@ exports.aceCreateDomLine = function(name, context){
exports.aceGetFilterStack = function(name, context){
var linestylefilter = context.linestylefilter;
var filter = getCustomRegexpFilter(
internalHrefRegexp,
new CustomRegexp(internalHrefRegexp, linkSanitizingFn),
'internalHref',
linkSanitizingFn,
linestylefilter
);
return [filter];
Expand Down

1 comment on commit 648aa57

@JohnMcLear
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Please sign in to comment.