Skip to content

Commit

Permalink
Merge pull request #141 from adamwight/blockflow-quotes
Browse files Browse the repository at this point in the history
Quote values with an initial ":{"
  • Loading branch information
mruoss authored Jul 14, 2023
2 parents b38c2e9 + 0884859 commit 789c418
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

<!-- ### Added | Changed | Deprecated | Removed | Fixed | Security -->

### Added

- Quote values beginning with `:{`

<!--------------------- Don't add new entries after this line --------------------->

## [4.1.0] - 2023-04-23
Expand Down
1 change: 1 addition & 0 deletions lib/ymlr/encode.ex
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ defmodule Ymlr.Encode do
String.at(data, -1) in @quote_when_last -> with_quotes(data)
String.starts_with?(data, "- ") -> with_quotes(data)
String.starts_with?(data, ": ") -> with_quotes(data)
String.starts_with?(data, ":{") -> with_quotes(data)
String.starts_with?(data, "? ") -> with_quotes(data)
String.contains?(data, " #") -> with_quotes(data)
String.contains?(data, ": ") -> with_quotes(data)
Expand Down
1 change: 1 addition & 0 deletions test/ymlr/encode_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ defmodule Ymlr.EncodeTest do
assert MUT.to_s!("? explicit mapping key") == ~S('? explicit mapping key')
assert MUT.to_s!("{flow_mapping") == ~S('{flow_mapping')
assert MUT.to_s!("}flow_mapping") == ~S('}flow_mapping')
assert MUT.to_s!(":{ block flow") == ~S(':{ block flow')
assert MUT.to_s!("[sequence_mapping") == ~S('[sequence_mapping')
assert MUT.to_s!("]sequence_mapping") == ~S(']sequence_mapping')

Expand Down

0 comments on commit 789c418

Please sign in to comment.