| Crates.io | arinamcnulty-markdown-parser |
| lib.rs | arinamcnulty-markdown-parser |
| version | 0.1.1 |
| created_at | 2025-11-04 13:08:13.150922+00 |
| updated_at | 2025-11-12 18:43:44.561811+00 |
| description | Markdown parser - university project. |
| homepage | https://github.com/arinamcnulty/markdown-parser |
| repository | https://github.com/arinamcnulty/markdown-parser |
| max_upload_size | |
| id | 1916239 |
| size | 64,419 |
A comprehensive Markdown to HTML converter built in Rust using Pest grammar. This project provides a command-line interface and library for parsing Markdown documents.
The package is published on crates.io.
cargo install arinamcnulty-markdown-parser
git clone https://github.com/arinamcnulty/markdown-parser.git
cd markdown-parser
cargo build --release
You can read documentation on docs.rs
markdown_parser convert -i document.md -o document.html
markdown_parser parse -t "# Hello World!"
markdown_parser info
use markdown_parser::{str_to_html, convert_file_to_html};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Parse markdown string
let markdown = "# Hello World\n\nThis is **bold** text with `inline code`.";
let html = str_to_html(markdown)?;
println!("{}", html.join("\n"));
// Convert file
convert_file_to_html("input.md", "output.html")?;
Ok(())
}
This parser supports the full CommonMark Markdown specification. Here are examples of supported syntax:
# Heading Level 1
## Heading Level 2
### Heading Level 3
**Bold text**
*Italic text*
~~Strikethrough text~~
__Underline text__
[Click here](https://example.com)

Use `code` for inline code snippets.
```rust
fn main() {
println!("Hello, world!");
}
```
- Item 1
- Item 2
* Another item
1. First item
2. Second item
3. Third item
> This is a blockquote
> Second line of blockquote
---
***
___
\*literal asterisk\*
\[literal bracket\]
The parser uses Pest grammar for efficient parsing. The grammar is organized into the following main components:
document_structure = { SOI ~ (document_block ~ NEWLINE*)* ~ document_block? ~ EOI? }
document_block = {
document_heading
| document_quote
| code_fence
| document_unordered_list
| document_ordered_list
| thematic_break
| document_paragraph
}
inline_content = _{
image
| link
| text_formatting
| inline_code
| escape_sequence
| plain_text
}
text_formatting = _{
bold_formatting
| italic_formatting
| strikethrough_formatting
| underline_formatting
}
Run the test suite:
cargo test
Run with formatting and linting:
cargo fmt
cargo clippy
parse_markdown(input: &str) - Parse markdown string to syntax treestr_to_html(input: &str) - Convert markdown string to HTML vectorconvert_file_to_html(input: &Path, output: &Path) - Convert markdown file to HTML fileprint_html_to_console(input: &str) - Print HTML conversion to stdout#[derive(Debug, thiserror::Error)]
pub enum MarkdownError {
#[error("Parsing failed: {0}")]
ParseError(String),
#[error("File operation failed: {0}")]
IoError(#[from] std::io::Error),
}
src/
├── main.rs # CLI application
├── lib.rs # Library implementation
└── grammar.pest # Pest grammar rules
tests/
└── grammar_tests.rs # Unit tests
grammar.pestlib.rsconvert_to_html match statementtests/grammar_tests.rscargo build
cargo run -- info
Formatting: cargo fmt
Linting: cargo clippy
Testing: cargo test
Zudilova Oryna - Initial work - arinamcnulty