From dfc767320a2b7cb509716e6b84152d4cd0a32f87 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Wed, 4 Feb 2026 23:37:15 -0500 Subject: [PATCH] fix: Improve architectural unit parsing and formatting - Add fallback to parse plain decimal inches without unit symbols - Fix fraction-only display to show "1/2" instead of "0-1/2" Co-Authored-By: Claude Opus 4.5 --- CutList.Core/Formatting/ArchUnits.cs | 10 ++++++++++ CutList.Core/Formatting/FormatHelper.cs | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/CutList.Core/Formatting/ArchUnits.cs b/CutList.Core/Formatting/ArchUnits.cs index 25049bd..d0dce37 100644 --- a/CutList.Core/Formatting/ArchUnits.cs +++ b/CutList.Core/Formatting/ArchUnits.cs @@ -28,7 +28,17 @@ namespace CutList.Core.Formatting var match2 = regex.Match(input); if (!match2.Success) + { + // If no unit symbols, try to parse as plain inches (e.g., "0.5" or "1/2" converted to "0.5") + if (!input.Contains("'") && !input.Contains("\"")) + { + if (double.TryParse(input.Trim(), out var plainInches)) + { + return Math.Round(plainInches, 8); + } + } throw new Exception("Input is not in a valid format."); + } var feet = match2.Groups["Feet"]; var inches = match2.Groups["Inches"]; diff --git a/CutList.Core/Formatting/FormatHelper.cs b/CutList.Core/Formatting/FormatHelper.cs index 73daa5b..9b3132a 100644 --- a/CutList.Core/Formatting/FormatHelper.cs +++ b/CutList.Core/Formatting/FormatHelper.cs @@ -39,6 +39,12 @@ namespace CutList.Core.Formatting return wholeNumber.ToString(); } + // If whole number is 0, just show the fraction + if (wholeNumber == 0) + { + return $"{numerator}/{denominator}"; + } + return $"{wholeNumber}-{numerator}/{denominator}"; }