I've been sleeping on mdformat for too long, I've made and effort to make my own unsuccessfully. mdformat does the thing I want it to, format markdown, 80 character hard wrap, format code with a code formatter, format tables.

These are the flags I'm going with for now, I might add more plugins as I go.


mdformat() {
  uvx \
    --with "mdformat-ruff" \
    --with "mdformat-beautysh" \
    --with "mdformat-web" \
    --with "mdformat-config" \
    --with "mdformat-gfm" \
    --with "mdformat-front-matters" \
    mdformat \
    --wrap 80 \
    --end-of-line lf \
    --codeformatters python \
    --codeformatters bash \
    "$@"
}

And as a pre_commit hook:


repos:
  - repo: https://github.com/hukkin/mdformat
    rev: 1.0.0  # pin to the version you want
    hooks:
      - id: mdformat
        args:
          - --wrap
          - "80"
          - --end-of-line
          - lf
          - --codeformatters
          - python
          - --codeformatters
          - bash
        additional_dependencies:
          - mdformat-ruff
          - mdformat-beautysh
          - mdformat-web
          - mdformat-config
          - mdformat-gfm
          - mdformat-front-matters
Reply by email