---
name: preview
description: Preview Markdown, LaTeX, PDF, or code artifacts in the browser or as PDF. Use when the user wants to review a written artifact, export a report, or view a rendered document.
allowed-tools: Bash(open:*), Bash(xdg-open:*), Bash(pandoc:*)
---

# Preview

Render and open artifacts produced by the research workflows. This is a thin wrapper over OS-native openers and `pandoc`.

> **Upstream note.** Feynman ships a `/preview` slash command. Outside Feynman, fall back to the bash commands below — both Claude Code and OpenCode can execute them.

## Open a file in the default app

macOS:

```bash
open <file.md>
open <file.pdf>
open <file.html>
```

Linux:

```bash
xdg-open <file.md>
xdg-open <file.pdf>
xdg-open <file.html>
```

The default app is whatever the OS has registered for the extension — usually a Markdown viewer, Preview/Evince, or a browser.

## Export Markdown to PDF

`pandoc` is the standard cross-platform renderer:

```bash
pandoc outputs/<slug>.md -o outputs/<slug>.pdf \
  --pdf-engine=xelatex \
  --variable geometry:margin=1in \
  --toc
```

For papers with LaTeX equations, prefer `--pdf-engine=xelatex` or `lualatex`. If LaTeX is not installed, `--pdf-engine=weasyprint` is a lightweight alternative that renders HTML+CSS to PDF.

## Export to HTML

```bash
pandoc outputs/<slug>.md -o outputs/<slug>.html --standalone --mathjax
```

## When to use

- User asks to "preview", "render", "export", or "view" a written artifact
- Before delivering a paper or brief, sanity-check rendering
- Converting `.md` outputs to PDF for sharing outside the repo

## What to pass back to the user

- The absolute path to the rendered file
- Whether the render succeeded or had LaTeX/pandoc warnings
- If the user wanted it opened, confirm the OS opener returned exit 0
