From d27006f237ff7b81c6bd47ef0c68f717df82089c Mon Sep 17 00:00:00 2001 From: Quentin Renard Date: Wed, 2 Oct 2024 09:05:47 +0200 Subject: [PATCH] Now handling \N character in webvtt --- ssa.go | 5 ++++- testdata/example-in.ssa | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ssa.go b/ssa.go index 3e2580d..d94d805 100644 --- a/ssa.go +++ b/ssa.go @@ -1057,8 +1057,11 @@ func (e *ssaEvent) item(styles map[string]*Style) (i *Item, err error) { } } + // \N and \n are both valid new line characters in SSA + text := strings.ReplaceAll(e.text, "\\N", "\\n") + // Loop through lines - for _, s := range strings.Split(e.text, "\\n") { + for _, s := range strings.Split(text, "\\n") { // Init s = strings.TrimSpace(s) var l = Line{VoiceName: e.name} diff --git a/testdata/example-in.ssa b/testdata/example-in.ssa index 195b0e6..d02a7b0 100644 --- a/testdata/example-in.ssa +++ b/testdata/example-in.ssa @@ -28,5 +28,5 @@ Dialogue: Marked=1,0:02:04.08,0:02:07.12,2,autre,0000,0000,0000,,MAN:\nHow did w Dialogue: Marked=1,0:02:12.16,0:02:15.20,*3,autre,0000,0000,0000,,This place is horrible. Not understood line Dialogue: Marked=1,0:02:20.24,0:02:22.28,1,autre,0000,0000,0000,,Smells like balls. -Dialogue: Marked=1,0:02:28.32,0:02:31.36,2,autre,0000,0000,0000,,We don't belong\nin this shithole. +Dialogue: Marked=1,0:02:28.32,0:02:31.36,2,autre,0000,0000,0000,,We don't belong\Nin this shithole. Dialogue: Marked=1,0:02:31.40,0:02:33.44,3,autre,0000,0000,0000,,(computer playing\nelectronic melody) \ No newline at end of file