Dockerized markdownlint-cli with various versions, easy to use and easy to integrate with CI.
Without speicifying a image tag, the latest
tag will be used as the latest version of markdownlint-cli:
docker run -v $PWD:/md peterdavehello/markdownlint markdownlint .
- Replace
$PWD
with path of markdown files,$PWD
means the current working directory. - If you don't want to scan all the markdown files recursively, replace
.
with the specify the file path and name.
Just like above, but specify a version tag of markdownlint-cli, for example, 0.35.0
:
docker run -v $PWD:/md peterdavehello/markdownlint:0.35.0 markdownlint .
Enable Docker service in your .travis.yml
:
services:
- docker
And use the same command in the scripts
part as the command line mentions, for example:
services:
- docker
scripts:
- docker run -v $TRAVIS_BUILD_DIR:/md peterdavehello/markdownlint:0.35.0 markdownlint example.md
This will lint a example markdown file called example.md
Add this block to your .gitlab-ci.yml
:
markdownlint:
stage: lint
variables:
markdownlint_cli_version: "0.35.0"
image: peterdavehello/markdownlint:$markdownlint_cli_version
only:
changes:
- "**/*.md"
- "**/*.markdown"
script:
- markdownlint .
Just pass -h
/--help
to markdownlint to get its help message, for example:
docker run peterdavehello/markdownlint markdownlint --help
You'll get the output like below:
Usage: markdownlint [options] <files|directories|globs>
MarkdownLint Command Line Interface
Options:
-V, --version output the version number
-c, --config [configFile] configuration file (JSON, JSONC, JS, or YAML)
-d, --dot include files/folders with a dot (for example `.github`)
-f, --fix fix basic errors (does not work with STDIN)
-i, --ignore [file|directory|glob] file(s) to ignore/exclude (default: [])
-j, --json write issues in json format
-o, --output [outputFile] write issues to file (no console)
-p, --ignore-path [file] path to file with ignore pattern(s)
-q, --quiet do not write issues to STDOUT
-r, --rules [file|directory|glob|package] include custom rule files (default: [])
-s, --stdin read from STDIN (does not work with files)
--enable [rules...] Enable certain rules, e.g. --enable MD013 MD041 --
--disable [rules...] Disable certain rules, e.g. --disable MD013 MD041 --
-h, --help display help for command
For more details, check out the markdownlint-cli project page.
Build command, you need to specify a valid markdownlint version argument to MARKDOWNLINT_CLI_VER
:
docker build --build-arg MARKDOWNLINT_CLI_VER="0.35.0" -t docker-markdownlint .
# Replace "docker-markdownlint" with the preferred image name
You can find a valid version on markdownlint-cli npm registry page, or just poke the registry to retrieve more details.