markdoc-pdf 0.11.1

Render Markdoc documents to PDF, as a CLI or a library
Documentation
# CI for markdoc-pdf
#
# The gate itself is in `.github/scripts/check.sh`, not here, so release.yml
# runs exactly the same set before it publishes anything. A second list of
# steps drifts, and the half that drifts is always the one nobody watches.
#
# It runs on Linux, macOS and Windows, because the renderer finds its fonts
# through a different system on each, and on Windows on ARM64 as well,
# before a release depends on it. Cargo fetches every dependency, so this
# repository is the only checkout.

name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: short

jobs:
  test:
    name: Test (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
      - name: Check out markdoc-pdf
        uses: actions/checkout@v5
        with:
          path: markdoc-pdf

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy

      - name: Install system dependencies
        if: runner.os == 'Linux'
        run: |
          sudo apt-get update
          # fonts-liberation: the per-element font tests need two distinct
          # installed families to tell elements apart. macOS and Windows
          # ship suitable ones; don't rely on the Linux runner's defaults.
          sudo apt-get install -y libfontconfig1-dev fonts-liberation

      - name: Cargo cache
        uses: Swatinem/rust-cache@v2
        with:
          workspaces: markdoc-pdf
          save-if: ${{ github.ref == 'refs/heads/main' }}

      - name: check.sh
        shell: bash
        run: bash markdoc-pdf/.github/scripts/check.sh markdoc-pdf

  # ────────────────────────────────────────────────────────────────────
  # Windows on ARM64, proven here before any release depends on it. The
  # tests run natively; then the binary is built as a release would build
  # it, with the C runtime linked in, and is checked and made to render.
  # The C in it, markdoc's stack growth (psm) and ring under ureq's TLS,
  # needs MSVC's ARM64 tools and, for ring, clang: this runner image has
  # both.
  # ────────────────────────────────────────────────────────────────────
  windows-arm64:
    name: Windows on ARM64
    runs-on: windows-11-arm
    steps:
      - name: Check out markdoc-pdf
        uses: actions/checkout@v5
        with:
          path: markdoc-pdf

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Cargo cache
        uses: Swatinem/rust-cache@v2
        with:
          workspaces: markdoc-pdf
          key: windows-arm64
          save-if: ${{ github.ref == 'refs/heads/main' }}

      - name: cargo test
        working-directory: markdoc-pdf
        run: cargo test --all-targets

      - name: Release build, the C runtime linked in
        shell: bash
        working-directory: markdoc-pdf
        env:
          RUSTFLAGS: -C target-feature=+crt-static
        run: cargo build --release --target aarch64-pc-windows-msvc --bin markdoc-pdf --features mermaid

      # What release.yml checks of every Windows binary. An import of
      # vcruntime140.dll would mean the Visual C++ Redistributable is needed
      # after all, and this runner, which has it installed, would not notice.
      - name: It needs no Visual C++ runtime, and it renders
        shell: bash
        working-directory: markdoc-pdf
        run: |
          set -eu
          exe=target/aarch64-pc-windows-msvc/release/markdoc-pdf.exe
          if grep -a -q -i 'vcruntime140' "$exe"; then
            echo "::error::$exe imports the Visual C++ runtime (vcruntime140.dll)" >&2
            exit 1
          fi
          echo "$exe: $(wc -c < "$exe") bytes, the C runtime linked in"
          "$exe" --version
          "$exe" --input examples/rich.mdoc --output rich-arm64.pdf \
              --style examples/themes/letter.style.toml --assets-root examples
          test -s rich-arm64.pdf