src/language-yaml/printer-yaml.js/genericPrint
function genericPrint(path, options, print) {
  const node = path.getValue();
  const parentNode = path.getParentNode();

  const tag = !node.tag ? "" : path.call(print, "tag");
  const anchor = !node.anchor ? "" : path.call(print, "anchor");

  const nextEmptyLine =
    isNode(node, [
      "mapping",
      "sequence",
      "comment",
      "directive",
      "mappingItem",
      "sequenceItem",
    ]) && !isLastDescendantNode(path)
      ? printNextEmptyLine(path, options.originalText)
      : "";

  return concat([
    node.type !== "mappingValue" && hasLeadingComments(node)
      ? concat([join(hardline, path.map(print, "leadingComments")), hardline])
      : "",
    tag,
    tag && anchor ? " " : "",
    anchor,
    tag || anchor
      ? isNode(node, ["sequence", "mapping"]) && !hasMiddleComments(node)
        ? hardline
        : " "
      : "",
    hasMiddleComments(node)
      ? concat([
          node.middleComments.length === 1 ? "" : hardline,
          join(hardline, path.map(print, "middleComments")),
          hardline,
        ])
      : "",
    hasPrettierIgnore(path)
      ? concat(
          replaceEndOfLineWith(
            options.originalText
              .slice(node.position.start.offset, node.position.end.offset)
              .trimEnd(),
            literalline
          )
        )
      : group(_print(node, parentNode, path, options, print)),
    hasTrailingComment(node) && !isNode(node, ["document", "documentHead"])
      ? lineSuffix(
          concat([
            node.type === "mappingValue" && !node.content ? "" : " ",
            parentNode.type === "mappingKey" &&
            path.getParentNode(2).type === "mapping" &&
            isInlineNode(node)
              ? ""
              : breakParent,
            path.call(print, "trailingComment"),
          ])
        )
      : "",
    shouldPrintEndComments(node)
      ? align(
          node.type === "sequenceItem" ? 2 : 0,
          concat([
            hardline,
            join(
              hardline,
              path.map(
                (path) =>
                  concat([
                    isPreviousLineEmpty(
                      options.originalText,
                      path.getValue(),
                      locStart
                    )
                      ? hardline
                      : "",
                    print(path),
                  ]),
                "endComments"
              )
            ),
          ])
        )
      : "",
    nextEmptyLine,
  ]);
}