Skip to content
Snippets Groups Projects
Verified Commit 2b68a755 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

chore: commit save point

parent ec978893
No related branches found
No related tags found
No related merge requests found
...@@ -37,7 +37,7 @@ func initDocumentPDF(command *flags.Command) { ...@@ -37,7 +37,7 @@ func initDocumentPDF(command *flags.Command) {
case "template": case "template":
opt.Description = translations.T.Sprintf("template for the new document") opt.Description = translations.T.Sprintf("template for the new document")
case "output": 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": case "format":
opt.Description = translations.T.Sprintf("format of the finished documentation") opt.Description = translations.T.Sprintf("format of the finished documentation")
case "verbose": case "verbose":
......
...@@ -87,6 +87,10 @@ func runPandoc(source string, outputName string, latexPath string, luaFilter str ...@@ -87,6 +87,10 @@ func runPandoc(source string, outputName string, latexPath string, luaFilter str
arguments += "--toc " arguments += "--toc "
arguments += "--output=" + outputName + " " arguments += "--output=" + outputName + " "
if verbose {
fmt.Println(arguments)
}
cmd := exec.Command("bash", "-c", arguments) cmd := exec.Command("bash", "-c", arguments)
log, err := cmd.Output() log, err := cmd.Output()
......
...@@ -87,6 +87,17 @@ func BuildPDF(env BuildPdfEnvironment) error { ...@@ -87,6 +87,17 @@ func BuildPDF(env BuildPdfEnvironment) error {
environment.ExitWithError(2, "if the type is pdf, the output option must be specified") 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) file, err := ioutil.TempFile(os.TempDir(), environment.State.GetInfo().Mnemonic)
checkError(err) checkError(err)
...@@ -113,10 +124,6 @@ func BuildPDF(env BuildPdfEnvironment) error { ...@@ -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) runPandoc(file.Name(), output, env.Templates.Latex, luaFilter.Name(), env.Verbose)
return nil return nil
......
...@@ -8,8 +8,16 @@ import ( ...@@ -8,8 +8,16 @@ import (
"strings" "strings"
) )
const defaultMarkdownTemplate = `
{{ .Documents }}
`
func ReadTemplate(argPath string) string { func ReadTemplate(argPath string) string {
if argPath == "" {
return defaultMarkdownTemplate
}
current, err := os.Getwd() current, err := os.Getwd()
if err != nil { if err != nil {
ExitWithError(2, "The current directory cannot be read") ExitWithError(2, "The current directory cannot be read")
...@@ -23,7 +31,7 @@ func ReadTemplate(argPath string) string { ...@@ -23,7 +31,7 @@ func ReadTemplate(argPath string) string {
template, err := os.ReadFile(p) template, err := os.ReadFile(p)
if err != nil { 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)) return convertTemplateImages(string(template), path.Dir(p))
......
{ {
"version": "1.0.35" "version": "1.0.36"
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment