Skip to content

ihaagrawal/CLI_Parser-Rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Markdown CLI Parser

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.


Features

  • Accepts a Markdown file path from user input
  • Validates that the file has a .md extension
  • Reads the Markdown file contents
  • Converts Markdown to HTML
  • Writes the generated HTML to a new .html file
  • Uses a fast Markdown parser crate

Technologies Used

  • Rust
  • pulldown-cmark for Markdown parsing

Project Structure

CLI_Parser/
│
├── Cargo.toml
├── README.md
└── src/
    └── main.rs

Installation

Clone the repository:

git clone https://github.com/ihaagrawal/CLI_Parser-Rust.git
cd CLI_Parser-Rust

Install dependencies and build the project:

cargo build

Running the Program

Run the CLI application:

cargo run

The 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:

  1. Read the Markdown file
  2. Convert it to HTML
  3. Generate an output HTML file

Example Markdown Input

# Hello Rust

This is **Markdown** converted to HTML.

- Item 1
- Item 2
- Item 3

Example HTML Output

<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>

Dependencies

Add the Markdown parser crate in Cargo.toml:

[dependencies]
pulldown-cmark = "0.10"

Possible Improvements

  • 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

About

Markdown to HTML convertor in Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors