A simple Rust CLI tool that reads a Markdown (.md) file from user input, parses it, converts it into HTML, and writes the output to an HTML file.
- Accepts a Markdown file path from user input
- Validates that the file has a
.mdextension - Reads the Markdown file contents
- Converts Markdown to HTML
- Writes the generated HTML to a new
.htmlfile - Uses a fast Markdown parser crate
- Rust
pulldown-cmarkfor Markdown parsing
CLI_Parser/
│
├── Cargo.toml
├── README.md
└── src/
└── main.rs
Clone the repository:
git clone https://github.com/ihaagrawal/CLI_Parser-Rust.git
cd CLI_Parser-RustInstall dependencies and build the project:
cargo buildRun the CLI application:
cargo runThe program will prompt you for a Markdown file path.
Example:
Enter the markdown file path:
example.md
If the file is valid, the program will:
- Read the Markdown file
- Convert it to HTML
- Generate an output HTML file
# Hello Rust
This is **Markdown** converted to HTML.
- Item 1
- Item 2
- Item 3
<h1>Hello Rust</h1>
<p>This is <strong>Markdown</strong> converted to HTML.</p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
Add the Markdown parser crate in Cargo.toml:
[dependencies]
pulldown-cmark = "0.10"
- Accept CLI arguments instead of interactive input
- Automatically generate the HTML filename from the Markdown file
- Add support for multiple Markdown files
- Improve error handling
- Add CSS styling for rendered HTML
- Support GitHub-flavored Markdown features