@minjun0219/mdwire 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -35
- package/bundler/mdwire.d.ts +3 -5
- package/bundler/mdwire_bg.js +9 -16
- package/bundler/mdwire_bg.wasm +0 -0
- package/js/events.js +1 -1
- package/js/react.d.ts +1 -4
- package/js/react.js +11 -7
- package/node/mdwire.d.ts +3 -5
- package/node/mdwire.js +9 -16
- package/node/mdwire_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,12 +5,12 @@ English | [한국어](README.ko.md)
|
|
|
5
5
|
Send LLM-generated Markdown to chat channels without it breaking.
|
|
6
6
|
Docs, API reference and a live demo: [mdwire.minjun.dev](https://mdwire.minjun.dev).
|
|
7
7
|
|
|
8
|
-
Agents emit Markdown. Chat channels don't
|
|
8
|
+
Agents emit Markdown. Chat channels don't take it as is — each has its own subset, its own
|
|
9
9
|
escaping rules, and its own length limit. Existing converters assume the input is
|
|
10
10
|
well-formed CommonMark and target one channel at a time. Neither assumption holds for
|
|
11
11
|
agent output.
|
|
12
12
|
|
|
13
|
-
**Status: v0.1.
|
|
13
|
+
**Status: v0.1.10.** Normalizing, rendering, splitting and streaming work for six
|
|
14
14
|
targets — Telegram HTML, Slack `markdown_text`, GitHub comments (GFM), Notion pages, plain text,
|
|
15
15
|
and HTML for the browser — from a Rust core, a CLI,
|
|
16
16
|
an npm package (WASM), and a Go port. See `SPEC.md` for what is in v0.1 and what was
|
|
@@ -22,15 +22,16 @@ deliberately deferred. `SPEC.md` and `DESIGN.md` are written in Korean.
|
|
|
22
22
|
LLM markdown → normalize → render for channel → split safely → send
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
1. **Normalize.** Agent
|
|
26
|
-
|
|
25
|
+
1. **Normalize.** Agent-written Markdown may not render correctly through a standard
|
|
26
|
+
Markdown converter. Typical cases: unpaired `**`, emphasis that spans a line break in wrapped
|
|
27
|
+
prose, unclosed code fences. Repair before rendering.
|
|
27
28
|
2. **Render.** Emit the syntax the channel actually accepts. Telegram HTML allows nine
|
|
28
29
|
tags; Slack `markdown_text` takes standard Markdown directly. GitHub takes it too, but
|
|
29
30
|
reads a lone `~` as strikethrough and `<T>` as an HTML tag — so a `~` or `<` meant as a
|
|
30
|
-
character goes out escaped (`\~`, `\<`), and emphasis GFM would not close
|
|
31
|
-
followed directly by a Korean particle
|
|
31
|
+
character goes out escaped (`\~`, `\<`), and emphasis that GFM would not close (`**(a)**`
|
|
32
|
+
followed directly by a Korean particle) goes out as `<strong>`. Notion renders that bold as is
|
|
32
33
|
but shows inline HTML as text, so `notion-markdown` strips the tags and escapes a literal `*`
|
|
33
|
-
or `\` instead. For the browser, `html`
|
|
34
|
+
or `\` instead. For the browser, `html` renders
|
|
34
35
|
blocks as tags too and is safe to set as `innerHTML`: text is escaped, inline tags from the
|
|
35
36
|
source keep no attributes, and only `http(s)`/`mailto` links become `<a>` — line breaks,
|
|
36
37
|
images and allowed schemes are options. While streaming,
|
|
@@ -38,13 +39,11 @@ LLM markdown → normalize → render for channel → split safely → s
|
|
|
38
39
|
3. **Split.** Respect the channel's limit — and never cut through markup. This also
|
|
39
40
|
covers streaming: a chunk boundary must not land inside `**bold**`.
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
stripped HTML, bullets, tables, converted markers — so you can log how often the model
|
|
47
|
-
breaks its own formatting and see what a channel changes before you adopt it.
|
|
42
|
+
The pipeline has one option. **Repair report:** how many times the normalizer stepped
|
|
43
|
+
in — unclosed emphasis, unclosed fence, unpaired backticks, dropped markers — and what it
|
|
44
|
+
rewrote for the channel — escaped characters, tags for emphasis, stripped HTML, bullets,
|
|
45
|
+
tables, converted markers — so you can log how often the model breaks its own formatting
|
|
46
|
+
and see what a channel changes before you adopt it.
|
|
48
47
|
|
|
49
48
|
## Use it
|
|
50
49
|
|
|
@@ -53,10 +52,9 @@ cat agent-output.md | mdwire --channel telegram-html # parts separated
|
|
|
53
52
|
cat agent-output.md | mdwire --channel slack-markdown --stream # emit as it arrives
|
|
54
53
|
cat agent-output.md | mdwire --channel plain --limit 4096 # plain fallback into Telegram
|
|
55
54
|
|
|
56
|
-
#
|
|
57
|
-
#
|
|
58
|
-
|
|
59
|
-
cat agent-output.md | mdwire --channel slack-markdown --from slack-mrkdwn --report
|
|
55
|
+
# --report prints what the normalizer fixed and rewrote (unclosed emphasis, escaped `~`,
|
|
56
|
+
# stripped tags, …) to stderr as one JSON line.
|
|
57
|
+
cat agent-output.md | mdwire --channel slack-markdown --report
|
|
60
58
|
```
|
|
61
59
|
|
|
62
60
|
```rust
|
|
@@ -71,7 +69,7 @@ s.finish_into(&mut out); // flush, closing anything left open
|
|
|
71
69
|
import { render, renderWithReport, Streamer } from "@minjun0219/mdwire"; // npm — bundlers, Node, Bun
|
|
72
70
|
|
|
73
71
|
const parts = render(markdown, "telegram-html");
|
|
74
|
-
const { repairs } = renderWithReport(markdown, "slack-markdown"
|
|
72
|
+
const { repairs } = renderWithReport(markdown, "slack-markdown");
|
|
75
73
|
|
|
76
74
|
// A channel that rewrites the whole message (Telegram edit): send acc plus the preview —
|
|
77
75
|
// what is still held (open bold, table rows, a code span) drawn as if the input ended here.
|
|
@@ -121,22 +119,31 @@ every file one character and 64 characters at a time and reports any divergence.
|
|
|
121
119
|
`SPEC.md` §8.2.
|
|
122
120
|
|
|
123
121
|
The streamer holds back only what it must: a prefix it cannot classify yet, a marker run
|
|
124
|
-
at the end of a chunk, and the inside of an emphasis that has not closed.
|
|
122
|
+
at the end of a chunk, and the inside of an emphasis that has not closed. A whole paragraph is
|
|
125
123
|
never held — a renderer that waits for a newline is not streaming.
|
|
126
124
|
|
|
127
125
|
## Why another one
|
|
128
126
|
|
|
129
|
-
|
|
127
|
+
We found three gaps in existing tools:
|
|
130
128
|
|
|
131
|
-
- **
|
|
129
|
+
- **Emphasis spanning lines is common.** In a sample of 60 agent-generated documents,
|
|
132
130
|
44 contained emphasis spanning a line break. A regex-based converter mispaired those
|
|
133
131
|
into *inverted* emphasis ranges — and the channel returned HTTP 200, so nothing caught it.
|
|
134
|
-
- **
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
-
|
|
139
|
-
|
|
132
|
+
- **Common Korean notation collides with Markdown.**
|
|
133
|
+
- In `**설정(config)**을` or `**52%**다`, the bold ends in a symbol and a particle follows right
|
|
134
|
+
after. Under CommonMark's rules the bold does not close and the `**` shows as text. GitHub and
|
|
135
|
+
browser renderers follow those rules.
|
|
136
|
+
- In `약 ~40km, 5~6월`, tildes mark an approximation and a range. With two of them in one
|
|
137
|
+
paragraph, GitHub (GFM), which reads a single `~` as strikethrough, pairs them and strikes
|
|
138
|
+
everything in between (`40km, 5`).
|
|
139
|
+
|
|
140
|
+
The two converters we compared disagree on Korean-adjacent emphasis (one pads it with U+200B, the
|
|
141
|
+
other leaves it alone), and neither checked the channel. mdwire measured each channel: on GitHub it writes just that
|
|
142
|
+
bold as `<strong>` and escapes a literal `~` as `\~`.
|
|
143
|
+
- **Chat-channel converters ignore streaming.** Some browser renderers, like Streamdown, patch
|
|
144
|
+
unclosed syntax while tokens stream in. The Telegram and Slack converters we looked at all
|
|
145
|
+
take the whole document and convert it in one pass. When tokens arrive incrementally,
|
|
146
|
+
markup splits across chunk boundaries.
|
|
140
147
|
|
|
141
148
|
## Design
|
|
142
149
|
|
|
@@ -164,14 +171,16 @@ Every release also carries its own artifacts, if you would rather not go through
|
|
|
164
171
|
|
|
165
172
|
```sh
|
|
166
173
|
# npm package (works under a bundler and in plain Node)
|
|
167
|
-
npm install https://github.com/minjun0219/mdwire/releases/download/v0.1.
|
|
174
|
+
npm install https://github.com/minjun0219/mdwire/releases/download/v0.1.10/mdwire-0.1.10.tgz
|
|
168
175
|
|
|
169
|
-
# CLI binary —
|
|
170
|
-
curl -L https://github.com/minjun0219/mdwire/releases/download/v0.1.
|
|
171
|
-
curl -L https://github.com/minjun0219/mdwire/releases/download/v0.1.
|
|
176
|
+
# CLI binary — pick your platform
|
|
177
|
+
curl -L https://github.com/minjun0219/mdwire/releases/download/v0.1.10/mdwire-v0.1.10-aarch64-apple-darwin.tar.gz | tar xz # macOS, Apple silicon
|
|
178
|
+
curl -L https://github.com/minjun0219/mdwire/releases/download/v0.1.10/mdwire-v0.1.10-x86_64-unknown-linux-gnu.tar.gz | tar xz # Linux x86_64 (glibc)
|
|
179
|
+
curl -L https://github.com/minjun0219/mdwire/releases/download/v0.1.10/mdwire-v0.1.10-aarch64-unknown-linux-gnu.tar.gz | tar xz # Linux arm64 (glibc)
|
|
180
|
+
curl -LO https://github.com/minjun0219/mdwire/releases/download/v0.1.10/mdwire-v0.1.10-x86_64-pc-windows-msvc.zip # Windows x86_64
|
|
172
181
|
```
|
|
173
182
|
|
|
174
|
-
The release notes list a SHA-256 for every artifact —
|
|
183
|
+
The release notes list a SHA-256 for every artifact — verify the download against it when installing by URL.
|
|
175
184
|
|
|
176
185
|
Or from source: `cargo install --path crates/mdwire-cli`.
|
|
177
186
|
|
|
@@ -189,7 +198,7 @@ s := mdwire.NewStreamer(mdwire.SlackMarkdown)
|
|
|
189
198
|
s.PushTo(chunk, &out) // no allocation per chunk
|
|
190
199
|
s.FinishTo(&out)
|
|
191
200
|
|
|
192
|
-
out := mdwire.RenderWith(input, mdwire.SlackMarkdown, mdwire.Options{
|
|
201
|
+
out := mdwire.RenderWith(input, mdwire.SlackMarkdown, mdwire.Options{})
|
|
193
202
|
log.Printf("%+v", out.Repairs)
|
|
194
203
|
```
|
|
195
204
|
|
|
@@ -200,7 +209,7 @@ log.Printf("%+v", out.Repairs)
|
|
|
200
209
|
./scripts/smoke.sh # install it into a scratch project; call it from Node, Bun, and TypeScript
|
|
201
210
|
```
|
|
202
211
|
|
|
203
|
-
The wasm binary is 111 KB
|
|
212
|
+
The wasm binary is 111 KB (release build, after `wasm-opt`). The package carries two builds and
|
|
204
213
|
picks by `exports` condition: `node` gets a CommonJS build that loads the wasm from disk,
|
|
205
214
|
everything else gets the ESM bundler build. The script writes the root `package.json`
|
|
206
215
|
itself: the crate has to stay `mdwire-wasm` because the core's library is already named
|
package/bundler/mdwire.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
-
/** 변환 옵션. 생략하면
|
|
4
|
+
/** 변환 옵션. 생략하면 채널의 기본값이다. */
|
|
5
5
|
export interface RenderOptions {
|
|
6
|
-
/** 입력 표기. 슬랙 레거시 mrkdwn(`*굵게*` `~취소~`)으로 쓴 에이전트 출력이면 "slack-mrkdwn". */
|
|
7
|
-
from?: "markdown" | "slack-mrkdwn";
|
|
8
6
|
/** 조각 한도(글자 수). 생략하면 채널의 한도다 — plain 을 텔레그램에 보내면 4096. 스트리밍은 나누지 않는다. */
|
|
9
7
|
limit?: number;
|
|
10
8
|
/** 브라우저 채널("html")의 정책. 기본값이 가장 보수적이다. */
|
|
@@ -61,7 +59,7 @@ export class Repairs {
|
|
|
61
59
|
*/
|
|
62
60
|
droppedMarker: number;
|
|
63
61
|
/**
|
|
64
|
-
* 채널이 구문으로 읽을 글자를
|
|
62
|
+
* 채널이 구문으로 읽을 글자를 이스케이프한 수(GitHub 의 `\~`·`\<`·`\*`).
|
|
65
63
|
*/
|
|
66
64
|
escapedChar: number;
|
|
67
65
|
/**
|
|
@@ -81,7 +79,7 @@ export class Repairs {
|
|
|
81
79
|
*/
|
|
82
80
|
strippedHtml: number;
|
|
83
81
|
/**
|
|
84
|
-
*
|
|
82
|
+
* 채널이 마커로 못 읽는 자리라 다르게 낸 강조(GitHub 의 `<strong>`, 슬랙의 U+2060).
|
|
85
83
|
*/
|
|
86
84
|
tagEmphasis: number;
|
|
87
85
|
}
|
package/bundler/mdwire_bg.js
CHANGED
|
@@ -99,7 +99,7 @@ export class Repairs {
|
|
|
99
99
|
return ret >>> 0;
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
|
-
* 채널이 구문으로 읽을 글자를
|
|
102
|
+
* 채널이 구문으로 읽을 글자를 이스케이프한 수(GitHub 의 `\~`·`\<`·`\*`).
|
|
103
103
|
* @returns {number}
|
|
104
104
|
*/
|
|
105
105
|
get escapedChar() {
|
|
@@ -139,7 +139,7 @@ export class Repairs {
|
|
|
139
139
|
return ret >>> 0;
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
|
-
*
|
|
142
|
+
* 채널이 마커로 못 읽는 자리라 다르게 낸 강조(GitHub 의 `<strong>`, 슬랙의 U+2060).
|
|
143
143
|
* @returns {number}
|
|
144
144
|
*/
|
|
145
145
|
get tagEmphasis() {
|
|
@@ -175,7 +175,7 @@ export class Repairs {
|
|
|
175
175
|
wasm.__wbg_set_repairs_droppedMarker(this.__wbg_ptr, arg0);
|
|
176
176
|
}
|
|
177
177
|
/**
|
|
178
|
-
* 채널이 구문으로 읽을 글자를
|
|
178
|
+
* 채널이 구문으로 읽을 글자를 이스케이프한 수(GitHub 의 `\~`·`\<`·`\*`).
|
|
179
179
|
* @param {number} arg0
|
|
180
180
|
*/
|
|
181
181
|
set escapedChar(arg0) {
|
|
@@ -210,7 +210,7 @@ export class Repairs {
|
|
|
210
210
|
wasm.__wbg_set_repairs_strippedHtml(this.__wbg_ptr, arg0);
|
|
211
211
|
}
|
|
212
212
|
/**
|
|
213
|
-
*
|
|
213
|
+
* 채널이 마커로 못 읽는 자리라 다르게 낸 강조(GitHub 의 `<strong>`, 슬랙의 U+2060).
|
|
214
214
|
* @param {number} arg0
|
|
215
215
|
*/
|
|
216
216
|
set tagEmphasis(arg0) {
|
|
@@ -472,37 +472,30 @@ export function __wbg___wbindgen_string_get_92ab86bb19cbc12f(arg0, arg1) {
|
|
|
472
472
|
export function __wbg___wbindgen_throw_5d9e815e6fdf150f(arg0, arg1) {
|
|
473
473
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
474
474
|
}
|
|
475
|
-
export function
|
|
476
|
-
const ret = getObject(arg1).from;
|
|
477
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
478
|
-
var len1 = WASM_VECTOR_LEN;
|
|
479
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
480
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
481
|
-
}
|
|
482
|
-
export function __wbg_html_a628fe022a5daeaf(arg0) {
|
|
475
|
+
export function __wbg_html_0aa47f0cff3bfe93(arg0) {
|
|
483
476
|
const ret = getObject(arg0).html;
|
|
484
477
|
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
485
478
|
}
|
|
486
|
-
export function
|
|
479
|
+
export function __wbg_images_7df1f16cee267678(arg0, arg1) {
|
|
487
480
|
const ret = getObject(arg1).images;
|
|
488
481
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
489
482
|
var len1 = WASM_VECTOR_LEN;
|
|
490
483
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
491
484
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
492
485
|
}
|
|
493
|
-
export function
|
|
486
|
+
export function __wbg_limit_7811a23349eec87f(arg0, arg1) {
|
|
494
487
|
const ret = getObject(arg1).limit;
|
|
495
488
|
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
496
489
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
497
490
|
}
|
|
498
|
-
export function
|
|
491
|
+
export function __wbg_lineBreaks_1d80ff3d107b92c9(arg0, arg1) {
|
|
499
492
|
const ret = getObject(arg1).lineBreaks;
|
|
500
493
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
501
494
|
var len1 = WASM_VECTOR_LEN;
|
|
502
495
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
503
496
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
504
497
|
}
|
|
505
|
-
export function
|
|
498
|
+
export function __wbg_schemes_aa169c7c8566f577(arg0, arg1) {
|
|
506
499
|
const ret = getObject(arg1).schemes;
|
|
507
500
|
var ptr1 = isLikeNone(ret) ? 0 : passArrayJsValueToWasm0(ret, wasm.__wbindgen_export);
|
|
508
501
|
var len1 = WASM_VECTOR_LEN;
|
package/bundler/mdwire_bg.wasm
CHANGED
|
Binary file
|
package/js/events.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// mdwire 의 html 채널 출력을 이벤트 열로 푼다.
|
|
2
2
|
//
|
|
3
|
-
// **mdwire 가 낸 HTML 만 읽는다.** 코어가 글자를 전부
|
|
3
|
+
// **mdwire 가 낸 HTML 만 읽는다.** 코어가 글자를 전부 이스케이프하고 태그를 고정된 집합으로만
|
|
4
4
|
// 내므로(SPEC 4절) 여기서 필요한 것은 작은 토크나이저 하나다. 남이 쓴 HTML 을 넣으면 모르는
|
|
5
5
|
// 태그는 글자로 돌려준다 — 이 모듈은 새니타이저가 아니다. 안전 판단은 코어 한 곳에 있다.
|
|
6
6
|
|
package/js/react.d.ts
CHANGED
|
@@ -8,10 +8,8 @@ export type MdComponents = Partial<Record<MdTag, ElementType>>;
|
|
|
8
8
|
export interface MarkdownProps {
|
|
9
9
|
/** 에이전트가 쓴 마크다운(완성된 글). 스트리밍은 `Streamer` + `toElements` 로 — 누적본을 매번 넘기면 처음부터 다시 변환한다. */
|
|
10
10
|
text: string;
|
|
11
|
-
/** 입력 표기. 슬랙 레거시 mrkdwn 이면 "slack-mrkdwn". */
|
|
12
|
-
from?: "markdown" | "slack-mrkdwn";
|
|
13
11
|
components?: MdComponents;
|
|
14
|
-
/** 코어에 넘길 옵션 — `html` 정책(줄바꿈·이미지·스킴)이 여기 든다.
|
|
12
|
+
/** 코어에 넘길 옵션 — `html` 정책(줄바꿈·이미지·스킴)이 여기 든다. */
|
|
15
13
|
options?: RenderOptions;
|
|
16
14
|
}
|
|
17
15
|
|
|
@@ -19,7 +17,6 @@ export interface MarkdownProps {
|
|
|
19
17
|
export function Markdown(props: MarkdownProps): ReactElement;
|
|
20
18
|
|
|
21
19
|
export interface MarkdownStreamOptions {
|
|
22
|
-
from?: "markdown" | "slack-mrkdwn";
|
|
23
20
|
components?: MdComponents;
|
|
24
21
|
options?: RenderOptions;
|
|
25
22
|
/** 붙든 것(열린 강조·표 행·코드 스팬)도 먼저 그린다. 기본 `true`. `false` 면 확정된 것만. */
|
package/js/react.js
CHANGED
|
@@ -89,10 +89,9 @@ export function toElements(html, components = {}, schemes = DEFAULT_SCHEMES) {
|
|
|
89
89
|
* 보였다가 사라진다. 스트리밍은 [`useMarkdownStream`].
|
|
90
90
|
* @param {import("./react.d.ts").MarkdownProps} props
|
|
91
91
|
*/
|
|
92
|
-
export function Markdown({ text,
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
return createElement(Fragment, null, ...toElements(html, components, opts.html?.schemes ?? DEFAULT_SCHEMES));
|
|
92
|
+
export function Markdown({ text, components, options }) {
|
|
93
|
+
const html = render(text, "html", options).join("");
|
|
94
|
+
return createElement(Fragment, null, ...toElements(html, components, options?.html?.schemes ?? DEFAULT_SCHEMES));
|
|
96
95
|
}
|
|
97
96
|
|
|
98
97
|
/**
|
|
@@ -107,13 +106,18 @@ export function Markdown({ text, from, components, options }) {
|
|
|
107
106
|
* 다른가다. 같으면 훅은 다시 그리지 않는다.
|
|
108
107
|
* @param {import("./react.d.ts").MarkdownStreamOptions} [opts]
|
|
109
108
|
*/
|
|
110
|
-
export function useMarkdownStream({
|
|
109
|
+
export function useMarkdownStream({ components, options, eager = true, onSettled } = {}) {
|
|
111
110
|
const ref = useRef(null);
|
|
112
111
|
const init = useRef(null);
|
|
113
112
|
const [, rerender] = useReducer((n) => n + 1, 0);
|
|
114
113
|
if (init.current === null) {
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
init.current = () => ({
|
|
115
|
+
streamer: new Streamer("html", options),
|
|
116
|
+
acc: "",
|
|
117
|
+
done: false,
|
|
118
|
+
eager,
|
|
119
|
+
schemes: options?.html?.schemes ?? DEFAULT_SCHEMES,
|
|
120
|
+
});
|
|
117
121
|
}
|
|
118
122
|
// 해제됐으면 다시 만든다 — StrictMode 개발 모드는 이펙트를 붙였다 떼었다 다시 붙여서, 정리
|
|
119
123
|
// 함수가 스트리머를 먼저 해제한다(토큰이 오기 전이라 잃는 것은 없다).
|
package/node/mdwire.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
-
/** 변환 옵션. 생략하면
|
|
4
|
+
/** 변환 옵션. 생략하면 채널의 기본값이다. */
|
|
5
5
|
export interface RenderOptions {
|
|
6
|
-
/** 입력 표기. 슬랙 레거시 mrkdwn(`*굵게*` `~취소~`)으로 쓴 에이전트 출력이면 "slack-mrkdwn". */
|
|
7
|
-
from?: "markdown" | "slack-mrkdwn";
|
|
8
6
|
/** 조각 한도(글자 수). 생략하면 채널의 한도다 — plain 을 텔레그램에 보내면 4096. 스트리밍은 나누지 않는다. */
|
|
9
7
|
limit?: number;
|
|
10
8
|
/** 브라우저 채널("html")의 정책. 기본값이 가장 보수적이다. */
|
|
@@ -61,7 +59,7 @@ export class Repairs {
|
|
|
61
59
|
*/
|
|
62
60
|
droppedMarker: number;
|
|
63
61
|
/**
|
|
64
|
-
* 채널이 구문으로 읽을 글자를
|
|
62
|
+
* 채널이 구문으로 읽을 글자를 이스케이프한 수(GitHub 의 `\~`·`\<`·`\*`).
|
|
65
63
|
*/
|
|
66
64
|
escapedChar: number;
|
|
67
65
|
/**
|
|
@@ -81,7 +79,7 @@ export class Repairs {
|
|
|
81
79
|
*/
|
|
82
80
|
strippedHtml: number;
|
|
83
81
|
/**
|
|
84
|
-
*
|
|
82
|
+
* 채널이 마커로 못 읽는 자리라 다르게 낸 강조(GitHub 의 `<strong>`, 슬랙의 U+2060).
|
|
85
83
|
*/
|
|
86
84
|
tagEmphasis: number;
|
|
87
85
|
}
|
package/node/mdwire.js
CHANGED
|
@@ -102,7 +102,7 @@ class Repairs {
|
|
|
102
102
|
return ret >>> 0;
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
|
-
* 채널이 구문으로 읽을 글자를
|
|
105
|
+
* 채널이 구문으로 읽을 글자를 이스케이프한 수(GitHub 의 `\~`·`\<`·`\*`).
|
|
106
106
|
* @returns {number}
|
|
107
107
|
*/
|
|
108
108
|
get escapedChar() {
|
|
@@ -142,7 +142,7 @@ class Repairs {
|
|
|
142
142
|
return ret >>> 0;
|
|
143
143
|
}
|
|
144
144
|
/**
|
|
145
|
-
*
|
|
145
|
+
* 채널이 마커로 못 읽는 자리라 다르게 낸 강조(GitHub 의 `<strong>`, 슬랙의 U+2060).
|
|
146
146
|
* @returns {number}
|
|
147
147
|
*/
|
|
148
148
|
get tagEmphasis() {
|
|
@@ -178,7 +178,7 @@ class Repairs {
|
|
|
178
178
|
wasm.__wbg_set_repairs_droppedMarker(this.__wbg_ptr, arg0);
|
|
179
179
|
}
|
|
180
180
|
/**
|
|
181
|
-
* 채널이 구문으로 읽을 글자를
|
|
181
|
+
* 채널이 구문으로 읽을 글자를 이스케이프한 수(GitHub 의 `\~`·`\<`·`\*`).
|
|
182
182
|
* @param {number} arg0
|
|
183
183
|
*/
|
|
184
184
|
set escapedChar(arg0) {
|
|
@@ -213,7 +213,7 @@ class Repairs {
|
|
|
213
213
|
wasm.__wbg_set_repairs_strippedHtml(this.__wbg_ptr, arg0);
|
|
214
214
|
}
|
|
215
215
|
/**
|
|
216
|
-
*
|
|
216
|
+
* 채널이 마커로 못 읽는 자리라 다르게 낸 강조(GitHub 의 `<strong>`, 슬랙의 U+2060).
|
|
217
217
|
* @param {number} arg0
|
|
218
218
|
*/
|
|
219
219
|
set tagEmphasis(arg0) {
|
|
@@ -483,37 +483,30 @@ function __wbg_get_imports() {
|
|
|
483
483
|
__wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
|
|
484
484
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
485
485
|
},
|
|
486
|
-
|
|
487
|
-
const ret = getObject(arg1).from;
|
|
488
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
489
|
-
var len1 = WASM_VECTOR_LEN;
|
|
490
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
491
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
492
|
-
},
|
|
493
|
-
__wbg_html_a628fe022a5daeaf: function(arg0) {
|
|
486
|
+
__wbg_html_0aa47f0cff3bfe93: function(arg0) {
|
|
494
487
|
const ret = getObject(arg0).html;
|
|
495
488
|
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
496
489
|
},
|
|
497
|
-
|
|
490
|
+
__wbg_images_7df1f16cee267678: function(arg0, arg1) {
|
|
498
491
|
const ret = getObject(arg1).images;
|
|
499
492
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
500
493
|
var len1 = WASM_VECTOR_LEN;
|
|
501
494
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
502
495
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
503
496
|
},
|
|
504
|
-
|
|
497
|
+
__wbg_limit_7811a23349eec87f: function(arg0, arg1) {
|
|
505
498
|
const ret = getObject(arg1).limit;
|
|
506
499
|
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
507
500
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
508
501
|
},
|
|
509
|
-
|
|
502
|
+
__wbg_lineBreaks_1d80ff3d107b92c9: function(arg0, arg1) {
|
|
510
503
|
const ret = getObject(arg1).lineBreaks;
|
|
511
504
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
512
505
|
var len1 = WASM_VECTOR_LEN;
|
|
513
506
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
514
507
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
515
508
|
},
|
|
516
|
-
|
|
509
|
+
__wbg_schemes_aa169c7c8566f577: function(arg0, arg1) {
|
|
517
510
|
const ret = getObject(arg1).schemes;
|
|
518
511
|
var ptr1 = isLikeNone(ret) ? 0 : passArrayJsValueToWasm0(ret, wasm.__wbindgen_export);
|
|
519
512
|
var len1 = WASM_VECTOR_LEN;
|
package/node/mdwire_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@minjun0219/mdwire",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Streaming Markdown renderer for chat channels and the browser. Telegram HTML, Slack markdown_text, GitHub, HTML, React.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": { "type": "git", "url": "https://github.com/minjun0219/mdwire" },
|