Commit d6fb836
committed
feat: add way to style identifiers
Replace "default" segment with "whitespace" and "identifier" segments,
with fallback to "unknown" segment.
Also, classify backticked identifiers like `foo` as "identifier" rather than "string".
This allows for identifiers to be styled independently from strings and whitespace.
It also simplifies getSegments() from 30 lines down to 5, by removing the special-case
code for the "default" segment.
BREAKING CHANGE: The `default` segment has been split into `identifier` and `whitespace`
segments. There's also a new `unknown` segment that will only show up for malformed
SQL such as an unclosed string.
However, the highlight() function works largely the same as before, both normal mode and HTML mode,
except for the bug fix to stop classifying identifiers as strings. In other words, SQL like
select * from EMP where NAME="John Smith"
will get highlighted the same as before, i.e. no syntax highlighting for EMP or NAME.
Fixes #147.1 parent 4a3aa67 commit d6fb836
3 files changed
+85
-111
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
116 | | - | |
| 115 | + | |
| 116 | + | |
117 | 117 | | |
118 | | - | |
119 | | - | |
120 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
121 | 121 | | |
122 | | - | |
123 | | - | |
124 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
125 | 125 | | |
126 | | - | |
127 | | - | |
128 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | 22 | | |
25 | 23 | | |
26 | 24 | | |
27 | 25 | | |
28 | | - | |
| 26 | + | |
29 | 27 | | |
30 | 28 | | |
31 | 29 | | |
| |||
34 | 32 | | |
35 | 33 | | |
36 | 34 | | |
37 | | - | |
38 | | - | |
| 35 | + | |
39 | 36 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
44 | 43 | | |
45 | | - | |
| 44 | + | |
46 | 45 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
52 | 51 | | |
53 | 52 | | |
54 | 53 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
85 | 58 | | |
86 | 59 | | |
87 | 60 | | |
| |||
90 | 63 | | |
91 | 64 | | |
92 | 65 | | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | 66 | | |
97 | 67 | | |
98 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
99 | 72 | | |
100 | | - | |
| 73 | + | |
101 | 74 | | |
102 | 75 | | |
103 | 76 | | |
| |||
0 commit comments