add support for a wrap function in bbcode replace

This commit is contained in:
Sam 2017-06-29 16:43:57 -04:00
parent d941ed90d6
commit ca40c1725c
1 changed files with 12 additions and 4 deletions

View File

@ -109,11 +109,19 @@ function processBBCode(state, silent) {
endDelim = delimiters[startDelim.end];
let split = tagInfo.rule.wrap.split('.');
let tag = split[0];
let className = split.slice(1).join(' ');
token = state.tokens[startDelim.token];
let tag, className;
if (typeof tagInfo.rule.wrap === 'function') {
if (!tagInfo.rule.wrap(token, tagInfo)) {
return false;
}
tag = token.tag;
} else {
let split = tagInfo.rule.wrap.split('.');
tag = split[0];
className = split.slice(1).join(' ');
}
token.type = 'bbcode_' + tagInfo.tag + '_open';
token.tag = tag;