flav-md

A lightweight Markdown parser with automatic CSS class generation

GitHub version npm version Bun CI Status

What's flav-md?

flav-md is a lightweight and flexible Markdown parser that converts Markdown to HTML with automatic CSS class generation. When parsing md files with flav-md, HTML tags in generated documents automatically receive semantic CSS classes like flav-md-h1, flav-md-text, flav-md-p, etc.

This makes styling incredibly easy - you just write Markdown content and CSS styles, and flav-md handles the rest!

Key Features

  • 🚀 Lightweight - Minimal dependencies and fast parsing
  • 🎨 CSS-Ready - Automatic CSS class generation for all elements
  • 📝 Full Markdown Support - Headers, lists, links, images, code blocks, tables, and more
  • 🔧 Easy Integration - Works with Node.js, ES6, and TypeScript

How to install?

You can install flav-md via npm with

$ npm install flav-md

How to use?

You can use flav-md in Node.js (CommonJS), ES6 modules, and TypeScript.

CommonJS

const { createFlavMd } = require('flav-md');

const result = createFlavMd()
  .readMdText('# Hello World')
  .readCssText('.flav-md-h1 { color: red; }')
  .build();

ES6 and TypeScript

import { createFlavMd } from 'flav-md';

const result = createFlavMd()
  .readMdText('# Hello World')
  .readCssText('.flav-md-h1 { color: red; }')
  .build();

Working with Files

For file operations, use Node.js file system utilities:

import { readFileSync } from 'fs';
import { createFlavMd } from 'flav-md';

const markdownContent = readFileSync('example.md', 'utf-8');
const cssContent = readFileSync('example.css', 'utf-8');

const result = createFlavMd()
  .readMdText(markdownContent)
  .readCssText(cssContent)
  .build();

Documentation & Resources

Contributions are welcome! Feel free to submit issues, feature requests, or pull requests on GitHub.