diff --git a/Gemfile b/Gemfile
index ccc4da06a..c524ee3c1 100644
--- a/Gemfile
+++ b/Gemfile
@@ -25,7 +25,6 @@ gem "trilogy", "~> 2.9"
gem "bcrypt", "~> 3.1.7"
gem "geared_pagination", "~> 1.2"
gem "rqrcode"
-gem "redcarpet"
gem "rouge"
gem "jbuilder"
gem "lexxy", bc: "lexxy"
diff --git a/Gemfile.lock b/Gemfile.lock
index d20d773b7..f937c83e8 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -355,7 +355,6 @@ GEM
erb
psych (>= 4.0.0)
tsort
- redcarpet (3.6.1)
regexp_parser (2.11.3)
reline (0.6.3)
io-console (~> 0.5)
@@ -521,7 +520,6 @@ DEPENDENCIES
puma (>= 5.0)
rack-mini-profiler
rails!
- redcarpet
rouge
rqrcode
rubocop-rails-omakase
diff --git a/Gemfile.saas.lock b/Gemfile.saas.lock
index 84b5cf2b3..4d267e4fd 100644
--- a/Gemfile.saas.lock
+++ b/Gemfile.saas.lock
@@ -466,7 +466,6 @@ GEM
erb
psych (>= 4.0.0)
tsort
- redcarpet (3.6.1)
regexp_parser (2.11.3)
reline (0.6.3)
io-console (~> 0.5)
@@ -676,7 +675,6 @@ DEPENDENCIES
rack-mini-profiler
rails!
rails_structured_logging!
- redcarpet
rouge
rqrcode
rubocop-rails-omakase
diff --git a/app/assets/stylesheets/cards.css b/app/assets/stylesheets/cards.css
index f36b4e76f..272ff7b1f 100644
--- a/app/assets/stylesheets/cards.css
+++ b/app/assets/stylesheets/cards.css
@@ -220,6 +220,15 @@
.card__title-link {
color: inherit;
}
+
+ code {
+ background-color: var(--color-canvas);
+ border: 1px solid var(--color-ink-lighter);
+ border-radius: 0.25ch;
+ font-family: var(--font-mono);
+ font-size: smaller;
+ padding: 0.1ch 0.25ch;
+ }
}
.card__description {
diff --git a/app/helpers/html_helper.rb b/app/helpers/html_helper.rb
index a3d0bbab3..7b65d34cf 100644
--- a/app/helpers/html_helper.rb
+++ b/app/helpers/html_helper.rb
@@ -2,4 +2,10 @@ module HtmlHelper
def format_html(html)
Loofah::HTML5::DocumentFragment.parse(html).scrub!(AutoLinkScrubber.new).to_html.html_safe
end
+
+ def card_html_title(card)
+ return card.title if card.title.blank?
+
+ ERB::Util.html_escape(card.title).gsub(/`([^`]+)`/, '\1').html_safe
+ end
end
diff --git a/app/views/cards/container/_content_display.html.erb b/app/views/cards/container/_content_display.html.erb
index 46a9a83d1..e99b5784f 100644
--- a/app/views/cards/container/_content_display.html.erb
+++ b/app/views/cards/container/_content_display.html.erb
@@ -1,5 +1,5 @@
bug in production", element.inner_html
+ end
end
test "edit" do
diff --git a/test/helpers/html_helper_test.rb b/test/helpers/html_helper_test.rb
index 1af507ddf..0fd6c268a 100644
--- a/test/helpers/html_helper_test.rb
+++ b/test/helpers/html_helper_test.rb
@@ -119,4 +119,29 @@ class HtmlHelperTest < ActionView::TestCase
assert_no_match(/foo and bar", 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 "whataboutthis", card_html_title(cards(:logo).tap { _1.title = "what`about`this" })
+ end
+
+ test "card_html_title escapes HTML tags" do
+ assert_equal "<script>alert(1)</script>", card_html_title(cards(:logo).tap { _1.title = "" })
+ end
+
+ test "card_html_title escapes HTML inside backticks" do
+ assert_equal "<script>", card_html_title(cards(:logo).tap { _1.title = "`