diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b54f2c6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +# Generated by Cargo. +Cargo.lock +debug/ +target/ + +# Coverage results. +coverage/ diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..4c4d0e2 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,25 @@ +# https://doc.rust-lang.org/cargo/reference/manifest.html + +[package] +name = "toml-frontmatter" +description = "TOML frontmatter parser." +repository = "https://git.bauke.xyz/Holllo/toml-frontmatter" +license = "MIT OR Apache-2.0" +version = "0.0.0" +authors = ["Holllo "] +edition = "2021" + +[lib] +path = "source/lib.rs" + +[dependencies] +anyhow = "1.0.68" +toml = "0.5.10" + +[dependencies.serde] +features = ["derive"] +version = "1.0.152" + +[dev-dependencies.insta] +features = ["toml"] +version = "1.24.1" diff --git a/Makefile.toml b/Makefile.toml new file mode 100644 index 0000000..d7da164 --- /dev/null +++ b/Makefile.toml @@ -0,0 +1,40 @@ +[tasks.fmt] +command = "cargo" +args = ["fmt", "${@}"] + +[tasks.check] +command = "cargo" +args = ["check", "${@}"] + +[tasks.clippy] +command = "cargo" +args = ["clippy", "${@}"] + +[tasks.test] +command = "cargo" +args = ["test", "${@}"] + +[tasks.doc] +command = "cargo" +args = ["doc", "${@}"] + +[tasks.build] +command = "cargo" +args = ["build", "${@}"] + +[tasks.complete-check] +dependencies = ["fmt", "check", "clippy", "test", "doc", "build"] + +[tasks.code-coverage] +workspace = false +install_crate = "cargo-tarpaulin" +command = "cargo" +args = [ + "tarpaulin", + "--exclude-files=target/*", + "--out=html", + "--output-dir=coverage", + "--skip-clean", + "--target-dir=target/tarpaulin", + "--workspace" +] diff --git a/README.md b/README.md new file mode 100644 index 0000000..6626f22 --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +# toml-frontmatter + +> **TOML frontmatter parser.** + +## API + +For documentation see [docs.rs](https://docs.rs/toml-frontmatter). + +## Example + +```rust +#[derive(serde::Deserialize)] +struct Frontmatter { + date: String, +} + +let sample = r#" +---toml +date = "2023-01-01" +--- + +Some **Markdown**. Or something else! +"#.trim(); + +let (frontmatter, markdown) = toml_frontmatter::parse::(sample).unwrap(); +``` + +## License + +Distributed under the [Apache License 2.0](https://spdx.org/licenses/Apache-2.0.html) and [MIT](https://spdx.org/licenses/MIT.html) licenses, see [LICENSE-Apache](https://git.bauke.xyz/Holllo/toml-frontmatter/src/branch/main/LICENSE-Apache) and [LICENSE-MIT](https://git.bauke.xyz/Holllo/toml-frontmatter/src/branch/main/LICENSE-MIT) for more information. diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..4c1eefa --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,2 @@ +max_width = 80 +tab_spaces = 2