panache 2.43.1

An LSP, formatter, and linter for Markdown, Quarto, and R Markdown
---
title: "Integrations"
description: >
  This section provides instructions for integrating Panache with other tools,
  such as pre-commit hooks and GitHub actions, to automatically format and lint
  your documents on commit or pull request.
---

## Pre-Commit

[pre-commit](https://pre-commit.com/) is a framework for managing and
maintaining multi-language pre-commit hooks. It runs checks on your code before
each commit to ensure quality and consistency.

Create a `.pre-commit-config.yaml` file in your repository root:

```yaml
repos:
  - repo: https://github.com/jolars/panache
    rev: v{{< meta version >}}
    hooks:
      - id: panache-format
      - id: panache-lint
```

Then install the hooks:

```bash
pre-commit install
```

Panache provides two hook IDs:

`panache-format`
:   Automatically formats files according to Panache's formatting rules

`panache-lint`
:   Lints files and automatically applies fixes where possible

Pass additional arguments to Panache:

```yaml
repos:
  - repo: https://github.com/jolars/panache
    rev: v{{< meta version >}}
    hooks:
      - id: panache-format
        args: [--config, custom-config.toml]
```

### File Patterns

By default, hooks run on `.qmd`, `.md`, `.markdown`, `.mdown`, `mkd`, and `.Rmd`
files. You can override this with `files`, for instance to only run on `.qmd`
and `.Rmd`:

```yaml
repos:
  - repo: https://github.com/jolars/panache
    rev: v{{< meta version >}}
    hooks:
      - id: panache-format
        files: '\.(qmd|Rmd)$'
```

## GitHub Actions

Use the dedicated Panache action for a one-line setup:

```yaml
name: panache
on:
  pull_request:
  push:
    branches: [main]

jobs:
  format-and-lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: jolars/panache-action@v1
```

This workflow:

1. Installs Panache from official releases
2. Checks that all files are formatted (`--check` mode)
3. Runs the linter in CI mode (`--check` mode)

Both steps will fail (exit code 1) if issues are found, causing the workflow to
fail.

### Common options

Pin a specific Panache CLI release:

```yaml
- uses: jolars/panache-action@v1
  with:
    panache-version: v2.23.0
```

Run only one check:

```yaml
- uses: jolars/panache-action@v1
  with:
    lint: "false" # format only
```

```yaml
- uses: jolars/panache-action@v1
  with:
    format: "false" # lint only
```

### Manual setup (advanced)

If you prefer installing via Rust directly, you can keep using a manual
workflow:

```yaml
name: panache
on:
  pull_request:
  push:
    branches: [main]

jobs:
  format-and-lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Install Rust
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: 1.94

      - name: Cache cargo
        uses: actions/cache@v5
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
          key: ${{ runner.os }}-cargo-panache-${{ hashFiles('**/Cargo.lock') }}
      - name: Install panache
        run: cargo install panache --locked
      - name: Check formatting
        run: panache format --check .
      - name: Run linter
        run: panache lint --check .
```