Skip to content

[Close #21] Concat lines with trailing slash #28

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

Merged
merged 3 commits into from
Dec 10, 2020
Merged

Conversation

schneems
Copy link
Collaborator

Ruby lines that end with a slash \ indicate that the next line should be concatenated with the current line so:

  if "trailing" \
     "line" do
  end

Is functionally equivalent to:

  if "trailing" "line" do
  endf

We can replicate this logic by taking note when a line ends with a trailing slash and then concatenating it with the next line.

Functionally the TrailingSlashJoin class does this by concatenating the lines, and then hiding the original line.

To allow for output, the DisplayCodeWithLineNumbers is now aware that a code line may contain multiple code lines, and it will split and render each.

Ruby lines that end with a slash `\` indicate that the next line should be concatenated with the current line so:

```ruby
  if "trailing" \
     "line" do
  end
```

Is functionally equivalent to:

```ruby
  if "trailing" "line" do
  endf
```

We can replicate this logic by taking note when a line ends with a trailing slash and then concatenating it with the next line.

Functionally the TrailingSlashJoin class does this by concatenating the lines, and then hiding the original line.

To allow for output, the DisplayCodeWithLineNumbers is now aware that a code line may contain multiple code lines, and it will split and render each.
@schneems schneems force-pushed the schneems/trailing-do branch from 8f6083f to 4853d63 Compare December 10, 2020 18:07
@schneems schneems merged commit e4cc8c0 into main Dec 10, 2020
@schneems schneems deleted the schneems/trailing-do branch December 10, 2020 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant