fix(llm): trim trailing blank lines from the markdown output#82
Merged
Conversation
safe-content only trimmed leading newlines, so content with trailing blank lines (generated/content-adapter pages, or multi-shortcode output such as table renderers) left stray trailing blanks in the LLM markdown output — flagged by markdownlint MD012. Trim both ends and emit a single final newline, so the output has no trailing blank lines (MD012) and ends with one newline (MD047). Adds an exampleSite fixture that exercises trailing-blank handling.
Contributor
Author
|
🎉 This PR is included in version 1.3.4 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Problem
safe-content.htmltrims only leading newlines (strings.TrimLeft "\n"). Content with trailing blank lines therefore leaves stray blank lines at the end of the generatedindex.md/llms.txt, which markdownlint flags as MD012 (multiple consecutive blank lines).This shows up with generated / content-adapter pages and multi-shortcode output — e.g. a JSON-Schema table renderer that emits one
{{< schema >}}call per definition: each call's trailing newline plus the join newline accumulate into trailing blanks the wrapper preserves.Fix
Trim both ends and emit a single final newline:
Result: no trailing blank lines (MD012) and a single final newline (MD047). The leading trim is preserved (the caller still controls top-of-content spacing).
Verification
Added
exampleSite/content/docs/trailing-blanks.md(a page with trailing blank lines). Before: itsindex.mdended with…\n\n→ MD012. After: ends with a single\n, MD012/MD047 clean. No change to existing pages (getting-started, blog, etc. still end with a single newline).🤖 Generated with Claude Code