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

Support syntax highlighting of functions and fields with accents #279

Merged
merged 3 commits into from
Dec 30, 2019

Conversation

fuhrmanator
Copy link
Contributor

For example, recognize the field activé in a class:

class A {
activé : Boolean
}

For example, recognize the field `activé` in a class:

class A {
    activé : Boolean
}
@fuhrmanator fuhrmanator changed the title Support functions and fields with accents Support syntax highlighting of functions and fields with accents Dec 3, 2019
@qjebbs
Copy link
Owner

qjebbs commented Dec 26, 2019

I suggest you replace [0-9a-zA-Z_]+ with \S+. If characters other than ascii is allowed, then allow all, not some of them

@fuhrmanator
Copy link
Contributor Author

fuhrmanator commented Dec 27, 2019

I suggest you replace [0-9a-zA-Z_]+ with \S+. If characters other than ascii is allowed, then allow all, not some of them

EDIT: The problem with \S is that it allows any non-whitespace, so a class named "Ab!@347" would be allowed. Perhaps better, but too permissive?

OK - the scope of my PR was to allow accented characters (incremental improvement), but I suppose this could also include any valid characters. It's pretty ambitious since UTF has a lot of possibilities (Voltaire said the best is the enemy of good).

I am not good with .yaml-tmLanguage syntax. Is there a documentation for how it works in VSCode? How can I define a reg-ex variables for things like identifiers? I found http://www.sublimetext.com/docs/3/syntax.html which has a variables: section, but I am not sure it's compatible with what the project will use.

@qjebbs
Copy link
Owner

qjebbs commented Dec 28, 2019

@fuhrmanator Agree with you. I firstly want to change to \w, but the JS RegExp behaviors different with other languages.

Within this project, you can run npm run buildsyntax to convert diagram.yaml-tmLanguage to diagram.tmLanguage.

@fuhrmanator
Copy link
Contributor Author

I think I solved it with \p{L}, but I wasn't sure my tests are accurate. I'm on windows 10 with npm in bash.

@fuhrmanator
Copy link
Contributor Author

See https://rubular.com/r/9p7JpPGAJtcGFJ and https://rubular.com/r/cJ15lkb8dcSGvK for tests -- I checked with my extension and it seems to work well.

@fuhrmanator
Copy link
Contributor Author

Also, I could not get the variables: definition to work, at least not the way it's documented in http://www.sublimetext.com/docs/3/syntax.html#variables -- I suppose .yaml-tmLanguage is not really the same format?

@qjebbs
Copy link
Owner

qjebbs commented Dec 30, 2019

I can confirm that [\p{L}0-9_]+ works, when it replace [0-9a-zA-Z_]+. And please squash commits into one commit, before I can merge.

.yaml-tmLanguage should finally convert to .tmLanguage, before it can be used. I don't know how well VSCode implemented (like the variables you said) according to the sumlime documentations.

@fuhrmanator
Copy link
Contributor Author

please squash commits into one commit, before I can merge.

GitHub will squash for you on the merge I think, if you choose the option. Is it ok?

https://stackoverflow.com/a/36377439/1168342

@qjebbs qjebbs merged commit 3ddf504 into qjebbs:master Dec 30, 2019
@qjebbs
Copy link
Owner

qjebbs commented Dec 30, 2019

OK, thanks for all your work!

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