Commit 0bcb679
* fix: drop whitespace before punctuation when format field is empty (closes #139)
When string_format contains a field like "{last} {suffix}, {first}" and suffix
is absent, the rendered string was "Smith , John" due to the space left between
the empty field and the following comma. Added a post-format substitution step
that strips whitespace before punctuation characters (,;:), consistent with the
existing progressive cleanup pattern in __str__.
* fix: narrow space-before-punctuation regex to commas only
; and : have no known use case in name string_format patterns.
Matching only \s+, keeps the fix scoped to the reported issue.
* test: replace placeholder tests with ones that exercise the new regex
The two replaced tests passed via pre-existing collapse_whitespace logic
and didn't exercise space_before_comma at all. Replaced with:
- suffix-present path (regression guard against over-stripping)
- multiple empty fields before comma
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c8ea8cf commit 0bcb679
3 files changed
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| 192 | + | |
192 | 193 | | |
193 | 194 | | |
194 | 195 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
106 | 122 | | |
107 | 123 | | |
108 | 124 | | |
| |||
0 commit comments