Skip to content

Commit 00b79e2

Browse files
docs: explain why single-quote handling is correct for '' escapes
1 parent 54513b7 commit 00b79e2

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/document.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,10 @@ fn find_key_colon(content: &str) -> Option<usize> {
328328
while i < bytes.len() {
329329
match bytes[i] {
330330
b'\'' => {
331+
// YAML '' escape (literal single quote) is handled correctly here:
332+
// the first ' closes, the second immediately reopens, producing
333+
// the same result as explicit escape handling since '' is the
334+
// only escape sequence in single-quoted YAML strings.
331335
i += 1;
332336
while i < bytes.len() && bytes[i] != b'\'' {
333337
i += 1;
@@ -375,6 +379,8 @@ fn extract_inline_comment(line: &str) -> Option<&str> {
375379
while i < bytes.len() {
376380
match bytes[i] {
377381
b'\'' if !in_double_quote => {
382+
// YAML '' escape: two toggles (true→false→true) is a no-op,
383+
// which is correct since '' is the only escape in single-quoted strings.
378384
in_single_quote = !in_single_quote;
379385
}
380386
b'"' if !in_single_quote => {

0 commit comments

Comments
 (0)