These are block chomping indicators, they influence how the trailing newlines in a literal (|
) or folded (>
) block style scalar are handled.
By default, if there is no +
or -
after the |
(or >
), those trailing newlines are clipped, i.e. the scalar will be loaded as a string ending in a single newline, independent of whether there are multiple empty lines at the end of the scalar.
If +
is specified, each newline is kept, so the scalar will have one extra newline for every empty line before the outdent for the next node (in addition to the one ending the last non-empty line)
If -
is specified, the scalar is stripped and will not end in a newline, even if there are multiple empty lines at the end of the block style scalar.
Please note that your second example is invalid, the production rules indicate that the chomping indicator can only be separated from the |
by the indentation indicator (i.e. number, if specified) and that no space is allowed between |
and -
.