Minimal JavaScript Markdown renderer with near-GitHub Flavored Markdown compatibility
Integrate MiniGFM into your project in just a few steps:
Include via CDN:
<script src="https://cdn.jsdelivr.net/npm/@oblivionOcean/minigfm@latest/dist/index.min.js"></script>
Install via NPM:
npm install @oblivionocean/minigfm
Usage in your project:
// Using ESModule
import MiniGFM from '@oblivionocean/minigfm';
// Using CommonJS
const MiniGFM = require('@oblivionocean/minigfm').MiniGFM;
// Create instance and parse Markdown
const md = new MiniGFM();
console.log(md.parse('# Hello World')); // <h1>Hello World</h1>
MiniGFM offers flexible configuration to meet your project's needs.
Property | Type | Default | Description |
---|---|---|---|
unsafe |
boolean | false | Enable raw HTML tags (beware of XSS risks) |
hljs |
object | null | Enable code highlighting with highlight.js instance |
// Create configured instance
const md = new MiniGFM({
unsafe: true, // Allow raw HTML rendering
hljs: hljs, // Use highlight.js for code blocks
});
// Parse Markdown
const html = md.parse('# Hello World');
console.log(html); // <h1>Hello World</h1>