markemental 0.0.0-stage → 0.3.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 NeyaPey
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,102 @@
1
- # Temporary Holding Version
1
+ # markemental
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > **Note:** This project is still under active development. APIs may change between releases.
4
+
5
+ Incremental modular markdown renderer. Push markdown in arbitrarily-sized chunks and complete blocks render to the target as they arrive, instead of waiting for the full document.
6
+
7
+ Two pipelines cover the GFM/CommonMark flavors, and the environment is implicit: the same code drives a live page in the browser and lightweight DOMs like linkedom on the server through a minimal `DOMNodeLike` interface.
8
+
9
+ ## Features
10
+
11
+ - Streaming input: `push()` chunks as they arrive, `flush()` the remainder.
12
+ - Incremental commit: tables render row-by-row from the delimiter row on, and lists item-by-item, instead of waiting for the whole block.
13
+ - Blocks: headings, paragraphs, fenced code, bullet and ordered lists, blockquotes, thematic breaks.
14
+ - Inlines: emphasis, strong, inline code, links, images, autolinks, escapes, hard breaks.
15
+ - GFM extras: tables (with column alignment) and strikethrough; CommonMark has no tables, so table syntax renders as plain paragraph text.
16
+ - Pipelines batch DOM writes on `requestAnimationFrame` when given a scheduler.
17
+
18
+ ## Install
19
+
20
+ ```sh
21
+ npm install markemental
22
+ ```
23
+
24
+ Server-side rendering also needs a DOM implementation:
25
+
26
+ ```sh
27
+ npm install linkedom
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ Render a streamed response into a live page:
33
+
34
+ ```ts
35
+ import { createGFMPipeline } from "markemental";
36
+
37
+ const pipeline = createGFMPipeline(
38
+ document.getElementById("out")!,
39
+ document,
40
+ {},
41
+ requestAnimationFrame,
42
+ );
43
+
44
+ for await (const chunk of streamResponse()) {
45
+ await pipeline.push(chunk);
46
+ }
47
+ await pipeline.flush();
48
+ ```
49
+
50
+ Render on the server with linkedom:
51
+
52
+ ```ts
53
+ import { parseHTML } from "linkedom";
54
+ import { createGFMPipeline } from "markemental";
55
+
56
+ const { document } = parseHTML("<div></div>");
57
+ const target = document.querySelector("div")!;
58
+ const pipeline = createGFMPipeline(target, document, {});
59
+
60
+ await pipeline.push("# Hello\n\nWorld\n");
61
+ await pipeline.flush();
62
+ console.log(target.innerHTML);
63
+ ```
64
+
65
+ Pick a pipeline by flavor:
66
+
67
+ | Factory | Flavor |
68
+ |---|---|
69
+ | `createGFMPipeline` | GFM |
70
+ | `createCommonMarkPipeline` | CommonMark |
71
+
72
+ The trailing partial block is held back until more input completes it or `flush()` runs. Tables commit once the delimiter row arrives and lists commit per item, so large blocks render progressively. Pushing after `flush()` throws. See the TSDoc on each factory for details.
73
+
74
+ ## Custom renderers
75
+
76
+ Implement `MarkdownRenderer` to bring your own flavor or wrap a third-party parser, and compose it with any target through `createMarkdownPipeline`:
77
+
78
+ ```ts
79
+ import { createMarkdownPipeline, createRenderTarget } from "markemental";
80
+
81
+ const pipeline = createMarkdownPipeline(
82
+ new MyRenderer(createRenderTarget(document.getElementById("out")!), document),
83
+ );
84
+ ```
85
+
86
+ The pipeline splits pushed chunks into lines and feeds them to the renderer one at a time; the renderer owns its target, document, and parse state. See the TSDoc on `createMarkdownPipeline` and `MarkdownRenderer` for details.
87
+
88
+ ## MVP limitations
89
+
90
+ Single-line list items with basic indented nesting, single-paragraph quotes, and same-line code spans. No task lists, lazy list continuation, bare-URL autolinking, footnotes, or raw HTML passthrough yet.
91
+
92
+ ## Development
93
+
94
+ ```sh
95
+ npm install
96
+ npm run check # typecheck + build + test
97
+ npm test # vitest run
98
+ ```
99
+
100
+ ## License
101
+
102
+ MIT. See [LICENSE](LICENSE).