mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
21 lines
458 B
JavaScript
21 lines
458 B
JavaScript
/**
|
|
* Run extension
|
|
*/
|
|
showdown.subParser('runExtension', function (ext, text, options, globals) {
|
|
'use strict';
|
|
|
|
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);
|
|
}
|
|
|
|
return text;
|
|
});
|