docs: def serialize_smarttag(ctx, document, el, root):
      "Serializes smarttag."
  
      if ctx.options['smarttag_span']:
          _span = etree.SubElement(root, 'span', {'class': 'smarttag', 'data-smarttag-element': el.element})
      else:
          _span = root
  
      for elem in el.elements:
          _ser = ctx.get_serializer(elem)
  
          if _ser:
              _td = _ser(ctx, document, elem, _span)
          else:
              if isinstance(elem, doc.Text):
                  children = list(_span)
  
                  if len(children) == 0:
                      _text = _span.text or u''
  
                      _span.text = u'{}{}'.format(_text, elem.text)
                  else:
                      _text = children[-1].tail or u''
  
                      children[-1].tail = u'{}{}'.format(_text, elem.text)
  
      fire_hooks(ctx, document, el, _span, ctx.get_hook('smarttag'))
  
      return root