From rp1-base
Generates browser-viewable HTML previews from markdown, plain text, and Mermaid diagrams. Validates diagrams, applies GitHub/dark/minimal styling, saves to temp dir, and auto-opens in default browser for docs, reports, and visualizations.
How this skill is triggered — by the user, by Claude, or both
Slash command
/rp1-base:markdown-previewThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Generate self-contained HTML files from markdown content and automatically open them in the user's default browser.
Generate self-contained HTML files from markdown content and automatically open them in the user's default browser.
Use this skill when you need to:
Trigger scenarios: markdown preview, HTML generation, browser preview, document visualization, diagram rendering.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| content | string | Yes | - | Markdown, plain text, or Mermaid content to render |
| title | string | No | "Markdown Preview" | HTML page title |
| theme | string | No | "github" | Template theme: "github", "dark", or "minimal" |
Extract content from agent context or parameters. The skill expects markdown content as a string input.
Efficient Validation Strategy:
Instead of validating each diagram individually, validate the entire markdown document at once:
Write markdown to temp file:
TEMP_MD=$(mktemp /tmp/markdown-preview.XXXXXX.md)
echo "$CONTENT" > "$TEMP_MD"
Validate all diagrams in one pass:
rp1 agent-tools mmd-validate "$TEMP_MD"
EXIT_CODE=$?
Check validation result:
EXIT_CODE = 0: All diagrams valid, proceed with generationEXIT_CODE = 1: One or more diagrams invalidHandle validation failures:
if [ $EXIT_CODE -ne 0 ]; then
# Extract error message from validation output
# Prepend warning to markdown content:
CONTENT="⚠️ **Mermaid Validation Warning**: Some diagrams have syntax errors. They may not render correctly in the preview.\n\n$CONTENT"
# Continue with HTML generation (non-blocking)
fi
Clean up temp file:
rm -f "$TEMP_MD"
Why This Approach is Better:
rp1 agent-tools mmd-validate for validationError Handling:
Dependencies:
agent-tools mmd-validate command)Template Selection:
Based on theme parameter, select appropriate template from TEMPLATES.md:
Template Loading:
Template Processing:
{{TITLE}} with actual page title{{MARKDOWN_CONTENT}} with markdown contentHTML Features (embedded in templates):
See TEMPLATES.md for complete HTML structure and styling details.
Filename Generation:
TIMESTAMP=$(date +%s%N)
FILENAME="markdown-preview-$TIMESTAMP.html"
TEMP_DIR="/tmp"
FILE_PATH="$TEMP_DIR/$FILENAME"
File Operations:
Platform-specific temp directories:
$TMPDIR or /tmp%TEMP%Platform Detection:
# Detect platform via $OSTYPE
if [[ "$OSTYPE" == "darwin"* ]]; then
PLATFORM="macos"
OPEN_CMD="open"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
PLATFORM="linux"
OPEN_CMD="xdg-open"
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OSTYPE" == "win32" ]]; then
PLATFORM="windows"
OPEN_CMD="start"
else
PLATFORM="unknown"
OPEN_CMD=""
fi
Browser Opening:
if [ -n "$OPEN_CMD" ]; then
$OPEN_CMD "$FILE_PATH" 2>&1
if [ $? -eq 0 ]; then
BROWSER_OPENED=true
else
BROWSER_OPENED=false
# Log error but continue (non-blocking)
fi
else
BROWSER_OPENED=false
# Log warning: unknown platform
fi
Error Handling:
browserOpened=false, but still return successOutput Format:
{
"status": "success" | "error",
"filePath": "/tmp/markdown-preview-1699464000000.html",
"message": "Preview generated successfully.",
"diagramsValidated": true,
"browserOpened": true,
"theme": "github"
}
Success Response:
Error Response:
{
"status": "error",
"message": "Failed to write HTML file: Permission denied",
"filePath": null,
"diagramsValidated": false,
"browserOpened": false
}
Empty/Whitespace Input:
File Write Errors:
Validation Script Unavailable:
Browser Launch Failures (non-blocking):
Malformed Markdown (best-effort):
Invalid Theme:
Invalid Mermaid Diagrams (non-blocking):
From PR Visualizer Agent:
## Generate HTML Preview
After creating the markdown file, use the markdown-preview skill to generate the HTML preview.
Use the Skill tool:
skill: "rp1-base:markdown-preview"
Read the generated markdown file and pass content:
- content: Read from {{$RP1_ROOT}}/work/pr_reviews/<pr-id>-visual.md
- title: "PR Visualization for PR #{pr-number}"
- theme: "github"
The skill will:
1. Write markdown to temp file
2. Validate ALL Mermaid diagrams in one pass using rp1 CLI tool
3. Generate self-contained HTML with professional styling
4. Save to temp directory
5. Auto-open in browser
6. Return file path for logging
Log the file path and report to user:
"✓ Preview generated: {filePath}"
From Documentation Agent:
Use skill: "rp1-base:markdown-preview"
Pass documentation content:
- content: Generated markdown documentation
- title: "Project Documentation"
- theme: "github"
Skill validates all diagrams once and generates HTML.
Browser opens automatically.
Optimized Performance (<5 seconds total):
Typical Content:
Performance Improvement:
Internal:
agent-tools mmd-validate)External (embedded via CDN):
System Requirements:
EXECUTE IMMEDIATELY:
No user interaction required during execution. Complete the entire workflow autonomously.
npx claudepluginhub rp1-run/rp1Serves markdown as live-reloading browser previews using mdserve for complex docs, tables, Mermaid diagrams, and multi-file sets. Handles iterative edits.
Converts Markdown to styled HTML with WeChat-compatible themes, supporting code highlighting, math, Mermaid (PNG via headless Chrome), PlantUML, footnotes, alerts, infographics, and optional bottom citations for external links.
Generates or updates an HTML Preview from any Markdown document (PRD, Decision Brief, Tech Research, Design, or other) for visual review. Supports PRD mode (by feature name) and generic mode (by file path).