From 4a908f4f3e643f9e017ce0c45afee5207efb5a5f Mon Sep 17 00:00:00 2001 From: Jason Pochanke Date: Sat, 18 Jul 2026 02:54:42 +0200 Subject: [PATCH] init --- .github/workflows/test.yml | 23 +++++++++++ .gitignore | 4 ++ README.md | 24 +++++++++++ gleam.toml | 22 ++++++++++ manifest.toml | 24 +++++++++++ src/luma_markdown.gleam | 75 +++++++++++++++++++++++++++++++++++ test.txt | 8 ++++ test/luma_markdown_test.gleam | 13 ++++++ 8 files changed, 193 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 .gitignore create mode 100644 README.md create mode 100644 gleam.toml create mode 100644 manifest.toml create mode 100644 src/luma_markdown.gleam create mode 100644 test.txt create mode 100644 test/luma_markdown_test.gleam diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..eb8b0e4 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,23 @@ +name: test + +on: + push: + branches: + - master + - main + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: erlef/setup-beam@v1 + with: + otp-version: "29" + gleam-version: "1.17.0" + rebar3-version: "3" + # elixir-version: "1" + - run: gleam deps download + - run: gleam test + - run: gleam format --check src test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..599be4e --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.beam +*.ez +/build +erl_crash.dump diff --git a/README.md b/README.md new file mode 100644 index 0000000..ccd0bdc --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# luma_markdown + +[![Package Version](https://img.shields.io/hexpm/v/luma_markdown)](https://hex.pm/packages/luma_markdown) +[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/luma_markdown/) + +```sh +gleam add luma_markdown@1 +``` +```gleam +import luma_markdown + +pub fn main() -> Nil { + // TODO: An example of the project in use +} +``` + +Further documentation can be found at . + +## Development + +```sh +gleam run # Run the project +gleam test # Run the tests +``` diff --git a/gleam.toml b/gleam.toml new file mode 100644 index 0000000..fa66d78 --- /dev/null +++ b/gleam.toml @@ -0,0 +1,22 @@ +name = "luma_markdown" +version = "1.0.0" + +# Fill out these fields if you intend to generate HTML documentation or publish +# your project to the Hex package manager. +# +# description = "" +# licences = ["Apache-2.0"] +# repository = { type = "github", user = "", repo = "" } +# links = [{ title = "Website", href = "" }] +# +# For a full reference of all the available options, you can have a look at +# https://gleam.run/writing-gleam/gleam-toml/. + +[dependencies] +gleam_stdlib = ">= 1.0.0 and < 2.0.0" +luma = ">= 1.0.0 and < 2.0.0" +simplifile = ">= 2.5.0 and < 3.0.0" +argv = ">= 1.1.0 and < 2.0.0" + +[dev_dependencies] +gleeunit = ">= 1.0.0 and < 2.0.0" diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..c7bb761 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,24 @@ +# Do not manually edit this file, it is managed by Gleam. +# +# This file locks the dependency versions used, to make your build +# deterministic and to prevent unexpected versions from being included +# in your application. +# +# You should check this file into your source control repository. + +packages = [ + { name = "argv", version = "1.1.0", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "3277D100448BDB4A29B6D58C0F36F631CBC349E8BDD09766C6309DF202831140" }, + { name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" }, + { name = "gleam_json", version = "3.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "44FDAA8847BE8FC48CA7A1C089706BD54BADCC4C45B237A992EDDF9F2CDB2836" }, + { name = "gleam_stdlib", version = "1.0.3", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "1F543AFBA5D33DA493E6087F4E4C4F20D899411343512686C98A8ABB2963CF22" }, + { name = "gleeunit", version = "1.11.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "EC31ABA74256AEA531EDF8169931D775BBB384FED0A8A1BDC4DD9354E3E21826" }, + { name = "luma", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib", "simplifile"], otp_app = "luma", source = "hex", outer_checksum = "29735CECF484D4482F223EF9546C17D4B7614F3FFBE4653D7B17F944316C1E2A" }, + { name = "simplifile", version = "2.5.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "6C72DCCDF25C38A5931740B30E823969F33106831FD1637719B5EDBCA30027A4" }, +] + +[requirements] +argv = { version = ">= 1.1.0 and < 2.0.0" } +gleam_stdlib = { version = ">= 1.0.0 and < 2.0.0" } +gleeunit = { version = ">= 1.0.0 and < 2.0.0" } +luma = { version = ">= 1.0.0 and < 2.0.0" } +simplifile = { version = ">= 2.5.0 and < 3.0.0" } diff --git a/src/luma_markdown.gleam b/src/luma_markdown.gleam new file mode 100644 index 0000000..4b8c15e --- /dev/null +++ b/src/luma_markdown.gleam @@ -0,0 +1,75 @@ +import luma/definition +import gleam/list +import gleam/io +import argv +import luma/parser +import simplifile +type Information { + Information(lowesthirachy: Int, + highesthirachy: Int) +} +fn gather(instructions: List(definition.Instruction))-> Information { + let pushes = + instructions + |> list.filter_map(fn(instruction) { + case instruction { + definition.Push(pusher) -> case pusher { + definition.Hirachy(push) -> Ok(push) + _ -> Error(Nil) + } + _ -> Error(Nil) + } + }) + echo pushes + + let min_max = + case pushes { + [] -> Error(Nil) + [first, ..rest] -> + Ok( + list.fold(rest, #(first, first), fn(acc, n) { + let #(min, max) = acc + + #( + case n < min { + True -> n + False -> min + }, + case n > max { + True -> n + False -> max + }, + ) + }) + ) + } + case min_max { + Ok(#(min, max)) -> { + Information(min, max) + } + Error(_) -> { + Information(0, 0) + } + } +} +pub fn main() -> Nil { + case argv.load().arguments { + [filename] -> { + case simplifile.read(filename) { + Ok(contents) -> { + //programm goes here + let instructins = parser.handler(contents) + let result = case instructins { + definition.TextInstructions(instruction) -> gather(instruction) + _ -> Information(-124, 41234) + } + echo result + Nil + } + Error(_) -> io.println("Couldn't read file") + } + } + _ -> io.println("Usage: gleam run ") + } + +} diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..6f3dc51 --- /dev/null +++ b/test.txt @@ -0,0 +1,8 @@ +some text about cats +@2! A slightly important statement !1 I believe is wrong, !- quoted inside another quote. +!3 A slightly important statement I believe is wrong, quoted inside another quote. +#3!2@2 A slightly important statement I believe is wrong, quoted inside another quote. + +!2@3 important trusted but @- important !5 more important !- 2 important and !- normal +#1 heading #- !1 important !- @2 true @- >3 quote >- +#4 diff --git a/test/luma_markdown_test.gleam b/test/luma_markdown_test.gleam new file mode 100644 index 0000000..fba3c88 --- /dev/null +++ b/test/luma_markdown_test.gleam @@ -0,0 +1,13 @@ +import gleeunit + +pub fn main() -> Nil { + gleeunit.main() +} + +// gleeunit test functions end in `_test` +pub fn hello_world_test() { + let name = "Joe" + let greeting = "Hello, " <> name <> "!" + + assert greeting == "Hello, Joe!" +}