Browse Source

Fixed newline shenanigans in rpdata-as2storyimport

1.0
Gisle Aune 6 years ago
parent
commit
136302084d
  1. 8
      cmd/rpdata-as2storyimport/main.go

8
cmd/rpdata-as2storyimport/main.go

@ -83,11 +83,17 @@ func main() {
log.Fatalln(err) log.Fatalln(err)
} }
// Change the story title
title := result.Name title := result.Name
if strings.HasPrefix(result.Source, "#") { if strings.HasPrefix(result.Source, "#") {
firstNewline := strings.Index(result.Source, "\n") firstNewline := strings.Index(result.Source, "\n")
title = result.Source[1:firstNewline]
result.Name = strings.Replace(result.Source[1:firstNewline], "\r", "", -1)
result.Source = result.Source[firstNewline+1:] result.Source = result.Source[firstNewline+1:]
result.Source = strings.Replace(result.Source, "\r\n", "\n", -1)
if strings.HasPrefix(result.Source, "\r") || strings.HasPrefix(result.Source, "\n") {
result.Source = result.Source[1:]
}
} }
chapter, err := story.AddChapter(title, result.Author, result.Source, publishDate, fictionalDate) chapter, err := story.AddChapter(title, result.Author, result.Source, publishDate, fictionalDate)

Loading…
Cancel
Save