From 031aad43a573323ad6efaf690d58c19da1fa9d21 Mon Sep 17 00:00:00 2001 From: schneems Date: Thu, 12 Nov 2020 10:37:45 -0600 Subject: [PATCH] Use indentation code blocks instead of code fences When copying and pasting the output to GitHub issues I found that I could not put it inside of code blocks since the output itself has code blocks. To alleviate this we can use indentation to mark the code block instead. This allows us to directly copy and paste the output into GitHub. --- CHANGELOG.md | 1 + lib/syntax_search/display_invalid_blocks.rb | 5 +---- spec/unit/code_search_spec.rb | 2 +- spec/unit/display_invalid_blocks_spec.rb | 2 -- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d03a970..e183e55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## HEAD (unreleased) +- Codeblocks in output are now indented with 4 spaces and "code fences" are removed (https://github.com/zombocom/syntax_search/pull/11) - "Unmatched end" and "missing end" not generate different error text instructions (https://github.com/zombocom/syntax_search/pull/10) ## 0.1.1 diff --git a/lib/syntax_search/display_invalid_blocks.rb b/lib/syntax_search/display_invalid_blocks.rb index b380a80..8fa1310 100644 --- a/lib/syntax_search/display_invalid_blocks.rb +++ b/lib/syntax_search/display_invalid_blocks.rb @@ -64,16 +64,13 @@ def call EOM end - def indent(string, with: " ") + def indent(string, with: " ") string.each_line.map {|l| with + l }.join end def code_block string = String.new("") - string << "```\n" - # string << "#".rjust(@digit_count) + " filename: #{filename}\n\n" if filename string << code_with_lines - string << "```\n" string end diff --git a/spec/unit/code_search_spec.rb b/spec/unit/code_search_spec.rb index 9ce3e71..82ceece 100644 --- a/spec/unit/code_search_spec.rb +++ b/spec/unit/code_search_spec.rb @@ -17,7 +17,7 @@ def hai search.call expect(search.record_dir.entries.map(&:to_s)).to include("1-add-1.txt") - expect(search.record_dir.join("1-add-1.txt").read).to eq(<<~EOM.indent(2)) + expect(search.record_dir.join("1-add-1.txt").read).to eq(<<~EOM.indent(4)) 1 class OH 2 def hello ❯ 3 def hai diff --git a/spec/unit/display_invalid_blocks_spec.rb b/spec/unit/display_invalid_blocks_spec.rb index 6155ca9..c8f54fc 100644 --- a/spec/unit/display_invalid_blocks_spec.rb +++ b/spec/unit/display_invalid_blocks_spec.rb @@ -60,13 +60,11 @@ def hai terminal: false ) expect(display.code_block).to eq(<<~EOM) - ``` 1 class OH ❯ 2 def hello 3 def hai 4 end 5 end - ``` EOM end it "shows terminal characters" do