Append 'out' parameter, to dump html files

This commit is contained in:
Fred Pauchet 2022-09-19 21:36:09 +02:00
parent 647e9b546d
commit aa6aef939d
1 changed files with 13 additions and 4 deletions

17
main.go
View File

@ -1,12 +1,13 @@
package main
import (
"bytes"
"flag"
"fmt"
"log"
"os"
"path/filepath"
"bytes"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension"
"github.com/yuin/goldmark/parser"
@ -44,10 +45,10 @@ func convertMarkdownToHtml(file string) {
goldmark.WithParserOptions(
parser.WithAutoHeadingID(),
),
goldmark.WithRendererOptions(
goldmark.WithRendererOptions(
html.WithHardWraps(),
html.WithXHTML(),
),
),
)
var buf bytes.Buffer
@ -61,8 +62,15 @@ func convertMarkdownToHtml(file string) {
func main() {
var rootDir *string
var outputDir *string
defaultOutputDir, err := os.MkdirTemp("", "go-jack")
if err != nil {
panic(err)
}
rootDir = flag.String("dir", ".", "Specify the directory to parse.")
outputDir = flag.String("out", defaultOutputDir, "Specify the output directory")
flag.Usage = func() {
fmt.Printf("Jack expects: \n")
fmt.Printf("./jack -d <rootDir>\n")
@ -75,5 +83,6 @@ func main() {
fmt.Println(file)
convertMarkdownToHtml(file)
}
}
fmt.Println(*outputDir)
}