mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 22:21:19 +08:00
Revert "Integrate new engine, correct old specs"
This reverts commit f1b38ba4fb778c08a45dd001300fc651c92718ba.
This commit is contained in:
@ -57,7 +57,6 @@ function tokanizeBBCode(state, silent, ruler) {
|
||||
|
||||
let token = state.push('text', '' , 0);
|
||||
token.content = state.src.slice(pos, pos+tagInfo.length);
|
||||
token.meta = 'bbcode';
|
||||
|
||||
state.delimiters.push({
|
||||
bbInfo: tagInfo,
|
||||
@ -106,15 +105,10 @@ function processBBCode(state, silent) {
|
||||
let tag, className;
|
||||
|
||||
if (typeof tagInfo.rule.wrap === 'function') {
|
||||
let content = "";
|
||||
for (let j = startDelim.token+1; j < endDelim.token; j++) {
|
||||
let inner = state.tokens[j];
|
||||
if (inner.type === 'text' && inner.meta !== 'bbcode') {
|
||||
content += inner.content;
|
||||
}
|
||||
if (!tagInfo.rule.wrap(token, tagInfo)) {
|
||||
return false;
|
||||
}
|
||||
tagInfo.rule.wrap(token, state.tokens[endDelim.token], tagInfo, content);
|
||||
continue;
|
||||
tag = token.tag;
|
||||
} else {
|
||||
let split = tagInfo.rule.wrap.split('.');
|
||||
tag = split[0];
|
||||
@ -166,35 +160,19 @@ export function setup(helper) {
|
||||
}
|
||||
});
|
||||
|
||||
const simpleUrlRegex = /^http[s]?:\/\//;
|
||||
ruler.push('url', {
|
||||
tag: 'url',
|
||||
wrap: function(startToken, endToken, tagInfo, content) {
|
||||
replace: function(state, tagInfo, content) {
|
||||
let token;
|
||||
|
||||
const url = (tagInfo.attrs['_default'] || content).trim();
|
||||
token = state.push('link_open', 'a', 1);
|
||||
token.attrs = [['href', content], ['data-bbcode', 'true']];
|
||||
|
||||
if (simpleUrlRegex.test(url)) {
|
||||
startToken.type = 'link_open';
|
||||
startToken.tag = 'a';
|
||||
startToken.attrs = [['href', url], ['data-bbcode', 'true']];
|
||||
startToken.content = '';
|
||||
startToken.nesting = 1;
|
||||
token = state.push('text', '', 0);
|
||||
token.content = content;
|
||||
|
||||
endToken.type = 'link_close';
|
||||
endToken.tag = 'a';
|
||||
endToken.content = '';
|
||||
endToken.nesting = -1;
|
||||
} else {
|
||||
// just strip the bbcode tag
|
||||
endToken.content = '';
|
||||
startToken.content = '';
|
||||
|
||||
// edge case, we don't want this detected as a onebox if auto linked
|
||||
// this ensures it is not stripped
|
||||
startToken.type = 'html_inline';
|
||||
}
|
||||
|
||||
return false;
|
||||
token = state.push('link_close', 'a', -1);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
@ -202,10 +180,9 @@ export function setup(helper) {
|
||||
tag: 'email',
|
||||
replace: function(state, tagInfo, content) {
|
||||
let token;
|
||||
let email = tagInfo.attrs['_default'] || content;
|
||||
|
||||
token = state.push('link_open', 'a', 1);
|
||||
token.attrs = [['href', 'mailto:' + email], ['data-bbcode', 'true']];
|
||||
token.attrs = [['href', 'mailto:' + content], ['data-bbcode', 'true']];
|
||||
|
||||
token = state.push('text', '', 0);
|
||||
token.content = content;
|
||||
|
Reference in New Issue
Block a user