Skip to content

Commit

Permalink
Restore feature from WOLips4.
Browse files Browse the repository at this point in the history
  • Loading branch information
nullterminated committed Jan 3, 2025
1 parent cc10e34 commit 35ba6d0
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.helger.css.ECSSVersion;
import com.helger.css.decl.CSSSelectorSimpleMember;
import com.helger.css.decl.CascadingStyleSheet;
import com.helger.css.decl.ICSSSelectorMember;
import com.helger.css.reader.CSSReader;

import jp.aonir.fuzzyxml.FuzzyXMLAttribute;
Expand Down Expand Up @@ -145,13 +146,19 @@ private void processStylesheet(String css) {
CascadingStyleSheet styles = CSSReader.readFromString(css, ECSSVersion.LATEST);
styles.getAllStyleRules().stream().forEach(stylerule ->{
stylerule.getAllSelectors().forEach(sel ->{
//FIXME add to _rules here
sel.getAllMembers().stream().forEach(mem ->{
//add to _rules here
String currentTag = "*";
ArrayList<String> currentClasses = _rules.computeIfAbsent(currentTag, k -> new ArrayList<>());
for(ICSSSelectorMember mem: sel.getAllMembers()) {
if(mem instanceof CSSSelectorSimpleMember m) {
if(m.isElementName()) {
currentTag = m.getValue();
currentClasses = _rules.computeIfAbsent(currentTag, k -> new ArrayList<>());
} else if(m.isClass()) {
currentClasses.add(m.getValue().substring(1));
}
}
});
}
});
});
}
Expand Down

0 comments on commit 35ba6d0

Please sign in to comment.