(quote: string)
| 782 | |
| 783 | // Read a quoted scalar one line at a time to keep scanning linear. |
| 784 | private readQuoted(quote: string): string { |
| 785 | const startOffset = this.offset + this.index |
| 786 | const pieces: Array<string> = [] |
| 787 | let start = this.index |
| 788 | let from = start + 1 |
| 789 | while (true) { |
| 790 | const end = closingQuote(this.line, quote, from) |
| 791 | if (end !== -1) { |
| 792 | this.index = end + 1 |
| 793 | pieces.push(this.line.slice(start, this.index)) |
| 794 | this.afterJsonNode = true |
| 795 | if (pieces.length > 1) { |
| 796 | // The rest of the closing line was read raw, so remove its comment now. |
| 797 | const rest = this.line.slice(this.index) |
| 798 | if (!rest.startsWith("#")) this.line = this.line.slice(0, this.index) + this.stripComment(rest, false) |
| 799 | } |
| 800 | return foldQuotedLines(pieces.join("")) |
| 801 | } |
| 802 | pieces.push(this.line.slice(start)) |
| 803 | // An escape at the end of the line consumes the next line's "\n". |
| 804 | const skipped = quote === "\"" && endsWithEscape(this.line) ? 1 : 0 |
| 805 | if (!this.nextChunk("quoted")) throw new SyntaxError(`Unterminated quoted scalar at flow offset ${startOffset}`) |
| 806 | start = 0 |
| 807 | from = skipped |
| 808 | } |
| 809 | } |
| 810 | |
| 811 | // YAML 1.2.2 §7.5: a tag is separated from its content, which may be empty before a |
| 812 | // flow indicator or at the end of the line. |
no test coverage detected