@profullstack/readm3 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 readm3 contributors
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,127 @@
1
+ # readm3
2
+
3
+ A terminal markdown reader. File browser on the left, the rendered document on
4
+ the right, and nothing else in the way.
5
+
6
+ Built on [HQTUI](https://github.com/profullstack/hqtui) — truecolor, mouse, and
7
+ a terminal that gets restored no matter how the process dies.
8
+
9
+ ```
10
+ ╭─ readm3 ──────────── 6 ─╮╭─ README.md ────────────────────────────────────── 24% ─╮
11
+ │ ▾ docs ││ readm3 │
12
+ │ usage.md ││ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │
13
+ │ README.md ││ │
14
+ │ CHANGELOG.md ││ A terminal markdown reader. File browser on the left, the │
15
+ │ ││ rendered document on the right. │
16
+ │ ││ │
17
+ │ ││ Install │
18
+ │ ││ ───────── │
19
+ │ ││ │
20
+ │ ││ ┌─ bash ──────────────────────────────────────────────── │
21
+ │ ││ │ bun add -g @profullstack/readm3 │
22
+ │ ││ └──────────────────────────────────────────────────────── │
23
+ ╰───────────────────────────╯╰──────────────────────────────────────────────────────────╯
24
+ ↑↓ move ↵ open ←→ fold / find tab reader ? keys q quit docs dark
25
+ ```
26
+
27
+ ## Install
28
+
29
+ ```bash
30
+ bun add -g @profullstack/readm3 # Bun is the default runtime
31
+ npm install -g @profullstack/readm3 # Node 22.6+ works too
32
+ ```
33
+
34
+ Or run it without installing:
35
+
36
+ ```bash
37
+ bunx @profullstack/readm3
38
+ npx @profullstack/readm3
39
+ ```
40
+
41
+ ## Use
42
+
43
+ ```bash
44
+ readm3 # browse markdown under the current directory
45
+ readm3 ./docs # browse a directory
46
+ readm3 CHANGELOG.md # open a file, browse its directory
47
+ readm3 --theme nord # pick a palette
48
+ ```
49
+
50
+ The browser only shows markdown. Directories with nothing beneath them are
51
+ pruned, `node_modules` and friends are never walked, and README sorts first.
52
+
53
+ ## Keys
54
+
55
+ | | | | |
56
+ |---|---|---|---|
57
+ | `↑` `↓` `j` `k` | move or scroll | `tab` | switch pane |
58
+ | `→` `←` `l` `h` | expand or collapse | `/` | filter files |
59
+ | `enter` | open the file | `esc` | clear the filter |
60
+ | `space` `b` | page down / up | `r` | rescan and reload |
61
+ | `g` `G` | top / bottom | `[` `]` | sidebar width |
62
+ | `?` | help | `q` `ctrl+c` | quit |
63
+
64
+ The mouse works too: the wheel scrolls whichever pane it is over, and a click
65
+ opens a file.
66
+
67
+ ## What it renders
68
+
69
+ Headings, **bold**, *italic*, `inline code`, links, fenced and indented code
70
+ blocks with a language label, ordered and unordered lists, nested lists, task
71
+ lists, blockquotes, tables with per-column alignment, horizontal rules, images
72
+ as labelled placeholders, and YAML front matter — shown rather than hidden,
73
+ because it is usually what you opened the file for.
74
+
75
+ The HTML that real READMEs are full of is folded back into markdown rather than
76
+ printed as tags, and inline code is held out of that, so `Array<string>`
77
+ survives.
78
+
79
+ ## Options
80
+
81
+ ```
82
+ -t, --theme <name> dark, dracula, nord, tokyo-night, gruvbox, matrix,
83
+ monochrome, high-contrast, light
84
+ -w, --width <n> sidebar width in columns (default: 28% of the terminal)
85
+ -a, --all include dot-directories and dotfiles
86
+ -M, --no-mouse disable mouse tracking
87
+ -v, --version
88
+ -h, --help
89
+ ```
90
+
91
+ ## As a library
92
+
93
+ The renderer and the file tree are pure and need no terminal, so they can be
94
+ reused on their own:
95
+
96
+ ```ts
97
+ import { renderMarkdown, toText, scan, files } from "@profullstack/readm3";
98
+
99
+ const lines = renderMarkdown("# Hello\n\nSome **text**.", 60);
100
+ console.log(toText(lines));
101
+ // [ 'Hello', '━━━…', '', 'Some text.' ]
102
+
103
+ for (const file of files(scan("./docs"))) console.log(file.path);
104
+ ```
105
+
106
+ `renderMarkdown` returns lines of spans carrying a semantic `role` — `h1`,
107
+ `code`, `link`, `quote` and so on — rather than colors, so the same document can
108
+ be re-themed without re-parsing.
109
+
110
+ ## Runtimes
111
+
112
+ Bun is the default. Node 22.6+ runs the same code. Tested on Linux, macOS and
113
+ Windows Terminal.
114
+
115
+ ## Develop
116
+
117
+ ```bash
118
+ bun install
119
+ bun src/cli.ts . # run it against its own repo
120
+ bun test test/ # 48 tests, no TTY needed
121
+ bun run typecheck
122
+ bun run build
123
+ ```
124
+
125
+ ## License
126
+
127
+ MIT.
package/bin/readm3.mjs ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import { main } from "../dist/cli.js";
3
+
4
+ main(process.argv.slice(2)).catch((error) => {
5
+ console.error(error instanceof Error ? error.message : error);
6
+ process.exit(1);
7
+ });
package/dist/cli.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { type ViewerOptions } from "./viewer.ts";
2
+ export declare const VERSION = "0.1.0";
3
+ export interface ParsedArgs extends ViewerOptions {
4
+ help: boolean;
5
+ version: boolean;
6
+ }
7
+ export declare function parseArgs(argv: string[]): ParsedArgs;
8
+ export declare function main(argv?: string[]): Promise<void>;
9
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAOA,OAAO,EAAO,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAEtD,eAAO,MAAM,OAAO,UAAU,CAAC;AA2B/B,MAAM,WAAW,UAAW,SAAQ,aAAa;IAC/C,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAID,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAuEpD;AAED,wBAAsB,IAAI,CAAC,IAAI,GAAE,MAAM,EAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BhF"}
package/dist/cli.js ADDED
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Argument parsing and entry point. `readm3 --help` is the contract.
3
+ */
4
+ import { statSync } from "node:fs";
5
+ import { dirname, resolve } from "node:path";
6
+ import { pathToFileURL } from "node:url";
7
+ import { themeList } from "@profullstack/hqtui";
8
+ import { run } from "./viewer.js";
9
+ export const VERSION = "0.1.0";
10
+ const USAGE = `readm3 — a terminal markdown reader
11
+
12
+ Usage
13
+ readm3 [path] [options]
14
+
15
+ path A directory to browse, or a file to open. Defaults to the
16
+ current directory.
17
+
18
+ Options
19
+ -t, --theme <name> Color theme. One of: ${themeList.map((t) => t.name).join(", ")}
20
+ -w, --width <n> Sidebar width in columns. Default: 28% of the terminal
21
+ -a, --all Include dot-directories and dotfiles
22
+ -M, --no-mouse Disable mouse tracking
23
+ -v, --version Print the version
24
+ -h, --help Print this help
25
+
26
+ Keys
27
+ up/down j k move or scroll tab switch pane
28
+ right/left l h expand or collapse / filter files
29
+ enter open the file r rescan and reload
30
+ space / b page down / up [ ] sidebar width
31
+ g / G top / bottom ? help
32
+ q quit
33
+ `;
34
+ class UsageError extends Error {
35
+ }
36
+ export function parseArgs(argv) {
37
+ const parsed = {
38
+ root: process.cwd(),
39
+ help: false,
40
+ version: false,
41
+ mouse: true,
42
+ all: false,
43
+ };
44
+ let target;
45
+ for (let i = 0; i < argv.length; i++) {
46
+ const arg = argv[i];
47
+ const next = () => {
48
+ const value = argv[++i];
49
+ if (value === undefined)
50
+ throw new UsageError(`${arg} needs a value`);
51
+ return value;
52
+ };
53
+ switch (arg) {
54
+ case "-h":
55
+ case "--help":
56
+ parsed.help = true;
57
+ break;
58
+ case "-v":
59
+ case "--version":
60
+ parsed.version = true;
61
+ break;
62
+ case "-t":
63
+ case "--theme":
64
+ parsed.theme = next();
65
+ break;
66
+ case "-w":
67
+ case "--width": {
68
+ const value = Number.parseInt(next(), 10);
69
+ if (!Number.isFinite(value) || value <= 0)
70
+ throw new UsageError("--width needs a positive number");
71
+ parsed.sidebar = value;
72
+ break;
73
+ }
74
+ case "-a":
75
+ case "--all":
76
+ parsed.all = true;
77
+ break;
78
+ case "-M":
79
+ case "--no-mouse":
80
+ parsed.mouse = false;
81
+ break;
82
+ default:
83
+ if (arg.startsWith("-") && arg !== "-")
84
+ throw new UsageError(`Unknown option: ${arg}`);
85
+ if (target !== undefined)
86
+ throw new UsageError("Only one path may be given");
87
+ target = arg;
88
+ break;
89
+ }
90
+ }
91
+ if (target !== undefined) {
92
+ const path = resolve(target);
93
+ let isDir;
94
+ try {
95
+ isDir = statSync(path).isDirectory();
96
+ }
97
+ catch {
98
+ throw new UsageError(`No such file or directory: ${target}`);
99
+ }
100
+ if (isDir) {
101
+ parsed.root = path;
102
+ }
103
+ else {
104
+ parsed.root = dirname(path);
105
+ parsed.open = path;
106
+ }
107
+ }
108
+ return parsed;
109
+ }
110
+ export async function main(argv = process.argv.slice(2)) {
111
+ let args;
112
+ try {
113
+ args = parseArgs(argv);
114
+ }
115
+ catch (error) {
116
+ if (error instanceof UsageError) {
117
+ process.stderr.write(`readm3: ${error.message}\n\n${USAGE}`);
118
+ process.exitCode = 2;
119
+ return;
120
+ }
121
+ throw error;
122
+ }
123
+ if (args.help) {
124
+ process.stdout.write(USAGE);
125
+ return;
126
+ }
127
+ if (args.version) {
128
+ process.stdout.write(`${VERSION}\n`);
129
+ return;
130
+ }
131
+ if (!process.stdout.isTTY) {
132
+ process.stderr.write("readm3: needs a terminal. Try `readm3 --help`.\n");
133
+ process.exitCode = 1;
134
+ return;
135
+ }
136
+ await run(args);
137
+ }
138
+ // Running the source directly (`bun src/cli.ts`, `node src/cli.ts`) should start
139
+ // the reader. The published bin calls `main` itself, so this stays quiet there.
140
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
141
+ void main().catch((error) => {
142
+ process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
143
+ process.exit(1);
144
+ });
145
+ }
146
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAsB,MAAM,aAAa,CAAC;AAEtD,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,MAAM,KAAK,GAAG;;;;;;;;;8CASgC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;;;;;;;;CAcpF,CAAC;AAOF,MAAM,UAAW,SAAQ,KAAK;CAAG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AAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * readm3 — a terminal markdown reader.
3
+ *
4
+ * The renderer and the file tree are exported so they can be reused: both are
5
+ * pure, and neither needs a terminal.
6
+ */
7
+ export { renderMarkdown, parseInline, wrapSpans, plain, toText } from "./markdown.ts";
8
+ export type { Line, Span, Role } from "./markdown.ts";
9
+ export { scan, flatten, files, filterTree, matches, reveal, indexOfPath, label, MARKDOWN, DEFAULT_IGNORE, } from "./tree.ts";
10
+ export type { Entry, FlatEntry, ScanOptions } from "./tree.ts";
11
+ export { run } from "./viewer.ts";
12
+ export type { ViewerOptions } from "./viewer.ts";
13
+ export { main, parseArgs, VERSION } from "./cli.ts";
14
+ export type { ParsedArgs } from "./cli.ts";
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACtF,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EACL,IAAI,EACJ,OAAO,EACP,KAAK,EACL,UAAU,EACV,OAAO,EACP,MAAM,EACN,WAAW,EACX,KAAK,EACL,QAAQ,EACR,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACpD,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * readm3 — a terminal markdown reader.
3
+ *
4
+ * The renderer and the file tree are exported so they can be reused: both are
5
+ * pure, and neither needs a terminal.
6
+ */
7
+ export { renderMarkdown, parseInline, wrapSpans, plain, toText } from "./markdown.js";
8
+ export { scan, flatten, files, filterTree, matches, reveal, indexOfPath, label, MARKDOWN, DEFAULT_IGNORE, } from "./tree.js";
9
+ export { run } from "./viewer.js";
10
+ export { main, parseArgs, VERSION } from "./cli.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEtF,OAAO,EACL,IAAI,EACJ,OAAO,EACP,KAAK,EACL,UAAU,EACV,OAAO,EACP,MAAM,EACN,WAAW,EACX,KAAK,EACL,QAAQ,EACR,cAAc,GACf,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,35 @@
1
+ export type Role = "text" | "h1" | "h2" | "h3" | "code" | "fence" | "gutter" | "lang" | "link" | "url" | "quote" | "bullet" | "rule" | "meta" | "th";
2
+ export interface Span {
3
+ text: string;
4
+ role?: Role;
5
+ bold?: boolean;
6
+ italic?: boolean;
7
+ underline?: boolean;
8
+ dim?: boolean;
9
+ }
10
+ export interface Line {
11
+ spans: Span[];
12
+ }
13
+ type Style = Omit<Span, "text">;
14
+ /** The visible text of a line, with all styling dropped. Handy in tests. */
15
+ export declare function plain(line: Line): string;
16
+ /** Every line as plain text. */
17
+ export declare function toText(lines: Line[]): string[];
18
+ /**
19
+ * Fold the HTML that real READMEs are full of back into markdown.
20
+ *
21
+ * Inline code is held out of this: `Array<string>` must survive tag stripping.
22
+ */
23
+ export declare function normalizeHtml(src: string): string;
24
+ export declare function parseInline(src: string, base?: Style): Span[];
25
+ /** Greedy word wrap that carries each word's styling with it. */
26
+ export declare function wrapSpans(spans: Span[], width: number, first?: number, hanging?: number): Line[];
27
+ /**
28
+ * Render markdown to styled lines already wrapped to `width`.
29
+ *
30
+ * `width` is the pane's interior, so a resize re-renders rather than reflows —
31
+ * cheap, and it keeps tables and code gutters honest.
32
+ */
33
+ export declare function renderMarkdown(source: string, width: number): Line[];
34
+ export {};
35
+ //# sourceMappingURL=markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,IAAI,GACZ,MAAM,GACN,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,MAAM,GACN,OAAO,GACP,QAAQ,GACR,MAAM,GACN,MAAM,GACN,KAAK,GACL,OAAO,GACP,QAAQ,GACR,MAAM,GACN,MAAM,GACN,IAAI,CAAC;AAET,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,IAAI,EAAE,CAAC;CACf;AAED,KAAK,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAehC,4EAA4E;AAC5E,wBAAgB,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAExC;AAED,gCAAgC;AAChC,wBAAg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