@@ -1,15 +1,95 @@
11 # yoctomarkdown
22
3-To install dependencies:
3+A small, fast, Bun-native Markdown highlighter for terminal output.
4+
5+`yoctomarkdown` reads Markdown and writes ANSI-colored text to stdout or returns it as a string. It focuses on simple, fast, incremental rendering for CLI and programmatic use, supporting a practical subset of Markdown specifically for terminal display.
6+
7+## Features
8+
9+- **Incremental processing**: Stream chunks of Markdown without buffering the entire document.
10+- **Terminal optimized**: Styles headings, code blocks, lists, and more using `yoctocolors`.
11+- **Flexible**: Use it as a library (`highlightSync`, `createHighlighter`) or as a CLI tool.
12+- **Fast**: Built for the Bun runtime.
13+
14+## Installation
415
516 ```bash
6-bun install
17+bun add yoctomarkdown
718 ```
819
9-To run:
20+## Usage
21+
22+### CLI
23+
24+Run via the command line:
1025
1126 ```bash
12-bun run index.ts
27+# Read from a file
28+yoctomarkdown README.md
29+
30+# Read from stdin
31+cat README.md | yoctomarkdown
32+```
33+
34+**Options:**
35+
36+- `-t, --theme <name>`: Theme to use (`16`, `256`, `truecolor`, `minimal`, `none`). Defaults to `16`.
37+- `-w, --wrap <n|auto|0>`: Word wrapping length. Defaults to `auto` (terminal width).
38+- `-h, --help`: Show help.
39+
40+### Library API
41+
42+You can use `yoctomarkdown` programmatically in two ways: synchronously for complete strings, or incrementally via the highlighter.
43+
44+#### Synchronous
45+
46+```typescript
47+import { highlightSync } from "yoctomarkdown";
48+
49+const markdown = "# Hello World\n\nThis is **bold** text.";
50+const output = highlightSync(markdown, { theme: "truecolor" });
51+console.log(output);
52+```
53+
54+#### Streaming / Incremental
55+
56+```typescript
57+import { createHighlighter } from "yoctomarkdown";
58+
59+const highlighter = createHighlighter({ theme: "16" });
60+
61+process.stdout.write(highlighter.write("# Chunk 1\n"));
62+process.stdout.write(highlighter.write("Some *italic* text in Chunk 2.\n"));
63+process.stdout.write(highlighter.end());
64+```
65+
66+## Options
67+
68+```typescript
69+interface Options {
70+ theme?: "16" | "256" | "truecolor" | "minimal" | "none" | Theme; // default: "16"
71+ tabWidth?: number; // default: 2
72+ wordWrap?: number | "auto" | 0; // default: "auto"
73+ yieldEvery?: number; // default: 1000
74+}
1375 ```
1476
15-This project was created using `bun init` in bun v1.3.9. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
77+## Supported Markdown
78+
79+- Headings (`#`, `##`, `###`)
80+- Bold (`**text**`) and Italic (`*text*`)
81+- Inline code (` \`code\` `) and Fenced code blocks (` ``` `)
82+- Links (`[text](url)`)
83+- Lists (`-`, `*`, `1.`)
84+- Blockquotes (`>`)
85+- Horizontal rules (`---`)
86+
87+Unsupported Markdown elements are preserved as plain text.
88+
89+## Scripts
90+
91+To contribute or develop locally, the following commands are available:
92+
93+- `bun run check`: Runs formatting, linting, typechecking, and duplication checks.
94+- `bun run format`: Formats code using Prettier.
95+- `bun test`: Runs tests.