From 136302084d39b1b508443aac116b99cb1eeb04ac Mon Sep 17 00:00:00 2001 From: Gisle Aune Date: Sat, 7 Jul 2018 12:53:52 +0200 Subject: [PATCH] Fixed newline shenanigans in rpdata-as2storyimport --- cmd/rpdata-as2storyimport/main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/rpdata-as2storyimport/main.go b/cmd/rpdata-as2storyimport/main.go index 7e47f5e..23b6f82 100644 --- a/cmd/rpdata-as2storyimport/main.go +++ b/cmd/rpdata-as2storyimport/main.go @@ -83,11 +83,17 @@ func main() { log.Fatalln(err) } + // Change the story title title := result.Name if strings.HasPrefix(result.Source, "#") { 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 = 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)