Skip to content

Commit

Permalink
Old habits die hard; adhere to GO's var naming conventions:
Browse files Browse the repository at this point in the history
Error: cmd/md2pdf/md2pdf.go:123:12: don't use underscores in Go names; range var file_path should be filePath
Error: cmd/md2pdf/md2pdf.go:124:6: don't use underscores in Go names; var file_contents should be fileContents
  • Loading branch information
jessp01 committed Nov 10, 2023
1 parent 845bb58 commit a0935b9
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions cmd/md2pdf/md2pdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"runtime"
"strings"

"github.com/mandolyte/mdtopdf"
"github.com/gomarkdown/markdown/parser"
"github.com/mandolyte/mdtopdf"
"golang.org/x/exp/slices"
)

Expand Down Expand Up @@ -52,15 +52,15 @@ func processRemoteInputFile(url string) ([]byte, error) {
}

func glob(dir string, validExts []string) ([]string, error) {
files := []string{}
err := filepath.Walk(dir, func(path string, f os.FileInfo, err error) error {
if slices.Contains(validExts,filepath.Ext(path)) {
files = append(files, path)
}
return nil
})

return files, err
files := []string{}
err := filepath.Walk(dir, func(path string, f os.FileInfo, err error) error {
if slices.Contains(validExts, filepath.Ext(path)) {
files = append(files, path)
}
return nil
})

return files, err
}

func main() {
Expand Down Expand Up @@ -103,38 +103,38 @@ func main() {
if httpRegex.Match([]byte(*input)) {
content, err = processRemoteInputFile(*input)
if err != nil {
log.Fatal(err)
log.Fatal(err)
}
// get the base URL so we can adjust relative links and images
inputBaseURL = strings.Replace(filepath.Dir(*input), ":/", "://", 1)
} else {
fileInfo, err := os.Stat(*input)
if err != nil {
log.Fatal(err)
log.Fatal(err)
}

if fileInfo.IsDir() {
opts = append(opts, mdtopdf.IsHorizontalRuleNewPage(true))
validExts := []string{".md",".markdown"}
files, err := glob(*input, validExts)
if err != nil {
log.Fatal(err)
}
for i, file_path := range(files){
file_contents, err := ioutil.ReadFile(file_path)
opts = append(opts, mdtopdf.IsHorizontalRuleNewPage(true))
validExts := []string{".md", ".markdown"}
files, err := glob(*input, validExts)
if err != nil {
log.Fatal(err)
log.Fatal(err)
}
content = append(content, file_contents...)
if (i < len(files) -1){
content = append(content, []byte("---\n")...)
for i, filePath := range files {
fileContents, err := ioutil.ReadFile(filePath)
if err != nil {
log.Fatal(err)
}
content = append(content, fileContents...)
if i < len(files)-1 {
content = append(content, []byte("---\n")...)
}
}
}
} else {
content, err = ioutil.ReadFile(*input)
if err != nil {
log.Fatal(err)
}
content, err = ioutil.ReadFile(*input)
if err != nil {
log.Fatal(err)
}
}
}
}
Expand Down

0 comments on commit a0935b9

Please sign in to comment.