diff --git a/app/assets/javascripts/discourse/dialects/bbcode_dialect.js b/app/assets/javascripts/discourse/dialects/bbcode_dialect.js index 3222747ca9..9cdb9de55b 100644 --- a/app/assets/javascripts/discourse/dialects/bbcode_dialect.js +++ b/app/assets/javascripts/discourse/dialects/bbcode_dialect.js @@ -78,6 +78,19 @@ 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) { + if (/hello @bob's @bob,@bob; @bob\"

" end - it 'should add spoiler tags' do - PrettyText.cook("[spoiler]hello[/spoiler]").should match_html "

hello

" + it 'should spoiler text' do + PrettyText.cook("[spoiler]hello[/spoiler]").should match_html "

hello

" + end + + it 'should spoiler img' do + PrettyText.cook("[spoiler][/spoiler]").should match_html "

" end end diff --git a/test/javascripts/lib/bbcode_test.js b/test/javascripts/lib/bbcode_test.js index 70cda0b6e2..d1b059180f 100644 --- a/test/javascripts/lib/bbcode_test.js +++ b/test/javascripts/lib/bbcode_test.js @@ -30,7 +30,7 @@ test('code', function() { }); test('spoiler', function() { - format("[spoiler]it's a sled[/spoiler]", "
it's a sled
", "supports spoiler tags on text"); + format("[spoiler]it's a sled[/spoiler]", "it's a sled", "supports spoiler tags on text"); format("[spoiler][/spoiler]", "
", "supports spoiler tags on images"); });