From 69dd11f62841be437b6ad430ae56ac065a90d22a Mon Sep 17 00:00:00 2001 From: Michel Boucey Date: Sat, 20 May 2023 18:02:55 +0200 Subject: [PATCH] (re)Write sections only when it is asked --- main.go | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/main.go b/main.go index 365423b..0b4b7ed 100644 --- a/main.go +++ b/main.go @@ -38,7 +38,7 @@ import ( func main() { - version := "1.1.3" + version := "1.1.4" var headerCounters [7]int var mdTmpFile *os.File @@ -112,23 +112,30 @@ func main() { title := matches[3] headerCounters[currentHeaderType]++ - for headerType := 1; headerType <= 6; headerType++ { - AddSectionChunk(§ion, headerCounters[headerType], currentHeaderType, headerType) - } - if *removeFlag { + rewrittenLine = header + " " + title + } else { + + for headerType := 1; headerType <= 6; headerType++ { + AddSectionChunk(§ion, headerCounters[headerType], currentHeaderType, headerType) + } + rewrittenLine = header + " " + section + " " + title } WriteTmpFile(*writeFlag, mdTmpFile, rewrittenLine, newLine) - for i := currentHeaderType + 1; i <= 6; i++ { - headerCounters[i] = 0 - } + if !*removeFlag { + + for i := currentHeaderType + 1; i <= 6; i++ { + headerCounters[i] = 0 + } - section = "" + section = "" + + } } else {