diff --git a/manifest.toml b/manifest.toml index 7442601..11cee1f 100644 --- a/manifest.toml +++ b/manifest.toml @@ -2,11 +2,11 @@ # You typically do not need to edit this file packages = [ - { name = "filepath", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "EFB6FF65C98B2A16378ABC3EE2B14124168C0CE5201553DE652E2644DCFDB594" }, - { name = "gleam_stdlib", version = "0.38.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "663CF11861179AF415A625307447775C09404E752FF99A24E2057C835319F1BE" }, - { name = "gleeunit", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "72CDC3D3F719478F26C4E2C5FED3E657AC81EC14A47D2D2DEBB8693CA3220C3B" }, + { name = "filepath", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "67A6D15FB39EEB69DD31F8C145BB5A421790581BD6AA14B33D64D5A55DBD6587" }, + { name = "gleam_stdlib", version = "0.43.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "69EF22E78FDCA9097CBE7DF91C05B2A8B5436826D9F66680D879182C0860A747" }, + { name = "gleeunit", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "F7A7228925D3EE7D0813C922E062BFD6D7E9310F0BEE585D3A42F3307E3CFD13" }, { name = "htmb", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "htmb", source = "hex", outer_checksum = "915186FE1759EB8B78CBDC01228D0B7ED74DA2E64B08B4115525E293B036C428" }, - { name = "simplifile", version = "2.0.1", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "5FFEBD0CAB39BDD343C3E1CCA6438B2848847DC170BA2386DF9D7064F34DF000" }, + { name = "simplifile", version = "2.2.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0DFABEF7DC7A9E2FF4BB27B108034E60C81BEBFCB7AB816B9E7E18ED4503ACD8" }, { name = "snag", version = "0.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "snag", source = "hex", outer_checksum = "54D32E16E33655346AA3E66CBA7E191DE0A8793D2C05284E3EFB90AD2CE92BCC" }, ] diff --git a/src/content/chapter0_basics/lesson14_type_imports/code.gleam b/src/content/chapter0_basics/lesson14_type_imports/code.gleam index 61f552a..aeb6493 100644 --- a/src/content/chapter0_basics/lesson14_type_imports/code.gleam +++ b/src/content/chapter0_basics/lesson14_type_imports/code.gleam @@ -1,10 +1,10 @@ -import gleam/bytes_builder -import gleam/string_builder.{type StringBuilder} +import gleam/bytes_tree +import gleam/string_tree.{type StringTree} pub fn main() { // Referring to a type in a qualified way - let _bytes: bytes_builder.BytesBuilder = bytes_builder.new() + let _bytes: bytes_tree.BytesTree = bytes_tree.new() // Refering to a type in an unqualified way - let _text: StringBuilder = string_builder.new() + let _text: StringTree = string_tree.new() } diff --git a/src/content/chapter1_functions/lesson07_pipelines/code.gleam b/src/content/chapter1_functions/lesson07_pipelines/code.gleam index ec9b805..893642b 100644 --- a/src/content/chapter1_functions/lesson07_pipelines/code.gleam +++ b/src/content/chapter1_functions/lesson07_pipelines/code.gleam @@ -3,12 +3,12 @@ import gleam/string pub fn main() { // Without the pipe operator - io.debug(string.drop_left(string.drop_right("Hello, Joe!", 1), 7)) + io.debug(string.drop_start(string.drop_end("Hello, Joe!", 1), 7)) // With the pipe operator "Hello, Mike!" - |> string.drop_right(1) - |> string.drop_left(7) + |> string.drop_end(1) + |> string.drop_start(7) |> io.debug // Changing order with function capturing diff --git a/src/tour.gleam b/src/tour.gleam index 57461cf..75f5352 100644 --- a/src/tour.gleam +++ b/src/tour.gleam @@ -4,7 +4,7 @@ import gleam/list import gleam/option.{type Option, None, Some} import gleam/result import gleam/string -import gleam/string_builder +import gleam/string_tree import htmb.{type Html, h, text} import simplifile import snag @@ -303,7 +303,7 @@ fn contents_list_html(chapters: List(Chapter)) -> String { fn render_html(html: Html) -> String { html |> htmb.render - |> string_builder.to_string + |> string_tree.to_string } fn ensure_directory(path: String) -> snag.Result(Nil) { @@ -486,9 +486,6 @@ fn generate_stdlib_bundle(modules: List(String)) -> snag.Result(Nil) { |> string.replace("$", "\\$") |> string.split("\n") |> list.filter(fn(line) { !string.starts_with(string.trim(line), "//") }) - |> list.filter(fn(line) { - !string.starts_with(line, "@external(erlang") - }) |> list.filter(fn(line) { line != "" }) |> string.join("\n") @@ -666,7 +663,7 @@ fn lesson_page_render(lesson: Lesson) -> String { h("section", [#("id", "left"), #("class", "content-nav")], [ h("div", [], [ h("h2", [], [text(lesson.name)]), - htmb.dangerous_unescaped_fragment(string_builder.from_string( + htmb.dangerous_unescaped_fragment(string_tree.from_string( lesson.text, )), ]), @@ -691,9 +688,7 @@ fn lesson_page_render(lesson: Lesson) -> String { theme_picker_script(), arrow_keys_navigation_script(lesson.next, lesson.previous), h("script", [#("type", "gleam"), #("id", "code")], [ - htmb.dangerous_unescaped_fragment(string_builder.from_string( - lesson.code, - )), + htmb.dangerous_unescaped_fragment(string_tree.from_string(lesson.code)), ]), html_script("/index.js", ScriptOptions(module: True, defer: False), []), ], @@ -705,7 +700,7 @@ fn lesson_page_render(lesson: Lesson) -> String { /// Transform a path into a slug fn slugify_path(path: String) -> String { string.replace(path, "/", "-") - |> string.drop_left(up_to: 1) + |> string.drop_start(up_to: 1) } /// Renders a lesson item in the everyting page's list @@ -717,7 +712,7 @@ fn everything_page_lesson_html(lesson: Lesson, index: Int, end_index: Int) { h("a", [#("href", "#" <> slugify_path(lesson.path)), #("class", "link")], [ h("h2", [#("class", "lesson-title")], [text(lesson.name)]), ]), - htmb.dangerous_unescaped_fragment(string_builder.from_string(lesson.text)), + htmb.dangerous_unescaped_fragment(string_tree.from_string(lesson.text)), h("pre", [#("class", "lesson-snippet hljs gleam language-gleam")], [ h("code", [], [text(lesson.code)]), h( @@ -770,7 +765,7 @@ fn everything_page_chapters_html(chapters: List(Chapter)) -> List(Html) { ] } - list.concat([chapter_header, ..lessons]) + list.flatten([chapter_header, ..lessons]) } /// Renders a link to a lesson in the table of contents @@ -897,7 +892,7 @@ pub fn html_dangerous_inline_script( ]) } h("script", attrs, [ - htmb.dangerous_unescaped_fragment(string_builder.from_string(content)), + htmb.dangerous_unescaped_fragment(string_tree.from_string(content)), ]) } @@ -971,7 +966,7 @@ fn head(with config: HeadConfig) -> htmb.Html { ..list.map(config.stylesheets, html_stylesheet) ] - let head_content = list.concat([head_meta, head_links, config.scripts]) + let head_content = list.flatten([head_meta, head_links, config.scripts]) h("head", [], head_content) } @@ -1064,5 +1059,5 @@ pub fn render_page(page config: PageConfig) -> String { config |> render_page_html |> htmb.render_page() - |> string_builder.to_string + |> string_tree.to_string } diff --git a/static/index.js b/static/index.js index 01d5b66..ea1469b 100644 --- a/static/index.js +++ b/static/index.js @@ -1,6 +1,4 @@ import CodeFlask from "https://cdn.jsdelivr.net/npm/codeflask@1.4.1/+esm"; - -console.log(CodeFlask); globalThis.CodeFlask = CodeFlask; const output = document.querySelector("#output");