Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Hash sign breaks highlighting #114

Open
Tracked by #1
Nixinova opened this issue Mar 12, 2021 · 6 comments
Open
Tracked by #1

Hash sign breaks highlighting #114

Nixinova opened this issue Mar 12, 2021 · 6 comments

Comments

@Nixinova
Copy link

Nixinova commented Mar 12, 2021

Removing most of the checklist as I'm not using atom, I'm using the grammar file directly.

Description

The syntax grammar does not correctly tokenise properties with hashes inside them:

---
C#:
  programming: true
Language:
  name: C#

This syntax is valid and should be shown as such.

@Nixinova
Copy link
Author

Nixinova commented Mar 12, 2021

The issue is the [^...#...] and [^#]*? bits here (and in similar constructs):

'begin': '(?>^(\\s*)(-)?\\s*)([^!{@#%&*>,\'"][^#]*?)(:)\\s+((!!)omap)?'

@winstliu
Copy link
Contributor

It's been quite a while since I touched these regexes but looking at the line you linked, we're not being strict enough about hitting a comment. We break as soon as a # is found, even though the spec says "Comments must be separated from other tokens by white space characters". Maybe something like this would work:
([^!{@#%&*>,\'"](?:[^#]|(?<!\\s#)*?)
Maybe. I forget if the lookbehind would behave as expected there.

@Nixinova
Copy link
Author

I've messed around with a regex for this and like the many other times I've tried to figure out how to negate multiple characters, but can't figure out how to do it.

It would probably be more easier and accurate to have a comment token overwrite all the other tokens.

@winstliu
Copy link
Contributor

So I realized that negating multiple characters is very hard, but explicitly capturing the "space with everything except a # after it" is easier.
([^!{@#%&*>,\'"](?>\s[^#]|\S)*\s*)
Is that better? If not then yeah we might have to settle for what you proposed.

@Nixinova
Copy link
Author

That seems like it could work

@winstliu
Copy link
Contributor

@Nixinova would you mind creating a PR? If not I can go and setup my environment again and do it :).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants