<commit_before>package eg.syntax;

/**
 * Syntax highlighting for CSS
 */
public class CSSHighlighter implements Highlighter {

   // complete ?
   private final static String[] PROPERTIES = {
      "all",
      "background", "background-attachment", "background-clip", "background-color",
      "background-image", "background-origin", "background-position",
      "background-repreat", "background-size",
      "border", "border-bottom", "border-bottom-color", "border-bottom-left-radius",
      "border-bottom-rigth-radius",  "border-bottom-style", "border-bottom-width",
      "border-collapse", "border-color", "border-image",  "border-image-outset",
      "border-image-repeat", "border-image-slice", "border-image-source",
      "border-image-width", "border-left", "border-left-color", "border-left-style",
      "border-left-width", "border-radius", "border-right", "border-right-color",
      "border-right-style", "border-right-width", "border-spacing", "border-style",
      "border-top", "border-top-color", "border-top-left-radius",
      "border-top-right-radius", "border-top-style", "border-top-width",
      "border-width", "bottom", "box-shadow",
      "caption-side", "clear", "clip", "color", "content", "counter-increment",
      "counter-reset", "cursor",
      "direction", "display",
      "empty-cells",
      "float", "font", "font-family", "font-size", "font-size-adjust",
      "font-stretch", "font-style", "font-synthesis", "font-variant", "font-weight",
      "height",
      "left", "letter-spacing", "line-height", "list-style", "list-style-image",
      "list-style-position", "list-style-type",
      "margin", "margin-bottom", "margin-left", "margin-right", "margin-top",
      "max-height", "max-width", "min-height", "min-width",
      "opacity", "orphans", "outline", "outline-color", "outline-style",
      "outline-width", "overflow",
      "padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
      "page-break-after", "page-break-before", "page-break-inside", "position",
      "quotes",
      "right",
      "size",
      "table-layout", "text-align", "text-decoration", "text-indent",
      "text-transform",
      "top", "transform", "transform-origin", "transition", "transition-delay",
      "transition-duration", "transition-property", "transition-timing-function",
      "unicode-bidi",
      "vertical-align", "visibility",
      "white-space", "widows", "width", "word-spacing",
      "z-index"
   };

   private final static char[] CLASS_START = {
      '.', '#'
   };

   private final static char[] CLASS_END = {
      ' ', '{'
   };

   private final static char[] NON_PROP_START = {
      '-', '.'
   };

   @Override
   public void highlight(SyntaxHighlighter.SyntaxSearcher searcher) {
      if (!searcher.isInBlock(SyntaxUtils.BLOCK_CMNT_START,
            SyntaxUtils.BLOCK_CMNT_END)) {

         searcher.setCharAttrBlack();
         searcher.keywords(HTMLHighlighter.TAGS, CLASS_START, false,
               Attributes.BLUE_PLAIN);
               
         searcher.signedVariables(CLASS_START, CLASS_END, false,
               Attributes.BLUE_PLAIN);
               
         searcher.keywords(PROPERTIES, NON_PROP_START, true, Attributes.RED_PLAIN);
         searcher.bracesGray();
      }
      searcher.blockComments(SyntaxUtils.BLOCK_CMNT_START, SyntaxUtils.BLOCK_CMNT_END);
   }
}<commit_msg>split properties, e.g. search for "-size" only if "background" is found<commit_after>package eg.syntax;

/**
 * Syntax highlighting for CSS
 */
public class CSSHighlighter implements Highlighter {

