* fix: nil-pointer panic in WriteToSSA when Metadata is nil
WriteToSSA dereferenced s.Metadata unconditionally when computing the
v4plus flag, but Metadata is an optional *Metadata that only ReadFromSSA
populates. Reading any other format (WebVTT, SRT, TTML, STL) and writing
SSA therefore panicked with a nil-pointer dereference.
Guard the read: nil Metadata now yields v4plus=false (legacy [V4 Styles]
output), matching the existing nil-safe newSSAScriptInfo one line above.
Adds TestWriteToSSANilMetadata as a regression test.
* Address review feedback on TestWriteToSSANilMetadata
Move the nil-metadata comment above the subtitles literal and simplify
its wording, and replace the post-write asserts with assert.NotPanics
to focus the test on the regression (writing SSA no longer panics).
Previously, parsing a WebVTT line like '00:00:01.000 -->' with no end
timestamp panicked with an index out of range error. Now return a
descriptive error instead.
* fix: preserve color codes in STL
* add STLColor in StyleAttributes, and cleanup stl color code
* parse ttml colors and propagate to stl
* add tests on stl colors
* refactor color fields from *string to *Color
* rename newColorFromTTMLString to newColorFromHTMLString
* add Color.HTMLString and Color.CSSString
* rename Color.CSSString to Color.WebVTTString
* improve WebVTT to TTML conversion
* introduce a WebVTTPosition struct to store x-position and optional alignment
* remove unused map
* include propagateWebVTTPosition into propagateWebVTTAttributes
* [ttml] Support style and region inheritance body>div>p
* [ttml/test] Test case for style and region inheritance
* Add more case
* Rename function and correct code
* Updated escaping to be general for ampersand and escape for srt
* Moved html escaping to subtitles.go and updated tests
* Move back to using acceptable list of escapable html entities
* Detect UTF-8 for vtt/srt, error if encoded otherwise
* Switch to isValidUTF8Reader
* Remove isValidUTF8Reader function
* Enforce valid UTF8 on each SRT and WebVTT line
* Add benchmark tests for webvtt and srt
* Update benchmark test
* Add non-utf-8 tests and files
* Remove benchmarks
* Add support for X-TIMESTAMP-MAP r/w persistence
* Refactor TimestampMap struct per review feedback
* Fix MPEGTS / LOCAL ordering, update tests
* Clean up timestamp map vtt test
* Simple support for WebVTT style
* fixup! Simple support for WebVTT style
* [webvtt/test] Add cases of STYLES
* [webvtt] Use long condition instead of function
---------
Co-authored-by: Nhan Nguyen <nhan.trong.nguyen@edgeware.tv>
* Support parsing srt without sequence numbers.
There are many srt in the wild that are missing sequence numbers. It's
easy to detect by looking for an empty line vs index/sequence in the
line before the time. In my analysis of many srt I have not seen ones
missing the empty line, but it's feasible that these also exist. This
shouldn't affect parsing otherwise, however, and in my experience the
missing sequence number is common enough that it's useful to handle.
* Remove duplicate testdata file and use existing.
* escape-unescape '<' character for WebVTT
* add test for escape-unescape '<' character for WebVTT
* correct places to escape-unescape webvtt text
---------
Co-authored-by: Nhan Nguyen <nhan.trong.nguyen@edgeware.tv>