diff --git a/pkg/tfgen/docs.go b/pkg/tfgen/docs.go index e4e4e9edf..3e36d364a 100644 --- a/pkg/tfgen/docs.go +++ b/pkg/tfgen/docs.go @@ -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 } diff --git a/pkg/tfgen/installation_docs_test.go b/pkg/tfgen/installation_docs_test.go index b92494e53..2b8928b49 100644 --- a/pkg/tfgen/installation_docs_test.go +++ b/pkg/tfgen/installation_docs_test.go @@ -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 { diff --git a/pkg/tfgen/test_data/strip-front-matter/ise-expected.md b/pkg/tfgen/test_data/strip-front-matter/ise-expected.md new file mode 100644 index 000000000..857e7e17a --- /dev/null +++ b/pkg/tfgen/test_data/strip-front-matter/ise-expected.md @@ -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. \ No newline at end of file diff --git a/pkg/tfgen/test_data/strip-front-matter/ise-input.md b/pkg/tfgen/test_data/strip-front-matter/ise-input.md new file mode 100644 index 000000000..c96393497 --- /dev/null +++ b/pkg/tfgen/test_data/strip-front-matter/ise-input.md @@ -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. \ No newline at end of file