Skip to content

Commit

Permalink
Rename vars and fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
philipgiuliani committed Nov 18, 2023
1 parent 855a16c commit 7c3f34c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/glubs/webvtt.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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))
}
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 7c3f34c

Please sign in to comment.