38 Commits
Author SHA1 Message Date
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 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
2025-11-04 16:58:04 +01: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
2025-10-14 11:05:44 +02:00
Quentin Renard 716eb3660b Maintain whitespace from original source in ttml 2025-03-01 15:33:11 +01:00
Justin TaylorandGitHub 58297a613f Maintain whitespace from original source (#127) 2025-02-27 15:31:39 +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) 2024-12-19 09:16:26 +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
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
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
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>
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
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
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 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
Torbjörn EinarssonandGitHub 0d77988dd5 fix: ignore STL timecodeStartOfProgram and test that it works (#52) 2021-07-22 09:18:53 +02:00
discovery-avishekgulshanandGitHub 982542a681 TTML: Fixed improper spacing between captions (#43)
* 1. Fixed improper spacing between captions while converting TTML -> VTT

2. Added String To Pointer utility.

3. Converted TTML style attributes to pointers

4. Fixed Webvtt not using parent style attributes in region

* 1. Fixed Test cases
2. Fixed SRT and STL strings join

* 1. Removed Util
2. Added Regex to remove multiple space
3. In ttml.go update 'getStyleAttributes()' to 'newStyleAttributesFromTTMLInStyleAttributes()'
4. Using go-astikit to convert string to string pointer.

* Improper spacing fix

* Improper spacing fix

* Added Space in TTML out.
Added comments

* Added space to fix unit test

* update go.sum

* update go.sum

* Update go.sum

* Update go.sum
2021-06-14 17:36:23 +02:00
Arne M. StørksenandGitHub 21f973026e Add support for open stl subtitles (#33)
* Add support for open stl subtitles

* Adding STL OPN test and some more metadata

* Updated based on comments

* Moved functions from open_subtitle.go to stl.go

* Updated based on comments
2020-12-08 10:55:55 +01:00
Quentin Renard 0e2e94aea6 Not returning error on .srt positions 2020-11-25 09:35:50 +01:00
Quentin Renard 88639b8130 Oops 2020-08-17 14:48:43 +02:00
Quentin Renard 7bcc7717d3 Fixed multi-space bug in WebVTT 2020-08-17 12:23:29 +02:00
Nick ChadwickandGitHub 0299560178 Fix a bug parsing lines with only spaces (#23)
* Fix a bug parsing lines with only spaces

Adds a simple test file, broken-in.vtt, that starts with a single
space character, followed by a newline. In master this file panics
with an index out-of-bounds. This is fixed by checking both that
the line length is greater than zero, and that the resulting fields
length is also greater than zero.

* Updates based on PR feedback
2020-06-18 10:53:38 +02:00
Des-Nerger e2ca1c7ce8 SSA: changed Outline, Shadow, Spacing to float64 2018-12-31 18:08:34 +10:00
Quentin Renard b11e56c657 Added proper .stl character parsing 2018-02-25 11:28:59 +01:00
Quentin Renard a9b103e25e Added more SSA fields to Metadata 2017-12-23 08:51:29 +01:00
Quentin Renard ab7701f327 Added .ssa/.ass 2017-12-24 03:41:14 +01:00
Quentin Renard e01c27e4e7 Moved TTML namespaces 2017-07-08 23:27:27 +02:00
Quentin Renard 317e96dfcc Styles and regions are now maps 2017-07-08 10:10:58 +02:00
Quentin Renard b27e576885 Fixed tests 2017-07-02 15:59:57 +02:00
Quentin Renard bf83847f3e Added readme 2017-07-02 15:53:23 +02:00