Render inline code in card titles (#2518)

* Remove unused marked JS dependency

* Remove unused redcarpet dependency

* Render inline code in card titles

Add card_html_title helper that HTML-escapes input then converts
backtick-wrapped text to <code> elements. Apply to card titles in
board preview, card detail, public views, and notification emails.
Style inline code elements in titles to match description styling.

Co-authored-by: Andy Smith <andy@37signals.com>

---------

Co-authored-by: Andy Smith <andy@37signals.com>
This commit is contained in:
Mike Dalessio
2026-02-12 12:07:40 -05:00
committed by GitHub
parent 486da76a26
commit 851f13a934
15 changed files with 63 additions and 2597 deletions
+25
View File
@@ -119,4 +119,29 @@ class HtmlHelperTest < ActionView::TestCase
assert_no_match(/<img/, output, "should not create an img element")
assert_includes output, "&lt;img"
end
test "card_html_title renders backticks as code elements" do
assert_equal "Fix the <code>bug</code> in production", card_html_title(cards(:logo).tap { _1.title = "Fix the `bug` in production" })
end
test "card_html_title renders multiple code spans" do
assert_equal "<code>foo</code> and <code>bar</code>", card_html_title(cards(:logo).tap { _1.title = "`foo` and `bar`" })
end
test "card_html_title renders code spans without surrounding spaces" do
assert_equal "what<code>about</code>this", card_html_title(cards(:logo).tap { _1.title = "what`about`this" })
end
test "card_html_title escapes HTML tags" do
assert_equal "&lt;script&gt;alert(1)&lt;/script&gt;", card_html_title(cards(:logo).tap { _1.title = "<script>alert(1)</script>" })
end
test "card_html_title escapes HTML inside backticks" do
assert_equal "<code>&lt;script&gt;</code>", card_html_title(cards(:logo).tap { _1.title = "`<script>`" })
end
test "card_html_title returns blank title as-is" do
assert_nil card_html_title(cards(:logo).tap { _1.title = nil })
assert_equal "", card_html_title(cards(:logo).tap { _1.title = "" })
end
end