peekmd 1.0.0 → 1.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/README.md +155 -36
- package/cli.ts +7 -0
- package/index.ts +1190 -0
- package/package.json +8 -11
- package/dist/cli.js +0 -51307
- package/dist/index.js +0 -51303
package/README.md
CHANGED
|
@@ -1,86 +1,205 @@
|
|
|
1
1
|
# peekmd
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/peekmd)
|
|
4
|
+
[](https://www.npmjs.com/package/peekmd)
|
|
5
|
+
[](https://github.com/HelgeSverre/peekmd/releases)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
3
8
|
A CLI tool to preview markdown files with GitHub-style rendering in your browser.
|
|
4
9
|
|
|
5
10
|
## Features
|
|
6
11
|
|
|
7
|
-
- GitHub
|
|
12
|
+
- GitHub Flavored Markdown (GFM) rendering
|
|
8
13
|
- Syntax highlighting for code blocks
|
|
14
|
+
- GitHub-style alerts (`[!NOTE]`, `[!TIP]`, `[!WARNING]`, `[!IMPORTANT]`, `[!CAUTION]`)
|
|
15
|
+
- Task lists with checkboxes
|
|
16
|
+
- Anchor links on headings
|
|
17
|
+
- File tree sidebar
|
|
9
18
|
- Opens in your default browser automatically
|
|
10
|
-
-
|
|
19
|
+
- Auto-closes when you close the browser tab
|
|
11
20
|
- Cross-platform: macOS, Linux, Windows
|
|
12
21
|
|
|
22
|
+
## Requirements
|
|
23
|
+
|
|
24
|
+
**[Bun](https://bun.sh) is required** to run peekmd. Install it with:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
curl -fsSL https://bun.sh/install | bash
|
|
28
|
+
```
|
|
29
|
+
|
|
13
30
|
## Installation
|
|
14
31
|
|
|
15
|
-
###
|
|
32
|
+
### Quick Run (no install)
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Using bunx (recommended)
|
|
36
|
+
bunx peekmd README.md
|
|
37
|
+
|
|
38
|
+
# Using npx (requires Bun in PATH)
|
|
39
|
+
npx peekmd README.md
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Global Installation
|
|
16
43
|
|
|
17
44
|
```bash
|
|
18
|
-
|
|
45
|
+
# Using bun (recommended)
|
|
46
|
+
bun install -g peekmd
|
|
47
|
+
|
|
48
|
+
# Using npm (requires Bun in PATH)
|
|
49
|
+
npm install -g peekmd
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Then run from anywhere:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
peekmd README.md
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Manual Installation (from source)
|
|
59
|
+
|
|
60
|
+
Clone the repository and choose one of the following approaches:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
git clone https://github.com/HelgeSverre/peekmd.git
|
|
19
64
|
cd peekmd
|
|
20
65
|
bun install
|
|
21
|
-
bun build ./index.ts --compile --outfile peekmd
|
|
22
|
-
chmod +x peekmd
|
|
23
|
-
./peekmd README.md
|
|
24
66
|
```
|
|
25
67
|
|
|
26
|
-
|
|
68
|
+
#### Option A: Link for Development
|
|
69
|
+
|
|
70
|
+
This creates a symlink so you can run `peekmd` from anywhere. Requires Bun to be in your PATH.
|
|
27
71
|
|
|
28
72
|
```bash
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
chmod +x peekmd
|
|
73
|
+
bun link
|
|
74
|
+
```
|
|
32
75
|
|
|
33
|
-
|
|
34
|
-
curl -L https://github.com/yourusername/peekmd/releases/download/v1.0.0/peekmd-macos-x64 -o peekmd
|
|
35
|
-
chmod +x peekmd
|
|
76
|
+
Now you can run:
|
|
36
77
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
78
|
+
```bash
|
|
79
|
+
peekmd /path/to/file.md
|
|
80
|
+
```
|
|
40
81
|
|
|
41
|
-
|
|
42
|
-
|
|
82
|
+
To unlink later:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
bun unlink peekmd
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### Option B: Build Standalone Binary
|
|
89
|
+
|
|
90
|
+
This creates a self-contained executable that works without Bun installed at runtime.
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
bun run compile
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
This creates a `peekmd` binary in the project directory. Move it to your PATH:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# macOS/Linux
|
|
100
|
+
sudo mv peekmd /usr/local/bin/
|
|
101
|
+
|
|
102
|
+
# Or add to your local bin
|
|
103
|
+
mv peekmd ~/.local/bin/
|
|
43
104
|
```
|
|
44
105
|
|
|
45
106
|
## Usage
|
|
46
107
|
|
|
47
108
|
```bash
|
|
48
109
|
# Preview a README file
|
|
49
|
-
|
|
110
|
+
peekmd README.md
|
|
50
111
|
|
|
51
112
|
# Preview any markdown file
|
|
52
|
-
|
|
113
|
+
peekmd docs/guide.md
|
|
53
114
|
|
|
54
115
|
# Preview with full path
|
|
55
|
-
|
|
116
|
+
peekmd /path/to/file.md
|
|
56
117
|
```
|
|
57
118
|
|
|
58
|
-
## Options
|
|
59
|
-
|
|
60
|
-
No options required. Simply pass the markdown file path.
|
|
61
|
-
|
|
62
119
|
## Controls
|
|
63
120
|
|
|
64
121
|
- Press `ESC` to close the preview
|
|
65
122
|
- Close the browser tab to exit
|
|
66
123
|
|
|
67
|
-
##
|
|
124
|
+
## What it does
|
|
125
|
+
|
|
126
|
+
peekmd renders your markdown files with a GitHub-style interface by:
|
|
127
|
+
|
|
128
|
+
1. **Reading the markdown file** specified in the CLI argument
|
|
129
|
+
2. **Extracting metadata**:
|
|
130
|
+
- **Description**: Finds the first paragraph after any heading (filters out headings, lists, and code blocks)
|
|
131
|
+
- **Topics**: Generates placeholder tags based on the repository name (currently hardcoded: "markdown", "preview", "documentation")
|
|
132
|
+
- **Repository stats**: Placeholder values for stars (0), watchers (1), and forks (0)
|
|
133
|
+
3. **Generating a file tree**: Creates a directory tree view of the current working directory (up to 3 levels deep, max 20 items per level)
|
|
134
|
+
4. **Rendering the markdown**: Converts markdown to HTML with:
|
|
135
|
+
- GitHub Flavored Markdown (GFM) support
|
|
136
|
+
- Syntax highlighting for code blocks
|
|
137
|
+
- GitHub-style alerts (`[!NOTE]`, `[!TIP]`, etc.)
|
|
138
|
+
- Task lists with checkboxes
|
|
139
|
+
- Anchor links on headings
|
|
140
|
+
5. **Replacing template placeholders**:
|
|
141
|
+
- `{{filename}}` - The markdown filename
|
|
142
|
+
- `{{repoName}}` - The parent directory name
|
|
143
|
+
- `{{dirPath}}` - The relative directory path
|
|
144
|
+
- `{{content}}` - The rendered markdown HTML
|
|
145
|
+
- `{{fileTree}}` - The directory tree structure
|
|
146
|
+
- `{{description}}` - The extracted description
|
|
147
|
+
- `{{topics}}` - The generated topic tags
|
|
148
|
+
- `{{stars}}`, `{{watchers}}`, `{{forks}}` - Repository stats
|
|
149
|
+
6. **Starting a local server** on port 3456 and opening the preview in your default browser
|
|
150
|
+
|
|
151
|
+
## Development
|
|
68
152
|
|
|
69
153
|
```bash
|
|
70
|
-
#
|
|
71
|
-
bun
|
|
154
|
+
# Run in development mode
|
|
155
|
+
bun run dev
|
|
72
156
|
|
|
73
|
-
#
|
|
74
|
-
bun
|
|
157
|
+
# Format code
|
|
158
|
+
bun run format
|
|
75
159
|
|
|
76
|
-
#
|
|
160
|
+
# Build standalone binary
|
|
161
|
+
bun run compile
|
|
77
162
|
```
|
|
78
163
|
|
|
79
|
-
##
|
|
164
|
+
## Why Bun?
|
|
165
|
+
|
|
166
|
+
peekmd uses Bun's built-in HTTP server (`Bun.serve()`) for its simplicity and performance. This means:
|
|
167
|
+
|
|
168
|
+
- Zero configuration HTTP server
|
|
169
|
+
- Native TypeScript execution
|
|
170
|
+
- Fast startup time
|
|
171
|
+
- Small package size (ships TypeScript source, no build step needed)
|
|
172
|
+
|
|
173
|
+
## Troubleshooting
|
|
174
|
+
|
|
175
|
+
### "bun: command not found"
|
|
176
|
+
|
|
177
|
+
Bun is not installed or not in your PATH. Install it:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
curl -fsSL https://bun.sh/install | bash
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Then restart your terminal or run:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
source ~/.bashrc # or ~/.zshrc
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### "ReferenceError: Bun is not defined"
|
|
190
|
+
|
|
191
|
+
You're running with Node.js instead of Bun. This can happen if:
|
|
192
|
+
|
|
193
|
+
- You installed an older version of peekmd
|
|
194
|
+
- The shebang is incorrect
|
|
195
|
+
|
|
196
|
+
Update to the latest version:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
bun install -g peekmd@latest
|
|
200
|
+
```
|
|
80
201
|
|
|
81
|
-
|
|
82
|
-
- No external dependencies (self-contained binary)
|
|
83
|
-
- Default browser for preview
|
|
202
|
+
Or if running from source, make sure `cli.ts` has `#!/usr/bin/env bun` as the first line.
|
|
84
203
|
|
|
85
204
|
## License
|
|
86
205
|
|