{"record":{"id":"02a824e8659302a7","repo":"spectreconsole/spectre.console","slug":"could-not-find-color-or-style-part","errorCode":null,"errorMessage":"Could not find color or style '{part}'.","messagePattern":"Could not find color or style '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Spectre.Console.Ansi/AnsiMarkupTagParser.cs","lineNumber":10,"sourceCode":"namespace Spectre.Console;\n\ninternal static class AnsiMarkupTagParser\n{\n    public static (Style Style, Link? Link) Parse(string text)\n    {\n        var result = Parse(text, out var error);\n        if (error != null)\n        {\n            throw new InvalidOperationException(error);\n        }\n\n        return result ?? throw new InvalidOperationException(\"Could not parse style.\");\n    }\n\n    public static bool TryParse(string text, [NotNullWhen(true)] out (Style Style, Link?)? result)\n    {\n        result = Parse(text, out _);\n        return result != null;\n    }\n\n    private static (Style Style, Link? Link)? Parse(string text, out string? error)\n    {\n        var effectiveDecoration = (Decoration?)null;\n        var effectiveForeground = (Color?)null;\n        var effectiveBackground = (Color?)null;\n        var effectiveLink = (string?)null;\n","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/spectreconsole/spectre.console/blob/0acc92fada6c42f13984e79c2b5f3d993bdfb099/src/Spectre.Console.Ansi/AnsiMarkupTagParser.cs#L1-L28","documentation":"In the foreground position (before any `on`), a part matched no decoration, no color name, and is not hex/rgb/integer, so it is neither a known color nor a style. The parser reports 'Could not find color or style {part}.' and the public Parse re-throws it.","triggerScenarios":"Foreground slot with an unknown token, e.g. `[bonld]` (typo of bold), `[mycolor]`, or a stray decoration keyword placed where it isn't recognized.","commonSituations":"Misspelled style name; using a non-existent decoration; copy-pasting a style name from an incompatible library version.","solutions":["Use a decoration name registered in DecorationTable (e.g. bold, italic, underline, dim) or a known color","Check spelling against the library's supported style vocabulary","Use hex/rgb/index forms for colors"],"exampleFix":"// before\nAnsiMarkup.Parse(\"[bonld]text[/]\");\n\n// after\nAnsiMarkup.Parse(\"[bold]text[/]\");","handlingStrategy":"validation","validationCode":"public static bool IsValidFgToken(string token) =>\n    DecorationTable.GetDecoration(token) != null\n    || ColorTable.GetColor(token) != null\n    || Regex.IsMatch(token, @\"^#[0-9A-Fa-f]{6}$\")\n    || Regex.IsMatch(token, @\"^rgb\\(\\d{1,3},\\d{1,3},\\d{1,3}\\)$\")\n    || (int.TryParse(token, out var n) && n is >= 0 and <= 255);","typeGuard":null,"tryCatchPattern":"try { AnsiMarkup.Parse(markup); }\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Could not find color or style\"))\n{ /* drop the unknown token or substitute a known style */ }","preventionTips":["Cross-check style names against the library's DecorationTable","Use hex/rgb for colors to avoid name typos","Build style strings from an allow-list of known tokens"],"tags":["markup","color","style","parsing","spectre-console"],"backgroundTag":null,"analyzedSha":"0acc92fada6c42f13984e79c2b5f3d993bdfb099","analyzedAt":"2026-08-13T18:27:21.983Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}