@indiekitai/glamour
v0.1.0
Published
Stylesheet-based markdown rendering for terminals - port of charmbracelet/glamour
Maintainers
Readme
@indiekitai/glamour
Stylesheet-based markdown rendering for terminals. A TypeScript port of charmbracelet/glamour.
Features
- 🎨 Built-in themes — Dark, Light, ASCII, Pink, Dracula, Tokyo Night, NoTTY
- 📝 Markdown rendering — Headings, bold, italic, code, lists, tables, links, images, blockquotes
- 📏 Word wrapping — Automatic word wrap to terminal width
- 🎭 Custom styles — Full stylesheet-based customization via JSON or objects
- 🔧 MCP Server — Model Context Protocol integration
- 🖥️ CLI —
npx @indiekitai/glamour README.md - 📦 Zero native deps — Pure TypeScript, uses
markedfor parsing
Installation
npm install @indiekitai/glamourQuick Start
import { render } from '@indiekitai/glamour';
// Render with auto-detected style
console.log(render('# Hello World\n\nThis is **glamour**!'));
// Render with a specific style
console.log(render('# Hello', 'dark'));
console.log(render('# Hello', 'dracula'));
console.log(render('# Hello', 'ascii'));API
render(markdown, style?)
Quick render function. Style can be a name ('dark', 'light', 'ascii', etc.) or a StyleConfig object.
import { render } from '@indiekitai/glamour';
console.log(render('**bold** and *italic*', 'dark'));new TermRenderer(options?)
Create a reusable renderer with full configuration.
import { TermRenderer } from '@indiekitai/glamour';
const renderer = new TermRenderer({
style: 'dark', // or 'light', 'ascii', 'pink', 'dracula', 'tokyo-night', StyleConfig
wordWrap: 100, // default: 80
baseURL: 'https://github.com/user/repo',
preserveNewLines: true,
});
console.log(renderer.render('# Title\n\nBody text'));renderWithEnvironmentConfig(markdown)
Renders using the GLAMOUR_STYLE environment variable (falls back to 'auto').
import { renderWithEnvironmentConfig } from '@indiekitai/glamour';
// Set GLAMOUR_STYLE=dark in your environment
console.log(renderWithEnvironmentConfig('# Hello'));Built-in Styles
| Style | Description |
|-------|-------------|
| auto | Auto-detect (dark if TTY, notty otherwise) |
| dark | Dark terminal theme with colors |
| light | Light terminal theme |
| ascii | ASCII-only, no ANSI colors |
| notty | For non-TTY output (same as ascii) |
| pink | Pink accent theme |
| dracula | Dracula color scheme |
| tokyo-night | Tokyo Night color scheme |
Custom Styles
import { TermRenderer, type StyleConfig } from '@indiekitai/glamour';
const myStyle: StyleConfig = {
document: { margin: 4, color: '#FFFFFF' },
heading: { bold: true, color: '#FF6B6B', blockSuffix: '\n' },
h1: { prefix: '🚀 ' },
strong: { bold: true, color: '#FFD700' },
code: { prefix: ' ', suffix: ' ', color: '#50FA7B', backgroundColor: '#282A36' },
link: { color: '#8BE9FD', underline: true },
};
const r = new TermRenderer({ style: myStyle });
console.log(r.render('# My Doc\n\n**Important** info'));CLI
# Render a file
npx @indiekitai/glamour README.md
# Pipe from stdin
cat README.md | npx @indiekitai/glamour
# Choose a style
npx @indiekitai/glamour --style dracula README.md
# Set width
npx @indiekitai/glamour --width 60 README.md
# JSON output
npx @indiekitai/glamour --json README.mdMCP Server
Start the MCP server for AI agent integration:
node dist/mcp.jsAvailable tools:
render_markdown— Render markdown with a chosen stylerender_plain— Render with ASCII-only stylelist_styles— List available styles
Utilities
import { stripAnsi, visibleWidth, wordwrap, indentText, padText } from '@indiekitai/glamour';
stripAnsi('\x1b[1mBold\x1b[0m'); // 'Bold'
visibleWidth('\x1b[1mHello\x1b[0m'); // 5
wordwrap('long text here', 10);
indentText('line1\nline2', 2); // ' line1\n line2'License
MIT
Credits
TypeScript port of charmbracelet/glamour by IndieKit AI.
