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 <noreply@anthropic.com>
This commit is contained in:
@@ -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"];
|
||||
|
||||
@@ -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}";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user