An open API service indexing awesome lists of open source software.

https://github.com/openpeeps/marvdown

This is Marvdown ⚡️ A stupid simple Markdown parser, cli app & native addon for NodeJS / Bun. 👑 Written in Nim language
https://github.com/openpeeps/marvdown

Last synced: 3 months ago
JSON representation

This is Marvdown ⚡️ A stupid simple Markdown parser, cli app & native addon for NodeJS / Bun. 👑 Written in Nim language

Awesome Lists containing this project

README

          




This is Marvdown ⚡️ A stupid simple Markdown parser


nimble install marvdown / npm install @openpeeps/marvdown


API reference | Download


Github Actions Github Actions

> [!NOTE]
> Marv is still in early development. Some features are not fully implemented yet. Contributions are welcome!

## 😍 Key Features
- [x] Extremely Fast & Lightweight! [Check benchmarks](#benchmarks)
- [x] Compiled cross-platform CLI app
- [x] Nim library for easy integration in your 👑 Nim projects
- [x] Addon for Node.js JavaScript runtime via N-API
- [x] Markdown to HTML
- [x] Auto-generate Table of Contents (ToC)
- [x] Auto-generate heading IDs for anchor links
- [ ] Markdown to PDF
- [x] Markdown to JSON (structured data)
- [ ] GitHub Flavored Markdown (GFM)

## About
Marv is a stupid simple markdown parser written in [Nim](https://nim-lang.org). It can be used as a library in your Nim projects or as a CLI tool to convert markdown files to HTML. Currently, it supports basic markdown syntax like headings, paragraphs, bold, italic, links, images, lists, blockquotes, code blocks and inline code.

## Installing

Install Marvdown via [Nimble](https://nim-lang.org/docs/nimble.html)
```
nimble install marvdown
```

For Node.js install Marvdown via [npm](https://www.npmjs.com/package/@openpeeps/marvdown)

A GitHub action will build the binary CLI app and Node.js addon evertime a new release is published. Download the latest version of Marvdown from the [Github releases page](https://github.com/openpeeps/marvdown/releases).

## Example Usage
Using Marvdown from the command line is super easy. Just run:
```
marvdown html sample.md --optAnchors --bench
```
Enable anchor generations for headings with `--optAnchors` flag. Run benchmarks with `--bench` flag.

### Programming with Marvdown

In Nim language the fastest way to convert markdown to HTML is to use the `toHtml()` proc.
```nim
import marvdown

echo marvdown.toHtml(readFile("sample.md"))
```

In JavaScript or TypeScript you can load the N-API addon and use the `toHtml()` function.
```js
const fs = require('fs');
const marvdown = require('@openpeeps/marvdown')

let output = marvdown.toHtml(fs.readFileSync('sample.md', 'utf8'))
console.log(output)
```

_todo: example of custom options_

For more examples, see the [/examples folder](#). Also check out the [API reference](https://openpeeps.github.io/marvdown/) for more details 👌

### Benchmarks
Marvdown is super fast! It can parse large markdown files in milliseconds. Here is a quick benchmark
over 100K lines of markdown text (~5.3 MB)

```
Benchmark 1: marvdown html bigdoc.md
Time (abs ≡): 188.1 ms [User: 166.9 ms, System: 19.8 ms]
```

_Benchmark made with [hyperfine](https://github.com/sharkdp/hyperfine)_

### ❤ Contributions & Support
- 🐛 Found a bug? [Create a new Issue](https://github.com/openpeeps/marvdown/issues)
- 👋 Wanna help? [Fork it!](https://github.com/openpeeps/marvdown/fork)
- 😎 [Get €20 in cloud credits from Hetzner](https://hetzner.cloud/?ref=Hm0mYGM9NxZ4)
- 🥰 [Donate to OpenPeeps via PayPal address](https://www.paypal.com/donate/?hosted_button_id=RJK3ZTDWPL55C)

### Credits
Original illustration made by 💙 [Olha](https://www.deviantart.com/jo316) remixed with Sora.

### 🎩 License
**Marv** | [MIT License](https://github.com/openpeeps/marvdown/blob/main/LICENSE).
[Made by Humans from OpenPeeps](https://github.com/openpeeps).

Copyright © 2024 OpenPeeps & Contributors — All rights reserved.