This repository was archived by the owner on Nov 19, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +116
-1
lines changed Expand file tree Collapse file tree 8 files changed +116
-1
lines changed Original file line number Diff line number Diff line change
1
+ style '_checks/md_style'
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ gem 'wdm', platform: :mswin
10
10
11
11
group :test do
12
12
gem 'html-proofer'
13
+ gem 'mdl'
13
14
gem 'launchy'
14
15
end
15
16
Original file line number Diff line number Diff line change 106
106
rb-fsevent (~> 0.9 , >= 0.9.4 )
107
107
rb-inotify (~> 0.9 , >= 0.9.7 )
108
108
ruby_dep (~> 1.2 )
109
+ mdl (0.5.0 )
110
+ kramdown (~> 1.12 , >= 1.12.0 )
111
+ mixlib-cli (~> 1.7 , >= 1.7.0 )
112
+ mixlib-config (~> 2.2 , >= 2.2.1 )
109
113
mercenary (0.3.6 )
110
114
mini_portile2 (2.3.0 )
111
115
minitest (5.11.3 )
116
+ mixlib-cli (1.7.0 )
117
+ mixlib-config (2.2.18 )
118
+ tomlrb
112
119
multipart-post (2.1.1 )
113
120
netrc (0.11.0 )
114
121
nokogiri (1.8.5 )
137
144
faraday (> 0.8 , < 2.0 )
138
145
thor (0.20.3 )
139
146
thread_safe (0.3.6 )
147
+ tomlrb (1.2.8 )
140
148
typhoeus (1.3.1 )
141
149
ethon (>= 0.9.0 )
142
150
tzinfo (1.2.5 )
@@ -166,6 +174,7 @@ DEPENDENCIES
166
174
jekyll-sitemap
167
175
jekyll-titles-from-headings
168
176
launchy
177
+ mdl
169
178
wdm
170
179
whatsup_github
171
180
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ desc 'Pull docs from external repositories'
62
62
task init : %w[ multirepo:init ]
63
63
64
64
desc 'Run checks (image optimization).'
65
- task check : %w[ check:image_optim ]
65
+ task check : %w[ check:image_optim check:mdl ]
66
66
67
67
desc 'Generate data for the weekly digest.'
68
68
task :whatsnew do
Original file line number Diff line number Diff line change
1
+ # This Jekyll hook runs Markdown linter (https://github.com/markdownlint/markdownlint)
2
+ # on .md files that git tracks as 'modified' ('git ls-files -m').
3
+ # '_checks/md_style' sets a style (https://github.com/markdownlint/markdownlint/blob/master/docs/creating_styles.md)
4
+ # that is a set of rules to be applied when linting (https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md).
5
+ # '.mdlrc' sets linting configuration (https://github.com/markdownlint/markdownlint/blob/master/docs/configuration.md).
6
+ #
7
+ # The plugin runs in serving mode only.
8
+ #
9
+ Jekyll ::Hooks . register :site , :post_write do |site |
10
+ next unless site . config [ 'serving' ]
11
+ staged_files = `git ls-files -m` . split ( "\n " )
12
+ staged_md_files = staged_files . select { |file | File . extname ( file ) == '.md' }
13
+ next if staged_md_files . empty?
14
+ puts 'Checking Markdown syntax...' . blue
15
+ staged_md_files_as_a_string = staged_md_files . join ( ' ' )
16
+ report = `bin/mdl #{ staged_md_files_as_a_string } `
17
+ puts report . yellow
18
+ puts 'The style is defined in _checks/md_style' . yellow
19
+ end
Original file line number Diff line number Diff line change
1
+ # Approved style
2
+ rule 'MD001'
3
+ exclude_rule 'MD002'
4
+ rule 'MD003', :style => :atx
5
+ rule 'MD004'
6
+ rule 'MD005'
7
+ rule 'MD006'
8
+ rule 'MD009'
9
+ rule 'MD010'
10
+ rule 'MD011'
11
+ rule 'MD012'
12
+ exclude_rule 'MD013'
13
+ exclude_rule 'MD014'
14
+ rule 'MD018'
15
+ rule 'MD019'
16
+ exclude_rule 'MD020'
17
+ exclude_rule 'MD021'
18
+ rule 'MD022'
19
+ rule 'MD023'
20
+ rule 'MD024', :allow_different_nesting => true
21
+ rule 'MD025'
22
+
23
+ # The following rules still require Docs team review and approval
24
+ exclude_rule 'MD007'
25
+ exclude_rule 'MD026'
26
+ exclude_rule 'MD027'
27
+ exclude_rule 'MD028'
28
+ exclude_rule 'MD029'
29
+ exclude_rule 'MD030'
30
+ exclude_rule 'MD031'
31
+ exclude_rule 'MD032'
32
+ exclude_rule 'MD033'
33
+ exclude_rule 'MD034'
34
+ exclude_rule 'MD035'
35
+ exclude_rule 'MD036'
36
+ exclude_rule 'MD037'
37
+ exclude_rule 'MD038'
38
+ exclude_rule 'MD039'
39
+ exclude_rule 'MD040'
40
+ exclude_rule 'MD041'
41
+ exclude_rule 'MD046'
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'mdl' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV [ "BUNDLE_GEMFILE" ] ||= File . expand_path ( "../../Gemfile" ,
13
+ Pathname . new ( __FILE__ ) . realpath )
14
+
15
+ bundle_binstub = File . expand_path ( "../bundle" , __FILE__ )
16
+
17
+ if File . file? ( bundle_binstub )
18
+ if File . read ( bundle_binstub , 300 ) =~ /This file was generated by Bundler/
19
+ load ( bundle_binstub )
20
+ else
21
+ abort ( "Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again." )
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem . bin_path ( "mdl" , "mdl" )
Original file line number Diff line number Diff line change @@ -11,4 +11,19 @@ namespace :check do
11
11
end
12
12
system "bin/image_optim --no-pngout --no-svgo --recursive #{ path } "
13
13
end
14
+
15
+ desc 'Check Markdown syntax in modified files or in a particular file or directory by path (e.g. path=mftf)'
16
+ task :mdl do
17
+ path = ENV [ 'path' ]
18
+ unless path
19
+ staged_files = `git ls-files -m` . split ( "\n " )
20
+ staged_md_files = staged_files . select { |file | File . extname ( file ) == '.md' }
21
+ abort 'Cannot find any modified .md files.' . magenta if staged_md_files . empty?
22
+ path = staged_md_files . join ( ' ' )
23
+ end
24
+ puts 'Running Markdown linter ...' . magenta
25
+ report = `bin/mdl #{ path } `
26
+ puts report . yellow
27
+ puts 'The rules are defined in _checks/md_style' . magenta
28
+ end
14
29
end
You can’t perform that action at this time.
0 commit comments