Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

markdown-preview

БесплатноБез исполняемых скриптовНе проверен

Generate browser-viewable HTML previews from markdown, plain text, and Mermaid diagrams. Auto-validates, styles, and opens in browser.

rp1-runот rp1-run★ 38 звёзд на GitHub21 установка в других каталогах

Об этом скилле

Markdown Preview Generator — Browser-Ready HTML from Markdown

Generate self-contained HTML files from markdown content and automatically open them in the user's default browser.

What This Skill Does

  • Accepts GitHub-flavored markdown, plain text, and Mermaid diagrams
  • Validates all Mermaid diagrams in document at once (single validation pass)
  • Generates single-page HTML with embedded libraries (marked.js, Prism.js, Mermaid.js)
  • Applies professional styling (GitHub-style, dark mode, or minimal)
  • Saves HTML to system temp directory with unique filename
  • Auto-opens preview in default browser (cross-platform: macOS, Linux, Windows)
  • Returns file path and execution status

When to Use

Use this skill when you need to:

  • Preview markdown documentation in a browser
  • Visualize Mermaid diagrams with proper rendering
  • Generate formatted HTML reports for users
  • Display code blocks with syntax highlighting
  • Create professional previews of generated content

Trigger scenarios: markdown preview, HTML generation, browser preview, document visualization, diagram rendering.

Parameters

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"

Workflow

1. Parse Input Content

Extract content from agent context or parameters. The skill expects markdown content as a string input.

2. Validate All Mermaid Diagrams (Single Pass)

Efficient Validation Strategy:

Instead of validating each diagram individually, validate the entire markdown document at once:

  1. Write markdown to temp file:

    TEMP_MD=$(mktemp /tmp/markdown-preview.XXXXXX.md)
    echo "$CONTENT" > "$TEMP_MD"
    
  2. Validate all diagrams in one pass:

    rp1 agent-tools mmd-validate "$TEMP_MD"
    EXIT_CODE=$?
    
  3. Check validation result:

    • If EXIT_CODE = 0: All diagrams valid, proceed with generation
    • If EXIT_CODE = 1: One or more diagrams invalid
  4. Handle 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
    
  5. Clean up temp file:

    rm -f "$TEMP_MD"
    

Why This Approach is Better:

  • ✅ Single validation pass instead of per-diagram validation
  • ✅ Faster: Validates all diagrams in ~2-5 seconds total (not per diagram)
  • ✅ Uses CLI tool: Leverages rp1 agent-tools mmd-validate for validation
  • ✅ Simpler logic: No loops, no retry attempts
  • ✅ Non-blocking errors: Invalid diagrams show in preview with Mermaid's own error rendering
  • ✅ Better user experience: User sees actual diagram syntax errors in browser

Error Handling:

  • Validation failures are non-blocking (HTML generation continues)
  • Invalid diagrams render with Mermaid.js's built-in error display
  • User can see exact syntax errors in browser preview
  • Warning message prepended to document if validation fails

Dependencies:

  • Requires rp1 CLI v0.3.0+ (includes agent-tools mmd-validate command)
  • CLI tool supports markdown files with multiple Mermaid blocks

3. Generate Self-Contained HTML

Template Selection:

Based on theme parameter, select appropriate template from TEMPLATES.md:

  • "github" (default): GitHub-style with professional appearance
  • "dark": Dark mode for late-night work or presentations
  • "minimal": Lightweight, print-friendly styling

Template Loading:

  1. Read selected template from TEMPLATES.md
  2. Identify template section markers
  3. Extract complete HTML template

Template Processing:

  1. Replace {{TITLE}} with actual page title
  2. Replace {{MARKDOWN_CONTENT}} with markdown content
  3. Ensure proper escaping of special characters in content

HTML Features (embedded in templates):

  • Libraries: marked.js (markdown), Prism.js (syntax highlighting), Mermaid.js (diagrams)
  • Security: Content Security Policy prevents XSS attacks
  • Styling: Professional CSS embedded inline
  • Rendering: Client-side JavaScript handles markdown parsing and diagram rendering
  • Error Display: Mermaid.js automatically shows syntax errors for invalid diagrams
  • Languages: Syntax highlighting for 10+ languages (Python, JavaScript, TypeScript, Bash, JSON, YAML, Rust, Go, Java, Markdown)

See TEMPLATES.md for complete HTML structure and styling details.

4. Write HTML to Temp Directory

Filename Generation:

TIMESTAMP=$(date +%s%N)
FILENAME="markdown-preview-$TIMESTAMP.html"
TEM
Полный SKILL.md на GitHub

Установить markdown-preview в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Read
Write
Bash
Skill

Вложенные файлы

EXAMPLES.mdTEMPLATES.md

FAQ

Что делает скилл markdown-preview?

Generate browser-viewable HTML previews from markdown, plain text, and Mermaid diagrams. Auto-validates, styles, and opens in browser.

Как установить скилл markdown-preview?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл markdown-preview запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить markdown-preview с