implemented SubFix.encode function

This commit is contained in:
2020-11-10 15:42:07 -05:00
parent 0310142814
commit 2d3713d0c9
4 changed files with 122 additions and 3 deletions

View File

@@ -35,7 +35,7 @@ import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.State (StateT, evalStateT, get, put)
import Data.Char (chr)
import SubFix.Internal (decodeTime)
import SubFix.Internal (decodeTime, encodeTime)
-- | Defines a caption group
data Caption = Caption
@@ -64,7 +64,9 @@ decode = evalStateT decodeLoop . lines
-- | Encodes a list of caption groups
encode :: [Caption] -> String
encode = undefined
encode [] = ""
encode [c] = encodeCaption c
encode (c:cs) = encodeCaption c ++ "\n" ++ encode cs
editText :: String -> String
editText = checkCaret . checkNotes
@@ -132,4 +134,10 @@ nextLine = get >>= \case
return line
[] -> lift $ Left "missing line"
encodeCaption :: Caption -> String
encodeCaption c = unlines $
[ show $ capID c
, encodeTime (capStart c) ++ " --> " ++ encodeTime (capEnd c)
] ++ lines (capText c)
--jl