Portability | unknown |
---|---|
Maintainer | ruben.astud@gmail.com |
Safe Haskell | None |
A basic parser for .srt files (subtitles) based on Attoparsec
and Text
- module Text.Subtitles.SRT.Datatypes
- parseSRT :: Parser Subtitles
- parseSingleLine :: Parser Line
- parseOnly' :: Parser a -> Text -> Either String a
Terminology of the module
All the sections of a Line have their corresponding ADT in Text.Subtitles.SRT.Datatypes
2 00:00:50,050 --> 00:00:52,217 X1:1 X2:2 Y1:1 Y2:2 Drama here
The whole Line is represented in the Line
ADT which constructors
represented by different ADTs
- The first line is called index, which is the first constructor of
Line
. - The second one is called
Range
, which correspond to two separatedTime
. - After the range is an optional field called Rectangle which says what geometry should the text obey.
- The last one is the
subs
. Which is just Text and correspond to the third constructor ofLine
.
Re-exported Datatypes
module Text.Subtitles.SRT.Datatypes
Main parsers
parseSRT :: Parser SubtitlesSource
Main Parser, gives you a list of all the Lines of the subtitle. It fails if the subtitle doesn't have any Lines.
parseSingleLine :: Parser LineSource
The individual Line parser. Given the upper example return the corresponding Line representation