@@ -77,10 +77,10 @@ function Read-YamlBlockMapping {
7777 $isExplicit = Test-YamlIndicator - Text $content - Indicator ' ?'
7878 if ($isExplicit ) {
7979 $afterQuestion = $content.Substring (1 )
80- $leading = $afterQuestion.Length - $afterQuestion.TrimStart ().Length
81- $keyText = $afterQuestion.TrimStart ()
80+ $leading = $afterQuestion.Length - $afterQuestion.TrimStart (' ' , " `t " ).Length
81+ $keyText = $afterQuestion.TrimStart (' ' , " `t " )
8282 $keyColumn = $contentColumn + 1 + $leading
83- if ([string ]::IsNullOrWhiteSpace ((Get-YamlContentWithoutComment - Text $keyText ))) {
83+ if ([string ]::IsNullOrEmpty ((Get-YamlContentWithoutComment - Text $keyText ))) {
8484 $Context.LineIndex ++
8585 Skip-YamlBlockTrivia - Context $Context
8686 if ($Context.LineIndex -ge $Context.Lines.Count ) {
@@ -104,9 +104,12 @@ function Read-YamlBlockMapping {
104104 }
105105 }
106106 } elseif (Test-YamlIndicator - Text $keyText - Indicator ' -' ) {
107- $firstItem = $keyText.Substring (1 ).TrimStart()
107+ $firstItem = $keyText.Substring (1 ).TrimStart(' ' , " `t " )
108108 $dashColumn = $keyColumn
109- $itemColumn = $dashColumn + 1 + ($keyText.Substring (1 ).Length - $keyText.Substring (1 ).TrimStart().Length)
109+ $itemColumn = $dashColumn + 1 + (
110+ $keyText.Substring (1 ).Length -
111+ $keyText.Substring (1 ).TrimStart(' ' , " `t " ).Length
112+ )
110113 $key = Read-YamlBlockSequence - Context $Context - Indent $dashColumn - Depth ($Depth + 1 ) `
111114 - FirstItemText $firstItem - FirstItemColumn $itemColumn
112115 } else {
@@ -130,10 +133,10 @@ function Read-YamlBlockMapping {
130133 if ($valueIndent -eq $Indent -and
131134 (Test-YamlIndicator - Text $valueContent - Indicator ' :' )) {
132135 $valueText = $valueContent.Substring (1 )
133- $leading = $valueText.Length - $valueText.TrimStart ().Length
134- $valueText = $valueText.TrimStart ()
136+ $leading = $valueText.Length - $valueText.TrimStart (' ' , " `t " ).Length
137+ $valueText = $valueText.TrimStart (' ' , " `t " )
135138 $valueColumn = $Indent + 1 + $leading
136- if ([string ]::IsNullOrWhiteSpace ((Get-YamlContentWithoutComment - Text $valueText ))) {
139+ if ([string ]::IsNullOrEmpty ((Get-YamlContentWithoutComment - Text $valueText ))) {
137140 $valueLineNumber = $Context.LineIndex
138141 $Context.LineIndex ++
139142 Skip-YamlBlockTrivia - Context $Context
@@ -171,7 +174,7 @@ function Read-YamlBlockMapping {
171174 continue
172175 }
173176
174- $colon = Find-YamlMappingColon - Text $content
177+ $colon = Find-YamlMappingColon - Text $content - AllowAnchorFallback
175178 if ($colon -lt 0 ) {
176179 $mark = New-YamlMark - Index ($Context.LineStarts [$lineNumber ] + $contentColumn ) `
177180 - Line $lineNumber - Column $contentColumn
@@ -192,17 +195,17 @@ function Read-YamlBlockMapping {
192195 - Line $lineNumber - Column $contentColumn
193196 $key = New-YamlEmptyScalar - Context $Context - Depth ($Depth + 1 ) - Mark $mark
194197 } else {
195- $keyText = $content.Substring (0 , $colon ).TrimEnd()
198+ $keyText = $content.Substring (0 , $colon ).TrimEnd(' ' , " `t " )
196199 $key = Read-YamlBlockKey - Context $Context - Text $keyText - Line $lineNumber `
197200 - Column $contentColumn - Depth ($Depth + 1 )
198201 }
199202
200203 $valueStart = $colon + 1
201204 $valueSource = $content.Substring ($valueStart )
202- $leading = $valueSource.Length - $valueSource.TrimStart ().Length
203- $valueText = $valueSource.TrimStart ()
205+ $leading = $valueSource.Length - $valueSource.TrimStart (' ' , " `t " ).Length
206+ $valueText = $valueSource.TrimStart (' ' , " `t " )
204207 $valueColumn = $contentColumn + $valueStart + $leading
205- if ([string ]::IsNullOrWhiteSpace ((Get-YamlContentWithoutComment - Text $valueText ))) {
208+ if ([string ]::IsNullOrEmpty ((Get-YamlContentWithoutComment - Text $valueText ))) {
206209 $Context.LineIndex = $lineNumber + 1
207210 Skip-YamlBlockTrivia - Context $Context
208211 if ($Context.LineIndex -lt $Context.Lines.Count ) {
@@ -242,7 +245,8 @@ function Read-YamlBlockMapping {
242245 }
243246 $Context.LineIndex = $lineNumber
244247 $value = Read-YamlBlockNode - Context $Context - ParentIndent $Indent - Depth ($Depth + 1 ) `
245- - Segment $valueText - SegmentColumn $valueColumn - AllowIndentlessSequence
248+ - Segment $valueText - SegmentColumn $valueColumn - AllowIndentlessSequence `
249+ - DisallowCompactMapping
246250 }
247251 $node.Entries.Add ([pscustomobject ]@ { Key = $key ; Value = $value })
248252 }
0 commit comments