stringifyElement = (node, config, state) => {
  // empty element and short tag
  if (node.children.length === 0) {
    if (config.useShortTags) {
      return (
        createIndent(config, state) +
        config.tagShortStart +
        node.name +
        stringifyAttributes(node, config) +
        config.tagShortEnd
      );
    }

    return (
      createIndent(config, state) +
      config.tagShortStart +
      node.name +
      stringifyAttributes(node, config) +
      config.tagOpenEnd +
      config.tagCloseStart +
      node.name +
      config.tagCloseEnd
    );
  }

  // non-empty element
  let tagOpenStart = config.tagOpenStart;
  let tagOpenEnd = config.tagOpenEnd;
  let tagCloseStart = config.tagCloseStart;
  let tagCloseEnd = config.tagCloseEnd;
  let openIndent = createIndent(config, state);
  let closeIndent = createIndent(config, state);

  if (state.textContext) {
    tagOpenStart = defaults.tagOpenStart;
    tagOpenEnd = defaults.tagOpenEnd;
    tagCloseStart = defaults.tagCloseStart;
    tagCloseEnd = defaults.tagCloseEnd;
    openIndent = '';
  } else if (textElems.has(node.name)) {
    tagOpenEnd = defaults.tagOpenEnd;
    tagCloseStart = defaults.tagCloseStart;
    closeIndent = '';
    state.textContext = node;
  }

  const children = stringifyNode(node, config, state);

  if (state.textContext === node) {
    state.textContext = null;
  }

  return (
    openIndent +
    tagOpenStart +
    node.name +
    stringifyAttributes(node, config) +
    tagOpenEnd +
    children +
    closeIndent +
    tagCloseStart +
    node.name +
    tagCloseEnd
  );
}
@param {import('./types.js').XastElement} node
@param {Options} config
@param {State} state
@returns {string}