一键导入
markdown-preview
Generate browser-viewable HTML previews from markdown, plain text, and Mermaid diagrams. Auto-validates, styles, and opens in browser.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate browser-viewable HTML previews from markdown, plain text, and Mermaid diagrams. Auto-validates, styles, and opens in browser.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Agent-only canonical output templates for rp1 artifacts. Load when producing structured markdown to ensure format consistency and routing metadata.
Ask about rp1 capabilities, discover skills, and get workflow guidance.
Evidence-gated tech debt and bloat detection. Scouts signals, ranks by materiality, validates by refutation, reports up to 5 findings with actions.
Synchronizes user-facing documentation with the current knowledge base through validate -> stale gate -> scan -> approval -> process orchestration.
Orchestrates parallel KB generation using spatial analysis and a map-reduce architecture with incremental and feature-learning modes.
Analyzes systems holistically to provide strategic recommendations balancing cost, quality, performance, complexity, and business objectives with quantified trade-offs.
| name | markdown-preview |
| description | Generate browser-viewable HTML previews from markdown, plain text, and Mermaid diagrams. Auto-validates, styles, and opens in browser. |
| allowed-tools | Read, Write, Bash, Skill |
| metadata | {"category":"documentation","is_workflow":false} |
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.
Invoke the `rp1-base:markdown-preview` skill.
Load the generated markdown file and pass content:
- content: Read from .rp1/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:
Invoke `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:
{% include_shared "anti-loop.md" %}
No user interaction required during execution. Complete the entire workflow autonomously.