2015-03-02 02:15:32 +08:00
|
|
|
/**
|
2015-06-01 03:56:28 +08:00
|
|
|
* Run extension
|
2015-03-02 02:15:32 +08:00
|
|
|
*/
|
2015-06-01 03:56:28 +08:00
|
|
|
showdown.subParser('runExtension', function (ext, text, options, globals) {
|
2015-03-02 02:15:32 +08:00
|
|
|
'use strict';
|
|
|
|
|
2015-06-01 03:56:28 +08:00
|
|
|
if (ext.filter) {
|
|
|
|
text = ext.filter(text, globals.converter, options);
|
|
|
|
|
|
|
|
} else if (ext.regex) {
|
|
|
|
// TODO remove this when old extension loading mechanism is deprecated
|
|
|
|
var re = ext.regex;
|
|
|
|
if (!re instanceof RegExp) {
|
|
|
|
re = new RegExp(re, 'g');
|
|
|
|
}
|
|
|
|
text = text.replace(re, ext.replace);
|
2015-03-02 02:15:32 +08:00
|
|
|
}
|
2015-06-01 03:56:28 +08:00
|
|
|
|
|
|
|
return text;
|
2015-03-02 02:15:32 +08:00
|
|
|
});
|