#markdown #md #markdown-html #dark-mode #render

app omd

A minimalistic and slick looking markdown viewer with support for hot reloading and latex

5 releases

0.2.0 Oct 26, 2024
0.1.4 Oct 21, 2024
0.1.3 Oct 21, 2024
0.1.2 Oct 21, 2024
0.1.1 Oct 18, 2024

#595 in Parser implementations

MIT license

305KB
399 lines

omd

omd is a simple, fast, and lightweight Markdown renderer and previewer written in Rust. It allows you to convert Markdown files to HTML and preview them in your browser, either statically or with live-reload support.

Features

  • Static Mode: Convert Markdown files to HTML and open them directly in your default browser without running a server.
  • Server Mode: Run a local server to preview your Markdown files with live-reload functionality as you edit them.
  • CommonMark Extensions: Supports strikethrough, tables, footnotes, task lists, etc.
  • Customizable Styling: Includes default CSS styling, which can be customized by editing style.css.
  • Embedded Fonts and Favicon: Uses embedded fonts and favicon for a consistent look and self-contained HTML output.

Installation

Prerequisites

Build from Source

  1. Clone the Repository

    git clone https://github.com/ptrglbvc/omd.git
    cd omd
    
  2. Build the Project

    cargo build --release
    
  3. Install

    Optionally, you can install omd to your local Cargo bin directory:

    cargo install --path .
    

    This allows you to run omd from anywhere on your system.

Get it from crates.io

cargo install omd

That is it.

Usage

omd [OPTIONS] [FILE]

Options

  • -s, --static-mode: Run in static mode. Converts the Markdown file to HTML and opens it in your default browser without starting a server.

Examples

Static Mode

Convert a Markdown file to HTML and open it in your browser:

omd --static-mode README.md

If no file is specified, omd will read from stdin:

cat README.md | omd --static-mode

Server Mode (Live Preview)

Start a local server to preview your Markdown file with live-reload functionality:

omd README.md

Open http://localhost:3030 in your browser. Whenever you save changes to README.md, the browser will automatically reload to reflect the updates.

Note that it will crash if the port is taken, like for example if you have another instance of omd openned. To solve this change the port number with the --port flag. Like so:

omd --port 6969 README.md

How It Works

  • Static Mode: Renders the Markdown to HTML, writes it to a temporary file, and opens it in your default browser.
  • Server Mode: Starts a local web server using Warp and watches the Markdown file for changes using Notify. The browser automatically reloads when changes are detected.

Dependencies

  • Pulldown-Cmark for parsing and rendering Markdown.
  • Warp for running the web server in server mode.
  • Notify for watching file changes.

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Commit your changes with clear messages.
  4. Push to your fork and submit a Pull Request.

Please make sure to update tests as appropriate.

Acknowledgments

  • Thanks to the Rust community for their amazing crates that make projects like this possible.
  • Inspired by the need for a simple Markdown previewer without unnecessary overhead.

Contact

For questions or suggestions, feel free to open an issue or reach out via email at petar0golubovic@gmail.com.

Dependencies

~14–25MB
~391K SLoC