Skip to content

Commit

Permalink
Update to Gleam 0.33
Browse files Browse the repository at this point in the history
  • Loading branch information
philipgiuliani committed Dec 6, 2023
1 parent d243956 commit 457b397
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
gleam 0.32.4
gleam 0.33.0-rc1
erlang 26
4 changes: 2 additions & 2 deletions src/glubs/srt.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ fn cue_to_string(cue: Cue) -> StringBuilder {
}

fn parse_cue(input: String) -> Result(Cue, String) {
let [id, ts, ..lines] = string.split(input, "\n")
let assert [id, ts, ..lines] = string.split(input, "\n")

use id <- result.try(
id
|> int.parse()
|> result.replace_error("Cannot parse identifier"),
)

use #(start_time, end_time, "") <- result.try(timestamp.parse_range(ts, ","))
use #(start_time, end_time, _) <- result.try(timestamp.parse_range(ts, ","))

Ok(Cue(
id: id,
Expand Down
6 changes: 3 additions & 3 deletions src/glubs/webvtt.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ 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, ..body] =
let assert [header, ..body] =
webvtt
|> string.replace("\r\n", "\n")
|> string.trim_right()
|> string.split("\n\n")

let [header, ..metadata] = string.split(header, "\n")
let assert [header, ..metadata] = string.split(header, "\n")

use comment <- result.try(parse_comment(header))
use metadata <- result.try(parse_metadata(metadata))
Expand Down Expand Up @@ -317,6 +317,6 @@ fn parse_start_tag(input: String) -> Token {
}

fn parse_tag_and_classes(input: String) -> #(String, List(String)) {
let [tag, ..classes] = string.split(input, on: ".")
let assert [tag, ..classes] = string.split(input, on: ".")
#(tag, classes)
}

0 comments on commit 457b397

Please sign in to comment.