()
| 763 | |
| 764 | // Return source text for the same key conversion used in block mappings. |
| 765 | private parseKey(): string { |
| 766 | this.skipWhitespace() |
| 767 | const character = this.peek() |
| 768 | if (isPropertyIndicatorCode(character.charCodeAt(0))) this.fail(keyPropertyError) |
| 769 | if (character === "\"" || character === "'") return this.readQuoted(character) |
| 770 | const text = this.readPlain(isFlowPlainEnd) |
| 771 | // A comment or line break may separate the key from its `:`. |
| 772 | this.skipWhitespace() |
| 773 | if (this.peek() !== ":") { |
| 774 | if (text === "") this.expect(":") |
| 775 | // Reject `{a:1}` rather than choose between a YAML valueless key and a JSON-like pair. |
| 776 | if (text.includes(":")) { |
| 777 | this.fail(`Flow mapping key '${text}' has no value, add a space after ':' or quote the key`) |
| 778 | } |
| 779 | } |
| 780 | return text |
| 781 | } |
| 782 | |
| 783 | // Read a quoted scalar one line at a time to keep scanning linear. |
| 784 | private readQuoted(quote: string): string { |
no test coverage detected