Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use indentation code blocks instead of code fences #11

Merged
merged 1 commit into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 1 addition & 4 deletions lib/syntax_search/display_invalid_blocks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/code_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions spec/unit/display_invalid_blocks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down