class_docstr: Render named entities as HTML.
class_docstr_tok: ["Render","named","entities","as","HTML","."]
docstr: Render entities in text.
  
  text (str): Original text.
  spans (list): Individual entity spans and their start, end, label, kb_id and kb_url.
  title (str / None): Document title set in Doc.user_data['title'].
docstr_tok: ["Render","entities","in","text",".","text","(","str",")",":","Original","text",".","spans","(","list",")",":","Individual","entity","spans","and","their","start",",","end",",","label",",","kb_id","and","kb_url",".","title","(","str","\/","None",")",":","Document","title","set","in","Doc.user_data","[","'title","'","]","."]
code: def render_ents(
      self, text: str, spans: List[Dict[str, Any]], title: Optional[str]
  ) -> str:
      """Render entities in text.
  
      text (str): Original text.
      spans (list): Individual entity spans and their start, end, label, kb_id and kb_url.
      title (str / None): Document title set in Doc.user_data['title'].
      """
      markup = ""
      offset = 0
      for span in spans:
          label = span["label"]
          start = span["start"]
          end = span["end"]
          kb_id = span.get("kb_id", "")
          kb_url = span.get("kb_url", "#")
          kb_link = (
              TPL_KB_LINK.format(kb_id=kb_id, kb_url=kb_url)
              if kb_id
              else ""
          )
          additional_params = span.get("params", {})
          entity = escape_html(text[start:end])
          fragments = text[offset:start].split("\n")
          for i, fragment in enumerate(fragments):
              markup += escape_html(fragment)
              if len(fragments) > 1 and i != len(fragments) - 1:
                  markup += "<br>"
          if self.ents is None or label.upper() in self.ents:
              color = self.colors.get(label.upper(), self.default_color)
              ent_settings = {
                  "label": label,
                  "text": entity,
                  "bg": color,
                  "kb_link": kb_link,
              }
              ent_settings.update(additional_params)
              markup += self.ent_template.format(**ent_settings)
          else:
              markup += entity
          offset = end
      fragments = text[offset:].split("\n")
      for i, fragment in enumerate(fragments):
          markup += escape_html(fragment)
          if len(fragments) > 1 and i != len(fragments) - 1:
              markup += "<br>"
      markup = TPL_ENTS.format(content=markup, dir=self.direction)
      if title:
          markup = TPL_TITLE.format(title=title) + markup
      return markup
  
imports: import uuid
  from typing import Any, Dict, List, Optional, Tuple, Union
  from ..errors import Errors
  from ..util import escape_html, minify_html, registry
  from .templates import TPL_DEP_ARCS, TPL_DEP_SVG, TPL_DEP_WORDS, TPL_DEP_WORDS_LEMMA, TPL_ENT, TPL_ENT_RTL, TPL_ENTS, TPL_FIGURE, TPL_KB_LINK, TPL_PAGE, TPL_SPAN, TPL_SPAN_RTL, TPL_SPAN_SLICE, TPL_SPAN_SLICE_RTL, TPL_SPAN_START, TPL_SPAN_START_RTL, TPL_SPANS, TPL_TITLE
label_desc: Use image node_id 3 for calling the EntityRenderer obj's underlying member method code with example usage: obj.render_ents(text, spans, title) and returns: markup