From 0dfe0f814210d5764e889b421034e93dba534351 Mon Sep 17 00:00:00 2001 From: Sebastian Frank Date: Tue, 19 Mar 2019 11:34:35 +0100 Subject: [PATCH] Run function --- cmd/mark2web/main.go | 14 ++------------ pkg/mark2web/run.go | 11 +++++++++++ pkg/mark2web/tree.go | 3 ++- 3 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 pkg/mark2web/run.go diff --git a/cmd/mark2web/main.go b/cmd/mark2web/main.go index df95038..61ee90b 100644 --- a/cmd/mark2web/main.go +++ b/cmd/mark2web/main.go @@ -22,8 +22,6 @@ var ( var log = helper.Log -var tree = new(mark2web.TreeNode) - func main() { inDir := flag.String("in", "./", "input directory") outDir := flag.String("out", "html", "output directory") @@ -127,19 +125,11 @@ func main() { Quality: 75, } - tree.ReadContentDir(*inDir+"/content", *outDir, "", defaultPathConfig) - //spew.Dump(contentConfig) - - //spew.Dump(navMap) - - templatesDir := *inDir + "/templates" - mark2web.SetTemplateDir(templatesDir) - filtersDir := templatesDir + "/filters" + filtersDir := *inDir + "/templates/filters" if _, err := os.Stat(filtersDir); !os.IsNotExist(err) { filter.RegisterFilters(filtersDir) } - tree.ProcessContent() - mark2web.ProcessAssets() + mark2web.Run(*inDir, *outDir, defaultPathConfig) } diff --git a/pkg/mark2web/run.go b/pkg/mark2web/run.go new file mode 100644 index 0000000..3f859fe --- /dev/null +++ b/pkg/mark2web/run.go @@ -0,0 +1,11 @@ +package mark2web + +func Run(inDir, outDir string, defaultPathConfig *PathConfig) { + SetTemplateDir(inDir + "/templates") + + tree := new(TreeNode) + tree.ReadContentDir(inDir+"/content", outDir, "", defaultPathConfig) + tree.ProcessContent() + + ProcessAssets() +} diff --git a/pkg/mark2web/tree.go b/pkg/mark2web/tree.go index 615d63c..5cd15da 100644 --- a/pkg/mark2web/tree.go +++ b/pkg/mark2web/tree.go @@ -16,5 +16,6 @@ type TreeNode struct { Config *PathConfig Sub []*TreeNode - root *TreeNode // shows always to root of tree + root *TreeNode // shows always to root of tree + parent *TreeNode }