### Install mdwire Go module
Source: https://mdwire.minjun.dev/docs/go
Install the Go implementation of mdwire. Requires Go and network access to fetch the module.
```sh
go get github.com/minjun0219/mdwire/go@latest
```
--------------------------------
### Install mdwire CLI with Cargo or Go
Source: https://mdwire.minjun.dev/docs/cli
Install the mdwire CLI via Cargo (Rust) or Go. The Go version has the same flags but lacks -V/--version.
```sh
cargo install mdwire-cli # Rust
go install github.com/minjun0219/mdwire/go/cmd/mdwire@latest # Go — same flags, no -V/--version
```
--------------------------------
### Install @minjun0219/mdwire with npm
Source: https://mdwire.minjun.dev/docs/npm
Install the @minjun0219/mdwire package from npm. The package selects its build via the exports condition: Node gets a CommonJS build that loads WASM from disk, while bundlers get an ESM build that imports WASM as an ES module. Under a bundler, Vite requires vite-plugin-wasm and build.target: "esnext" for top-level await.
```sh
npm install @minjun0219/mdwire
```
--------------------------------
### Repair report JSON output from --report
Source: https://mdwire.minjun.dev/docs/cli
Example JSON line printed to stderr by --report. The first four keys are repairs; the other six are channel rewrites.
```json
{"closedEmphasis":1,"closedFence":0,"revertedCodeSpan":0,"droppedMarker":0,"escapedChar":0,"tagEmphasis":0,"strippedHtml":0,"rewrittenBullet":0,"rewrittenTable":0,"convertedMarker":0}
```
--------------------------------
### new Streamer(channel, options?)
Source: https://mdwire.minjun.dev/docs/npm
Creates a new Streamer instance for the given channel and optional options. The Streamer provides methods to push chunks, preview the tail, close open markup, finish the stream, check if the result was revised, get repairs, and free WASM memory.
```APIDOC
## `new Streamer(channel, options?)`
### Description
Creates a new Streamer instance for the given channel and optional options. The Streamer provides methods to push chunks, preview the tail, close open markup, finish the stream, check if the result was revised, get repairs, and free WASM memory.
### Method
Constructor
### Parameters
- **channel** (string) - Required - The channel name.
- **options** (RenderOptions) - Optional - Rendering options.
### Methods
| Method | Returns | Description |
|---|---|---|
| `push(chunk)` | `string` | What is safe to send now. Final. |
| `preview()` | `string` | The tail to append when redrawing the whole message. Does not change state; call it when you draw, not per chunk. |
| `closeOpen()` | `string` | The tail that only closes block markup already sent. Does not change state. |
| `finish()` | `string` | The rest, with open markup closed. |
| `revised()` | `boolean` | After `finish`: does the result differ from the last `preview()` frame? |
| `repairs()` | `Repairs` | What was repaired so far — the whole document after `finish`. |
| `free()` | | Releases the WASM memory. |
### Example
```ts
import { Streamer } from "@minjun0219/mdwire";
const s = new Streamer("telegram-html");
let acc = "";
for await (const token of tokens) {
acc += s.push(token); // final — never rewritten
await edit(acc + s.preview()); // + what is held, drawn as if the input ended here
}
acc += s.finish();
if (s.revised()) await edit(acc); // skip when the last frame already equals the result
s.free();
```
```
--------------------------------
### Pipe Markdown through mdwire with various flags
Source: https://mdwire.minjun.dev/docs/cli
Example invocations of mdwire reading from stdin and writing to stdout. Shows the default NUL-separated output, --stream for immediate emission, --limit to cap part size, and --report to print the repair report to stderr.
```sh
cat agent-output.md | mdwire --channel telegram-html # parts separated by NUL
cat agent-output.md | mdwire --channel slack-markdown --stream # emit as it arrives
cat agent-output.md | mdwire --channel plain --limit 4096 # plain fallback into Telegram
cat agent-output.md | mdwire --channel slack-markdown --report
```
--------------------------------
### Render with options using render_with
Source: https://mdwire.minjun.dev/docs/rust
Renders with custom options using render_with. The returned Rendered struct contains parts and repairs, and the example shows a closed_emphasis repair count of 1.
```rust
use mdwire::{render_with, Channel, Options};
let options = Options { limit: Some(4096), ..Default::default() };
let out = render_with("**굵게** 는 **영향 범위", Channel::SlackMarkdown, options);
assert_eq!(out.parts, vec!["**굵게** 는 **영향 범위**"]);
assert_eq!(out.repairs.closed_emphasis, 1);
```
--------------------------------
### Stream markdown with Streamer
Source: https://mdwire.minjun.dev/docs/rust
Streams a document chunk by chunk using Streamer. push_into appends safe output to a buffer, preview shows what to draw, and finish_into closes open markup. The example asserts that the final output matches the last preview and that revised() is false.
```rust
use mdwire::{Channel, Streamer};
let mut s = Streamer::new(Channel::TelegramHtml);
let mut acc = String::new();
s.push_into("앞말 **굵", &mut acc);
assert_eq!(acc, "앞말 "); // final so far
assert_eq!(format!("{acc}{}", s.preview()), "앞말 굵"); // what to draw now
s.push_into("게** 끝", &mut acc);
let last = format!("{acc}{}", s.preview());
s.finish_into(&mut acc);
assert_eq!(acc, last);
assert!(!s.revised()); // the last frame was the result
```
--------------------------------
### Batch JSONL input and output format
Source: https://mdwire.minjun.dev/docs/cli
Example input and output for --batch jsonl. Each input line is a JSON object with an optional id (string or number) and a text field. Output lines are reports per document; bad lines produce an error object and cause a non-zero exit code.
```text
in {"id": "a1", "text": "**markdown"} id is a string or a number, and optional
out {"line":1,"id":"a1","closedEmphasis":1,…}
bad {"line":2,"error":"…"} reading continues; any bad line makes the exit code non-zero
```
--------------------------------
### Events integration: toEvents
Source: https://mdwire.minjun.dev/docs/npm
Converts the `html` channel output into a flat list of `open`, `text`, `close`, and `void` events. Attributes include `href`, `class`, `style`, `start`, and `src`/`alt` as emitted by the core.
```ts
import { toEvents } from "@minjun0219/mdwire/events";
toEvents(html); // [{ type: "open", tag: "p", attrs: {} }, { type: "text", text: "…" }, { type: "close", tag: "p" }, …]
```
--------------------------------
### render(input, channel, options?)
Source: https://mdwire.minjun.dev/docs/npm
Converts a finished document and returns the parts to send, one string unless the channel's limit (or options.limit) splits it.
```APIDOC
## render(input, channel, options?)
### Description
Converts a finished document. Returns the parts to send — one string unless the channel's limit (or `options.limit`) splits it.
### Method
render
### Endpoint
render(input, channel, options?)
### Parameters
- **input** (string) - Required - The markdown document to render.
- **channel** (string) - Required - The channel name (e.g., "telegram-html").
- **options** (object) - Optional - Options for rendering, including `limit`.
### Request Example
```ts
import { render } from "@minjun0219/mdwire";
const parts: string[] = render(markdown, "telegram-html");
```
### Response
#### Success Response
- **parts** (string[]) - The parts to send, one string unless split by limit.
```
--------------------------------
### Options and HtmlOptions struct definitions
Source: https://mdwire.minjun.dev/docs/rust
Defines the Options and HtmlOptions structs. Fields may be added, so build with ..Default::default(). MIN_LIMIT is 256.
```rust
pub struct Options {
pub limit: Option, // None = channel.limit(); below MIN_LIMIT (256) is raised
pub html: HtmlOptions, // Channel::Html only
}
pub struct HtmlOptions {
pub line_breaks: LineBreaks, // Br (default) | Space
pub images: Images, // Link (default) | Load
pub schemes: Option>, // None = http, https, mailto; Some replaces the default
}
```
--------------------------------
### RenderWith with SlackMarkdown and limit
Source: https://mdwire.minjun.dev/docs/go
Renders with SlackMarkdown and a custom limit. Returns parts and repair counts.
```go
out := mdwire.RenderWith(input, mdwire.SlackMarkdown, mdwire.Options{Limit: 4096})
out.Parts // []string
out.Repairs.ClosedEmphasis // see Repairs below
```
--------------------------------
### RenderWith
Source: https://mdwire.minjun.dev/docs/go
Renders a document with custom options, returning the parts and a repair report.
```APIDOC
## RenderWith
### Description
Renders a document with custom options, returning the parts and a repair report.
### Method
Function
### Signature
`mdwire.RenderWith(input string, ch mdwire.Channel, opts mdwire.Options) RenderResult`
### Parameters
- **input** (string) - Required - The input document to render.
- **ch** (mdwire.Channel) - Required - The output channel.
- **opts** (mdwire.Options) - Required - Options to customize rendering (e.g., `Limit`).
### Returns
- **out.Parts** ([]string) - The rendered parts.
- **out.Repairs** (Repairs) - The repair report (see Repairs).
### Example
```go
out := mdwire.RenderWith(input, mdwire.SlackMarkdown, mdwire.Options{Limit: 4096})
out.Parts // []string
out.Repairs.ClosedEmphasis // see Repairs below
```
```
--------------------------------
### Options and HTMLOptions structs
Source: https://mdwire.minjun.dev/docs/go
Options struct with zero value as default. Limit 0 uses channel's Limit; below 256 is raised. HTMLOptions only for HTML channel.
```go
type Options struct {
Limit int // 0 = the channel's Limit(); below MinLimit (256) is raised
HTML HTMLOptions // the HTML channel only
}
type HTMLOptions struct {
LineBreaks LineBreaks // LineBreaksBR (zero) | LineBreaksSpace
Images Images // ImagesLink (zero) | ImagesLoad
Schemes []string // nil = http, https, mailto; a list replaces the default; empty (non-nil) allows none
}
```
--------------------------------
### Options
Source: https://mdwire.minjun.dev/docs/go
Options for rendering, including limit and HTML-specific settings.
```APIDOC
## Options
### Description
Options for rendering. The zero value is the default.
### Type
`type Options struct`
### Fields
- **Limit** (int) - Optional - 0 = the channel's Limit(); below MinLimit (256) is raised.
- **HTML** (HTMLOptions) - Optional - The HTML channel only.
### HTMLOptions
- **LineBreaks** (LineBreaks) - Optional - LineBreaksBR (zero) | LineBreaksSpace.
- **Images** (Images) - Optional - ImagesLink (zero) | ImagesLoad.
- **Schemes** ([]string) - Optional - nil = http, https, mailto; a list replaces the default; empty (non-nil) allows none.
### Example
```go
type Options struct {
Limit int // 0 = the channel's Limit(); below MinLimit (256) is raised
HTML HTMLOptions // the HTML channel only
}
type HTMLOptions struct {
LineBreaks LineBreaks // LineBreaksBR (zero) | LineBreaksSpace
Images Images // ImagesLink (zero) | ImagesLoad
Schemes []string // nil = http, https, mailto; a list replaces the default; empty (non-nil) allows none
}
```
```
--------------------------------
### renderWithReport(input, channel, options?)
Source: https://mdwire.minjun.dev/docs/npm
Renders markdown and returns a repair report. The result and its repairs are WASM objects; call free() when done or use using (Symbol.dispose).
```APIDOC
## renderWithReport(input, channel, options?)
### Description
`render` plus the repair report. The result and its `repairs` are WASM objects: call `free()` when done, or use `using` (`Symbol.dispose`).
### Method
renderWithReport
### Endpoint
renderWithReport(input, channel, options?)
### Parameters
- **input** (string) - Required - The markdown document to render.
- **channel** (string) - Required - The channel name (e.g., "slack-markdown").
- **options** (object) - Optional - Options for rendering.
### Request Example
```ts
import { renderWithReport } from "@minjun0219/mdwire";
const out = renderWithReport(markdown, "slack-markdown");
out.parts; // string[]
out.repairs.closedEmphasis; // see "Repairs" below
out.free(); // the result lives in WASM memory
```
### Response
#### Success Response
- **parts** (string[]) - The rendered parts.
- **repairs** (object) - Repair report, e.g., `closedEmphasis`.
- **free** (function) - Call to free WASM memory.
```
--------------------------------
### Render with repair report using renderWithReport()
Source: https://mdwire.minjun.dev/docs/npm
Renders with a repair report. The result and its repairs are WASM objects, so call free() when done or use using (Symbol.dispose).
```ts
import { renderWithReport } from "@minjun0219/mdwire";
const out = renderWithReport(markdown, "slack-markdown");
out.parts; // string[]
out.repairs.closedEmphasis; // see "Repairs" below
out.free(); // the result lives in WASM memory
```
--------------------------------
### React integration: Markdown component and useMarkdownStream
Source: https://mdwire.minjun.dev/docs/npm
Builds React elements with `createElement` (no `innerHTML`). `Markdown` renders a finished answer; `useMarkdownStream` streams tokens via `push` and `finish`. `eager: false` shows only final content.
```tsx
import { Markdown, useMarkdownStream } from "@minjun0219/mdwire/react";
const { elements, push, finish } = useMarkdownStream(); // push(token) … finish()
const settled = useMarkdownStream({ eager: false }); // only what is final
```
--------------------------------
### Render with TelegramHTML
Source: https://mdwire.minjun.dev/docs/go
Converts a finished document to Telegram HTML parts. Splits at safe boundaries when over the limit.
```go
import "github.com/minjun0219/mdwire/go"
parts := mdwire.Render(input, mdwire.TelegramHTML) // []string
```
--------------------------------
### Add mdwire-core dependency
Source: https://mdwire.minjun.dev/docs/rust
Adds the mdwire-core crate as a dependency. The crate is named mdwire-core and is imported as mdwire.
```sh
cargo add mdwire-core
```
--------------------------------
### Render
Source: https://mdwire.minjun.dev/docs/go
Renders a complete document into parts, splitting at safe boundaries when the output exceeds the channel limit.
```APIDOC
## Render
### Description
Converts a finished document; over the limit it splits where no markup is open.
### Method
Function
### Signature
`mdwire.Render(input string, ch mdwire.Channel) []string`
### Parameters
- **input** (string) - Required - The input document to render.
- **ch** (mdwire.Channel) - Required - The output channel (e.g., `mdwire.TelegramHTML`).
### Returns
- **[]string** - The rendered parts, split at safe boundaries when over the limit.
### Example
```go
import "github.com/minjun0219/mdwire/go"
parts := mdwire.Render(input, mdwire.TelegramHTML) // []string
```
```
--------------------------------
### Render markdown to Telegram HTML with render()
Source: https://mdwire.minjun.dev/docs/npm
Converts a finished document using the render function. Returns the parts to send as an array of strings, one string unless the channel's limit (or options.limit) splits it.
```ts
import { render } from "@minjun0219/mdwire";
const parts: string[] = render(markdown, "telegram-html");
```
--------------------------------
### Streamer with PushTo and FinishTo
Source: https://mdwire.minjun.dev/docs/go
Streams chunks to a byte slice without allocation per chunk. FinishTo closes open markup.
```go
s := mdwire.NewStreamer(mdwire.SlackMarkdown)
var out []byte
for _, chunk := range chunks {
s.PushTo(chunk, &out) // no allocation per chunk
}
s.FinishTo(&out)
```
--------------------------------
### Render markdown with render
Source: https://mdwire.minjun.dev/docs/rust
Converts a finished document using the render function. It splits the output into parts when the limit is exceeded, choosing split points where no markup is open.
```rust
use mdwire::{render, Channel};
let parts: Vec = render("## 제목\n\n**굵게** 있는 문단", Channel::TelegramHtml);
assert_eq!(parts, vec!["제목\n\n굵게 있는 문단"]);
```
--------------------------------
### Widths
Source: https://mdwire.minjun.dev/docs/go
Functions to compute display widths for monospace tables.
```APIDOC
## Widths
### Description
Functions to compute display widths for monospace tables.
### Functions
- **CharWidth(rune) int** - The display width of a rune.
- **StrWidth(string) int** - The display width of a string.
### Example
```go
// No example provided in source.
```
```
--------------------------------
### Channel constants
Source: https://mdwire.minjun.dev/docs/go
Channel constants. Numeric values do not follow Channels() order; use names for storage.
```go
const ( TelegramHTML Channel = iota; SlackMarkdown; Plain; GithubMarkdown; HTML; NotionMarkdown )
```
--------------------------------
### RenderOptions interface
Source: https://mdwire.minjun.dev/docs/npm
Defines the RenderOptions interface for configuring rendering. An unknown channel name, an unknown html value, or a limit that is not a positive integer throws an Error.
```typescript
interface RenderOptions {
limit?: number; // a positive integer; below 256 is raised to 256
html?: { // the "html" channel only
lineBreaks?: "br" | "space"; // default "br"
images?: "link" | "load"; // default "link"
schemes?: string[]; // default ["http", "https", "mailto"]; replaces, does not add
};
}
```
--------------------------------
### React — @minjun0219/mdwire/react
Source: https://mdwire.minjun.dev/docs/npm
React bindings for the mdwire markdown parser, providing components and hooks to render markdown as React elements.
```APIDOC
## React — `@minjun0219/mdwire/react`
### Description
Builds React elements with `createElement` — no `innerHTML`. Escaping, the tag set and link schemes are decided by the core's `html` channel; you choose which component draws each tag.
### Components
#### ``
- **text** (string) - Required - The finished answer text.
- **components** (object) - Optional - Maps a tag (`a`, `code`, …) to your component.
- **options** (object) - Optional - Options for the core.
#### `useMarkdownStream({ components?, options?, eager?, onSettled? })`
- **components** (object) - Optional - Maps a tag to your component.
- **options** (object) - Optional - Options for the core.
- **eager** (boolean) - Optional - Default `true` draws held content early; `false` shows only what is final.
- **onSettled** (function) - Optional - Runs after `finish` with `(html, revised)`.
Returns `{ elements, push, finish }`.
#### `toElements(html, components?, schemes?)`
- **html** (string) - Required - `html` channel output (streaming: accumulated output + `preview()`).
- **components** (object) - Optional - Maps a tag to your component.
- **schemes** (object) - Optional - Pass the same `schemes` you gave the core.
Returns React nodes.
### Example
```tsx
import { Markdown, useMarkdownStream } from "@minjun0219/mdwire/react";
const { elements, push, finish } = useMarkdownStream(); // push(token) … finish()
const settled = useMarkdownStream({ eager: false }); // only what is final
```
```
--------------------------------
### Events — @minjun0219/mdwire/events
Source: https://mdwire.minjun.dev/docs/npm
Event stream adapter that converts HTML output into a flat list of open/text/close/void events for use in other frameworks.
```APIDOC
## Events — `@minjun0219/mdwire/events`
### Description
Converts the `html` channel output into a flat list of `open` / `text` / `close` / `void` events for other frameworks.
### Function
#### `toEvents(html)`
- **html** (string) - Required - The `html` channel output.
Returns an array of event objects: `{ type: "open", tag: "p", attrs: {} }`, `{ type: "text", text: "…" }`, `{ type: "close", tag: "p" }`, etc.
Attributes carry only what the core emits: `href` on `a`, `class` (`language-…`) on `code`, `style` (`text-align:…`) on `th` and `td`, `start` on `ol`, and `src` · `alt` on `img` when images load.
### Example
```ts
import { toEvents } from "@minjun0219/mdwire/events";
toEvents(html); // [{ type: "open", tag: "p", attrs: {} }, { type: "text", text: "…" }, { type: "close", tag: "p" }, …]
```
```
--------------------------------
### mdwire::width
Source: https://mdwire.minjun.dev/docs/rust
Utility functions for display width calculations used to align monospace tables.
```APIDOC
## mdwire::width
### Description
Utility functions for display width calculations used to align monospace tables.
### Functions
- `char_width(char) -> usize` - Returns the display width of a character (0, 1, or 2).
- `str_width(&str) -> usize` - Returns the display width of a string.
- `is_cjk(char) -> bool` - Returns whether the character is CJK.
```
--------------------------------
### Channel
Source: https://mdwire.minjun.dev/docs/go
Channel constants and functions for working with output channels.
```APIDOC
## Channel
### Description
Constants for output channels and functions to work with them.
### Constants
```go
const ( TelegramHTML Channel = iota; SlackMarkdown; Plain; GithubMarkdown; HTML; NotionMarkdown )
```
### Functions
- **Channels() []Channel** - Every channel.
- **ParseChannel(string) (Channel, bool)** - The string names.
### Methods
- **(Channel) Name() string** - The string name of the channel.
- **(Channel) Limit() int** - The part limit.
### Example
```go
const ( TelegramHTML Channel = iota; SlackMarkdown; Plain; GithubMarkdown; HTML; NotionMarkdown )
```
```
--------------------------------
### Channel
Source: https://mdwire.minjun.dev/docs/rust
Enum representing supported output channels with associated methods.
```APIDOC
## Channel
### Description
Enum representing supported output channels.
### Variants
- `TelegramHtml`
- `SlackMarkdown`
- `GithubMarkdown`
- `NotionMarkdown`
- `Plain`
- `Html`
### Methods
- `Channel::name(self) -> &'static str` - Returns the string name (e.g., `"telegram-html"`).
- `Channel::parse(&str) -> Option` - Parses a string name into a channel.
- `Channel::all()` - Returns every channel.
- `Channel::limit(self) -> usize` - Returns the part limit; `usize::MAX` for `Html`.
```
--------------------------------
### limit(channel)
Source: https://mdwire.minjun.dev/docs/npm
Returns the channel's part limit as a number. The `html` channel has no limit and returns `4294967295`.
```APIDOC
## `limit(channel)`
### Description
Returns the channel's part limit as a number. The `html` channel has no limit and returns `4294967295`.
### Method
Function
### Parameters
- **channel** (string) - Required - The channel name.
### Returns
- **number** - The part limit for the channel; `4294967295` for `html`.
```
--------------------------------
### Repairs struct
Source: https://mdwire.minjun.dev/docs/go
Repairs struct with counters for repairs and channel rewrites. Repaired() checks first four; Changed() checks all.
```go
type Repairs struct {
ClosedEmphasis, ClosedFence, RevertedCodeSpan, DroppedMarker int
// channel rewrites
EscapedChar, TagEmphasis, StrippedHTML, RewrittenBullet, RewrittenTable, ConvertedMarker int
}
```
--------------------------------
### Repairs
Source: https://mdwire.minjun.dev/docs/go
Repair report for a rendering operation, with counts of repairs and rewrites.
```APIDOC
## Repairs
### Description
Repair report for a rendering operation.
### Type
`type Repairs struct`
### Fields
- **ClosedEmphasis** (int) - Count of closed emphasis repairs.
- **ClosedFence** (int) - Count of closed fence repairs.
- **RevertedCodeSpan** (int) - Count of reverted code span repairs.
- **DroppedMarker** (int) - Count of dropped marker repairs.
- **EscapedChar** (int) - Count of escaped character rewrites.
- **TagEmphasis** (int) - Count of tag emphasis rewrites.
- **StrippedHTML** (int) - Count of stripped HTML rewrites.
- **RewrittenBullet** (int) - Count of rewritten bullet rewrites.
- **RewrittenTable** (int) - Count of rewritten table rewrites.
- **ConvertedMarker** (int) - Count of converted marker rewrites.
### Methods
- **Repaired() bool** - Did it repair anything (the first four).
- **Changed() bool** - Did it repair or rewrite anything.
### Example
```go
type Repairs struct {
ClosedEmphasis, ClosedFence, RevertedCodeSpan, DroppedMarker int
// channel rewrites
EscapedChar, TagEmphasis, StrippedHTML, RewrittenBullet, RewrittenTable, ConvertedMarker int
}
```
```
--------------------------------
### Streamer
Source: https://mdwire.minjun.dev/docs/rust
Streams markdown rendering incrementally, providing safe-to-send chunks and previews.
```APIDOC
## Streamer
### Description
Streams markdown rendering incrementally, providing safe-to-send chunks and previews.
### Constructors
- `Streamer::new(channel: Channel) -> Streamer` - Creates a new streamer for the given channel.
- `Streamer::with_options(channel: Channel, options: Options) -> Streamer` - Creates a streamer with custom options.
### Methods
- `push(&mut self, chunk: &str) -> &str` - Returns what is safe to send now, borrowed until the next call.
- `push_into(&mut self, chunk: &str, out: &mut String)` - Appends the safe-to-send part to the provided buffer, avoiding per-chunk allocation.
- `finish(&mut self) -> &str` - Returns the rest with open markup closed.
- `finish_into(&mut self, out: &mut String)` - Appends the rest with open markup closed to the buffer.
- `preview(&mut self) -> &str` - Returns the tail to append when redrawing the whole message. Cost grows with open blocks; call only when redrawing.
- `preview_into(&mut self, out: &mut String)` - Appends the preview tail to the buffer.
- `close_open(&self, out: &mut String)` - Appends only the closers for block markup already sent.
- `revised(&self) -> bool` - After `finish`, returns whether the result differs from the last `preview`. `true` means "may differ".
- `repairs(&self) -> Repairs` - Returns what was repaired so far.
### Example
```rust
use mdwire::{Channel, Streamer};
let mut s = Streamer::new(Channel::TelegramHtml);
let mut acc = String::new();
s.push_into("앞말 **굵", &mut acc);
assert_eq!(acc, "앞말 ");
assert_eq!(format!("{acc}{}", s.preview()), "앞말 굵");
s.push_into("게** 끝", &mut acc);
let last = format!("{acc}{}", s.preview());
s.finish_into(&mut acc);
assert_eq!(acc, last);
assert!(!s.revised());
```
```
--------------------------------
### Channel enum definition
Source: https://mdwire.minjun.dev/docs/rust
Defines the Channel enum with variants for different output formats. Channel::name returns string names like "telegram-html", Channel::limit returns the part limit (usize::MAX for Html).
```rust
pub enum Channel { TelegramHtml, SlackMarkdown, GithubMarkdown, NotionMarkdown, Plain, Html }
```
--------------------------------
### Stream tokens with Streamer
Source: https://mdwire.minjun.dev/docs/npm
Streams tokens through a Streamer instance, sending each push result and redrawing with preview, then finishing and freeing memory. Use for channels like telegram-html where you can edit messages; for append-only channels like Slack appendStream, send each push piece and never call preview().
```typescript
import { Streamer } from "@minjun0219/mdwire";
const s = new Streamer("telegram-html");
let acc = "";
for await (const token of tokens) {
acc += s.push(token); // final — never rewritten
await edit(acc + s.preview()); // + what is held, drawn as if the input ended here
}
acc += s.finish();
if (s.revised()) await edit(acc); // skip when the last frame already equals the result
s.free();
```
--------------------------------
### Streamer
Source: https://mdwire.minjun.dev/docs/go
Streams a document in chunks, providing methods to push chunks and finish the stream.
```APIDOC
## Streamer
### Description
Streams a document in chunks, providing methods to push chunks and finish the stream.
### Constructor
`mdwire.NewStreamer(ch mdwire.Channel) *Streamer`
`mdwire.NewStreamerWith(ch mdwire.Channel, opts mdwire.Options) *Streamer`
### Methods
- **PushTo(chunk []byte, out *[]byte)** - What is safe to send now. Allocation-free form.
- **Push(chunk []byte) string** - What is safe to send now.
- **FinishTo(out *[]byte)** - The rest, with open markup closed.
- **Finish() string** - The rest, with open markup closed.
- **PreviewTo(out *[]byte)** - The tail to append when redrawing the whole message.
- **Preview() string** - The tail to append when redrawing the whole message.
- **CloseOpenTo(out *[]byte)** - The tail that only closes block markup already sent.
- **CloseOpen() string** - The tail that only closes block markup already sent.
- **Revised() bool** - After Finish: does the result differ from the last preview?
- **Repairs() Repairs** - What was repaired so far.
### Example
```go
s := mdwire.NewStreamer(mdwire.SlackMarkdown)
var out []byte
for _, chunk := range chunks {
s.PushTo(chunk, &out) // no allocation per chunk
}
s.FinishTo(&out)
```
```
--------------------------------
### Repairs struct definition
Source: https://mdwire.minjun.dev/docs/rust
Defines the Repairs struct with counters for various repairs and rewrites. any() checks if any of the first four fields are non-zero, changed() checks if any repair or rewrite occurred.
```rust
pub struct Repairs {
pub closed_emphasis: usize,
pub closed_fence: usize,
pub reverted_code_span: usize,
pub dropped_marker: usize,
// channel rewrites
pub escaped_char: usize,
pub tag_emphasis: usize,
pub stripped_html: usize,
pub rewritten_bullet: usize,
pub rewritten_table: usize,
pub converted_marker: usize,
}
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.