home
readme
diff
tree
note
docs
0commit a21501590980a905fa9b902897d700a42a08b7f0
1Author: Mason Wright <mason@lakefox.net>
2Date: Mon Jun 23 14:25:00 2025 -0600
3
4 Updated parseSelectorParts to better handle brackets
5
6diff --git a/src/grim.cc b/src/grim.cc
7index 9950d0c..301e78f 100755
8--- a/src/grim.cc
9+++ b/src/grim.cc
10@@ -237,36 +237,41 @@ class StyleHandler {
11 // we will extract the quick to verify parts from it
12 // so we can build the basemap
13 std::string part;
14+ bool inbracket = false;
15 for (auto w : word) {
16 // if the current letter is a : that is either a pseudo element
17 // or selector. We don't care about that part for this part
18- if (w != ':') {
19- // We don't care if the thing we are splitting is a id or class we just
20- // need them split up so we can use them as map keys
21-
22- if (w == '#') {
23- if (part != "") {
24- parts.push_back(part);
25- part = "";
26- }
27-
28- } else if (w == '.') {
29- if (part != "") {
30- parts.push_back(part);
31- part = "";
32- }
33- } else if (w == '[' || w == ']') {
34- if (part != "") {
35- parts.push_back(part);
36- part = "";
37- }
38- continue;
39+ if (w == ':' && !inbracket) {
40+ break;
41+ }
42+ // We don't care if the thing we are splitting is a id or class we just
43+ // need them split up so we can use them as map keys
44+
45+ if (w == '#' && !inbracket) {
46+ if (part != "") {
47+ parts.push_back(part);
48+ part = "";
49 }
50
51- part += w;
52- } else {
53- break;
54+ } else if (w == '.' && !inbracket) {
55+ if (part != "") {
56+ parts.push_back(part);
57+ part = "";
58+ }
59+ } else if (w == '[' || w == ']') {
60+ if (w=='[') {
61+ inbracket = true;
62+ } else if (w == ']'){
63+ inbracket = false;
64+ }
65+ if (part != "") {
66+ parts.push_back(part);
67+ part = "";
68+ }
69+ continue;
70 }
71+
72+ part += w;
73 }
74
75 if (part != "") {