mirror of https://github.com/knative/func.git
fix: trailing white spaces in genrated docs (#1198)
Signed-off-by: Matej Vasek <mvasek@redhat.com> Signed-off-by: Matej Vasek <mvasek@redhat.com>
This commit is contained in:
parent
1f4db6eab4
commit
cd64b70b47
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"html/template"
|
"html/template"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
@ -117,7 +118,10 @@ func writeMarkdown(c *cobra.Command, name string, opts TemplateOptions) error {
|
||||||
fmt.Fprintf(os.Stderr, "unable to process help text: %v", err)
|
fmt.Fprintf(os.Stderr, "unable to process help text: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ioutil.WriteFile(targetDir+"/"+name+".md", out.Bytes(), 0666); err != nil {
|
re := regexp.MustCompile(`[^\S\r\n]+\n`)
|
||||||
|
data := re.ReplaceAll(out.Bytes(), []byte{'\n'}) // trim white spaces before EOL
|
||||||
|
|
||||||
|
if err := ioutil.WriteFile(targetDir+"/"+name+".md", data, 0666); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue