https://github.com/aliezzahn/rs-markdown-parser
A Node.js module for converting Markdown files to HTML using Rust
https://github.com/aliezzahn/rs-markdown-parser
cargo converter html loader markdown nodejs npm npm-package parser rust
Last synced: about 1 month ago
JSON representation
A Node.js module for converting Markdown files to HTML using Rust
- Host: GitHub
- URL: https://github.com/aliezzahn/rs-markdown-parser
- Owner: aliezzahn
- License: mit
- Created: 2025-05-03T13:13:42.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-05-03T19:52:06.000Z (9 months ago)
- Last Synced: 2025-09-17T06:27:30.343Z (5 months ago)
- Topics: cargo, converter, html, loader, markdown, nodejs, npm, npm-package, parser, rust
- Language: Rust
- Homepage: https://www.npmjs.com/package/rs-markdown-parser
- Size: 18.6 KB
- Stars: 10
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ rs-markdown-parser
A blazing-fast Node.js module for converting Markdown to HTML โ powered by Rustโs [`pulldown-cmark`](https://docs.rs/pulldown-cmark) and [Neon](https://neon-bindings.com/) 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
```bash
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
```js
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 ``;
```
#### TypeScript
```ts
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 ``;
```
---
## ๐งช Example
### Sample Markdown (`test.md`)
```markdown
# 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:
```js
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:
```bash
npm install --save-dev typescript
```
2. Import the module as usual. Type definitions are automatically applied.
---
## ๐งช Development & Testing
### Run tests:
```bash
npm run test
```
### Rebuild after source changes:
* Edit Rust: `src/lib.rs`
* Edit Types: `index.d.ts`
Then:
```bash
npm run debug
# or
npm run build
```
---
## ๐ License
MIT License โ see [LICENSE](./LICENSE).
---
## ๐ค Contributing
Contributions welcome! Please open an issue or PR:
๐ [GitHub Repository](https://github.com/aliezzahn/rs-markdown-parser)
---
## ๐ Issues & Support
Found a bug or need a feature?
๐ฌ Report it on [GitHub Issues](https://github.com/aliezzahn/rs-markdown-parser/issues)
## ๐ฅ Contributors
Thanks to these awesome people for their work on this project: