diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..63603d9 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[registries.gitea] +index = "sparse+https://git.jlux.dev/api/packages/scrac/cargo/" diff --git a/.gitea/workflows/cargo-release.yml b/.gitea/workflows/cargo-release.yml new file mode 100644 index 0000000..e33f4e0 --- /dev/null +++ b/.gitea/workflows/cargo-release.yml @@ -0,0 +1,19 @@ +name: Create release package + +on: + push: + branches: [ "master" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + release: + name: Release + runs-on: rust-latest + + steps: + - 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: cargo publish --registry gitea diff --git a/.gitea/workflows/cargo-test.yml b/.gitea/workflows/cargo-test.yml index 77ee916..8e3fbe8 100644 --- a/.gitea/workflows/cargo-test.yml +++ b/.gitea/workflows/cargo-test.yml @@ -3,8 +3,8 @@ name: Test the running changes on: push: branches: [ "dev" ] - #pull_request: - # branches: [ "master" ] + pull_request: + branches: [ "master" ] env: CARGO_TERM_COLOR: always @@ -15,8 +15,6 @@ jobs: runs-on: rust-latest steps: - #- run: apt-get update -y - #- uses: actions/checkout@v6 - run: git clone https://git.jlux.dev/${{ gitea.repository }} . && git checkout ${{ gitea.ref_name }} - run: cargo build --verbose - run: cargo clippy -- -D warnings diff --git a/Cargo.lock b/Cargo.lock index f1ea844..33f2ea2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,100 +2,10 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "anstream" -version = "0.6.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is_terminal_polyfill", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" - -[[package]] -name = "anstyle-parse" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" -dependencies = [ - "anstyle", - "once_cell_polyfill", - "windows-sys", -] - -[[package]] -name = "clap" -version = "4.5.53" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e340e012a1bf4935f5282ed1436d1489548e8f72308207ea5df0e23d2d03f8" -dependencies = [ - "clap_builder", -] - -[[package]] -name = "clap_builder" -version = "4.5.53" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76b5d13eaa18c901fd2f7fca939fefe3a0727a953561fefdf3b2922b8569d00" -dependencies = [ - "anstream", - "anstyle", - "clap_lex", - "strsim", -] - -[[package]] -name = "clap_lex" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" - -[[package]] -name = "colorchoice" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" - -[[package]] -name = "is_terminal_polyfill" -version = "1.70.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" - [[package]] name = "marginal" -version = "0.0.1" +version = "0.1.0" dependencies = [ - "clap", "nom", ] @@ -113,36 +23,3 @@ checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" dependencies = [ "memchr", ] - -[[package]] -name = "once_cell_polyfill" -version = "1.70.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" - -[[package]] -name = "strsim" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" - -[[package]] -name = "utf8parse" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" - -[[package]] -name = "windows-link" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" - -[[package]] -name = "windows-sys" -version = "0.61.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" -dependencies = [ - "windows-link", -] diff --git a/Cargo.toml b/Cargo.toml index 4ef899d..5ebb963 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "marginal" -version = "0.0.1" +version = "0.1.0" edition = "2024" +publish = ["gitea"] [dependencies] -clap = "4.5.53" nom = { version = "8.0.0", features = ["std"] } diff --git a/src/generator/block.rs b/src/generator/block.rs index 3febbfc..1b520be 100644 --- a/src/generator/block.rs +++ b/src/generator/block.rs @@ -5,8 +5,8 @@ use super::ToHtml; impl ToHtml for Vec { fn to_html(&self) -> String { let mut html = String::new(); - for block in self.iter() { - html.push_str(&block.to_html()) + for block in self { + html.push_str(&block.to_html()); } html } diff --git a/src/generator/inline.rs b/src/generator/inline.rs index 2038fa2..6d85385 100644 --- a/src/generator/inline.rs +++ b/src/generator/inline.rs @@ -5,8 +5,8 @@ use super::ToHtml; impl ToHtml for Vec { fn to_html(&self) -> String { let mut html = String::new(); - for inline in self.iter() { - html.push_str(&inline.to_html()) + for inline in self { + html.push_str(&inline.to_html()); } html } diff --git a/src/generator/mod.rs b/src/generator/mod.rs index 9237a2b..8760961 100644 --- a/src/generator/mod.rs +++ b/src/generator/mod.rs @@ -44,6 +44,8 @@ pub trait ToHtml { } pub trait TryToHtml { + /// # Errors + /// Could fail when reading file contents is unsuccessful or generation is unsuccessful. fn try_to_html(&self) -> Result; } diff --git a/src/main.rs b/src/lib.rs similarity index 62% rename from src/main.rs rename to src/lib.rs index d306d34..866fc9e 100644 --- a/src/main.rs +++ b/src/lib.rs @@ -1,10 +1,8 @@ -use crate::generator::TryToHtml; -use std::path::PathBuf; - mod ast; -mod generator; -mod parser; +pub mod generator; +pub mod parser; +/* fn main() { let infile = PathBuf::from("test.md"); @@ -12,3 +10,4 @@ fn main() { println!("{}", html); } +*/