Marc d'Ouane

a beautiful, epic Markdown linter

Logo

Installation

Install the gem and add to the application's Gemfile by executing:

bundle add marcdouane

If bundler is not being used to manage dependencies, install the gem by executing:

gem install marcdouane

Usage

Checking a file with default rules:

marcdouane check some-file.md

For the complete tour just use

marcdouane
marcdouane check --help

Configuration

Some rules have settings (see lib/marcdouane/rules.rb for now). These settings can be overriden with a YAML config file that resembles the Rubocop config:

LineLength:
  maximum_line_length: 90 # which is utter madness

Development

I'm doing it

Contributing

A rule must inherit Marcdouane::Rule. It must answer to check! and raise a Marcdouane::Error with an ERROR_MESSAGE and a line number. Example:

class CheckAnglois < Marcdouane::Rule
  ERROR_MESSAGE = "Do not mention the English"

  def check!
    File
      .read(file)
      .lines
      .each_with_index(line, index) do
      raise Marcdouane:Error.new(ERROR_MESSAGE, index + 1) if line =~ /anglois/
    end
  end
end

It is then expected to be tested throughout the Cucumber feature tests like such:

Feature: Built-in Markdown Rules
  # [...]

  Rule: Don't mention the English
    Example: It fails when the English are mentioned
      Given a file named "foo.md" with:
        """
        # Tout va bien
        Pas d'anglois à l'horizon
        """
      When I run `marcdouane check "foo.md"`
      Then it should fail with:
        """
        foo.md:2: Don't mention the English
        """

    Example: It passes when the English are not mentioned
      Given a file named "foo.md" with:
        """
        # Tout va bien
        Quelques voix dans la tête mais tranquille
        """
      When I run `marcdouane check "foo.md"`
      Then it should pass

Bug reports and pull requests are welcome on GitHub at https://github.com/freesteph/marcdouane.

License

The gem is available as open source under the terms of the MIT License.