ops: added a lint rule and adjusted the build workflow
This commit is contained in:
@@ -7,6 +7,21 @@ on:
|
||||
- "**" # Triggers on every commit to any branch
|
||||
|
||||
jobs:
|
||||
format:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: jaypoch/lumabuilder:latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Checking the format
|
||||
run: gleam format --check
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: jaypoch/lumabuilder:latest
|
||||
|
||||
build-and-bundle:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
@@ -22,7 +37,7 @@ jobs:
|
||||
|
||||
- name: Build bundle
|
||||
run: |
|
||||
esbuild build/dev/javascript/markdown2/markdown2.mjs \
|
||||
esbuild build/dev/javascript/luma/luma.mjs \
|
||||
--bundle \
|
||||
--outfile=parser.js \
|
||||
--format=iife \
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
name: formatcheck
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
@@ -0,0 +1,20 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Jaypoch
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,4 +1,4 @@
|
||||
ljiosfgdjiosdfgj
|
||||
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.
|
||||
+3
-8
@@ -1,16 +1,11 @@
|
||||
name = "markdown2"
|
||||
name = "luma"
|
||||
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/.
|
||||
description = "A parser for a made up markup language"
|
||||
licences = ["MIT"]
|
||||
|
||||
[dependencies]
|
||||
gleam_stdlib = ">= 1.0.0 and < 2.0.0"
|
||||
|
||||
Generated
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "markdown2",
|
||||
"name": "luma",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
//// The Main function definitions
|
||||
|
||||
import luma/definition
|
||||
import gleam/io
|
||||
import gleam/json
|
||||
import luma/parser
|
||||
|
||||
/// example main function that parses some text into json
|
||||
pub fn main() ->Nil{
|
||||
io.print("This is a debug function only used for testing")
|
||||
io.print(parse_to_json("!2 @3 important >1 quoted"))
|
||||
}
|
||||
|
||||
/// same as parse but formats The text instructions as a json string for easier use with javascript
|
||||
pub fn parse_to_json(input: String) -> String {
|
||||
let definition.TextInstructions(inlines) = parser.handler(input)
|
||||
|
||||
json.array(inlines, definition.inline_to_json)
|
||||
|> json.to_string
|
||||
}
|
||||
@@ -1,24 +1,30 @@
|
||||
import gleam/json
|
||||
import mode
|
||||
////Main definitions used throughout the programm
|
||||
|
||||
pub type Line {
|
||||
Line(List(Inline))
|
||||
import gleam/json
|
||||
import luma/mode
|
||||
|
||||
/// A list of single instructions
|
||||
pub type TextInstructions {
|
||||
TextInstructions(List(Instruction))
|
||||
}
|
||||
|
||||
pub type Inline {
|
||||
/// a single Instruction on how to change the state or to render text
|
||||
pub type Instruction {
|
||||
Text(String)
|
||||
Push(Feeling)
|
||||
//pop ignores the number
|
||||
Push(StateObject)
|
||||
///pop ignores the number
|
||||
Pop(mode.Type)
|
||||
}
|
||||
|
||||
pub type Feeling {
|
||||
/// A single primitive and its modifier
|
||||
pub type StateObject {
|
||||
Hirachy(Int)
|
||||
Truth(Int)
|
||||
Marking(Int)
|
||||
Quote(Int)
|
||||
}
|
||||
|
||||
/// The main state of the parser with a list of each primitives and there state lists
|
||||
pub type State {
|
||||
State(
|
||||
hirachystate: List(Int),
|
||||
@@ -28,7 +34,7 @@ pub type State {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn inline_to_json(inline: Inline) -> json.Json {
|
||||
pub fn inline_to_json(inline: Instruction) -> json.Json {
|
||||
case inline {
|
||||
Text(text) ->
|
||||
json.object([
|
||||
@@ -1,18 +1,20 @@
|
||||
import definition
|
||||
import luma/definition
|
||||
import gleam/dict
|
||||
import gleam/int
|
||||
import gleam/list
|
||||
import gleam/result
|
||||
import gleam/string
|
||||
import mode
|
||||
import luma/mode
|
||||
|
||||
pub fn handler(line: String) -> definition.Line {
|
||||
/// main parse function
|
||||
/// takes in some input text and returns instructions on how to parse it
|
||||
pub fn handler(line: String) -> definition.TextInstructions {
|
||||
let result = parse(line)
|
||||
let result = list.map(result, whatsthat)
|
||||
definition.Line(result)
|
||||
definition.TextInstructions(result)
|
||||
}
|
||||
|
||||
fn whatsthat(mod: String) -> definition.Inline {
|
||||
fn whatsthat(mod: String) -> definition.Instruction {
|
||||
let modes =
|
||||
dict.from_list([
|
||||
#("!", #(mode.Marking, definition.Marking)),
|
||||
@@ -1,24 +0,0 @@
|
||||
import definition
|
||||
import gleam/io
|
||||
import gleam/json
|
||||
import parser
|
||||
|
||||
pub fn main() -> Nil {
|
||||
io.print("This is a debug function only used for testing")
|
||||
io.print(parse_to_json("!2 @3 important >1 quoted"))
|
||||
}
|
||||
|
||||
fn line_to_json(line: definition.Line) -> String {
|
||||
let definition.Line(inlines) = line
|
||||
|
||||
json.array(inlines, definition.inline_to_json)
|
||||
|> json.to_string
|
||||
}
|
||||
|
||||
pub fn parse(input: String) -> definition.Line {
|
||||
parser.handler(input)
|
||||
}
|
||||
|
||||
pub fn parse_to_json(input: String) -> String {
|
||||
line_to_json(parser.handler(input))
|
||||
}
|
||||
Reference in New Issue
Block a user