Don't extract ERB comments as Ruby comments in herb_extract_ruby#98
Merged
Don't extract ERB comments as Ruby comments in herb_extract_ruby#98
herb_extract_ruby#98Conversation
herb_extract_ruby
herb_extract_rubyherb_extract_ruby
herb_extract_rubyherb_extract_ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request updates the
herb_extract_rubyandherb_extract_ruby_to_buffer_with_semicolonsmethods inextract.cto not extract the content of ERB Comment Nodes (<%#) as Ruby code.So a source file like this:
Was extracted to Ruby code as:
With the changes included in this pull request it's going to be:
titleThis is in order to resolve #91. It's valid to have multi-line ERB Comments like:
Which before this pull request was extracted to Ruby as:
Which is not a valid Ruby comment anymore, but treated as actual Ruby code from the second line on. If the comment itself included Ruby keywords it would cause syntax errors.
For now, we don't extract the ERB Comments at all - which is the change this pull request introduces.
In the future, we can implement #100 (and/or #102) and also make sure that multi-line ERB Comments get extracted to multi-line Ruby Comments, like:
or maybe even cleverer: replace the
<%with a=beginand the%>with a=end:Another case where it would break Ruby syntax is in this example:
Which is going to comment out the
endas well:This use-case is also fixed with this pull request, since we just skip over the ERB Comments content:
This last example could be solved even more elegantly if Ruby shipped the Inline Comments feature:
https://bugs.ruby-lang.org/issues/20405
This following example is still broken and this pull request does not address that use-case. I opened #101 for this.
Currently it does not address the case, where the comment is part of the Ruby Code itself, so the comment is not seen as a "ERB Comment Node":