Tokenise backslash in escape sequences#116
Tokenise backslash in escape sequences#116winstliu merged 3 commits intoatom:masterfrom Cutlery-Drawer:slash-token
Conversation
|
Hey look, something even hairier than I am: @50Wliu There's some odd double-escaping issue with my (The snippet I tried tokenising is real, BTW...) |
|
I would like another spec that tests for a normal backslash sequence, such as |
| expect(tokens[10]).toEqual value: '"', scopes: ['source.coffee', 'string.quoted.double.coffee', 'punctuation.definition.string.end.coffee'] | ||
|
|
||
| it "tokenises leading backslashes in single-quoted strings", -> | ||
| {tokens} = grammar.tokenizeLine("'a\\\\b\\\\\\\\c'") |
There was a problem hiding this comment.
This is why I love how YAML has a string sequence that doesn't allow escape characters, to avoid shenanigans like this and your other example.
There was a problem hiding this comment.
YAML doesn't allow tabs, so fuck YAML. =)
|
Done and done! 👍 |
spec/coffee-script-spec.coffee
Outdated
| expect(tokens[9]).toEqual value: 'c', scopes: ['source.coffee', 'string.quoted.double.coffee'] | ||
| expect(tokens[10]).toEqual value: '"', scopes: ['source.coffee', 'string.quoted.double.coffee', 'punctuation.definition.string.end.coffee'] | ||
|
|
||
| {tokens} = grammar.tokenizeLine('"\\\\a\\\\t\\\\a\\\\b"') |
There was a problem hiding this comment.
I think there's a slight misunderstanding - what I'm asking for is something like '"\\a\\t\\a\\b"'.
There was a problem hiding this comment.
Oops.
Force-pushed an amended commit, my bad.

Decided to do this before the JSDoc grammar starts getting hairy. It enables a user to style the first backslash of a double-escape with their stylesheet:
Which yields noticeable improvement to readability when you're working with CSON grammars:
CaveatsI haven't added specs because I want to focus on atom/language-javascript#495. I figured if I was going through the trouble of forking and dev-linking another package to make another job easier, I may as well share it.Let me know if you still want me to add specs; but I won't get to it instantly.EDIT: Belay that, specs added.
Addendum
FTR, it actually is possible to target the first character using the
::first-letterpseudo-element, but it's very limited in what properties can be applied: and that excludesopacity. Alternative would've been to squabble with text-colour, and... yeah, nah thanks.