markdown parser with css style
flav-md is a lightweight and flexible Markdown parser that converts Markdown to HTML with automatic CSS class generation. Unlike other Markdown parsers, flav-md adds semantic CSS classes to every HTML element, making it incredibly easy to style the output with CSS.
- 🚀 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
- 💾 Flexible Input - Read from files or strings
- 🎯 Semantic Classes - Predictable and consistent class naming
- Documentation sites - Generate styled docs from Markdown
- Blog systems - Convert posts with custom styling
- Static site generators - Build sites with Markdown content
- Content management - Process user-generated Markdown content
You can install via npm with
npm install flav-mdCommonJS
const { createFlavMd } = require('flav-md');
const result = createFlavMd()
.readMdText('# Hello World')
.readCssText('.flav-md-h1 { color: red; }')
.build();ES6 or TypeScript
import { createFlavMd } from 'flav-md';
const result = createFlavMd()
.readMdText('# Hello World')
.readCssText('.flav-md-h1 { color: red; }')
.build();If you need to read from files, 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();flav-md automatically generates CSS classes for all HTML elements. For a complete reference of all available CSS classes and styling examples, see:
- CSS Class Reference - Complete guide to all CSS classes
- GitHub Wiki - Additional documentation
Check out the examples directory for sample Markdown files and CSS styling.
Creates a new FlavMd instance.
const flavmd = createFlavMd();Reads Markdown content from a string and parses it to HTML.
flavmd.readMdText('# Hello World\n\nThis is **bold** text.');Reads CSS content from a string to be embedded in the final HTML.
flavmd.readCssText('.flav-md-h1 { color: blue; font-size: 2em; }');Generates the final HTML with embedded CSS.
const html = flavmd.build();Contributions are welcome! Please feel free to submit a Pull Request.
MIT © jiko21
