diff --git a/exampleSite/content/docs/trailing-blanks.md b/exampleSite/content/docs/trailing-blanks.md new file mode 100644 index 0000000..b5adf97 --- /dev/null +++ b/exampleSite/content/docs/trailing-blanks.md @@ -0,0 +1,11 @@ +--- +title: Trailing Blanks +description: Fixture for trailing blank-line handling in the markdown output. +--- + +First paragraph. + +Second paragraph. + + + diff --git a/layouts/partials/llm/safe-content.html b/layouts/partials/llm/safe-content.html index 49f18d4..4b2d8c2 100644 --- a/layouts/partials/llm/safe-content.html +++ b/layouts/partials/llm/safe-content.html @@ -131,7 +131,10 @@ {{- /* Collapse runs of 3+ newlines to a single blank line */ -}} {{- $content = $content | replaceRE `\n{3,}` "\n\n" -}} -{{- /* Trim leading newlines so the caller controls top-of-content spacing */ -}} -{{- $content = strings.TrimLeft "\n" $content -}} +{{- /* Trim surrounding blank lines and end with a single newline: the leading trim lets the + caller control top-of-content spacing, while trimming trailing blank lines and adding + one final newline avoids stray trailing blanks (MD012) yet keeps a single final + newline (MD047). */ -}} +{{- $content = strings.Trim $content "\n" -}} -{{- return $content -}} +{{- return (printf "%s\n" $content) -}}