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

Parser Error when erb comment tags span multiple lines #431

Closed
djuber opened this issue Mar 25, 2022 · 5 comments · Fixed by #432
Closed

Parser Error when erb comment tags span multiple lines #431

djuber opened this issue Mar 25, 2022 · 5 comments · Fixed by #432

Comments

@djuber
Copy link

djuber commented Mar 25, 2022

I noticed (initially when checking 1.0.2, but confirmed still in 1.0.4) an issue where multi-line comment tags like the following

  <%# this is a multiline comment
  it's totally fine
  nothing should fail %>

are recognized correctly by ERB and render correctly (don't render at all, the entire content is commented), but a parser error is raised when running 18n tasks

 bundle exec rspec
#<Thread:0x00005634a007a9d8 /home/djuber/reproduction/vendor/cache/ruby/3.0.0/gems/i18n-tasks-1.0.4/lib/i18n/tasks/scanners/scanner_multiplexer.rb:33 run> terminated with exception (report_on_exception is true):
/home/djuber/reproduction/vendor/cache/ruby/3.0.0/gems/parser-3.1.1.0/lib/parser/diagnostic/engine.rb:72:in `process': Error scanning app/views/layouts/application.html.erb: unterminated string meets end of file (I18n::Tasks::CommandError)


     Failure/Error: raise Parser::SyntaxError, diagnostic
     
     I18n::Tasks::CommandError:
       Error scanning app/views/layouts/application.html.erb: unterminated string meets end of file

Modifying the comment tag to include a # on each comment line resolves the parser error (tests run successfully), so we can work around this if needed, but indicates a drift between the ERB syntax and that recognized by the i18n tasks.

Originally we expected this was related to #430 (since the tag starts <%# and not <% # that was also possibly related), but the same problem was seen after updating to 1.0.4.

@glebm
Copy link
Owner

glebm commented Mar 26, 2022

Where is this syntax specified? Naively, it seems invalid, since <% indicates Ruby code and comments don't work like that in Ruby.

@glebm
Copy link
Owner

glebm commented Mar 26, 2022

/cc @davidwessman

glebm added a commit that referenced this issue Mar 26, 2022
glebm added a commit that referenced this issue Mar 26, 2022
@glebm
Copy link
Owner

glebm commented Mar 26, 2022

Released v1.0.5

@davidwessman
Copy link
Collaborator

https://ruby-doc.org/stdlib-3.1.1/libdoc/erb/rdoc/ERB.html

From Recognized tags ERB recommends not using ruby comments:

<%# comment -- ignored -- useful in testing %> (<% # doesn't work. Don't use Ruby comments.)

@djuber
Copy link
Author

djuber commented Mar 28, 2022

Thank you for the quick turn-around!

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 a pull request may close this issue.

3 participants