Merge pull request #4752 from cli/man-page

fix angle brackets in man pages
This commit is contained in:
Nate Smith 2021-11-17 15:58:29 -06:00 committed by GitHub
commit 235fdcdcc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -96,6 +96,7 @@ func GenMan(cmd *cobra.Command, header *GenManHeader, w io.Writer) error {
}
b := genMan(cmd, header)
_, err := w.Write(md2man.Render(b))
return err
}
@ -133,7 +134,13 @@ func manPreamble(buf *bytes.Buffer, header *GenManHeader, cmd *cobra.Command, da
`, header.Title, header.Section, header.date, header.Source, header.Manual))
buf.WriteString(fmt.Sprintf("%s \\- %s\n\n", dashedName, cmd.Short))
buf.WriteString("# SYNOPSIS\n")
buf.WriteString(fmt.Sprintf("**%s**\n\n", cmd.UseLine()))
// "<>" is rendered as HTML in md
synopsis := cmd.UseLine()
escAngle := strings.Replace(synopsis, "<", "\\<", -1)
escAngle = strings.Replace(escAngle, ">", "\\>", -1)
buf.WriteString(fmt.Sprintf("**%s**\n\n", escAngle))
buf.WriteString("# DESCRIPTION\n")
buf.WriteString(description + "\n\n")
}