MCPcopy Create free account
hub / github.com/Effect-TS/effect / readQuoted

Method readQuoted

packages/effect/src/encoding/Yaml.ts:784–809  ·  view source on GitHub ↗
(quote: string)

Source from the content-addressed store, hash-verified

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.

Callers 2

parseValueMethod · 0.95
parseKeyMethod · 0.95

Calls 8

stripCommentMethod · 0.95
nextChunkMethod · 0.95
closingQuoteFunction · 0.85
foldQuotedLinesFunction · 0.85
endsWithEscapeFunction · 0.85
sliceMethod · 0.80
pushMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected