@@ -15,9 +15,8 @@ class YAML < Scanner
15
15
16
16
def scan_tokens encoder , options
17
17
18
- value_expected = nil
19
18
state = :initial
20
- key_indent = indent = 0
19
+ key_indent = string_indent = 0
21
20
22
21
until eos?
23
22
@@ -55,14 +54,14 @@ def scan_tokens encoder, options
55
54
when match = scan ( /[|>][-+]?/ )
56
55
encoder . begin_group :string
57
56
encoder . text_token match , :delimiter
58
- string_indent = key_indent || column ( pos - match . size - 1 )
57
+ string_indent = key_indent || column ( pos - match . size ) - 1
59
58
encoder . text_token matched , :content if scan ( /(?:\n + {#{ string_indent + 1 } }.*)+/ )
60
59
encoder . end_group :string
61
60
next
62
61
when match = scan ( /(?![!"*&]).+?(?=$|\s +#)/ )
63
62
encoder . begin_group :string
64
63
encoder . text_token match , :content
65
- string_indent = key_indent || column ( pos - match . size - 1 )
64
+ string_indent = key_indent || column ( pos - match . size ) - 1
66
65
encoder . text_token matched , :content if scan ( /(?:\n + {#{ string_indent + 1 } }.*)+/ )
67
66
encoder . end_group :string
68
67
next
@@ -79,7 +78,7 @@ def scan_tokens encoder, options
79
78
next
80
79
when state == :initial && match = scan ( /[\w .() ]*\S (?= *:(?: |$))/ )
81
80
encoder . text_token match , :key
82
- key_indent = column ( pos - match . size - 1 )
81
+ key_indent = column ( pos - match . size ) - 1
83
82
state = :colon
84
83
next
85
84
when match = scan ( /(?:"[^"\n ]*"|'[^'\n ]*')(?= *:(?: |$))/ )
@@ -88,7 +87,7 @@ def scan_tokens encoder, options
88
87
encoder . text_token match [ 1 ..-2 ] , :content
89
88
encoder . text_token match [ -1 , 1 ] , :delimiter
90
89
encoder . end_group :key
91
- key_indent = column ( pos - match . size - 1 )
90
+ key_indent = column ( pos - match . size ) - 1
92
91
state = :colon
93
92
next
94
93
when match = scan ( /(![\w \/ ]+)(:([\w :]+))?/ )
0 commit comments