From 7c3f34caf26a550f52014ea56cf6e5c371f36db2 Mon Sep 17 00:00:00 2001 From: Philip Giuliani Date: Sat, 18 Nov 2023 10:39:44 +0100 Subject: [PATCH] Rename vars and fix comment --- src/glubs/webvtt.gleam | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/glubs/webvtt.gleam b/src/glubs/webvtt.gleam index 5b126ef..5b40bd7 100644 --- a/src/glubs/webvtt.gleam +++ b/src/glubs/webvtt.gleam @@ -17,7 +17,7 @@ pub type WebVTT { // Parses a WebVTT string and returns a Result containing the parsed WebVTT structure or a parsing error. pub fn parse(webvtt: String) -> Result(WebVTT, String) { - let [header, ..cues] = + let [header, ..body] = webvtt |> string.replace("\r\n", "\n") |> string.trim_right() @@ -27,7 +27,7 @@ pub fn parse(webvtt: String) -> Result(WebVTT, String) { let [header, ..] = string.split(header, "\n") use comment <- result.try(parse_comment(header)) - use items <- result.try(list.try_map(cues, parse_item)) + use items <- result.try(list.try_map(body, parse_item)) Ok(WebVTT(comment: comment, items: items)) } @@ -115,13 +115,13 @@ pub type TokenizationError { InvalidEndToken } +/// Tokenizes the given cue payload and returns a Result containing the list of generated tokens or a tokenization error. pub fn tokenize(payload: String) -> Result(List(Token), TokenizationError) { payload |> do_tokenize([]) |> result.map(list.reverse) } -/// Tokenizes the given cue payload and returns a Result containing the list of generated tokens or a tokenization error. fn do_tokenize( payload: String, acc: List(Token),