              color = self.colors.get(entity["label"].upper(), self.default_color)
              span_start = (
                  self.span_start_template.format(
                      bg=color,
                      top_offset=self.top_offset + step,
                      label=entity["label"],
                      kb_link=entity["kb_link"],
                  )
                  if entity["is_start"]
                  else ""
 
</s> remove         for entity, step in zip(entities, itertools.count(step=self.offset_step)):
 </s> add         for entity in entities: </s> remove                     ent["is_start"] = True if idx == span["start_token"] else False
 </s> add                     ent["is_start"] = span_start
                    if span_start:
                        # When the span starts, we need to know how many other
                        # spans are on the 'span stack' and will be rendered.
                        # This value becomes the vertical render slot for this entire span
                        span["render_slot"] = concurrent_spans
                    ent["render_slot"] = span["render_slot"] </s> remove             entities = sorted(token["entities"], key=lambda d: d["label"])
            if entities:
 </s> add             entities = sorted(token["entities"], key=lambda d: d["render_slot"])
            # Whitespace tokens disrupt the vertical space (no line height) so that the
            # span indicators get misaligned. We don't render them as individual
            # tokens anyway, so we'll just not display a span indicator either.
            is_whitespace = token["text"].strip() == ""
            if entities and not is_whitespace:
                    top_offset=top_offset,
              color = self.colors.get(entity["label"].upper(), self.default_color)
              span_start = (
                  self.span_start_template.format(
                      bg=color,
                    top_offset=top_offset,
                      label=entity["label"],
                      kb_link=entity["kb_link"],
                  )
                  if entity["is_start"]
                  else ""
keep keep keep keep replace keep keep keep keep keep
 displaCy Spans Vertical Alignment Fix 2 (#11092)

* add in span render slot fix

* fix spacing off by one

* rm demo

* adjust comments

* fix whitespace and overlap issue 
spacy/displacy/render.py