What's wrong
ExtractFrontmatterObjects (Frontmatter/Frontmatter.cs:318) calls block.Trim() before it parses each block. Trim() removes the indentation from the first line only. The remaining lines keep their indentation, so a uniformly indented block that is valid YAML becomes invalid YAML:
title: Hello -> "title: Hello\n tags: [a]"
tags: [a] (the second line is now read as a continuation of `title`'s value)
Parsing fails. ExtractFrontmatter returns null. AddFrontmatter treats the block as unreadable and returns the document unchanged, so the caller's new properties are lost without any error. CombineFrontmatter also leaves the document unchanged.
Repro
string d1 = "---\n title: Hello\n tags: [a]\n---\nBody\n";
Frontmatter.ExtractFrontmatter(d1); // null, expected { title, tags }
YamlSerializer.TryParseYamlObject(" title: Hello\n tags: [a]", out var r); // true: the YAML itself is valid
Frontmatter.AddFrontmatter(d1, new() { ["author"] = "X" }); // returns d1 unchanged; "author" is lost
Suggested fix
Don't strip the leading indentation of the first line. Use block.TrimEnd(), dropping only leading blank lines, or pass the block to the parser unchanged, since YamlDotNet already handles uniform indentation and leading blank lines. Keep the IsNullOrWhiteSpace skip.
Acceptance criteria
ExtractFrontmatter on a uniformly indented block returns its properties.
AddFrontmatter on such a document keeps the existing properties and adds the new ones.
What's wrong
ExtractFrontmatterObjects(Frontmatter/Frontmatter.cs:318) callsblock.Trim()before it parses each block.Trim()removes the indentation from the first line only. The remaining lines keep their indentation, so a uniformly indented block that is valid YAML becomes invalid YAML:Parsing fails.
ExtractFrontmatterreturnsnull.AddFrontmattertreats the block as unreadable and returns the document unchanged, so the caller's new properties are lost without any error.CombineFrontmatteralso leaves the document unchanged.Repro
Suggested fix
Don't strip the leading indentation of the first line. Use
block.TrimEnd(), dropping only leading blank lines, or pass the block to the parser unchanged, since YamlDotNet already handles uniform indentation and leading blank lines. Keep theIsNullOrWhiteSpaceskip.Acceptance criteria
ExtractFrontmatteron a uniformly indented block returns its properties.AddFrontmatteron such a document keeps the existing properties and adds the new ones.