Zero-dependency Go CLI streaming Markdown → ANSI terminal renderer.
Refactored from the Swift project SwiftStreamingMarkdown, fully implementing the Preprocess → Parse → Rewrite → Render four-stage pipeline. Supports streaming rendering mode.
| Category | Support |
|---|---|
| Headings | ATX # ~ ###### with colored levels |
| Emphasis | *italic*, **bold**, ~~strikethrough~~ |
| Code | Inline `code`, fenced code blocks ```lang ``` with language label and automatic line wrapping |
| Lists | Ordered 1., unordered - * +, task lists - [x] |
| Blockquotes | > blockquote with nesting support |
| Tables | | a | b | GFM tables with borders, automatic width fitting, and cell content wrapping |
| Links | [text](url), <autolink> |
| Images |  terminal rendering |
| Horizontal Rules | ---, ***, ___ |
| LaTeX Math | $$block$$, $inline$, \(paren\) preprocessed to code blocks/inline code |
| Streaming | --stream mode with speculative emphasis closure (anti-jitter) |
go install github.com/startvibecoding/GoStreamingMarkdown@latestgo get github.com/startvibecoding/GoStreamingMarkdowngit clone https://github.com/startvibecoding/GoStreamingMarkdown.git
cd GoStreamingMarkdown
go build -o GoStreamingMarkdown .Zero external dependencies — uses only Go standard library.
# Render a file
GoStreamingMarkdown README.md
# Read from pipe
cat README.md | GoStreamingMarkdown
# Streaming mode (real-time rendering, incremental updates)
cat stream.txt | GoStreamingMarkdown --stream --delay 100ms
# Specify theme and width
GoStreamingMarkdown -t light -w 100 doc.md
# Render Markdown stringecho'# Hello **world**'| GoStreamingMarkdown| Flag | Description |
|---|---|
-h, --help | Show help |
-s, --stream | Streaming mode (in-place redraw) |
-d, --delay <dur> | Stream update interval (e.g. 50ms, 1s) |
-t, --theme <name> | Theme: dark (default) or light |
-w, --width <cols> | Terminal width (default: 80) |
Complete replication of the Swift project's four-stage pipeline:
Input Text
│
▼
┌─────────────────────┐
│ 1. Preprocess (LaTeX)│ $$...$$ → fenced code block
│ │ $...$ → inline code
│ │ \(...\) → inline code
└──────────┬──────────┘
▼
┌─────────────────────┐
│ 2. Parse (AST) │ CommonMark compatible parser
│ │ Block: heading, paragraph, code,
│ │ blockquote, list, table, hr
│ │ Inline: emphasis, strong, code,
│ │ link, image, strikethrough, autolink
└──────────┬──────────┘
▼
┌─────────────────────┐
│ 3. Rewrite │ Speculative emphasis closure
│ (speculative) │ Prevents text jitter during streaming
└──────────┬──────────┘
▼
┌─────────────────────┐
│ 4. Render (ANSI) │ AST → ANSI terminal output
│ │ Dark/Light themes
│ │ Unicode box-drawing characters
└─────────────────────┘
GoStreamingMarkdown/
├── main.go # CLI entry point
├── go.mod # Go module definition (zero dependencies)
├── gsm/ # Convenience API package
│ └── gsm.go # Simplified streaming rendering API
├── parser/
│ ├── node.go # AST node type definitions
│ └── parser.go # Markdown parser + LaTeX preprocessor + rewriter
├── renderer/
│ └── renderer.go # ANSI terminal renderer + theme system
├── examples/ # Usage examples
└── README.md
package main
import (
"fmt""github.com/startvibecoding/GoStreamingMarkdown/gsm"
)
funcmain() {
// One-shot renderingoutput:=gsm.Render("# Hello **world**", 80, nil)
fmt.Println(output)
// Streaming renderingstream:=gsm.NewStream(80, nil)
stream.Update("partial markdown...")
fmt.Print(stream.Output())
}package main
import (
"fmt""github.com/startvibecoding/GoStreamingMarkdown/parser""github.com/startvibecoding/GoStreamingMarkdown/renderer"
)
funcmain() {
src:="# Hello **world**"// Parsedoc:=parser.Parse(src, parser.DefaultOption())
// Rendertheme:=renderer.DefaultTheme()
r:=renderer.New(theme, 80)
fmt.Println(r.Render(doc))
// Or one-stepfmt.Println(renderer.Render(src, 80, theme))
}opt:=parser.StreamOption() // Enable speculative rewritedoc:=parser.Parse(partialText, opt)For more examples, see examples/library-usage/
| Swift Component | Go Equivalent |
|---|---|
LaTexPreProcessor | parser.preprocessLaTeX() |
swift-markdown (cmark-gfm) | parser.Parse() |
PartialEmphasisRewriter | parser.rewriteSpeculative() |
MarkdownRenderable | parser.Node AST |
DocumentView | renderer.Render() |
MarkdownRenderConfig + Colors | renderer.Theme |
StreamedMarkdownSource | --stream CLI mode |
MIT