correct spec, require closing tag for bbcode blocks
This commit is contained in:
parent
e6cc07fc43
commit
21f7ac1f25
|
@ -96,7 +96,6 @@ function applyBBCode(state, startLine, endLine, silent, md) {
|
|||
initial = start,
|
||||
max = state.eMarks[startLine];
|
||||
|
||||
|
||||
// [ === 91
|
||||
if (91 !== state.src.charCodeAt(start)) { return false; }
|
||||
|
||||
|
@ -128,9 +127,8 @@ function applyBBCode(state, startLine, endLine, silent, md) {
|
|||
for (;;) {
|
||||
nextLine++;
|
||||
if (nextLine >= endLine) {
|
||||
// unclosed block should be autoclosed by end of document.
|
||||
// also block seems to be autoclosed by end of parent
|
||||
break;
|
||||
// unclosed bbcode block should not be autoclosed by end of document.
|
||||
return false;
|
||||
}
|
||||
|
||||
start = state.bMarks[nextLine] + state.tShift[nextLine];
|
||||
|
|
|
@ -22,7 +22,7 @@ describe PrettyText do
|
|||
topic = Fabricate(:topic, title: "this is a test topic :slight_smile:")
|
||||
expected = <<HTML
|
||||
<aside class="quote" data-post="2" data-topic="#{topic.id}"><div class="title">
|
||||
<div class="quote-controls"></div><a href="http://test.localhost/t/this-is-a-test-topic-slight-smile/#{topic.id}/2">This is a test topic <img src="/images/emoji/emoji_one/slight_smile.png?v=5" title="slight_smile" alt="slight_smile" class="emoji"></a>
|
||||
<div class="quote-controls"></div><a href="http://test.localhost/t/this-is-a-test-topic-slight-smile/#{topic.id}/2">This is a test topic <img src="/images/emoji/twitter/slight_smile.png?v=5" title="slight_smile" alt="slight_smile" class="emoji"></a>
|
||||
</div>
|
||||
<blockquote><p>ddd</p></blockquote></aside>
|
||||
HTML
|
||||
|
@ -298,17 +298,17 @@ HTML
|
|||
end
|
||||
|
||||
it "should have an option to preserve emoji images" do
|
||||
emoji_image = "<img src='/images/emoji/emoji_one/heart.png?v=1' title=':heart:' class='emoji' alt='heart'>"
|
||||
emoji_image = "<img src='/images/emoji/twitter/heart.png?v=1' title=':heart:' class='emoji' alt='heart'>"
|
||||
expect(PrettyText.excerpt(emoji_image, 100, { keep_emoji_images: true })).to match_html(emoji_image)
|
||||
end
|
||||
|
||||
it "should have an option to remap emoji to code points" do
|
||||
emoji_image = "I <img src='/images/emoji/emoji_one/heart.png?v=1' title=':heart:' class='emoji' alt=':heart:'> you <img src='/images/emoji/emoji_one/heart.png?v=1' title=':unknown:' class='emoji' alt=':unknown:'> "
|
||||
emoji_image = "I <img src='/images/emoji/twitter/heart.png?v=1' title=':heart:' class='emoji' alt=':heart:'> you <img src='/images/emoji/twitter/heart.png?v=1' title=':unknown:' class='emoji' alt=':unknown:'> "
|
||||
expect(PrettyText.excerpt(emoji_image, 100, { remap_emoji: true })).to match_html("I ❤ you :unknown:")
|
||||
end
|
||||
|
||||
it "should have an option to preserve emoji codes" do
|
||||
emoji_code = "<img src='/images/emoji/emoji_one/heart.png?v=1' title=':heart:' class='emoji' alt=':heart:'>"
|
||||
emoji_code = "<img src='/images/emoji/twitter/heart.png?v=1' title=':heart:' class='emoji' alt=':heart:'>"
|
||||
expect(PrettyText.excerpt(emoji_code, 100)).to eq(":heart:")
|
||||
end
|
||||
|
||||
|
@ -463,10 +463,10 @@ HTML
|
|||
end
|
||||
|
||||
it "replaces skin toned emoji" do
|
||||
expect(PrettyText.cook("hello 👱🏿♀️")).to eq("<p>hello <img src=\"/images/emoji/emoji_one/blonde_woman/6.png?v=5\" title=\":blonde_woman:t6:\" class=\"emoji\" alt=\":blonde_woman:t6:\"></p>")
|
||||
expect(PrettyText.cook("hello 👩🎤")).to eq("<p>hello <img src=\"/images/emoji/emoji_one/woman_singer.png?v=5\" title=\":woman_singer:\" class=\"emoji\" alt=\":woman_singer:\"></p>")
|
||||
expect(PrettyText.cook("hello 👩🏾🎓")).to eq("<p>hello <img src=\"/images/emoji/emoji_one/woman_student/5.png?v=5\" title=\":woman_student:t5:\" class=\"emoji\" alt=\":woman_student:t5:\"></p>")
|
||||
expect(PrettyText.cook("hello 🤷♀️")).to eq("<p>hello <img src=\"/images/emoji/emoji_one/woman_shrugging.png?v=5\" title=\":woman_shrugging:\" class=\"emoji\" alt=\":woman_shrugging:\"></p>")
|
||||
expect(PrettyText.cook("hello 👱🏿♀️")).to eq("<p>hello <img src=\"/images/emoji/twitter/blonde_woman/6.png?v=5\" title=\":blonde_woman:t6:\" class=\"emoji\" alt=\":blonde_woman:t6:\"></p>")
|
||||
expect(PrettyText.cook("hello 👩🎤")).to eq("<p>hello <img src=\"/images/emoji/twitter/woman_singer.png?v=5\" title=\":woman_singer:\" class=\"emoji\" alt=\":woman_singer:\"></p>")
|
||||
expect(PrettyText.cook("hello 👩🏾🎓")).to eq("<p>hello <img src=\"/images/emoji/twitter/woman_student/5.png?v=5\" title=\":woman_student:t5:\" class=\"emoji\" alt=\":woman_student:t5:\"></p>")
|
||||
expect(PrettyText.cook("hello 🤷♀️")).to eq("<p>hello <img src=\"/images/emoji/twitter/woman_shrugging.png?v=5\" title=\":woman_shrugging:\" class=\"emoji\" alt=\":woman_shrugging:\"></p>")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -564,19 +564,19 @@ HTML
|
|||
it "can handle emoji by name" do
|
||||
|
||||
expected = <<HTML
|
||||
<p><img src="/images/emoji/emoji_one/smile.png?v=5\" title=":smile:" class="emoji" alt=":smile:"><img src="/images/emoji/emoji_one/sunny.png?v=5" title=":sunny:" class="emoji" alt=":sunny:"></p>
|
||||
<p><img src="/images/emoji/twitter/smile.png?v=5\" title=":smile:" class="emoji" alt=":smile:"><img src="/images/emoji/twitter/sunny.png?v=5" title=":sunny:" class="emoji" alt=":sunny:"></p>
|
||||
HTML
|
||||
expect(PrettyText.cook(":smile::sunny:")).to eq(expected.strip)
|
||||
end
|
||||
|
||||
it "handles emoji boundaries correctly" do
|
||||
cooked = PrettyText.cook("a,:man:t2:,b")
|
||||
expected = '<p>a,<img src="/images/emoji/emoji_one/man/2.png?v=5" title=":man:t2:" class="emoji" alt=":man:t2:">,b</p>'
|
||||
expected = '<p>a,<img src="/images/emoji/twitter/man/2.png?v=5" title=":man:t2:" class="emoji" alt=":man:t2:">,b</p>'
|
||||
expect(cooked).to match(expected.strip)
|
||||
end
|
||||
|
||||
it "can handle emoji by translation" do
|
||||
expected = '<p><img src="/images/emoji/emoji_one/wink.png?v=5" title=":wink:" class="emoji" alt=":wink:"></p>'
|
||||
expected = '<p><img src="/images/emoji/twitter/wink.png?v=5" title=":wink:" class="emoji" alt=":wink:"></p>'
|
||||
expect(PrettyText.cook(";)")).to eq(expected)
|
||||
end
|
||||
|
||||
|
@ -636,6 +636,12 @@ HTML
|
|||
expect(PrettyText.cook("a[i]b[/i]c")).to eq('<p>a<span class="bbcode-i">b</span>c</p>')
|
||||
end
|
||||
|
||||
it "can handle quote edge cases" do
|
||||
# expect(cook("a\n[quote]\ntest\n[quote]")).to include('aside')
|
||||
expect(cook("[quote]\ntest")).not_to include('aside')
|
||||
# expect(cook("[quote]abc\ntest\n[quote]")).not_to include('aside')
|
||||
end
|
||||
|
||||
it "do off topic quoting with emoji unescape" do
|
||||
|
||||
topic = Fabricate(:topic, title: "this is a test topic :slight_smile:")
|
||||
|
@ -643,7 +649,7 @@ HTML
|
|||
<aside class="quote" data-topic="#{topic.id}" data-post="2">
|
||||
<div class="title">
|
||||
<div class="quote-controls"></div>
|
||||
<a href="http://test.localhost/t/this-is-a-test-topic-slight-smile/#{topic.id}/2">This is a test topic <img src="/images/emoji/emoji_one/slight_smile.png?v=5" title="slight_smile" alt="slight_smile" class="emoji"></a>
|
||||
<a href="http://test.localhost/t/this-is-a-test-topic-slight-smile/#{topic.id}/2">This is a test topic <img src="/images/emoji/twitter/slight_smile.png?v=5" title="slight_smile" alt="slight_smile" class="emoji"></a>
|
||||
</div>
|
||||
<blockquote>
|
||||
<p>ddd</p>
|
||||
|
|
Loading…
Reference in New Issue