   //
   // Properties
   private final static String[] PROPS = {
      "all",
      "bottom", "box-shadow",
      "caption-side", "clear", "clip", "color", "content", "counter-increment",
      "counter-reset", "cursor",
      "direction", "display",
      "empty-cells",
      "float",
      "height",
      "left", "letter-spacing", "line-height",
      "max-height", "max-width", "min-height", "min-width",
      "opacity", "orphans", "overflow",
      "page-break-after", "page-break-before", "page-break-inside", "position",
      "quotes",
      "right",
      "size",
      "table-layout", "text-align", "text-decoration", "text-indent",
      "text-transform",
      "top", "transform", "transform-origin",
      "unicode-bidi",
      "vertical-align", "visibility",
      "white-space", "widows", "width", "word-spacing",
      "z-index"
   };
   //
   // Property appandages
   private final static String[] BACKGROUND_PROPS = {
      "-attachment", "-clip", "-color",
      "-image", "-origin", "-position",
      "-repreat", "-size"
   };
   private final static String[] BORDER_PROPS = {
      "-bottom", "-bottom-color", "-bottom-left-radius",
      "-bottom-rigth-radius",  "-bottom-style", "-bottom-width",
      "-collapse", "-color", "-image",  "-image-outset",
      "-image-repeat", "-image-slice", "-image-source",
      "-image-width", "-left", "-left-color", "-left-style",
      "-left-width", "-radius", "-right", "-right-color",
      "-right-style", "-right-width", "-spacing", "-style",
      "-top", "-top-color", "-top-left-radius",
      "-top-right-radius", "-top-style", "-top-width",
      "-width"
   };
   private final static String[] TOP_LEFT_RIGHT_BOTTOM_OPT = {
      "-bottom", "-left", "-right", "-top"
   };
   private final static String[] FONT_PROPS = {
      "-family", "-size", "-size-adjust", "-stretch", "-style",
      "-synthesis", "-variant", "-weight"
   }; 
   private final static String[] LIST_PROPS = {
      "-style", "-style-image", "-style-position", "-style-type"
   };  
   private final static String[] MARGIN_PROPS = TOP_LEFT_RIGHT_BOTTOM_OPT;
   private final static String[] OUTLINE_PROPS = {
      "-color", "-style", "-width"
   };
   private final static String[] PADDING_PROPS = TOP_LEFT_RIGHT_BOTTOM_OPT;
   private final static String[] TRANSITION_PROPS = {
      "-delay", "-duration", "-property", "-timing-function"
   };
   //
   // General
   private final static char[] CLASS_START = {'.', '#'};
   private final static char[] CLASS_END = {' ', '{'};
   private final static char[] NON_PROP_START = {'-', '.'};

   @Override
   public void highlight(SyntaxHighlighter.SyntaxSearcher searcher) {
      if (!searcher.isInBlock(SyntaxUtils.BLOCK_CMNT_START,
            SyntaxUtils.BLOCK_CMNT_END)) {

         searcher.setCharAttrBlack();
         searcher.keywords(HTMLHighlighter.TAGS, CLASS_START, false,
               Attributes.BLUE_PLAIN);
               
         searcher.signedVariables(CLASS_START, CLASS_END, false,
               Attributes.BLUE_PLAIN);
         
         searcher.extensibleKeyword("background", BACKGROUND_PROPS,
               NON_PROP_START, true, Attributes.RED_PLAIN);
               
         searcher.extensibleKeyword("border", BORDER_PROPS, NON_PROP_START, true,
               Attributes.RED_PLAIN);
               
         searcher.extensibleKeyword("font", FONT_PROPS, NON_PROP_START, true,
               Attributes.RED_PLAIN);
               
         searcher.extensibleKeyword("list", LIST_PROPS, NON_PROP_START, true,
               Attributes.RED_PLAIN);
               
         searcher.extensibleKeyword("margin", MARGIN_PROPS, NON_PROP_START, true,
               Attributes.RED_PLAIN);
               
         searcher.extensibleKeyword("outline", OUTLINE_PROPS, NON_PROP_START, true,
               Attributes.RED_PLAIN);
               
         searcher.extensibleKeyword("padding", PADDING_PROPS, NON_PROP_START, true,
               Attributes.RED_PLAIN);
               
         searcher.extensibleKeyword("transition", TRANSITION_PROPS,
               NON_PROP_START, true, Attributes.RED_PLAIN);
                  
         searcher.keywords(PROPS, NON_PROP_START, true, Attributes.RED_PLAIN);
         searcher.bracesGray();
      }
      searcher.blockComments(SyntaxUtils.BLOCK_CMNT_START,
            SyntaxUtils.BLOCK_CMNT_END);
   }
}
{'fraction_non_alphanumeric': 0.16706413957574998, 'fraction_numerical': 0.0, 'mean_word_length': 2.785273159144893, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4492424', 'n_tokens_mistral': 2509, 'n_tokens_neox': 2436, 'n_words': 447}