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}"; }