@wipcomputer/markdown-viewer 1.0.0 → 1.0.2
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/package.json +10 -3
- package/skills/markdown-viewer/SKILL.md +68 -0
- package/CLAUDE.md +0 -138
- package/images/01.png +0 -0
- package/images/02.png +0 -0
- package/images/03.png +0 -0
package/package.json
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wipcomputer/markdown-viewer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Simple markdown viewer with live reload. Works in all browsers including Safari.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "server.js",
|
|
7
7
|
"bin": {
|
|
8
|
-
"mdview": "
|
|
8
|
+
"mdview": "server.js"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"start": "node server.js"
|
|
12
12
|
},
|
|
13
|
-
"keywords": [
|
|
13
|
+
"keywords": [
|
|
14
|
+
"markdown",
|
|
15
|
+
"viewer",
|
|
16
|
+
"live-reload",
|
|
17
|
+
"safari",
|
|
18
|
+
"ai-agents",
|
|
19
|
+
"claude-code"
|
|
20
|
+
],
|
|
14
21
|
"author": "Parker Todd Brooks",
|
|
15
22
|
"license": "MIT",
|
|
16
23
|
"repository": {
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: markdown-viewer
|
|
3
|
+
description: Live markdown viewer with SSE reload. Works in all browsers including Safari. Zero dependencies.
|
|
4
|
+
homepage: https://github.com/wipcomputer/wip-markdown-viewer
|
|
5
|
+
metadata:
|
|
6
|
+
{
|
|
7
|
+
"openclaw":
|
|
8
|
+
{
|
|
9
|
+
"emoji": "📝",
|
|
10
|
+
"requires": { "bins": ["node"] },
|
|
11
|
+
"install":
|
|
12
|
+
[
|
|
13
|
+
{
|
|
14
|
+
"id": "npm",
|
|
15
|
+
"kind": "npm",
|
|
16
|
+
"package": "@wipcomputer/markdown-viewer",
|
|
17
|
+
"global": true,
|
|
18
|
+
"bins": ["mdview"],
|
|
19
|
+
"label": "Install markdown-viewer (npm)",
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
# Live Markdown Viewer
|
|
27
|
+
|
|
28
|
+
See your documents update in real time as your AI edits them.
|
|
29
|
+
|
|
30
|
+
## Quick start
|
|
31
|
+
|
|
32
|
+
Start the server:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
curl -s http://127.0.0.1:3000/ > /dev/null 2>&1 || mdview &
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Open a file:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
open "http://127.0.0.1:3000/view?path=/absolute/path/to/file.md"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## How it works
|
|
45
|
+
|
|
46
|
+
1. Tell your AI coding tool to install `@wipcomputer/markdown-viewer` globally
|
|
47
|
+
2. Tell your AI to open a .md file in md view
|
|
48
|
+
3. AI opens the file in your default browser
|
|
49
|
+
4. Every save re-renders the page instantly. No refresh needed.
|
|
50
|
+
|
|
51
|
+
Open multiple tabs to work on multiple documents at once.
|
|
52
|
+
|
|
53
|
+
## Features
|
|
54
|
+
|
|
55
|
+
- SSE-powered live reload (works in Safari, Chrome, Firefox)
|
|
56
|
+
- Multi-file support (each tab watches its own file)
|
|
57
|
+
- GitHub Flavored Markdown (tables, task lists, strikethrough)
|
|
58
|
+
- Syntax highlighting (180+ languages)
|
|
59
|
+
- Dark mode
|
|
60
|
+
- Table of contents
|
|
61
|
+
- Mermaid diagrams
|
|
62
|
+
- KaTeX math equations
|
|
63
|
+
|
|
64
|
+
## Notes
|
|
65
|
+
|
|
66
|
+
- The `open` command works on macOS. On Linux use `xdg-open`. On Windows use `start`.
|
|
67
|
+
- Server runs at `http://127.0.0.1:3000` by default. Use `mdview --port 8080` to change.
|
|
68
|
+
- Zero npm dependencies. Pure Node.js.
|
package/CLAUDE.md
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
# CLAUDE.md
|
|
2
|
-
|
|
3
|
-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
-
|
|
5
|
-
## Project Overview
|
|
6
|
-
|
|
7
|
-
Two versions of a feature-rich markdown viewer with syntax highlighting, diagrams, math equations, and more:
|
|
8
|
-
|
|
9
|
-
1. **Web Browser Version** (`markdown-viewer.html`) - Standalone single-file HTML application
|
|
10
|
-
2. **BBEdit Preview Template** (`bbedit-preview-template.html`) - Integration for BBEdit's preview system
|
|
11
|
-
|
|
12
|
-
Both share the same rendering features but differ in file loading and refresh mechanisms.
|
|
13
|
-
|
|
14
|
-
## Architecture
|
|
15
|
-
|
|
16
|
-
### Web Browser Version (`markdown-viewer.html` - 1,052 lines)
|
|
17
|
-
|
|
18
|
-
**Single-file architecture** with embedded CSS and JavaScript:
|
|
19
|
-
|
|
20
|
-
- **CDN Dependencies**: marked.js (markdown parsing), highlight.js (syntax highlighting), Mermaid (diagrams), KaTeX (math)
|
|
21
|
-
- **CSS Variables**: Theme system for light/dark mode (`:root` and `[data-theme="dark"]`)
|
|
22
|
-
- **Key Components**:
|
|
23
|
-
- Drop zone UI with "Load File" button (supports drag-and-drop and File System Access API)
|
|
24
|
-
- Viewer container with header controls (TOC, Theme, Load, Refresh, Export, Print)
|
|
25
|
-
- TOC sidebar (collapsible, auto-generated from headings)
|
|
26
|
-
- Markdown content area (styled with GitHub-inspired typography)
|
|
27
|
-
|
|
28
|
-
**File Loading Flow**:
|
|
29
|
-
1. Drag-and-drop OR "Load File" button → `handleDrop()` or `loadNewFile()`
|
|
30
|
-
2. `loadFile()` → FileReader reads text → `displayMarkdown()`
|
|
31
|
-
3. `displayMarkdown()` → marked.js renders → sanitize HTML → highlight code → render Mermaid/KaTeX → generate TOC
|
|
32
|
-
|
|
33
|
-
**Auto-Refresh** (Chrome/Edge only):
|
|
34
|
-
- Uses File System Access API (`showOpenFilePicker`) to get `fileHandle`
|
|
35
|
-
- `checkForChanges()` polls every 2 seconds via `fileHandle.getFile()`
|
|
36
|
-
- Compares `lastModified` timestamp and reloads if changed
|
|
37
|
-
- Safari/Firefox: No File System Access API, must manually refresh
|
|
38
|
-
|
|
39
|
-
### BBEdit Preview Template (`bbedit-preview-template.html` - 558 lines)
|
|
40
|
-
|
|
41
|
-
**Simplified version designed for BBEdit's preview system**:
|
|
42
|
-
|
|
43
|
-
- **No file loading logic**: BBEdit handles markdown parsing and injects HTML at `#DOCUMENT_CONTENT#` marker
|
|
44
|
-
- **Removed**: Drop zone, file buttons, marked.js, File System Access API, file watching
|
|
45
|
-
- **Kept**: All rendering (highlight.js, Mermaid, KaTeX), TOC generation, dark mode, export
|
|
46
|
-
- **Auto-refresh**: Native BBEdit behavior (updates on save) - no polling needed
|
|
47
|
-
|
|
48
|
-
**Template Integration**:
|
|
49
|
-
1. BBEdit parses markdown → HTML
|
|
50
|
-
2. Injects at `#DOCUMENT_CONTENT#` marker in template
|
|
51
|
-
3. Template JavaScript runs: syntax highlight → render diagrams/math → generate TOC
|
|
52
|
-
4. Updates automatically when file is saved in BBEdit
|
|
53
|
-
|
|
54
|
-
**Installation**: Copy to `~/Library/Application Support/BBEdit/Preview Templates/`
|
|
55
|
-
|
|
56
|
-
## Key Features (Both Versions)
|
|
57
|
-
|
|
58
|
-
- **Syntax highlighting**: highlight.js with auto-detection (180+ languages)
|
|
59
|
-
- **Mermaid diagrams**: Renders flowcharts, sequence diagrams, etc. from code blocks
|
|
60
|
-
- **Math equations**: KaTeX renders inline `$...$` and display `$$...$$` LaTeX
|
|
61
|
-
- **Table of Contents**: Auto-generated from h1-h4, smooth scroll navigation
|
|
62
|
-
- **Dark mode**: Toggleable with localStorage persistence, updates highlight.js/Mermaid themes
|
|
63
|
-
- **GitHub Flavored Markdown**: Tables, task lists, strikethrough via marked.js GFM mode
|
|
64
|
-
- **XSS Protection**: Basic sanitization (removes `<script>`, validates `<iframe>` src)
|
|
65
|
-
|
|
66
|
-
## Development
|
|
67
|
-
|
|
68
|
-
### Testing Web Version
|
|
69
|
-
```bash
|
|
70
|
-
open markdown-viewer.html # macOS
|
|
71
|
-
# or open in any browser
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
Test with `demo/demo.md` which includes examples of all features.
|
|
75
|
-
|
|
76
|
-
### Testing BBEdit Template
|
|
77
|
-
```bash
|
|
78
|
-
# Copy template to BBEdit folder
|
|
79
|
-
cp bbedit-preview-template.html ~/Library/Application\ Support/BBEdit/Preview\ Templates/
|
|
80
|
-
|
|
81
|
-
# Open demo in BBEdit
|
|
82
|
-
open -a BBEdit demo/demo.md
|
|
83
|
-
|
|
84
|
-
# Press ⌃⌘P to preview, select template from menu
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Making Changes
|
|
88
|
-
|
|
89
|
-
**When modifying features:**
|
|
90
|
-
- Update BOTH files if feature is shared (syntax highlighting, dark mode, TOC, etc.)
|
|
91
|
-
- Update only web version for file loading/refresh logic
|
|
92
|
-
- Update only BBEdit version for template-specific behavior
|
|
93
|
-
|
|
94
|
-
**Key areas that differ between versions:**
|
|
95
|
-
- Web: Lines 484-520 (drop zone), 579-891 (file loading/watching)
|
|
96
|
-
- BBEdit: No file loading, uses `#DOCUMENT_CONTENT#` marker at line 401
|
|
97
|
-
|
|
98
|
-
**CSS theming:**
|
|
99
|
-
- Both use CSS variables (`:root` for light, `[data-theme="dark"]` for dark)
|
|
100
|
-
- Changing colors: Update CSS variables at top of `<style>` section
|
|
101
|
-
- Highlight.js theme switches via DOM: `document.getElementById('highlight-theme').href = ...`
|
|
102
|
-
|
|
103
|
-
## Common Tasks
|
|
104
|
-
|
|
105
|
-
### Adding a new CDN library
|
|
106
|
-
Add `<script>` or `<link>` in `<head>` section of both files (after existing CDN includes).
|
|
107
|
-
|
|
108
|
-
### Updating markdown renderer options
|
|
109
|
-
Web version only: Modify `marked.setOptions()` around line 496-509.
|
|
110
|
-
BBEdit version: BBEdit handles markdown parsing (cmark/GFM/MultiMarkdown configurable in BBEdit preferences).
|
|
111
|
-
|
|
112
|
-
### Changing dark mode colors
|
|
113
|
-
Update CSS variables in `[data-theme="dark"]` block (lines 34-47 in web version, similar in BBEdit).
|
|
114
|
-
|
|
115
|
-
### Modifying TOC generation
|
|
116
|
-
Both files: `generateTOC()` function queries `h1-h4` and builds sidebar list with smooth scroll.
|
|
117
|
-
|
|
118
|
-
## Repository Structure
|
|
119
|
-
|
|
120
|
-
```
|
|
121
|
-
.
|
|
122
|
-
├── markdown-viewer.html # Web browser version
|
|
123
|
-
├── bbedit-preview-template.html # BBEdit preview template
|
|
124
|
-
├── demo/
|
|
125
|
-
│ ├── demo.md # Feature demonstration file
|
|
126
|
-
│ └── demo-image.png # Test image (referenced in demo.md)
|
|
127
|
-
├── images/ # Screenshots for README
|
|
128
|
-
├── README.md # User documentation (installation, usage)
|
|
129
|
-
├── LICENSE # MIT License
|
|
130
|
-
└── CLAUDE.md # This file
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
## Important Notes
|
|
134
|
-
|
|
135
|
-
- **No build process**: Files are standalone HTML, edit and refresh
|
|
136
|
-
- **Image paths in markdown**: Relative to markdown file location (BBEdit resolves correctly)
|
|
137
|
-
- **Browser compatibility**: Auto-refresh requires File System Access API (Chrome/Edge/Opera only)
|
|
138
|
-
- **BBEdit markdown parsers**: Users can choose cmark, GFM, MultiMarkdown, or Pandoc in BBEdit preferences
|
package/images/01.png
DELETED
|
Binary file
|
package/images/02.png
DELETED
|
Binary file
|
package/images/03.png
DELETED
|
Binary file
|