Skip to content

Commit

Permalink
Merge c69b515 into 7e7bb49
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW authored Nov 14, 2022
2 parents 7e7bb49 + c69b515 commit dd42150
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ func ReplaceYAML(s string, repFn func(s string) (string, error), replaceMapKey b
if len(lines) == 1 {
quote = true
} else if len(lines) == 2 && strings.Trim(lines[1], " ") == "" {
quote = true
if tk.Prev != nil && tk.Prev.Type == token.LiteralType && token.Type(tk.Prev.Indicator) == token.Type(token.BlockScalarIndicator) {
// Block scalars does not quote
quote = false
} else {
quote = true
}
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions expand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ multi: |
hello : world :world
`},
{
`test: |
current.url == 'https://example.com/#about'
`,
map[string]string{},
`test: |
current.url == 'https://example.com/#about'
`},
}
for _, tt := range tests {
Expand Down

0 comments on commit dd42150

Please sign in to comment.