Skip to content

aliezzahn/rs-markdown-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 rs-markdown-parser

A blazing-fast Node.js module for converting Markdown to HTML — powered by Rust’s pulldown-cmark and Neon for seamless Node integration.


✨ Features

  • Ultra-fast conversion using Rust’s performance and pulldown-cmark.
  • 🧩 Optional GitHub Flavored Markdown (GFM) support — tables, footnotes, strikethrough, task lists, and heading attributes.
  • 📦 ES module export — easily import HTML in your frontend projects.
  • 🛡️ TypeScript ready — includes full type definitions.

📦 Installation

npm install rs-markdown-parser

💡 Note: To modify or rebuild the native module, follow the build instructions below.


🛠️ Building the Module

If you're editing the Rust source or cross-compiling, use one of the following scripts:

Mode Command Notes
Debug npm run debug Fast builds for development
Release npm run build Optimized builds for production
Cross-build npm run cross Build for other target platforms

The build will generate a native Node.js addon (index.node).


🚀 Usage

Importing the Module

JavaScript

const { processMarkdown } = require("rs-markdown-parser");
const { join } = require("path");

const filePath = join(__dirname, "test.md");
const result = processMarkdown(filePath, false);

console.log(result); // => export default `<html_content>`;

TypeScript

import { processMarkdown } from "rs-markdown-parser";
import { join } from "path";

const filePath: string = join(__dirname, "test.md");
const result: string = processMarkdown(filePath, false);

console.log(result); // => export default `<html_content>`;

🧪 Example

Sample Markdown (test.md)

# Hello, World!

This is a **Markdown** file.

- Item 1
- Item 2

# Product Comparison

| Product      | Price   | Features                   | In Stock |
|--------------|---------|----------------------------|----------|
| Phone A      | $299    | 64GB, 12MP Camera, 4G LTE  | Yes      |
| Phone B      | $399    | 128GB, 48MP Camera, 5G     | No       |
| Phone C      | $499    | 256GB, 108MP Camera, 5G    | Yes      |

Output (ES Module String)


🧬 GitHub Flavored Markdown (GFM)

Enable extended Markdown features with the gfm flag:

const result = processMarkdown(filePath, true);

Supported GFM features:

  • ✔️ Task lists
  • 📑 Footnotes
  • 🔡 Strikethrough (~~text~~)
  • 🧮 Tables
  • 🏷️ Heading attributes (## Title {#id})

🔷 TypeScript Support

This module includes index.d.ts for full TypeScript support. To use:

  1. Ensure TypeScript is installed:

    npm install --save-dev typescript
  2. Import the module as usual. Type definitions are automatically applied.


🧪 Development & Testing

Run tests:

npm run test

Rebuild after source changes:

  • Edit Rust: src/lib.rs
  • Edit Types: index.d.ts

Then:

npm run debug
# or
npm run build

📄 License

MIT License — see LICENSE.


🤝 Contributing

Contributions welcome! Please open an issue or PR:

👉 GitHub Repository


🐞 Issues & Support

Found a bug or need a feature?

📬 Report it on GitHub Issues

👥 Contributors

Thanks to these awesome people for their work on this project:

aliezzahn
aliezzahn
0xre2a
0xre2a
morihn
morihn

About

A Node.js module for converting Markdown files to HTML using Rust

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages