diff --git a/app/lib/advanced_text_formatter.rb b/app/lib/advanced_text_formatter.rb index 5ce87d306..728400819 100644 --- a/app/lib/advanced_text_formatter.rb +++ b/app/lib/advanced_text_formatter.rb @@ -9,7 +9,7 @@ class AdvancedTextFormatter < TextFormatter def block_code(code, _language) <<~HTML.squish -
#{h(code).gsub("\n", '
')}
+
#{ERB::Util.h(code).gsub("\n", '
')}
HTML end diff --git a/spec/lib/advanced_text_formatter_spec.rb b/spec/lib/advanced_text_formatter_spec.rb index c097b86e1..4e859c93c 100644 --- a/spec/lib/advanced_text_formatter_spec.rb +++ b/spec/lib/advanced_text_formatter_spec.rb @@ -34,6 +34,14 @@ RSpec.describe AdvancedTextFormatter do end end + context 'given a block code' do + let(:text) { "test\n\n```\nint main(void) {\n return 0;\n}\n```\n" } + + it 'formats code using
 and ' do
+          is_expected.to include '
int main'
+        end
+      end
+
       context 'given some quote' do
         let(:text) { "> foo\n\nbar" }