diff --git a/clidocstool_md.go b/clidocstool_md.go
index 24efee4..326a876 100644
--- a/clidocstool_md.go
+++ b/clidocstool_md.go
@@ -20,6 +20,7 @@ import (
"log"
"os"
"path/filepath"
+ "regexp"
"strings"
"text/template"
@@ -28,6 +29,10 @@ import (
"github.com/spf13/pflag"
)
+var (
+ nlRegexp = regexp.MustCompile(`\r?\n`)
+)
+
// GenMarkdownTree will generate a markdown page for this command and all
// descendants in the directory given.
func (c *Client) GenMarkdownTree(cmd *cobra.Command) error {
@@ -216,7 +221,7 @@ func mdCmdOutput(cmd *cobra.Command, old string) (string, error) {
} else if cd, ok := cmd.Annotations[annotation.CodeDelimiter]; ok {
usage = strings.ReplaceAll(usage, cd, "`")
}
- fmt.Fprintf(b, "%s | %s | %s | %s |\n", mdEscapePipe(name), mdEscapePipe(ftype), mdEscapePipe(defval), mdEscapePipe(usage))
+ fmt.Fprintf(b, "%s | %s | %s | %s |\n", mdEscapePipe(name), mdEscapePipe(ftype), mdEscapePipe(defval), mdReplaceNewline(mdEscapePipe(usage)))
})
fmt.Fprintln(b, "")
}
@@ -227,3 +232,7 @@ func mdCmdOutput(cmd *cobra.Command, old string) (string, error) {
func mdEscapePipe(s string) string {
return strings.ReplaceAll(s, `|`, `\|`)
}
+
+func mdReplaceNewline(s string) string {
+ return nlRegexp.ReplaceAllString(s, "
")
+}
diff --git a/clidocstool_test.go b/clidocstool_test.go
index 6d9e4a5..141bdd6 100644
--- a/clidocstool_test.go
+++ b/clidocstool_test.go
@@ -118,7 +118,8 @@ func init() {
buildxBuildFlags.StringVar(&ignore, "shm-size", "", `Size of "/dev/shm"`)
- buildxBuildFlags.StringArray("ssh", []string{}, `SSH agent socket or keys to expose to the build (format: "default|[=|[,]]")`)
+ buildxBuildFlags.StringArray("ssh", []string{}, `SSH agent socket or keys to expose to the build
+format: "default|[=|[,]]"`)
buildxBuildFlags.StringArrayP("tag", "t", []string{}, `Name and optionally a tag (format: "name:tag")`)
buildxBuildFlags.SetAnnotation("tag", annotation.ExternalURL, []string{"https://docs.docker.com/engine/reference/commandline/build/#tag-an-image--t"})
diff --git a/fixtures/buildx_build.md b/fixtures/buildx_build.md
index 1cf0c40..f56c8e4 100644
--- a/fixtures/buildx_build.md
+++ b/fixtures/buildx_build.md
@@ -29,7 +29,7 @@ Start a build
| `-q`, `--quiet` | | | Suppress the build output and print image ID on success |
| `--secret` | `stringArray` | | Secret file to expose to the build (format: `id=mysecret,src=/local/secret`) |
| `--shm-size` | `string` | | Size of `/dev/shm` |
-| `--ssh` | `stringArray` | | SSH agent socket or keys to expose to the build (format: `default\|[=\|[,]]`) |
+| `--ssh` | `stringArray` | | SSH agent socket or keys to expose to the build
format: `default\|[=\|[,]]` |
| [`-t`](https://docs.docker.com/engine/reference/commandline/build/#tag-an-image--t), [`--tag`](https://docs.docker.com/engine/reference/commandline/build/#tag-an-image--t) | `stringArray` | | Name and optionally a tag (format: `name:tag`) |
| [`--target`](https://docs.docker.com/engine/reference/commandline/build/#specifying-target-build-stage---target) | `string` | | Set the target build stage to build. |
| `--ulimit` | `string` | | Ulimit options |
diff --git a/fixtures/docker_buildx_build.yaml b/fixtures/docker_buildx_build.yaml
index 752775e..b522ff7 100644
--- a/fixtures/docker_buildx_build.yaml
+++ b/fixtures/docker_buildx_build.yaml
@@ -314,8 +314,9 @@ options:
- option: ssh
value_type: stringArray
default_value: '[]'
- description: |
- SSH agent socket or keys to expose to the build (format: `default|[=|[,]]`)
+ description: |-
+ SSH agent socket or keys to expose to the build
+ format: `default|[=|[,]]`
deprecated: false
hidden: false
experimental: false