New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

streammark

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

streammark

Beautiful terminal markdown renderer with first-class streaming support

latest
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

StreamMark

Beautiful terminal markdown renderer with first-class streaming support.

Built for LLM/agent output — renders tokens as they arrive without ever showing broken markdown.

Install

npm install streammark

Peer deps: chalk@^5, string-width@^7

Usage

One-shot render

import { render, print } from 'streammark';

// Get ANSI string back
const ansi = render('# Hello\n\nThis is **streammark**', { theme: 'dracula' });
console.log(ansi);

// Or print directly
print('# Hello\n\nThis is **streammark**', { theme: 'nord' });

Streaming (LLM/agent output)

import { MarkdownStream } from 'streammark';

const md = new MarkdownStream({ theme: 'dark' });

// Anthropic SDK
const stream = await anthropic.messages.stream({ ... });
for await (const chunk of stream) {
  if (chunk.type === 'content_block_delta') {
    md.write(chunk.delta.text);
  }
}
md.end();

// OpenAI SDK
const stream = await openai.chat.completions.create({ stream: true, ... });
for await (const chunk of stream) {
  md.write(chunk.choices[0]?.delta?.content ?? '');
}
md.end();

Themes

ThemeDescription
darkDefault dark, high contrast
draculaDracula palette
nordNord palette
lightClean light theme
// Pass theme name
new MarkdownStream({ theme: 'dracula' });

// Or bring your own theme object
import { themes } from 'streammark';
const myTheme = { ...themes.dark, h1: { color: '#FF0000', bold: true } };
new MarkdownStream({ theme: myTheme });

Streaming Behaviour

ElementBehaviour
Headings, HRRendered immediately when line is complete
ParagraphsRendered line-by-line as newlines arrive
Code blocksBuffered until closing ``` — then rendered with syntax highlighting
TablesBuffered until table ends — then rendered with borders
BlockquotesBuffered until block ends
ListsBuffered until paragraph boundary

Syntax Highlighting

Supported: js, ts, jsx, tsx, python, bash, sh, json, css

No external deps — built-in token-based highlighter.

API

render(markdown, opts?) → string

Render a complete markdown string. Returns ANSI-styled string.

print(markdown, opts?)

Render and write to stdout.

new MarkdownStream(opts?)

Streaming renderer.

  • opts.theme — theme name or object (default: 'dark')
  • opts.output — writable stream (default: process.stdout)

.write(chunk: string)

Feed a chunk (can be a single character/token).

.end()

Flush remaining content and finalize.

.pipe(asyncIterable)

Convenience: pipe any async iterable of string chunks.

Keywords

markdown

FAQs

Package last updated on 28 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts