Conversation
Distinguish subsequent YAML mappings from Markdown body content without restricting overwrite files to a single UID section. Keep initial-header validation and mapping diagnostics, and cover the reported content loss with reader and rendering regressions. Fixes dotnet#11088 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: bf666f99-8d30-4763-878d-b566c0ac2f2d
Explain mapping-shaped prose ambiguity, preserved syntax-error handling, and the diagnostic change for malformed non-mapping later headers. Recommend unambiguous thematic-break delimiters. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: bf666f99-8d30-4763-878d-b566c0ac2f2d
Move syntax and diagnostic cases to the real Markdown service without file I/O. Keep focused reader integration coverage for the report, repeated and distinct UIDs, metadata, source positions, and missing-UID validation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: bf666f99-8d30-4763-878d-b566c0ac2f2d
vwxyzh
approved these changes
Sep 17, 2026
This was referenced Sep 18, 2026
This was referenced Sep 19, 2026
This was referenced Sep 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #11088.
Overwrite files intentionally support multiple UID sections. Their Markdown pipeline enables Markdig's mid-document YAML parser before the thematic-break parser, so a pair of body
---lines currently consumes the enclosed Markdown as YAML. Dictionary deserialization then warns and drops that content.This change is a bounded reduction in false positives, not an unambiguous way to infer whether an author intended metadata or prose.
Approach
Keep Markdig's delimiter handling and inspect only the first YAML root event for subsequent header candidates:
*contentsyntax remain supported.uid.This is not a first-header-only restriction, a literal
uid:/first-line heuristic, or a "deserialization failed, so render Markdown" fallback. Recognizing a mapping commits the block to metadata processing; it does not require the rest of the block to deserialize successfully.Limitations and compatibility
The same
---delimiters can represent both overwrite headers and thematic breaks. YAML syntax can classify the structure, but cannot establish the author's intent.Title: Hellouid. Addinguidmakes it an overwrite section, even if the author intended to display it as prose.uid Some.Type, or a sequence such as- uid: Some.TypeUse
***or------for thematic breaks when unambiguous body rendering is required. The expanded Thematic breaks and limitations section indocs/tutorial/intro_overwrite_files.mdexplains these tradeoffs with an example. This PR does not claim to eliminate every ambiguity or preserve every diagnostic for invalid inputs.Test structure
YamlHeaderTestcall the realMarkdigMarkdownServicethrough the existingTestUtility.CreateMarkdownServicehelper. They check exact rendered HTML, header source ranges, and diagnostics without creating files. Theoverwrite.mdargument is only the logical source name used in diagnostics.Validation
Against upstream
ad05df46ab615d34af3f81849ae5e45ecb4fd51e:HostService, andMarkdownReader.ReadMarkdownAsOverwrite, preserving the summary, two rules, heading/list content, and source line ranges.Docfx.Build.Common.Tests: 25 passed on each of .NET 8 and .NET 10.Docfx.MarkdigEngine.Tests: 52 passed, 5 existing skips on each of .NET 8 and .NET 10; includes conceptual-mode and initial-header diagnostic coverage.git diff --checkpass..NET 9 runtime execution was unavailable locally; its target compiled successfully. No dependencies, workflows, release/versioning, certificates, or publishing configuration changed.