Compare commits

...

8 Commits

Author SHA1 Message Date
03b5360ec5 fixed weird block parsing issues
All checks were successful
Test the running changes / Test (push) Successful in 35s
2025-12-24 23:26:09 +02:00
d761bd036d release workflow fix 5 2025-12-23 23:19:02 +02:00
fa19f5ddf2 release workflow fix 4
Some checks failed
Create release package / Release (push) Failing after 32s
2025-12-23 23:04:51 +02:00
b142c62d65 release workflow fix 3 2025-12-23 23:02:25 +02:00
397bddd956 release workflow fix 2 2025-12-23 22:55:41 +02:00
0ca1bfecde release workflow fix 1
Some checks failed
Create release package / Release (push) Failing after 31s
2025-12-22 22:08:45 +02:00
6021861cfb Merge pull request 'version 0.1.0' (#2) from dev into master
Some checks failed
Create release package / Release (push) Failing after 31s
Reviewed-on: #2
2025-12-22 19:52:48 +00:00
24fc2deae1 Merge pull request 'Clean testing workflow' (#1) from dev into master
Reviewed-on: #1
2025-12-10 12:25:06 +00:00
7 changed files with 26 additions and 17 deletions

View File

@@ -13,7 +13,10 @@ jobs:
runs-on: rust-latest
steps:
- run: export TEST_TOKEN="${{ secrets.TEST }}"
- run: echo $TEST_TOKEN
- run: echo "Straight in: ${{ secrets.TEST }}"
- run: git clone https://git.jlux.dev/${{ gitea.repository }} . && git checkout ${{ gitea.ref_name }}
- run: cargo build --verbose --release
- run: export CARGO_REGISTRIES_GITEA_TOKEN=${{ secrets.CARGO_BEARER_TOKEN }}
- run: export CARGO_REGISTRIES_GITEA_TOKEN="${{ secrets.CARGO_TOKEN }}"
- run: cargo publish --registry gitea

2
Cargo.lock generated
View File

@@ -4,7 +4,7 @@ version = 4
[[package]]
name = "marginal"
version = "0.1.0"
version = "0.1.1"
dependencies = [
"nom",
]

View File

@@ -1,6 +1,6 @@
[package]
name = "marginal"
version = "0.1.0"
version = "0.1.1"
edition = "2024"
publish = ["gitea"]

View File

@@ -66,6 +66,7 @@ command = [
"cargo", "nextest", "run",
"--hide-progress-bar",
"--failure-output", "final",
"--no-fail-fast",
]
need_stdout = true
analyzer = "nextest"

View File

@@ -3,6 +3,7 @@ use nom::{
IResult, Parser,
branch::alt,
bytes::complete::{tag, take_until},
combinator::peek,
multi::{many_m_n, many0, many1},
sequence::{delimited, terminated},
};
@@ -14,6 +15,7 @@ pub fn blocks(input: &str) -> IResult<&str, Vec<Block>, MarkdownParseError> {
}
pub fn block(input: &str) -> IResult<&str, Block, MarkdownParseError> {
//alt((heading_block, code_block, quote_block, paragraph_block)).parse(input)
terminated(
alt((heading_block, code_block, quote_block, paragraph_block)),
tag("\n"),
@@ -45,7 +47,7 @@ fn code_block(input: &str) -> IResult<&str, Block, MarkdownParseError> {
delimited(
tag("```"),
(take_until("\n"), tag("\n"), take_until("```\n")),
tag("```\n"),
(tag("```"), peek(tag("\n"))),
)
.parse(input)
.map(|(rem, (lang, _, code))| {
@@ -83,10 +85,10 @@ mod test {
#[test]
fn single_paragraph() {
let md = "Hello markdown!!";
let md = "Hello markdown!!\n";
let (rem, block) = paragraph_block(md).unwrap();
assert_eq!(rem, "");
assert_eq!(rem, "\n");
assert_eq!(
block,
Block::Paragraph {
@@ -107,7 +109,7 @@ fn main() {
";
let (rem, block) = code_block(md).unwrap();
assert_eq!(rem, "");
assert_eq!(rem, "\n");
assert_eq!(
block,
Block::Code {
@@ -125,7 +127,7 @@ echo \"hello world\"
";
let (rem, block) = code_block(md).unwrap();
assert_eq!(rem, "");
assert_eq!(rem, "\n");
assert_eq!(
block,
Block::Code {
@@ -145,11 +147,11 @@ echo hello
}
#[test]
fn level_1_heading() {
let md = "## Heading2";
fn level_2_heading() {
let md = "## Heading2\n";
let (rem, block) = heading_block(md).unwrap();
assert_eq!(rem, "");
assert_eq!(rem, "\n");
assert_eq!(
block,
Block::Heading {
@@ -163,16 +165,16 @@ echo hello
#[test]
fn heading_no_space() {
let md = "#heading";
let md = "#heading\n";
assert!(heading_block(md).is_err());
}
#[test]
fn level_6_heading() {
let md = "###### Heading6";
let md = "###### Heading6\n";
let (rem, block) = heading_block(md).unwrap();
assert_eq!(rem, "");
assert_eq!(rem, "\n");
assert_eq!(
block,
Block::Heading {
@@ -186,7 +188,7 @@ echo hello
#[test]
fn no_level_7_heading() {
let md = "####### Heading7";
let md = "####### Heading7\n";
assert!(heading_block(md).is_err());
}

View File

@@ -85,10 +85,10 @@ mod test {
#[test]
fn single_text() {
let md = "hello normal inline";
let md = "hello normal inline\n";
let (rem, parsed) = text_inline(md).unwrap();
assert_eq!(rem, "");
assert_eq!(rem, "\n");
assert_eq!(
parsed,
Inline::Text {

View File

@@ -1,3 +1,6 @@
//! A weird markdown parser. Please don't forget to add a newline in the end of a file or it won't
//! work :)
use std::fmt::{Debug, Display};
pub mod block;