Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove frontmatter whitespace when trimming #2423

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/tfgen/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,9 @@ var (
)

func trimFrontMatter(text []byte) []byte {
body, ok := bytes.CutPrefix(text, []byte("---"))
// trim any leading or trailing whitespace
body := bytes.TrimSpace(text)
body, ok := bytes.CutPrefix(body, []byte("---"))
if !ok {
return text
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/tfgen/installation_docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ func TestTrimFrontmatter(t *testing.T) {
input: readfile(t, "test_data/strip-front-matter/artifactory-input.md"),
expected: readfile(t, "test_data/strip-front-matter/artifactory-expected.md"),
},
{
name: "Strips Upstream Frontmatter Wit Leading Whitespace",
input: readfile(t, "test_data/strip-front-matter/ise-input.md"),
expected: readfile(t, "test_data/strip-front-matter/ise-expected.md"),
},
}

for _, tt := range tests {
Expand Down
6 changes: 6 additions & 0 deletions pkg/tfgen/test_data/strip-front-matter/ise-expected.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

# ISE Provider

The ISE provider provides resources to interact with a Cisco ISE (Identity Service Engine) instance. It communicates with ISE via the REST API.

This provider uses both, the ERS and Open API.
13 changes: 13 additions & 0 deletions pkg/tfgen/test_data/strip-front-matter/ise-input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

---
layout: ""
page_title: "Provider: ISE"
description: |-
The ISE provider provides resources to interact with a Cisco ISE (Identity Service Engine) instance.
---

# ISE Provider

The ISE provider provides resources to interact with a Cisco ISE (Identity Service Engine) instance. It communicates with ISE via the REST API.

This provider uses both, the ERS and Open API.
Loading