From c65e8895197f4d1f6736dd1f486d89a2e120d69b Mon Sep 17 00:00:00 2001 From: lukas Date: Sat, 11 Sep 2021 23:26:06 +0200 Subject: [PATCH] fix #2 --- Main.go | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Main.go b/Main.go index ca0bc1b..c51b10c 100644 --- a/Main.go +++ b/Main.go @@ -119,11 +119,13 @@ func compileLatex() (*string, error) { argsWithoutProg = argsWithoutProg[:len(argsWithoutProg)-1] } + addArgIfNotExisting(&argsWithoutProg, "-interaction", "-interaction=nonstopmode") + addArgIfNotExisting(&argsWithoutProg, "-synctex", "-synctex=1") + addArgIfNotExisting(&argsWithoutProg, "-ouput-format", "-output-format=pdf") + addArgIfNotExisting(&argsWithoutProg, "-file-line-error", "-file-line-error") + // insert default args - argsWithoutProg = append(argsWithoutProg, "-file-line-error", - "-interaction=nonstopmode", - "-synctex=1", - "-output-format=pdf", filename) + argsWithoutProg = append(argsWithoutProg, filename) cmd := exec.Command(app, argsWithoutProg...) stdout, _ := cmd.StdoutPipe() @@ -158,6 +160,20 @@ func compileLatex() (*string, error) { return &output, err } +func addArgIfNotExisting(args *[]string, searchstring string, arg string) { + exists := false + for _, s := range *args { + if strings.Contains(s, searchstring) { + exists = true + } + } + + if !exists { + tmp := append(*args, arg) + *args = tmp + } +} + var i = 0 // printPoint print a point with every 10th method call