andreasscherbaum / check-markdown-files

Run a pre-flight check on Markdown files before committing blog postings
Apache License 2.0
1 stars 1 forks source link

check-markdown-files

Run a pre-flight check on Markdown files before committing blog postings

Usage

Run this script from inside your git repository with your blog Markdown files.

The script will attempt to find the file check-markdown-files.conf in the root of your repository, which includes your configuration.

git Commit Hook

In order to use this script as git commit hook, you have to execute it from .git/hooks/pre-commit, or make this script a symlink (Linux/Unix only).

The following example assumes that you are currently in the root directory of your blog repository, and this repository is checked out next to your blog repository.

cd .git/hooks/ && ln -s ../check-markdown-files/check-markdown-files.py pre-commit && cd -

Configuration

In check-markdown-files.conf, the following checks and config options are available. All checks are disabled by default, and can be enabled in the configuration file.

If a check is enabled, it applies to all Markdown files (global configuration). Most checks can be disabled on a local level, using flags in the suppresswarnings header in Frontmatter.

All available checks are listes in the CHECKS document.

Write a new check

Add the following parts:

Tests

All tests are found in the tests/ directory, or a subdirectory. Tests are defined in the tests.yml file, and run by the run-tests.py script.

Write a new test

Add the new test in tests.yml, as example:

new_test:
    rc_expected: 0
    cmdoptions: ""
    test_subdirectory: ""
    stdout_expected: False
    stderr_expected: False
    stdout_must_include: []
    stderr_must_include: []
    stdout_must_not_include: []
    stderr_must_not_include: []

The following options are available:

The following files are used: