Skip to content

Commit

Permalink
add option --readme-index
Browse files Browse the repository at this point in the history
  • Loading branch information
kpym committed Jan 25, 2024
1 parent ef330e7 commit 4836f65
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion gm_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ func buildMd(infile string) {
if infile == "" {
os.Stdout.Write(html)
} else {
outfile := filepath.Join(outdir, infile[:len(infile)-3]+".html")
var outfile string

if readme && strings.ToLower(filepath.Base(infile)) == "readme.md" {
// if it is a README.md file, we want to name it index.html
outfile = filepath.Join(outdir, infile[:len(infile)-9]+"index.html")
} else {
// otherwise we just change the extension
outfile = filepath.Join(outdir, infile[:len(infile)-3]+".html")
}
if os.MkdirAll(filepath.Dir(outfile), os.ModePerm) != nil {
check(err, "Problem to reach/create folder:", filepath.Dir(outfile))
}
Expand Down
2 changes: 2 additions & 0 deletions gm_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ var (
// build flags
outdir string
inpatterns []string
readme bool

// template flags
css string
Expand Down Expand Up @@ -111,6 +112,7 @@ func SetParameters() {
pflag.StringVar(&htmlshell, "html", "", "The html template (file or string).")

pflag.StringVarP(&outdir, "out-dir", "o", "", "The build output folder (created if not already existing, not used when serving).")
pflag.BoolVar(&readme, "readme-index", false, "Compile README.md to index.html (not used when serving).")
pflag.BoolVar(&localmdlinks, "links-md2html", true, "Replace .md with .html in links to local files (not used when serving).")

pflag.BoolVar(&attribute, "gm-attribute", true, "goldmark option: allows to define attributes on some elements.")
Expand Down

0 comments on commit 4836f65

Please sign in to comment.