This repository has been archived by the owner on Nov 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
style '_checks/md_style' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ gem 'wdm', platform: :mswin | |
|
||
group :test do | ||
gem 'html-proofer' | ||
gem "mdl" | ||
gem 'launchy' | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# This Jekyll hook runs Markdown linter (https://github.com/markdownlint/markdownlint) | ||
# on .md files that git tracks as 'modified' ('git ls-files -m'). | ||
# '_checks/md_style' sets a style (https://github.com/markdownlint/markdownlint/blob/master/docs/creating_styles.md) | ||
# that is a set of rules to be applied when linting (https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md). | ||
# '.mdlrc' sets linting configuration (https://github.com/markdownlint/markdownlint/blob/master/docs/configuration.md). | ||
# | ||
# The plugin runs in serving mode only. | ||
# | ||
Jekyll::Hooks.register :site, :post_write do |site| | ||
next unless site.config['serving'] | ||
puts 'Checking Markdown syntax.'.blue | ||
staged_files = `git ls-files -m`.split("\n") | ||
staged_md_files = staged_files.select { |file| File.extname(file) == '.md' } | ||
next if staged_md_files.empty? | ||
staged_md_files_as_a_string = staged_md_files.join(' ') | ||
report = `mdl #{staged_md_files_as_a_string}` | ||
puts report.yellow | ||
puts 'The rules are defined in _checks/md_style' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
all | ||
|
||
exclude_rule 'MD002' | ||
exclude_rule 'MD013' | ||
exclude_rule 'MD041' | ||
exclude_rule 'MD034' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
# | ||
# This file was generated by Bundler. | ||
# | ||
# The application 'mdl' is installed as part of a gem, and | ||
# this file is here to facilitate running it. | ||
# | ||
|
||
require "pathname" | ||
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", | ||
Pathname.new(__FILE__).realpath) | ||
|
||
bundle_binstub = File.expand_path("../bundle", __FILE__) | ||
|
||
if File.file?(bundle_binstub) | ||
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ | ||
load(bundle_binstub) | ||
else | ||
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. | ||
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") | ||
end | ||
end | ||
|
||
require "rubygems" | ||
require "bundler/setup" | ||
|
||
load Gem.bin_path("mdl", "mdl") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace :lint do | ||
desc 'Check Markdown syntax in a file or directory by path (e.g. path=mftf)' | ||
task :md do | ||
path = ENV['path'] | ||
unless path | ||
staged_files = `git ls-files -m`.split("\n") | ||
staged_md_files = staged_files.select { |file| File.extname(file) == '.md' } | ||
abort 'Cannot find any modified .md files.' if staged_md_files.empty? | ||
path = staged_md_files.join(' ') | ||
end | ||
# require 'pry' | ||
# binding.pry | ||
report = `mdl #{path}` | ||
puts report.yellow | ||
puts 'The rules are defined in _checks/md_style' | ||
end | ||
end |