#file-format #jpeg #blog-post #image #markdown #svg #exif

bin+lib spezilinter

spezifisch's linter for different file formats, linting for weirdly specific stuff

5 stable releases

1.1.2 Sep 18, 2024
1.0.1 Sep 18, 2024

#1875 in Parser implementations

GPL-3.0-only

3.5MB
371 lines

spezilinter

spezilinter is a personal linter for validating and enforcing specific rules on my blog posts. Maybe you can reuse some parts for your own stuff!

Features

  • Markdown Custom Tags Linting:
    • Lint special tags that I defined for my blog.
    • Checks if linked image file exists.
    • Validates image formats (JPG, PNG, etc.).
  • JPG: Validates that EXIF metadata has been stripped (e.g., GPS coordinates).
  • SVG (optional): Verifies SVG files for the presence of unsafe attributes like onload.

Installation

cargo install spezilinter

Usage

$ spezilinter --help
spezifisch's linter for different file formats, linting for weirdly specific stuff

Usage: spezilinter [OPTIONS] <files>...

Arguments:
  <files>...  List of markdown files to lint

Options:
      --root <root>          Root directory for resolving image paths [default: .]
      --disallow-onload      Disallow `onload` attribute in SVG files
      --stop-on-first-error  Stop on the first error encountered
  -h, --help                 Print help
  -V, --version              Print version

Development

Run

# inside this repository
cargo run -- --root <root-directory> <markdown-files>

Test

You'll need the bats package for this:

make ci

Pre-Commit Hook

Make sure to commit only cleanly formatted and tested code, please:

# run once
pre-commit install

# (optional) run manually
pre-commit run --all-files

License

GPL-3.0-only

Dependencies

~15MB
~263K SLoC