mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-10-18 20:26:30 +09:00
Keep a code block's leading newline when linking a message's text
A <pre> whose text starts with a newline needs one more written out to survive being parsed again, as the html5 serializer does with preserve_newline. Without it, linking text dropped one more of a code block's leading blank lines than rendering did before.
This commit is contained in:
1 parent
6052b123d5
commit
4e29c6e32b
2 files changed
+8
-1
No files matched your search
@@ -58,6 +58,12 @@ class MessagesHelperTest < ActionView::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
test "linking text doesn't eat a code block's leading blank line" do
|
||||
linked = view.send(:auto_link_text, "<pre>\n\n\nfirst https://example.com</pre>".html_safe)
|
||||
|
||||
assert_equal "\nfirst https://example.com", Nokogiri::HTML5.fragment(linked).at_css("pre").text
|
||||
end
|
||||
|
||||
test "message_presentation leaves an existing link's text alone" do
|
||||
message = Message.create! room: rooms(:pets), body: '<div><a href="https://example.com/">https://example.org/</a></div>', client_message_id: "0015", creator: users(:jason)
|
||||
|
||||
|
||||
Reference in new issue
Block a user