diff --git a/app/assets/javascripts/discourse/dialects/bbcode_dialect.js b/app/assets/javascripts/discourse/dialects/bbcode_dialect.js index ba6f4b5b3..3222747ca 100644 --- a/app/assets/javascripts/discourse/dialects/bbcode_dialect.js +++ b/app/assets/javascripts/discourse/dialects/bbcode_dialect.js @@ -57,8 +57,6 @@ replaceBBCode('ul', function(contents) { return ['ul'].concat(contents); }); replaceBBCode('ol', function(contents) { return ['ol'].concat(contents); }); replaceBBCode('li', function(contents) { return ['li'].concat(contents); }); -replaceBBCode('spoiler', function(contents) { return ['span', {'class': 'spoiler'}].concat(contents); }); - Discourse.Dialect.inlineBetween({ start: '[img]', stop: '[/img]', @@ -80,7 +78,6 @@ Discourse.Dialect.inlineBetween({ emitter: function(contents) { return ['a', {href: contents, 'data-bbcode': true}, contents]; } }); - replaceBBCodeParamsRaw("url", function(param, contents) { return ['a', {href: param, 'data-bbcode': true}, contents]; }); @@ -103,3 +100,11 @@ Discourse.Dialect.replaceBlock({ } }); +Discourse.Dialect.replaceBlock({ + start: /(\[spoiler\])([\s\S]*)/igm, + stop: '[/spoiler]', + + emitter: function(blockContents) { + return ['p', ['div', { 'class': 'spoiler' }, blockContents.join("\n")]]; + } +}); diff --git a/app/assets/javascripts/discourse/dialects/dialect.js b/app/assets/javascripts/discourse/dialects/dialect.js index 0b877870a..cf12fc64d 100644 --- a/app/assets/javascripts/discourse/dialects/dialect.js +++ b/app/assets/javascripts/discourse/dialects/dialect.js @@ -213,7 +213,7 @@ Discourse.Dialect = { @param {String} [opts.start] The starting token we want to find @param {String} [opts.matcher] The regular expression to match @param {Boolean} [opts.wordBoundary] If true, the match must be on a word boundary - @param {Boolean} [opts.spaceBoundary] If true, the match must be on a sppace boundary + @param {Boolean} [opts.spaceBoundary] If true, the match must be on a space boundary **/ inlineRegexp: function(args) { this.registerInline(args.start, function(text, match, prev) { diff --git a/app/assets/javascripts/discourse/lib/lightbox.js b/app/assets/javascripts/discourse/lib/lightbox.js index bdef16a11..bf0f865d2 100644 --- a/app/assets/javascripts/discourse/lib/lightbox.js +++ b/app/assets/javascripts/discourse/lib/lightbox.js @@ -9,7 +9,11 @@ Discourse.Lightbox = { apply: function($elem) { $LAB.script("/javascripts/jquery.magnific-popup-min.js").wait(function() { $("a.lightbox", $elem).each(function(i, e) { - $(e).magnificPopup({ + var $e = $(e); + // do not lightbox spoiled images + if ($e.parents(".spoiler").length > 0 || $e.parents(".spoiled").length > 0) { return; } + + $e.magnificPopup({ type: "image", closeOnContentClick: false, diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb index 1398937d0..5f70dbe14 100644 --- a/spec/components/pretty_text_spec.rb +++ b/spec/components/pretty_text_spec.rb @@ -41,7 +41,7 @@ describe PrettyText do end it 'should add spoiler tags' do - PrettyText.cook("[spoiler]hello[/spoiler]").should match_html "
hello
" + PrettyText.cook("[spoiler]hello[/spoiler]").should match_html "abc\n#def', 'it handles headings in a [code] block'); }); +test('spoiler', function() { + format("[spoiler]it's a sled[/spoiler]", "