Pre-commit hook
This repo provides the following plugin
to be used with the Pre-commit framework:
The .pre-commit-hooks.yaml file
1---
2# Define plugins (hooks) provided by this repo.
3# How to test: https://pre-commit.com/#developing-hooks-interactively
4
5- id: md-toc
6 name: Update markdown table-of-contents
7 description: 'Replace TOC marker with a table of contents'
8 language: python
9 types: [markdown] # as detected by pre-commit with identify-cli
10 entry: md_toc
11 args: [-p, github]
Add a .pre-commit-config.yaml
file in the root of your git repo.
These are the default plugin settings
A simple example of a .pre-commit-config.yaml file
1 repos:
2 - repo: https://codeberg.org/frnmst/md-toc
3 rev: master # or a specific git tag from md-toc
4 hooks:
5 - id: md-toc
You can override the defaults via the args
parameter, such as
Example of arguments passed as a pre-commit
1 repos:
2 - repo: https://codeberg.org/frnmst/md-toc
3 rev: master # or a specific git tag from md-toc
4 hooks:
5 - id: md-toc
6 args: [-p, --skip-lines, '1', redcarpet] # CLI options
This is what I use in some repositories
1# See https://pre-commit.com for more information
2# See https://pre-commit.com/hooks.html for more hooks
3repos:
4- repo: https://codeberg.org/pre-commit/pre-commit-hooks
5 rev: v2.4.0
6 hooks:
7 - id: trailing-whitespace
8 - id: end-of-file-fixer
9 - id: check-yaml
10 - id: check-added-large-files
11
12- repo: https://codeberg.org/frnmst/md-toc
13 rev: 'master' # or a specific git tag from md-toc
14 hooks:
15 - id: md-toc
16 args: [-p, 'github', '-l6'] # CLI options
Finally, run pre-commit install
to enable the hook.