Skip to content

fix(number_format): re-attach literal affixes around formatted numbers#346

Merged
MathNya merged 2 commits into
MathNya:masterfrom
developer0hye:fix/number-format-literal-affixes-upstream
Jul 22, 2026
Merged

fix(number_format): re-attach literal affixes around formatted numbers#346
MathNya merged 2 commits into
MathNya:masterfrom
developer0hye:fix/number-format-literal-affixes-upstream

Conversation

@developer0hye

Copy link
Copy Markdown
Contributor

Problem

get_formatted_value() drops literal text around the digit placeholders in numeric formats:

  • Quoted suffixes disappear: #,##0.00" €" returns 1,240.00 — Excel shows 1,240.00 €.
  • Prefixes other than $ disappear: € 0.00 returns 39.15 — Excel shows € 39.15 (only a \$[^0-9]* match was ever prepended).
  • Parenthesized sections lose their parentheses: (#,##0) returns 1,234 — Excel shows (1,234).

Fix

After the numeric core is formatted, re-attach the literal text found before the first and after the last digit placeholder of the (bracket-stripped) format. Quotes and escapes are already stripped at that point; _x skip-width placeholders render as a plain space, which is how they display in practice. The dollar-only prefix special case now applies only on paths that don't attach affixes (fractions), preserving its previous behavior there.

Note: test values deliberately avoid decimal-rounding ties, which are addressed separately in #345.

Testing

  • New unit tests: quoted euro suffix, non-dollar literal prefix, parenthesized section
  • cargo test — full suite green

🤖 Generated with Claude Code

Quoted literals after the digit placeholders were dropped, so
'#,##0.00" €"' printed only the bare number. Attach the literal
prefix/suffix surrounding the placeholder run (with skip-width '_x'
placeholders rendered as spaces), replacing the dollar-only prefix
special case for numeric formats.

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
@MathNya
MathNya merged commit 5eaaf2f into MathNya:master Jul 22, 2026
0 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants