SublimeText / PackageDev

Tools to ease the creation of snippets, syntax definitions, etc. for Sublime Text.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[sublime-syntax] No regex syntax highlighting in double-quoted strings

AmjadHD opened this issue · comments

Unlike single-quoted and unquoted strings in contexts where a regex is expected, syntax highlighting is not provided for double-quoted strings.
image
image

This is a conscious choice, because double-quoted strings inside YAML require an escape of the backslash character, which is heavily used in regular expressions, leading to the string becoming almost unreadable if defined correctly. This is also why your double-quoted example is not equal to the single-quoted one, as all backslashes would require another backslash to escape them.

Because such expressions would be a nightmare to read (JSON says hello), YAML has single-quoted strings that do not suffer from this problem, since their only escape sequence is a doubled single quote (''), and it would require basically a rewrite of the regular expression syntax definition that matches \\<any> sequences instead of \<any>, this is not feasible to support in my eyes. The current lack of highlighting should indicated that double-quoted strings are sub-optimal.