144 Commits
Author SHA1 Message Date
Steve ToroandGitHub 52190f1d60 fix: nil-pointer panic in WriteToSSA when Metadata is nil (#145)
* 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).
v0.42.0
2026-07-08 08:57:43 +02:00
qiangmzsxandGitHub b8dd60d1e7 fix: Panic in ReadFromSRT when cue has missing end time boundary (#144) v0.41.0 2026-06-22 08:50:19 +02:00
Eric LindvallandGitHub 4c9fa2793f Fix panic when WebVTT cue has missing end time boundary (#142)
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.
v0.40.0
2026-04-21 08:43:01 +02:00
David Le CorfecandGitHub dec0bf67e2 propagate stl alignment to ttml (#141)
* propagate stl alignment to ttml

* add tests for stl attributes propagation
v0.39.0
2026-02-23 11:28:58 +01:00
David Le CorfecandGitHub 2785085e23 fix: preserve color codes in STL (#135)
* 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
2026-02-23 11:27:05 +01:00
David Le CorfecandGitHub ab59fc08cc fix STL roundtrip: preserve subtitle text on write/read cycle (#137) 2026-01-20 14:30:11 +01:00
David Le CorfecandGitHub fc091000d7 fix missing STL25.01 in GSI block when converting TTML to STL (#136)
* fix missing STL25.01 in GSI block when converting TTML to STL

* add test for ttml to stl gsi block
2026-01-16 10:49:54 +01:00
Quentin Renard 220af05053 Teletext charsets tweaks #2 2026-01-09 10:11:04 +00:00
Quentin Renard 4d067b9218 Teletext charsets tweaks 2026-01-09 09:37:59 +00:00
Quentin Renard add3715e0f Re-generated teletext charsets 2026-01-08 15:59:23 +00:00
David Le CorfecandGitHub 995c70abad Improve WebVTT to TTML conversion (#132)
* improve WebVTT to TTML conversion

* introduce a WebVTTPosition struct to store x-position and optional alignment

* remove unused map

* include propagateWebVTTPosition into propagateWebVTTAttributes
v0.38.0
2025-11-04 16:58:04 +01:00
David Le CorfecandGitHub 1e38856821 stl: improve error messages (#128)
* stl: improve error messages

* stl: ignore atoi errors when parsing totalNumberOfDisks and diskSequenceNumber

* stl: ignore revisionNumber parsing errors, as this field is useless in converting subs

* stl: restore astisub prefix in error messages

* parseDurationSTL: restore astisub prefix
v0.37.0
2025-11-03 17:05:36 +01:00
Quentin Renard 083c8fc70a Added devcontainer 2025-10-28 11:38:22 +00:00
Nhan Trong NguyenandGitHub 90801f85db Support body div level style and region (#131)
* [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
v0.36.0
2025-10-14 11:05:44 +02:00
Justin TaylorandGitHub 2d1d91b6fa Add support for colon delimited milliseconds for srt (#129) v0.35.0 2025-09-05 08:57:17 +02:00
Quentin Renard 716eb3660b Maintain whitespace from original source in ttml v0.34.0 2025-03-01 15:33:11 +01:00
Justin TaylorandGitHub 58297a613f Maintain whitespace from original source (#127) v0.33.0 2025-02-27 15:31:39 +01:00
Quentin Renard a147a14783 Optimized webvtt tag write v0.32.1 2025-02-20 10:00:04 +01:00
Quentin Renard 6e9e3d6f9b Fixed non utf8 vtt test 2025-02-20 09:39:03 +01:00
Justin TaylorandGitHub 721d3fc825 Add custom split logic for scanner (#125) v0.32.0 2024-12-19 09:16:26 +01:00
Justin TaylorandGitHub 25b7e224de Allow for more lenient duration parsing (#124) 2024-12-18 09:39:22 +01:00
Justin TaylorandGitHub 646078d703 Allow for styles to persist over lines (#123)
* Allow for styles to persist over lines

* Update to pass by reference for style attributes
v0.31.0
2024-12-17 17:12:47 +01:00
Justin TaylorandGitHub f285923a0c SRT HTML Entities (#122)
* 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
2024-12-17 09:08:53 +01:00
Justin TaylorandGitHub cba5e0fa56 Srt html styling (#121)
* Setup parsing srt stylings for webvtt

* migrated tests

* clean up tests and testdata
v0.30.0
2024-11-20 12:34:46 +01:00
Nick BrandtandGitHub 80e6dcf52c Enforce UTF-8 encoding for input bytes (#115)
* 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
v0.29.0
2024-10-08 15:52:55 +02:00
a3932fdfae feat: Issues-116 support options for WriteToTTML (#117)
* feat: Issues-116 support options for WriteToTTML

Issue: https://github.com/asticode/go-astisub/issues/116

* chore: rename TestTTMLWithOptionsNoIndent to TestWriteToTTMLWithIndentOption

link: https://github.com/asticode/go-astisub/pull/117#discussion_r1789984044

* chore: use ./testdata/example-in.ttml

link: https://github.com/asticode/go-astisub/pull/117#discussion_r1790088428

---------

Co-authored-by: Min <min@mindeMacBook-Air.local>
v0.28.0
2024-10-07 15:08:08 +02:00
Quentin Renard d27006f237 Now handling \N character in webvtt 2024-10-02 09:05:47 +02:00
Nick BrandtandGitHub f9f932dcf5 fix: Add support for X-TIMESTAMP-MAP r/w persistence (#112)
* 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
v0.27.0
2024-09-10 08:55:13 +02:00
Nhan Trong NguyenandGitHub 593487ab1c [ttml] Rename ttml decoder to token reader and correct test data (#108) 2024-06-18 08:58:41 +02:00
Nhan Trong NguyenandGitHub 35e8bad643 Preserve br tag in ttml (#106)
* Preserve br tag in ttml

* [ttml] Change to more appropriate name and optimize ttml xml decoder
2024-06-17 14:23:38 +02:00
UmeshandGitHub 2f42372251 fix: keep sort order (#105)
Using stale sort to preserve original order
2024-05-10 14:20:26 +02:00
WithoutPantsandGitHub 90151b9902 Add support for inline timestamps (#102)
* Add support for inline timestamps

* Adjustments per review

* Return slice
2024-03-22 09:07:02 +01:00
Quentin Renard 967700d46e Fixed invalid rounding in formatDuration 2024-03-20 12:03:15 +01:00
Quentin Renard 6c644f7ded Fixed srt indexes v0.26.2 2024-01-09 09:11:58 +01:00
2d03157006 Preserve WebVTT tags in subtitle lines (#97)
* [webvtt] Preserve WebVTT tags

* [webvtt/test] Testcase for webvtt tags

---------

Co-authored-by: Nhan Nguyen <nhan.trong.nguyen@edgeware.tv>
v0.26.0 v0.26.1
2023-11-22 11:45:18 +01:00
2c5a2ccd3f Simple support for WebVTT style (#95)
* 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>
2023-11-03 10:34:15 +01:00
Fadhil MandagaandGitHub f1d0d10b2f fix: vlc expect 10 columns for ssa (new branch) (#92)
* vlc expect 10 columns for ssa

* protect nil

* remove unused func

* remove unused const
2023-10-29 10:24:55 +01:00
Samuel StaufferandGitHub fae4bff300 Support parsing srt without sequence numbers. (#93)
* 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.
2023-10-02 18:12:35 +02:00
Quentin Renard 04eba858f1 Added github action 2023-08-08 11:01:51 +02:00
95f3a9465a escape-unescape '<' character for WebVTT (#89)
* 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>
2023-07-26 15:14:52 +02:00
Quentin Renard 1e3a211581 Added webvtt escape 2023-07-04 10:50:41 +02:00
David Le CorfecandGitHub 9f9e6a8f36 fix vertical position conversion from stl teletext to webvtt (#88)
* fix vertical position conversion from stl teletext to webvtt

* add comments to teletext vertical position conversion to vtt
v0.25.1
2023-06-23 09:06:54 +02:00
David Le CorfecandGitHub 5214480cf0 Propagate STL vertical position to WebVTT (#87)
* propagate STL vertical position to WebVTT

* remove useless int cast
v0.25.0
2023-06-20 08:57:53 +02:00
Quentin Renard 4990be7897 Fixed readme example v0.24.0 2023-05-19 09:02:59 +02:00
Quentin Renard b6b18718dd Handle . millisecond separator for srt as well 2023-02-17 09:09:36 +01:00
David Le CorfecandGitHub 6526d9e248 STL: preserve editor's name and contact details, and TTI block justification (#76)
* stl: copy editor name and editor contact details to/from metadata

* stl: preserve justification when creating TTI blocks

* reorder alphabetically the fields of struct Metadata

* add stlJustificationCodeFromStyle method and reorder alphabetically some fields

* stl: fix typo in stlJustificationCodeFromStyle
2023-01-23 11:23:16 +01:00
David Le CorfecandGitHub 7acfe23468 Improve STL GSIBlock write (#75)
* add missing STL GSIBlock fields to Subtitles.Metadata

* write the same GSIBlock as read

* fix stl tests
2023-01-20 11:48:38 +01:00
Quentin Renard c19fe10597 Now handling ssa styles with leading * in events 2022-12-14 11:45:30 +01:00
356dc1d1ec support all characters in cue voice span (#70)
* support all characters in cue voice span

* Update webvtt.go

a clear regexp

Co-authored-by: finn peng <finn.peng@zoom.us>
v0.23.0
2022-11-15 11:39:00 +01:00
Quentin Renard 357c58359c Added STL original episode title v0.22.0 2022-11-12 11:54:41 +01:00