-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply .singleQuoted
on representing Node.Scalar
from String
if Resolver.default
resolves that to other than .str
.
#198
Conversation
Apply `.singleQuoted` on representing `Node.Scalar` from `String` if `Resolver.default` resolves that to other than `.str`. Fixes #197
…itTags()` It is more desirable behavior.
@@ -230,7 +228,8 @@ extension URL: ScalarRepresentable { | |||
extension String: ScalarRepresentable { | |||
/// This value's `Node.scalar` representation. | |||
public func represented() -> Node.Scalar { | |||
return .init(self) | |||
let scalar = Node.Scalar(self) | |||
return scalar.resolvedTag.name == .str ? scalar : .init(self, Tag(.str), .singleQuoted) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The performance impact can be almost ignored since resolvedTag
was previously called in serializeScalar(_:)
on serializing.
https://github.com/jpsim/Yams/blob/41c33b6f96/Sources/Yams/Emitter.swift#L413
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix! Should we backport this to a 2.0.x release without the breaking changes?
I'll branch |
Apply `.singleQuoted` on representing `Node.Scalar` from `String` if `Resolver.default` resolves that to other than `.str`.
…` from `String` if `Resolver.default` resolves that to other than `.str`.
Some values are now added quotes due to Yams 3.0.0 changes in jpsim/Yams#198
Fixes #197