Revert "New API for replacing elements in the final JsonML. Also changes spoiler"

This reverts commit 6b9b2d3d6a.

We have come up with a better solution that does not involve HTML
parsing.
This commit is contained in:
Robin Ward
2014-01-21 12:04:26 -05:00
parent 3c2d4070a8
commit 3c3449aa1b
3 changed files with 8 additions and 92 deletions
@@ -78,23 +78,16 @@ Discourse.Dialect.inlineBetween({
emitter: function(contents) { return ['a', {href: contents, 'data-bbcode': true}, contents]; }
});
Discourse.Dialect.inlineBetween({
start: '[spoiler]',
stop: '[/spoiler]',
rawContents: true,
emitter: function(contents) {
return ["__spoiler", this.processInline(contents)];
}
});
Discourse.Dialect.replaceElement('__spoiler', function(node, processInside) {
// Surround images with a `<div class='spoiler'>`, any other tags
// end up in a `span`
if (node.nodeType === 1 && node.nodeName === "IMG") {
return ['div', {class: 'spoiler'}, processInside(node)];
} else {
return ['span', {class: 'spoiler'}, processInside(node)];
if (/<img/i.test(contents)) {
return ['div', { 'class': 'spoiler' }, contents];
} else {
return ['span', { 'class': 'spoiler' }, contents];
}
}
});