asticode / go-astisub

Manipulate subtitles in GO (.srt, .ssa/.ass, .stl, .ttml, .vtt (webvtt), teletext, etc.)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Subtitles.go String() - why are subtitle lines joined with a " - ", instead of a new line ("\n")?

neoramos opened this issue · comments

When we display a subtitle, it may be broken into multiple lines.
Example:
"Solo se muestran controles que estén
en estado crítico o de advertencia."

Unfortunately, the call to subtitle.String() method converts this to:
"Solo se muestran controles que estén - en estado crítico o de advertencia."

// String implements the Stringer interface
func (i Item) String() string {
	var os []string
	for _, l := range i.Lines {
		os = append(os, l.String())
	}
	return strings.Join(os, " - ") // <-- could this please be changed to return strings.Join(os, "\n")?
}

Thank you.
Neo

The thing is the line separator depends on your subtitles format: it will be different between .srt and .stl for instance. Therefore the .String() function shouldn't be used to get your subtitle item's content in your subtitle format but should be used for log purposes only.

Thank you for the explanation @asticode!

The existing was implement by someone else.
I'll take a look at another way to get the subtitle text in it's original format.

Closing issue.