code: function formatElements(
    value: string,
    elements: Array<any> = []
  ): string | Array<any> {
    // TODO: warn if there're any unprocessed elements
    // TODO: warn if element at `index` doesn't exist
  
    const parts = value.replace(nlRe, "").split(tagRe)
  
    // no inline elements, return
    if (parts.length === 1) return value
  
    const tree = []
  
    const before = parts.shift()
    if (before) tree.push(before)
  
    for (const [index, children, after] of getElements(parts)) {
      const element = elements[index]
      tree.push(
        cloneElement(
          element,
          { key: index },
  
          // format children for pair tags
          // unpaired tags might have children if it's a component passed as a variable
          children ? formatElements(children, elements) : element.props.children
        )
      )
  
      if (after) tree.push(after)
    }
  
    return tree
  }
docs: `formatElements` - parse string and return tree of react elements
  
  `value` is string to be formatted with <0>Paired<0/> or <0/> (unpaired)
  placeholders. `elements` is a array of react elements which indexes
  correspond to element indexes in formatted string