JavaScript: add binaries, fix octals, improve escapes & allow Non-ASCII…

Authored by nibags on Aug 23 2018, 10:41 AM.

Description

JavaScript: add binaries, fix octals, improve escapes & allow Non-ASCII identifiers

Summary:
Changes:

  • Add binaries: 0b0101 [1]
  • Fix octals: the format of octals supported is: 0o1717, but the HlCOct rule is equivalent to 01717. [1]
  • Improve escapes [2]: HlCStringChar rule does not contain the exact escapes supported by JavaScript:
    • The reserved character escapes are '"\bfnrtv0. These are now highlighted in bold (itemData: "Reserved Char. Escape").
    • Hexadecimal escapes in JS only support 2 numbers: \xNN, but HlCStringChar admits 1 or 2.
    • The maximum value of octal escape is \377 (255 in decimal). For example, when typing \477, it's only considered as an escape: \47.
    • Any character can be escaped (previously, in the templates, the special character "$" for substitutions is not escaped).
  • In "JavaScript React" the context "Conditional Expression", which is unnecessary, is eliminated to simplify the code.
  • Add identifiers with Non-ASCII characters [3], to avoid highlighting RegExp and numbers after non-ASCII characters. This also applies to the highlighting of objects, functions and JSON properties.

BUG: 393633

References:

Reviewers: dhaumann, cullmann, Framework: Syntax Highlighting

Reviewed By: cullmann, Framework: Syntax Highlighting

Subscribers: kwrite-devel

Tags: Kate, Frameworks

Differential Revision: https://phabricator.kde.org/D13888