| 10584 | |
| 10585 | // Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9. |
| 10586 | function blockHeader(string, indentPerLevel) { |
| 10587 | var indentIndicator = (string[0] === ' ') ? String(indentPerLevel) : ''; |
| 10588 | |
| 10589 | // note the special case: the string '\n' counts as a "trailing" empty line. |
| 10590 | var clip = string[string.length - 1] === '\n'; |
| 10591 | var keep = clip && (string[string.length - 2] === '\n' || string === '\n'); |
| 10592 | var chomp = keep ? '+' : (clip ? '' : '-'); |
| 10593 | |
| 10594 | return indentIndicator + chomp + '\n'; |
| 10595 | } |
| 10596 | |
| 10597 | // (See the note for writeScalar.) |
| 10598 | function dropEndingNewline(string) { |