Skip to content

Commit

Permalink
Now handling \N character in webvtt
Browse files Browse the repository at this point in the history
  • Loading branch information
asticode committed Oct 2, 2024
1 parent f9f932d commit d27006f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion testdata/example-in.ssa
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit d27006f

Please sign in to comment.