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:
2026-02-04 23:37:15 -05:00
parent 5cc088ea6b
commit dfc767320a
2 changed files with 16 additions and 0 deletions

View File

@@ -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"];