markdown-novel-viewer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese[IMPORTANT] Useto break ALL work into small tasks BEFORE starting — including tasks for each file read. This prevents context loss from long files. For simple tasks, AI MUST ask user whether to skip.TaskCreate
[重要提示] 开始工作前请使用将所有工作拆分为小任务,包括每个文件读取的任务。这可以避免长文件导致的上下文丢失。对于简单任务,AI必须询问用户是否跳过拆分。TaskCreate
Quick Summary
快速概览
Goal: Background HTTP server that renders markdown files with a calm, book-like reading UI and browses directories.
Workflow:
- Start Server — Point at a markdown file or directory with CLI options
- View Content — Novel-themed reader (serif fonts, warm colors) or directory browser
- Navigate Plans — Auto-detects plan structures with sidebar, phase status, keyboard shortcuts
Key Rules:
- Requires before first use (marked, highlight.js, gray-matter)
npm install - Use slash command for quick access
/preview - Supports background mode, remote access via
--host 0.0.0.0
Be skeptical. Apply critical thinking, sequential thinking. Every claim needs traced proof.
目标: 后台运行的HTTP服务器,可渲染Markdown文件、提供舒缓的类书籍阅读UI,同时支持目录浏览。
工作流程:
- 启动服务器 — 通过CLI选项指定要打开的Markdown文件或目录
- 查看内容 — 小说风格阅读器(衬线字体、暖色调)或目录浏览器
- 导航计划 — 自动检测计划结构,支持侧边栏、阶段状态、键盘快捷键
核心规则:
- 首次使用前需要执行安装依赖(marked、highlight.js、gray-matter)
npm install - 使用斜杠命令快速访问
/preview - 支持后台模式,通过参数支持远程访问
--host 0.0.0.0
请保持怀疑态度,运用批判性思维、顺序思考,每一项主张都需要可追溯的证明。
markdown-novel-viewer
markdown-novel-viewer
Background HTTP server rendering markdown files with calm, book-like reading experience.
后台运行的HTTP服务器,用于渲染Markdown文件,提供舒缓的、类书籍的阅读体验。
⚠️ Installation Required
⚠️ 需要安装依赖
This skill requires npm dependencies. Run one of the following:
bash
undefined本skill需要安装npm依赖。 运行以下命令之一:
bash
undefinedOption 1: Install via ClaudeKit CLI (recommended)
Option 1: Install via ClaudeKit CLI (recommended)
ck init # Runs install.sh which handles all skills
ck init # Runs install.sh which handles all skills
Option 2: Manual installation
Option 2: Manual installation
cd .claude/skills/markdown-novel-viewer
npm install
**Dependencies:** `marked`, `highlight.js`, `gray-matter`
Without installation, you'll get **Error 500: Error rendering markdown**.cd .claude/skills/markdown-novel-viewer
npm install
**依赖:** `marked`, `highlight.js`, `gray-matter`
未安装的话会报错 **500错误:渲染Markdown失败**。Purpose
用途
Universal viewer - pass ANY path and view it:
- Markdown files → novel-reader UI with serif fonts, warm theme
- Directories → file listing browser with clickable links
通用查看器,传入任意路径即可查看:
- Markdown文件 → 采用衬线字体、暖色调主题的小说阅读器UI
- 目录 → 带可点击链接的文件列表浏览器
Quick Start
快速开始
bash
undefinedbash
undefinedView a markdown file
查看一个Markdown文件
node .claude/skills/markdown-novel-viewer/scripts/server.cjs
--file ./plans/my-plan/plan.md
--open
--file ./plans/my-plan/plan.md
--open
node .claude/skills/markdown-novel-viewer/scripts/server.cjs
--file ./plans/my-plan/plan.md
--open
--file ./plans/my-plan/plan.md
--open
Browse a directory
浏览目录
node .claude/skills/markdown-novel-viewer/scripts/server.cjs
--dir ./plans
--host 0.0.0.0
--open
--dir ./plans
--host 0.0.0.0
--open
node .claude/skills/markdown-novel-viewer/scripts/server.cjs
--dir ./plans
--host 0.0.0.0
--open
--dir ./plans
--host 0.0.0.0
--open
Background mode
后台模式
node .claude/skills/markdown-novel-viewer/scripts/server.cjs
--file ./README.md
--background
--file ./README.md
--background
node .claude/skills/markdown-novel-viewer/scripts/server.cjs
--file ./README.md
--background
--file ./README.md
--background
Stop all running servers
停止所有运行中的服务器
node $HOME/.claude/skills/markdown-novel-viewer/scripts/server.cjs --stop
undefinednode $HOME/.claude/skills/markdown-novel-viewer/scripts/server.cjs --stop
undefinedSlash Command
斜杠命令
Use for quick access:
/previewbash
/preview plans/my-plan/plan.md # View markdown file
/preview plans/ # Browse directory
/preview --stop # Stop server使用快速访问:
/previewbash
/preview plans/my-plan/plan.md # 查看Markdown文件
/preview plans/ # 浏览目录
/preview --stop # 停止服务器Features
功能特性
Novel Theme
小说主题
- Warm cream background (light mode)
- Dark mode with warm gold accents
- Libre Baskerville serif headings
- Inter body text, JetBrains Mono code
- Maximum 720px content width
- 暖奶油色背景(浅色模式)
- 带暖金色点缀的深色模式
- Libre Baskerville 衬线字体标题
- Inter 正文字体,JetBrains Mono 代码字体
- 最大内容宽度720px
Directory Browser
目录浏览器
- Clean file listing with emoji icons
- Markdown files link to viewer
- Folders link to sub-directories
- Parent directory navigation (..)
- Light/dark mode support
- 带emoji图标的清爽文件列表
- Markdown文件跳转至阅读器
- 文件夹跳转至子目录
- 上级目录导航(..)
- 支持浅色/深色模式
Plan Navigation
计划导航
- Auto-detects plan directory structure
- Sidebar shows all phases with status indicators
- Previous/Next navigation buttons
- Keyboard shortcuts: Arrow Left/Right
- 自动检测计划目录结构
- 侧边栏展示所有阶段及状态标识
- 上一个/下一个导航按钮
- 键盘快捷键:左右方向键
Keyboard Shortcuts
键盘快捷键
- - Toggle theme
T - - Toggle sidebar
S - - Navigate phases
Left/Right - - Close sidebar (mobile)
Escape
- - 切换主题
T - - 切换侧边栏
S - - 切换阶段
左/右方向键 - - 关闭侧边栏(移动端)
Escape
CLI Options
CLI参数
| Option | Description | Default |
|---|---|---|
| Markdown file to view | - |
| Directory to browse | - |
| Server port | 3456 |
| Host to bind ( | localhost |
| Auto-open browser | false |
| Run in background | false |
| Stop all servers | - |
| 参数 | 说明 | 默认值 |
|---|---|---|
| 要查看的Markdown文件路径 | - |
| 要浏览的目录路径 | - |
| 服务器端口 | 3456 |
| 绑定的主机地址( | localhost |
| 自动打开浏览器 | false |
| 后台运行 | false |
| 停止所有服务器 | - |
Architecture
架构
scripts/
├── server.cjs # Main entry point
└── lib/
├── port-finder.cjs # Dynamic port allocation
├── process-mgr.cjs # PID file management
├── http-server.cjs # Core HTTP routing (/view, /browse)
├── markdown-renderer.cjs # MD→HTML conversion
└── plan-navigator.cjs # Plan detection & nav
assets/
├── template.html # Markdown viewer template
├── novel-theme.css # Combined light/dark theme
├── reader.js # Client-side interactivity
├── directory-browser.css # Directory browser stylesscripts/
├── server.cjs # 主入口文件
└── lib/
├── port-finder.cjs # 动态端口分配
├── process-mgr.cjs # PID文件管理
├── http-server.cjs # 核心HTTP路由 (/view, /browse)
├── markdown-renderer.cjs # MD转HTML转换
└── plan-navigator.cjs # 计划检测与导航
assets/
├── template.html # Markdown阅读器模板
├── novel-theme.css # 深浅主题合并样式
├── reader.js # 客户端交互逻辑
├── directory-browser.css # 目录浏览器样式HTTP Routes
HTTP路由
| Route | Description |
|---|---|
| Markdown file viewer |
| Directory browser |
| Static assets |
| Local file serving (images) |
| 路由 | 说明 |
|---|---|
| Markdown文件阅读器 |
| 目录浏览器 |
| 静态资源 |
| 本地文件服务(图片等) |
Dependencies
依赖
- Node.js built-in: ,
http,fs,pathnet - npm: ,
marked,highlight.js(installed viagray-matter)npm install
- Node.js内置模块:,
http,fs,pathnet - npm依赖:,
marked,highlight.js(通过gray-matter安装)npm install
Customization
自定义
Theme Colors (CSS Variables)
主题颜色(CSS变量)
Light mode variables in :
assets/novel-theme.csscss
--bg-primary: #faf8f3; /* Warm cream */
--accent: #8b4513; /* Saddle brown */Dark mode:
css
--bg-primary: #1a1a1a; /* Near black */
--accent: #d4a574; /* Warm gold */assets/novel-theme.csscss
--bg-primary: #faf8f3; /* 暖奶油色 */
--accent: #8b4513; /* saddle brown */深色模式变量:
css
--bg-primary: #1a1a1a; /* 近黑色 */
--accent: #d4a574; /* 暖金色 */Content Width
内容宽度
css
--content-width: 720px;css
--content-width: 720px;Remote Access
远程访问
To access from another device on your network:
bash
undefined要从同一网络下的其他设备访问:
bash
undefinedStart with 0.0.0.0 to bind to all interfaces
使用0.0.0.0绑定所有网卡接口启动
node server.cjs --file ./README.md --host 0.0.0.0 --port 3456
When using `--host 0.0.0.0`, the server auto-detects your local network IP and includes it in the output:
```json
{
"success": true,
"url": "http://localhost:3456/view?file=...",
"networkUrl": "http://192.168.2.75:3456/view?file=...",
"port": 3456
}Use to access from other devices on the same network.
networkUrlnode server.cjs --file ./README.md --host 0.0.0.0 --port 3456
使用`--host 0.0.0.0`启动时,服务器会自动检测本地网络IP并输出到结果中:
```json
{
"success": true,
"url": "http://localhost:3456/view?file=...",
"networkUrl": "http://192.168.2.75:3456/view?file=...",
"port": 3456
}使用即可从同一网络下的其他设备访问。
networkUrlTroubleshooting
问题排查
Port in use: Server auto-increments to next available port (3456-3500)
Images not loading: Ensure image paths are relative to markdown file
Server won't stop: Check for stale PID files
/tmp/md-novel-viewer-*.pidRemote access denied: Use to bind to all interfaces
--host 0.0.0.0IMPORTANT Task Planning Notes (MUST FOLLOW)
- Always plan and break work into many small todo tasks
- Always add a final review todo task to verify work quality and identify fixes/enhancements
端口被占用:服务器会自动递增查找可用端口(3456-3500范围)
图片加载失败:请确保图片路径是相对于Markdown文件的相对路径
服务器无法停止:检查路径下是否有残留的PID文件
/tmp/md-novel-viewer-*.pid远程访问被拒绝:使用参数绑定所有网卡接口
--host 0.0.0.0重要任务规划说明(必须遵守)
- 始终规划并将工作拆分为多个小型待办任务
- 始终添加最终审核待办任务,验证工作质量,识别需要修复/优化的点