@plurnk/plurnk-mimetypes-text-markdown 0.1.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 PossumTech Laboratories, LLC
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 ADDED
@@ -0,0 +1,29 @@
1
+ # @plurnk/plurnk-mimetypes-text-markdown
2
+
3
+ `text/markdown` mimetype handler for [plurnk-service](https://github.com/plurnk/plurnk-service).
4
+
5
+ ## install
6
+
7
+ ```
8
+ npm i @plurnk/plurnk-mimetypes-text-markdown
9
+ ```
10
+
11
+ ## interface
12
+
13
+ Default export is a class implementing the plurnk mimetype handler contract (see plurnk-service `MIMETYPES.md`):
14
+
15
+ ```ts
16
+ class TextMarkdown {
17
+ readonly mimetype = "text/markdown";
18
+ readonly glyph = "📝";
19
+ validate(content: string): void;
20
+ symbols(content: string): string;
21
+ preview(content: string, budget: number): string;
22
+ }
23
+ ```
24
+
25
+ `symbols` extracts an indented heading outline from the source. `preview` returns the outline (when headings exist) or the body otherwise, truncated to `budget` characters.
26
+
27
+ ## license
28
+
29
+ MIT.
@@ -0,0 +1,8 @@
1
+ export default class TextMarkdown {
2
+ readonly mimetype = "text/markdown";
3
+ readonly glyph = "\uD83D\uDCDD";
4
+ validate(_content: string): void;
5
+ symbols(content: string): string;
6
+ preview(content: string, budget: number): string;
7
+ }
8
+ //# sourceMappingURL=TextMarkdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextMarkdown.d.ts","sourceRoot":"","sources":["../src/TextMarkdown.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,OAAO,YAAY;IAC7B,QAAQ,CAAC,QAAQ,mBAAmB;IACpC,QAAQ,CAAC,KAAK,kBAAQ;IAEtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAIhC,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAchC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;CAKnD"}
@@ -0,0 +1,34 @@
1
+ // text/markdown mimetype handler for plurnk-service. Implements the
2
+ // MimetypeHandler duck contract (see MIMETYPES.md in plurnk-service):
3
+ // - mimetype: string — declared mimetype identifier
4
+ // - glyph: string — single-character display marker
5
+ // - validate(content) — throw on malformed content (markdown accepts anything)
6
+ // - symbols(content) — structural outline (heading hierarchy)
7
+ // - preview(content, budget) — bounded structural view for index tiles
8
+ export default class TextMarkdown {
9
+ mimetype = "text/markdown";
10
+ glyph = "📝";
11
+ validate(_content) {
12
+ // any string is valid markdown
13
+ }
14
+ symbols(content) {
15
+ const lines = content.split("\n");
16
+ const headings = [];
17
+ for (const line of lines) {
18
+ const match = line.match(/^(#{1,6})\s+(.+?)\s*$/);
19
+ if (match === null)
20
+ continue;
21
+ const level = match[1].length;
22
+ const text = match[2];
23
+ const indent = " ".repeat(level - 1);
24
+ headings.push(`${indent}${text}`);
25
+ }
26
+ return headings.join("\n");
27
+ }
28
+ preview(content, budget) {
29
+ const outline = this.symbols(content);
30
+ const result = outline.length > 0 ? outline : content;
31
+ return result.length <= budget ? result : result.slice(0, budget);
32
+ }
33
+ }
34
+ //# sourceMappingURL=TextMarkdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextMarkdown.js","sourceRoot":"","sources":["../src/TextMarkdown.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,sEAAsE;AACtE,oDAAoD;AACpD,oDAAoD;AACpD,+EAA+E;AAC/E,8DAA8D;AAC9D,uEAAuE;AAEvE,MAAM,CAAC,OAAO,OAAO,YAAY;IACpB,QAAQ,GAAG,eAAe,CAAC;IAC3B,KAAK,GAAG,IAAI,CAAC;IAEtB,QAAQ,CAAC,QAAgB;QACrB,+BAA+B;IACnC,CAAC;IAED,OAAO,CAAC,OAAe;QACnB,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAClC,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;YAClD,IAAI,KAAK,KAAK,IAAI;gBAAE,SAAS;YAC7B,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YAC9B,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACtB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;YACtC,QAAQ,CAAC,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,EAAE,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,CAAC,OAAe,EAAE,MAAc;QACnC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACtC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;QACtD,OAAO,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACtE,CAAC;CACJ"}
@@ -0,0 +1,3 @@
1
+ export { default } from "./TextMarkdown.ts";
2
+ export { default as TextMarkdown } from "./TextMarkdown.ts";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { default } from "./TextMarkdown.js";
2
+ export { default as TextMarkdown } from "./TextMarkdown.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@plurnk/plurnk-mimetypes-text-markdown",
3
+ "version": "0.1.0",
4
+ "description": "text/markdown mimetype handler for plurnk-service.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "engines": {
11
+ "node": ">=25"
12
+ },
13
+ "plurnk": {
14
+ "kind": "mimetype",
15
+ "name": "text/markdown"
16
+ },
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "default": "./dist/index.js"
21
+ },
22
+ "./package.json": "./package.json"
23
+ },
24
+ "files": [
25
+ "dist/**/*",
26
+ "README.md"
27
+ ],
28
+ "scripts": {
29
+ "test:lint": "tsc --noEmit",
30
+ "test:unit": "node --test src/**/*.test.ts",
31
+ "test": "npm run test:lint && npm run test:unit",
32
+ "build:dist": "tsc -p tsconfig.build.json",
33
+ "build": "npm run build:dist",
34
+ "prepare": "npm run build"
35
+ },
36
+ "devDependencies": {
37
+ "@types/node": "^25.8.0",
38
+ "typescript": "^6.0.3"
39
+ }
40
+ }