You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For instance the following: "%s 0% fat Greek style yogurt"
when formatted with: "60ml"
should ideally result in: "60ml 0% fat Greek style yogurt"
Instead the outcome is nil
I've taken a look over the code and this could be fixed by tweaking line 587 in Sprinter.swift: if first == "%" { break }
to become:
if first == "%" {
if string.last == nil || string.last == " " {
break
}
}
I've tested this locally and all unit tests pass with the change (as well as this new case). I'm happy to create a PR? Let me know, cheers.
The text was updated successfully, but these errors were encountered:
I need to check the spec for what the expected behavior is here. I would think you are supposed to write %% in this case and that a % on its own is a syntax error, but in a case like this it seems reasonable to allow it.
The problem with that approach is that it would break formatting for tokens inlined, for example: Hello_%s_world
The approach I took to work around the problem initially was to swap out the '%' I wanted ignoring for a 'widepercent'. An alternative as you say could also be to double it up - '%%'. Would be nice to be able to defend against it in the formatting though :/
Each conversion specification is introduced by the character ( '%' ). After the character '%', the following shall appear in sequence:
... %: Write a '%' character; no argument is converted.
For instance the following:
"%s 0% fat Greek style yogurt"
when formatted with:
"60ml"
should ideally result in:
"60ml 0% fat Greek style yogurt"
Instead the outcome is
nil
I've taken a look over the code and this could be fixed by tweaking line 587 in
Sprinter.swift
:if first == "%" { break }
to become:
I've tested this locally and all unit tests pass with the change (as well as this new case). I'm happy to create a PR? Let me know, cheers.
The text was updated successfully, but these errors were encountered: