microsoft / microsoft/aspire.dev
CLI: `docs get` command displays code blocks without indentation
@IEvangelist is already working on this.
Since Jun 2, 2026.
- Dominant language
- MDX
- Stars
- 193
- Forks
- 87
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 73
Description
Description
When running aspire docs get <slug>, the rendered markdown output displays code blocks with all internal indentation/whitespace stripped. This makes code examples difficult to read.
Root Cause
The documentation content is sourced from the llms.txt file (from aspire.dev), which appears to deliver code blocks in a minified/compacted single-line format with internal whitespace removed.
The NormalizeContent method in DocsIndexService.cs attempts to reconstruct proper markdown structure from this compacted form. For multi-line code blocks it preserves the content as-is, but for single-line code blocks (where the entire block is collapsed onto one line), the NormalizeCodeBlock method splits on the first whitespace to detect the language identifier and wraps the remaining content — but it cannot restore the original indentation since that information is already lost in the source data.
Additionally, the LeadingWhitespaceRegex ((?m)^[ \t]+) in NormalizeMarkdownSegment strips all leading whitespace from lines that are not inside fenced code blocks as detected by MarkdownFenceBlockRegex. If any code block is not properly detected as fenced (e.g., edge cases in the regex matching), its indentation would also be stripped.
Relevant Code
src/Aspire.Cli/Documentation/Docs/DocsIndexService.cs—NormalizeContent,NormalizeCodeBlock,NormalizeMarkdownSegmentMarkdownFenceBlockRegex:```.*?```withRegexOptions.SinglelineLeadingWhitespaceRegex:(?m)^[ \t]+
Steps to Reproduce
- Run
aspire docs get <any-slug-with-code-examples> - Observe that code blocks in the output have no indentation
Expected Behavior
Code blocks should display with proper indentation preserved, making them readable and copy-paste friendly.
Possible Solutions
- Fix the upstream
llms.txtsource to preserve whitespace in code blocks - Add heuristic re-indentation in
NormalizeCodeBlockfor single-line code blocks (e.g., insert newlines before{, after;, and apply indentation based on brace depth) - Ensure
MarkdownFenceBlockRegexcorrectly identifies all fenced code blocks beforeLeadingWhitespaceRegexis applied
Area
area-cli
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.