Serializer that recursively calls itself, producing a hyperscript tree of spans
function serializeSpan(span, serializers, index, options) {
    if (span === '\n' && serializers.hardBreak) {
      return h(serializers.hardBreak, {key: `hb-${index}`})
    }

    if (typeof span === 'string') {
      return serializers.text ? h(serializers.text, {key: `text-${index}`}, span) : span
    }

    let children
    if (span.children) {
      children = {
        children: span.children.map((child, i) =>
          options.serializeNode(child, i, span.children, true)
        )
      }
    }

    const serializedNode = objectAssign({}, span, children)

    return h(serializers.span, {
      key: span._key || `span-${index}`,
      node: serializedNode,
      serializers
    })
  }