markemental 0.0.0-stage → 0.2.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,89 @@
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
+ Four pipelines cover the frontend/backend × GFM/CommonMark matrix. Rendering targets a minimal `DOMNodeLike` interface, so the same code drives a live page in the browser and lightweight DOMs like linkedom on the server.
8
+
9
+ ## Features
10
+
11
+ - Streaming input: `push()` chunks as they arrive, `flush()` the remainder.
12
+ - Blocks: headings, paragraphs, fenced code, bullet and ordered lists, blockquotes, thematic breaks.
13
+ - Inlines: emphasis, strong, inline code, links, images, autolinks, escapes, hard breaks.
14
+ - GFM extras: tables (with column alignment) and strikethrough; CommonMark pipelines degrade tables to paragraphs.
15
+ - Frontend pipelines batch DOM writes on `requestAnimationFrame` when given a scheduler.
16
+
17
+ ## Install
18
+
19
+ ```sh
20
+ npm install markemental
21
+ ```
22
+
23
+ Server-side rendering also needs a DOM implementation:
24
+
25
+ ```sh
26
+ npm install linkedom
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ Render a streamed response into a live page:
32
+
33
+ ```ts
34
+ import { createFrontendGFMPipeline } from "markemental";
35
+
36
+ const pipeline = createFrontendGFMPipeline(
37
+ document.getElementById("out")!,
38
+ document,
39
+ {},
40
+ requestAnimationFrame,
41
+ );
42
+
43
+ for await (const chunk of streamResponse()) {
44
+ await pipeline.push(chunk);
45
+ }
46
+ await pipeline.flush();
47
+ ```
48
+
49
+ Render on the server with linkedom:
50
+
51
+ ```ts
52
+ import { parseHTML } from "linkedom";
53
+ import { createBackendGFMPipeline } from "markemental";
54
+
55
+ const { document } = parseHTML("<div></div>");
56
+ const target = document.querySelector("div")!;
57
+ const pipeline = createBackendGFMPipeline(target, document, {});
58
+
59
+ await pipeline.push("# Hello\n\nWorld\n");
60
+ await pipeline.flush();
61
+ console.log(target.innerHTML);
62
+ ```
63
+
64
+ Pick a pipeline by environment and flavor:
65
+
66
+ | Factory | Environment | Flavor |
67
+ |---|---|---|
68
+ | `createFrontendGFMPipeline` | browser | GFM |
69
+ | `createFrontendCommonMarkPipeline` | browser | CommonMark |
70
+ | `createBackendGFMPipeline` | server | GFM |
71
+ | `createBackendCommonMarkPipeline` | server | CommonMark |
72
+
73
+ The trailing partial block is held back until more input completes it or `flush()` runs. Pushing after `flush()` throws. See the TSDoc on each factory for details.
74
+
75
+ ## MVP limitations
76
+
77
+ Single-line list items, flat lists, single-paragraph quotes, and same-line code spans. No task lists, bare-URL autolinking, footnotes, or raw HTML passthrough yet.
78
+
79
+ ## Development
80
+
81
+ ```sh
82
+ npm install
83
+ npm run check # typecheck + build + test
84
+ npm test # vitest run
85
+ ```
86
+
87
+ ## License
88
+
89
+ MIT. See [LICENSE](LICENSE).