diff --git a/application/source/commands/08_document_pdf.go b/application/source/commands/08_document_pdf.go index 39efe1610a1d78214daa14af0e1e9fc2524ee8b4..fa7ab67d939da18f8696997fd38e5912f43b53dd 100644 --- a/application/source/commands/08_document_pdf.go +++ b/application/source/commands/08_document_pdf.go @@ -37,7 +37,7 @@ func initDocumentPDF(command *flags.Command) { case "template": opt.Description = translations.T.Sprintf("template for the new document") case "output": - opt.Description = translations.T.Sprintf("directory in which the finished documentation is to be written") + opt.Description = translations.T.Sprintf("filename for the new document") case "format": opt.Description = translations.T.Sprintf("format of the finished documentation") case "verbose": diff --git a/application/source/document/pandoc.go b/application/source/document/pandoc.go index 3f933d488d124546c6e2ea3e2edf5a929c4f4102..9574352c964f46aba3c72979144056d2e7f3cf27 100644 --- a/application/source/document/pandoc.go +++ b/application/source/document/pandoc.go @@ -87,6 +87,10 @@ func runPandoc(source string, outputName string, latexPath string, luaFilter str arguments += "--toc " arguments += "--output=" + outputName + " " + if verbose { + fmt.Println(arguments) + } + cmd := exec.Command("bash", "-c", arguments) log, err := cmd.Output() diff --git a/application/source/document/pdf.go b/application/source/document/pdf.go index 63a53ed83efefb730fa7977c292f59d9353cf8ea..eaf58d27cbd5d22b4bfa79c28eb775f938de74b5 100644 --- a/application/source/document/pdf.go +++ b/application/source/document/pdf.go @@ -87,6 +87,17 @@ func BuildPDF(env BuildPdfEnvironment) error { environment.ExitWithError(2, "if the type is pdf, the output option must be specified") } + fileInfo, err := os.Stat(output) + if err != nil { + if !os.IsNotExist(err) { + environment.ExitWithError(2, "cannot stat output file", err.Error()) + } + } else { + if fileInfo.IsDir() { + environment.ExitWithError(2, "output file is a directory", output) + } + } + file, err := ioutil.TempFile(os.TempDir(), environment.State.GetInfo().Mnemonic) checkError(err) @@ -113,10 +124,6 @@ func BuildPDF(env BuildPdfEnvironment) error { } }() - c, _ := os.ReadFile(file.Name()) - - os.WriteFile("/tmp/debug.txt", c, 0644) - runPandoc(file.Name(), output, env.Templates.Latex, luaFilter.Name(), env.Verbose) return nil diff --git a/application/source/environment/template.go b/application/source/environment/template.go index 5967d6ca3305705b8a89aebe57859e618ba1e104..32260b8ecb42171c2bf1faa573c1a538aad47b2a 100644 --- a/application/source/environment/template.go +++ b/application/source/environment/template.go @@ -8,8 +8,16 @@ import ( "strings" ) +const defaultMarkdownTemplate = ` +{{ .Documents }} +` + func ReadTemplate(argPath string) string { + if argPath == "" { + return defaultMarkdownTemplate + } + current, err := os.Getwd() if err != nil { ExitWithError(2, "The current directory cannot be read") @@ -23,7 +31,7 @@ func ReadTemplate(argPath string) string { template, err := os.ReadFile(p) if err != nil { - ExitWithError(2, "The file %s cannot be read", p) + ExitWithError(2, "The template file %s cannot be read.", p) } return convertTemplateImages(string(template), path.Dir(p)) diff --git a/release.json b/release.json index 4e387676f2402ba793d1106a3a3a0e09854a1893..331eef031600de7d9903fec3d722b0b053628818 100644 --- a/release.json +++ b/release.json @@ -1,3 +1,3 @@ { - "version": "1.0.35" + "version": "1.0.36" } \ No newline at end of file