                      ent["kb_link"] = (
                          TPL_KB_LINK.format(kb_id=kb_id, kb_url=kb_url) if kb_id else ""
                      )
                      entities.append(ent)
              token_markup["entities"] = entities
              per_token_info.append(token_markup)
          markup = self._render_markup(per_token_info)
          markup = TPL_SPANS.format(content=markup, dir=self.direction)
 
</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: </s> remove                     top_offset=self.top_offset + step,
 </s> add                     top_offset=top_offset, </s> remove         for entity, step in zip(entities, itertools.count(step=self.offset_step)):
 </s> add         for entity in entities:
                else:
                    # We don't specifically need to do this since we loop
                    # over tokens and spans sorted by their start_token,
                    # so we'll never use a span again after the last token it appears in,
                    # but if we were to use these spans again we'd want to make sure
                    # this value was reset correctly.
                    span["render_slot"] = 0
                      ent["kb_link"] = (
                          TPL_KB_LINK.format(kb_id=kb_id, kb_url=kb_url) if kb_id else ""
                      )
                      entities.append(ent)
                else:
                    # We don't specifically need to do this since we loop
                    # over tokens and spans sorted by their start_token,
                    # so we'll never use a span again after the last token it appears in,
                    # but if we were to use these spans again we'd want to make sure
                    # this value was reset correctly.
                    span["render_slot"] = 0
              token_markup["entities"] = entities
              per_token_info.append(token_markup)
          markup = self._render_markup(per_token_info)
          markup = TPL_SPANS.format(content=markup, dir=self.direction)
keep keep keep add 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