Skip to content
Merged
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
2 changes: 2 additions & 0 deletions internal/docgen/mintlify.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ func (MintlifyFormatter) ExampleUseCases(commandName, example string) string {
exampleLines := all[i]
title := strings.Trim(exampleLines[0], ":")
if len(title) > 0 {
// Double quotes would terminate the JSX title attribute and break the MDX build.
title = strings.ReplaceAll(title, "\"", "'")
Comment thread
mbevc1 marked this conversation as resolved.
fmt.Fprintf(&b, "<Accordion title=\"%s\">\n", strings.TrimSpace(title[1:]))
fmt.Fprintf(&b, "```shell\n%s\n```\n", strings.Join(exampleLines[1:], "\n"))
b.WriteString("</Accordion>\n")
Expand Down
12 changes: 12 additions & 0 deletions internal/docgen/mintlify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,18 @@ func TestMintlifyExampleUseCases(t *testing.T) {
}
}

func TestMintlifyExampleUseCasesEscapesQuotesInTitle(t *testing.T) {
f := MintlifyFormatter{}
example := "# list controls whose name or identifier contains \"sdlc\":\nkosli list controls --search sdlc"
got := f.ExampleUseCases("kosli list controls", example)
if !strings.Contains(got, `<Accordion title="list controls whose name or identifier contains 'sdlc'">`) {
t.Errorf("expected double quotes in title to be replaced with single quotes, got:\n%s", got)
}
if strings.Contains(got, `contains "sdlc"`) {
t.Errorf("expected no raw double quotes inside the title attribute, got:\n%s", got)
}
}

func TestMintlifyLinkHandler(t *testing.T) {
f := MintlifyFormatter{}
got := f.LinkHandler("kosli_attest_snyk.md")
Expand Down
Loading