diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-05-24 12:11:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-24 12:11:56 +0200 |
commit | c279dbd47082e908d98dc8cf869c0ff7fc19f1ae (patch) | |
tree | dac7edd0f0c6ef72a865a2eed1c1f0b216c4745d | |
parent | 06de3a17f89e0a781389354aea6a9e3f72316b7d (diff) | |
parent | 55ba907108df537e90f2ca08d9b1674ff8649eb8 (diff) |
Merge pull request #1778 from ClearlyClaire/glitch-soc/fixes/code-block-indentation
Fix leading spaces being stripped in Markdown code blocks
-rw-r--r-- | app/lib/advanced_text_formatter.rb | 2 | ||||
-rw-r--r-- | spec/lib/advanced_text_formatter_spec.rb | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/app/lib/advanced_text_formatter.rb b/app/lib/advanced_text_formatter.rb index 728400819..dcaf34b91 100644 --- a/app/lib/advanced_text_formatter.rb +++ b/app/lib/advanced_text_formatter.rb @@ -8,7 +8,7 @@ class AdvancedTextFormatter < TextFormatter end def block_code(code, _language) - <<~HTML.squish + <<~HTML <pre><code>#{ERB::Util.h(code).gsub("\n", '<br/>')}</code></pre> HTML end diff --git a/spec/lib/advanced_text_formatter_spec.rb b/spec/lib/advanced_text_formatter_spec.rb index ea1a9570d..3255fc927 100644 --- a/spec/lib/advanced_text_formatter_spec.rb +++ b/spec/lib/advanced_text_formatter_spec.rb @@ -40,6 +40,10 @@ RSpec.describe AdvancedTextFormatter do it 'formats code using <pre> and <code>' do is_expected.to include '<pre><code>int main' end + + it 'does not strip leading spaces' do + is_expected.to include '> return 0' + end end context 'given some quote' do |