docs: def _parse_style_rules(self, css_body, ruleset_index):
          """Returns a list of rules to apply to this doc and a list of rules
          that won't be used because e.g. they are pseudoclasses. Rules
          look like: (specificity, selector, bulk)
          for example: ((0, 1, 0, 0, 0), u'.makeblue', u'color:blue').
          The bulk of the rule should not end in a semicolon.
          """
  
          def format_css_property(prop):
              if self.strip_important or prop.priority != "important":
                  return "{0}:{1}".format(prop.name, prop.value)
              else:
                  return "{0}:{1} !important".format(prop.name, prop.value)
  
          def join_css_properties(properties):
              """ Accepts a list of cssutils Property objects and returns
              a semicolon delimitted string like 'color: red; font-size: 12px'
              """
              return ";".join(format_css_property(prop) for prop in properties)
  
          leftover = []
          rules = []
          # empty string
          if not css_body:
              return rules, leftover
          sheet = self._parse_css_string(css_body, validate=not self.disable_validation)
          for rule in sheet:
              # handle media rule
              if rule.type == rule.MEDIA_RULE:
                  leftover.append(rule)
                  continue
              # only proceed for things we recognize
              if rule.type != rule.STYLE_RULE:
                  continue
  
              # normal means it doesn't have "!important"
              normal_properties = [
                  prop
                  for prop in rule.style.getProperties()
                  if prop.priority != "important"
              ]
              important_properties = [
                  prop
                  for prop in rule.style.getProperties()
                  if prop.priority == "important"
              ]
  
              # Create three strings that we can use to add to the `rules`
              # list later as ready blocks of css.
              bulk_normal = join_css_properties(normal_properties)
              bulk_important = join_css_properties(important_properties)
              bulk_all = join_css_properties(normal_properties + important_properties)
  
              selectors = (
                  x.strip()
                  for x in rule.selectorText.split(",")
                  if x.strip() and not x.strip().startswith("@")
              )
              for selector in selectors:
                  if (
                      ":" in selector
                      and self.exclude_pseudoclasses
                      and ":" + selector.split(":", 1)[1] not in FILTER_PSEUDOSELECTORS
                  ):
                      # a pseudoclass
                      leftover.append((selector, bulk_all))
                      continue
                  elif "*" in selector and not self.include_star_selectors:
                      continue
                  elif selector.startswith(":"):
                      continue
  
                  # Crudely calculate specificity
                  id_count = selector.count("#")
                  class_count = selector.count(".")
                  element_count = len(_element_selector_regex.findall(selector))
  
                  # Within one rule individual properties have different
                  # priority depending on !important.
                  # So we split each rule into two: one that includes all
                  # the !important declarations and another that doesn't.
                  for is_important, bulk in ((1, bulk_important), (0, bulk_normal)):
                      if not bulk:
                          # don't bother adding empty css rules
                          continue
                      specificity = (
                          is_important,
                          id_count,
                          class_count,
                          element_count,
                          ruleset_index,
                          len(rules),  # this is the rule's index number
                      )
                      rules.append((specificity, selector, bulk))
  
          return rules, leftover