in generator/app.go [340:377]
func getExistingContent(path string, fileFormat string) (string, error) {
capture := false
var captured []string
beginMarker := ""
endMarker := ""
switch fileFormat {
case "markdown":
beginMarker = beginCustomMarkdown
endMarker = endCustomMarkdown
case "yaml":
beginMarker = beginCustomYaml
endMarker = endCustomYaml
case "":
return "", nil
}
// NOTE: For some reason using bufio.Scanner with existing file pointer prepends
// a bunch of null ^@ characters, so using to ioutil.ReadFile instead.
content, err := ioutil.ReadFile(path)
if err != nil {
return "", err
}
for _, line := range strings.Split(string(content), "\n") {
if strings.Contains(line, endMarker) {
capture = false
}
if capture {
captured = append(captured, line)
}
if strings.Contains(line, beginMarker) {
capture = true
}
}
return strings.Join(captured, "\n"), nil
}