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

Warn about usage of non-breaking space #107

Merged
merged 8 commits into from
Apr 23, 2019
Merged

Warn about usage of non-breaking space #107

merged 8 commits into from
Apr 23, 2019

Conversation

byara
Copy link
Contributor

@byara byara commented Mar 7, 2019

Reference issue: #85

What changed in this PR:

This PR adds a warning about usage of non-breaking space in a template. Regarding this issue, a unit test is added.

@byara byara changed the title Better error message for Non-breakable space tokens Warn about usage of non-breaking space Mar 7, 2019
@byara
Copy link
Contributor Author

byara commented Mar 11, 2019

This issue could be addressed also by creating a new Token for non-breaking space and Melody would automatically throw a warning like, Invalid Token Expected symbol but found NonBreakingSpace instead.

@pago
Copy link
Contributor

pago commented Mar 12, 2019

Question: Do we also want to cover other unicode sequences which represent whitespace?

Resources:
https://codepen.io/rubikzube/pen/wolgB
http://xahlee.info/js/js_whitespace.html
https://mathiasbynens.be/notes/javascript-escapes
https://mathiasbynens.be/notes/javascript-unicode

@byara
Copy link
Contributor Author

byara commented Mar 13, 2019

Question: Do we also want to cover other unicode sequences which represent whitespace?

Resources:
https://codepen.io/rubikzube/pen/wolgB
http://xahlee.info/js/js_whitespace.html
https://mathiasbynens.be/notes/javascript-escapes
https://mathiasbynens.be/notes/javascript-unicode

I believe it is a good idea to address all unicode sequences which represent whitespace. It prevent the future bugs/bug reports regarding these type of issues.

We can also follow Babel example and use something similar to https://github.com/xtuc/charcodes/tree/master/packages/charcodes and use charCodeAt. Or just add the characters and address them in the appropriate function. One benefit of using charCodeAt + the separate package would be to target characters that cannot be easily read or shown.

@pago
Copy link
Contributor

pago commented Mar 14, 2019

Do what you think is best. :)

Copy link
Contributor

@pago pago left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed we will want to protect from some additional characters or at least use a unicode representation within the code to avoid confusion.

packages/melody-parser/src/Lexer.js Outdated Show resolved Hide resolved
@pago pago merged commit 92bf980 into trivago:master Apr 23, 2019
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.

2 participants