showdown/src/subParsers/runExtension.js

21 lines
458 B
JavaScript
Raw Normal View History

2015-03-02 02:15:32 +08:00
/**
* Run extension
2015-03-02 02:15:32 +08:00
*/
showdown.subParser('runExtension', function (ext, text, options, globals) {
2015-03-02 02:15:32 +08:00
'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);
2015-03-02 02:15:32 +08:00
}
return text;
2015-03-02 02:15:32 +08:00
});