# Pandoc Integration With Git Hooks

> Sub-skill of pandoc: Integration with Git Hooks (+1).

- Skill: `vamseeachanta/pandoc-integration-with-git-hooks` (Agent Skill)
- Install (CLI): `npx skillmds@latest add vamseeachanta/pandoc-integration-with-git-hooks`
- Raw SKILL.md: https://api.skillmd.com/api/skills/vamseeachanta/pandoc-integration-with-git-hooks/raw
- Safety review: PASS (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Docs & Writing
- Author: vamseeachanta (https://skillmd.com/u/vamseeachanta)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/vamseeachanta/pandoc-integration-with-git-hooks

---


# Integration with Git Hooks (+1)

## Integration with Git Hooks


```bash
#!/bin/bash
# .git/hooks/pre-commit
# Rebuild PDFs before commit

set -e

# Check if any markdown files changed
changed_md=$(git diff --cached --name-only --diff-filter=ACM | grep '\.md$' || true)

if [[ -n "$changed_md" ]]; then
    echo "Rebuilding PDF documents..."

    for file in $changed_md; do
        if [[ -f "$file" ]]; then
            output="${file%.md}.pdf"
            echo "  Converting: $file -> $output"
            pandoc "$file" -o "$output" --pdf-engine=xelatex --toc
            git add "$output"
        fi
    done
fi
```


## Integration with VS Code Tasks


```json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Pandoc: Build PDF",
            "type": "shell",
            "command": "pandoc",
            "args": [
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}.pdf",
                "--pdf-engine=xelatex",
                "--toc",
                "--number-sections"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "echo": true,
                "reveal": "always"
            }
        },
        {
            "label": "Pandoc: Build DOCX",
            "type": "shell",
            "command": "pandoc",
            "args": [
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}.docx",
                "--toc"
            ]
        },
        {
            "label": "Pandoc: Watch and Build",
            "type": "shell",
            "command": "find . -name '*.md' | entr -c pandoc ${file} -o ${fileDirname}/${fileBasenameNoExtension}.pdf --pdf-engine=xelatex",
            "isBackground": true,
            "problemMatcher": []
        }
    ]
}
```

