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

syntax highlighting issues #73

Open
3 tasks
nyurik opened this issue Jun 2, 2017 · 5 comments
Open
3 tasks

syntax highlighting issues #73

nyurik opened this issue Jun 2, 2017 · 5 comments

Comments

@nyurik
Copy link

nyurik commented Jun 2, 2017

Hi, awesome project, I would really like to use it, but ACE support seems to be partially broken, and might need a bit of love. As an editor, I should always know exactly what each element will be treated as, without knowing HJSON rules by heart. I feel that syntax highlighting should be in line with how JSON itself works in ACE: simply show how each element will be parsed -- structure elements {}[]:, comments, object keys, object string, number, booleans, and null values, and most importantly - errors. While ace seems to have extra support for json parsing, even showing things in a bright red will highlight problems, even if it doesn't cover all of them initially.

  • a comment is not shown as such if it has a ":" plus any chars, unless there is a space
{
  //abc:
  #xyz:
}
  • a string value with two slashes (e.g. a URL) is shown as a comment, which its not
{
  aa: https://example.com
  bb: 700://comment
}
  • in a list, special characters before any letters are shown in a different style, making it harder for novices to tell if there is anything special about them, even though HJson is treating it as simple strings
[
    abc
    $?!@^%^&*(){}[]/=-abc
]
@laktak
Copy link
Member

laktak commented Jul 18, 2017

I have to admit that the ACE rules were very hard to write - the whole thing is build on regular expressions that are a pain to debug.

If you want to take a look, the source can be found here

@nyurik
Copy link
Author

nyurik commented Dec 23, 2017

@taktak I would like to hack on the ACE highlighting rules. Turns out there is a rule tester, which makes the process much easier. Do you have any unit tests for it? It would be good to set up a comprehensive single HJSON test file that has every possible usecase, and ensure that the rules produce what is expected.

Thanks!

@laktak
Copy link
Member

laktak commented Dec 29, 2017

@nyurik I'm not familiar with the rule tester but we have a lot of tests in https://github.com/hjson/hjson/tree/master/testCases

These target the parser but we have also used them to check the syntax (although manually as I know of no other highlighters that allow unit tests).

@nyurik
Copy link
Author

nyurik commented Dec 29, 2017

@laktak ACE has a bunch of tokenization test for many languages - https://github.com/ajaxorg/ace/tree/master/lib/ace/mode/_test - so we can add one for hjson there as well. I guess the .txt file will be a combination of most of those test cases hjson has already defined.

@geekley
Copy link

geekley commented Jul 10, 2018

a comment is not shown as such if it has a ":" plus any chars, unless there is a space

The same happens with quoted and unquoted string values.

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

No branches or pull requests

3 participants