mdl 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e214c7494f0a1796f51fea727bc16877f8b9aa82
4
- data.tar.gz: 6342d6617202c3512dd2a0d721c321a0a9fa0edd
3
+ metadata.gz: 9b4aab66e36530dc982328a64e931370dcd484c9
4
+ data.tar.gz: 69c11c9027df69c408e9f854341a6e54412d2c1c
5
5
  SHA512:
6
- metadata.gz: bad0ee00e294fc844d26a47964008ec31ecd62ac696daa2cd43b81183063ef5eb647237df26b0f9b455a741b6d77d77a6080ab7d7eb5aa9c9572748b9db75235
7
- data.tar.gz: aa8a0269c402be1dd9ef0a0cdcfce900026c3726a73d8d2cc31b34080968c736131976e65386291088ed34ae6601f2958db1f4527ffdad76455b645691fea3c2
6
+ metadata.gz: 47a151052b1220aedefc36019406ec451a6f03c919c91e500780dcb696637bf2e315204ae08d468937d93536eaca078d2295b5ef013adecc4bb21155c9d8956e
7
+ data.tar.gz: 36228402d91b627ee1d35e2447dba6fa65457f971fc55a8dbdc94fd262032c7f541a43c7ea69441d987b0591bcf293ace021aa0ec13baf6882ef56ef3265d5e0
data/README.md CHANGED
@@ -13,7 +13,7 @@ simple to install and use.
13
13
 
14
14
  To install from rubygems, run:
15
15
 
16
- gem install markdownlint
16
+ gem install mdl
17
17
 
18
18
  To install the latest development version from github:
19
19
 
@@ -48,7 +48,8 @@ well as how to correct it:
48
48
  README.md:73: MD029 Ordered list item prefix
49
49
 
50
50
  Markdownlint has many more options you can pass on the command line, run
51
- `mdl --help` to see what they are.
51
+ `mdl --help` to see what they are, or see the documentation on
52
+ [configuring markdownlint](docs/configuration.md).
52
53
 
53
54
  ### Styles
54
55
 
data/docs/RULES.md CHANGED
@@ -164,7 +164,7 @@ Corrected Example:
164
164
  * List item
165
165
  * Nested list item indented by 2 spaces
166
166
 
167
- Rationale (2 space indent): indending by 2 spaces allows the content of a
167
+ Rationale (2 space indent): indenting by 2 spaces allows the content of a
168
168
  nested list to be in line with the start of the content of the parent list
169
169
  when a single space is used after the list marker.
170
170
 
@@ -189,7 +189,7 @@ find the line that is triggered and remove any trailing spaces from the end.
189
189
 
190
190
  Tags: whitespace, hard_tab
191
191
 
192
- This rule is triggered any any lines that contain hard tab characters instead
192
+ This rule is triggered by any lines that contain hard tab characters instead
193
193
  of using spaces for indentation. To fix this, replace any hard tab characters
194
194
  with spaces instead.
195
195
 
@@ -291,7 +291,7 @@ for more information.
291
291
 
292
292
  Tags: headers, atx, spaces
293
293
 
294
- This rule is triggered when when spaces are missing after the hash characters
294
+ This rule is triggered when spaces are missing after the hash characters
295
295
  in an atx style header:
296
296
 
297
297
  #Header 1
@@ -309,7 +309,7 @@ space:
309
309
 
310
310
  Tags: headers, atx, spaces
311
311
 
312
- This rule is triggered when when more than one space is used to separate the
312
+ This rule is triggered when more than one space is used to separate the
313
313
  header text from the hash characters in an atx style header:
314
314
 
315
315
  # Header 1
@@ -327,7 +327,7 @@ space:
327
327
 
328
328
  Tags: headers, atx_closed, spaces
329
329
 
330
- This rule is triggered when when spaces are missing inside the hash characters
330
+ This rule is triggered when spaces are missing inside the hash characters
331
331
  in a closed atx style header:
332
332
 
333
333
  #Header 1#
@@ -347,7 +347,7 @@ Note: this rule will fire if either side of the header is missing spaces.
347
347
 
348
348
  Tags: headers, atx_closed, spaces
349
349
 
350
- This rule is triggered when when more than one space is used to separate the
350
+ This rule is triggered when more than one space is used to separate the
351
351
  header text from the hash characters in a closed atx style header:
352
352
 
353
353
  # Header 1 #
@@ -388,7 +388,7 @@ To fix this, ensure that all headers have a blank line both before and after
388
388
 
389
389
  ## Header 2
390
390
 
391
- Rationale: Aside from asthetic reasons, some parsers, including kramdown, will
391
+ Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will
392
392
  not parse headers that don't have a blank line before, and will parse them as
393
393
  regular text.
394
394
 
@@ -607,3 +607,78 @@ inside the list:
607
607
 
608
608
  To fix this, ensure the correct number of spaces are used after list marker
609
609
  for your selected document style.
610
+
611
+ ## MD031 - Fenced code blocks should be surrounded by blank lines
612
+
613
+ Tags: code, blank_lines
614
+
615
+ This rule is triggered when fenced code blocks are either not preceded or not
616
+ followed by a blank line:
617
+
618
+ Some text
619
+ ```
620
+ Code block
621
+ ```
622
+
623
+ ```
624
+ Another code block
625
+ ```
626
+ Some more text
627
+
628
+ To fix this, ensure that all fenced code blocks have a blank line both before
629
+ and after (except where the block is at the beginning or end of the document):
630
+
631
+ Some text
632
+
633
+ ```
634
+ Code block
635
+ ```
636
+
637
+ ```
638
+ Another code block
639
+ ```
640
+
641
+ Some more text
642
+
643
+ Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will
644
+ not parse fenced code blocks that don't have blank lines before and after them.
645
+
646
+ ## MD032 - Lists should be surrounded by blank lines
647
+
648
+ Tags: bullet, ul, ol, blank_lines
649
+
650
+ This rule is triggered when lists (of any kind) are either not preceded or not
651
+ followed by a blank line:
652
+
653
+ Some text
654
+ * Some
655
+ * List
656
+
657
+ 1. Some
658
+ 2. List
659
+ Some text
660
+
661
+ To fix this, ensure that all lists have a blank line both before and after
662
+ (except where the block is at the beginning or end of the document):
663
+
664
+ Some text
665
+
666
+ * Some
667
+ * List
668
+
669
+ 1. Some
670
+ 2. List
671
+
672
+ Some text
673
+
674
+ Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will
675
+ not parse lists that don't have blank lines before and after them.
676
+
677
+ Note: List items without hanging indents are a violation of this rule; list
678
+ items with hanging indents are okay:
679
+
680
+ * This is
681
+ not okay
682
+
683
+ * This is
684
+ okay
@@ -0,0 +1,70 @@
1
+ # Mdl configuration
2
+
3
+ Markdownlint has several options you can configure both on the command line,
4
+ or in markdownlint's configuration file: `.mdlrc` in your home directory.
5
+ While markdownlint will work perfectly well out of the box, this page
6
+ documents some of the options you can change to suit your needs.
7
+
8
+ In general, anything you pass on the command line can also be put into
9
+ `~/.mdlrc` with the same option. For example, if you pass `--style foo` on the
10
+ command line, you can make this the default by putting `style "foo"` into your
11
+ `~/.mdlrc` file.
12
+
13
+ ## Configuration options
14
+
15
+ ### General options
16
+
17
+ Verbose - Print additional information about what markdownlint is doing.
18
+
19
+ * Command line: `-v`, `--verbose`
20
+ * Config file: `verbose true`
21
+ * Default: false
22
+
23
+ Show warnings - Kramdown will generate warnings of its own for some issues
24
+ found with documents during parsing, and markdownlint can print these out in
25
+ addition to using the built in rules. This option enables/disables that
26
+ behavior.
27
+
28
+ * Command line: `-w`, `--warnings`
29
+ * Config file: `show_kramdown_warnings true`
30
+ * Default: true
31
+
32
+ Recurse using files known to git - When mdl is given a directory name on the
33
+ command line, it will recurse into that directory looking for markdown files
34
+ to process. If this option is enabled, it will use git to look for files
35
+ instead, and ignore any files git doesn't know about.
36
+
37
+ * Command line: `-g`, `--git-recurse`
38
+ * Config file: `git_recurse true`
39
+ * Default: false
40
+
41
+ ### Specifying which rules mdl processes
42
+
43
+ Tags - Limit the rules mdl enables to those containing the provided tags.
44
+
45
+ * Command line: `-t tag1,tag2`, `--tags tag1,tag2`
46
+ * Config file: `tags "tag1", "tag2"`
47
+ * Default: process all rules (no tag limit)
48
+
49
+ Rules - Limit the rules mdl enables to those provided in this option.
50
+
51
+ * Command line: `-r MD001,MD002`, `--rules MD001,MD002`
52
+ * Config file: `rules "MD001", "MD002"`
53
+ * Default: process all rules (no rule limit)
54
+
55
+ Note: if both `--rules` and `--tags` are provided, then a given rule has to
56
+ both be in the list of enabled rules, as well as be tagged with one of the
57
+ tags provided with the `--tags` option.
58
+
59
+ Style - Select which style mdl uses. A 'style' is a file containing a list of
60
+ enabled/disable rules, as well as options for some rules that take them. For
61
+ example, one style might enforce a line length of 80 characters, while another
62
+ might choose 72 characters, and another might have no line length limit at all
63
+ (rule MD013).
64
+
65
+ * Command line: `-s style_name`, `--style style_name`
66
+ * Config file: `style "style_name"`
67
+ * Default: Use the style called 'default'
68
+
69
+ Note: the value for `style_name` must either end with `.rb` or have `/` in it
70
+ in order to tell `mdl` to look for a custom style, and not a built-in style.
@@ -0,0 +1,18 @@
1
+ # Rolling a new release
2
+
3
+ Bump the version. Markdownlint uses semantic versioning. From
4
+ <http://semver.org/>:
5
+
6
+ * Major version for backwards-incompatible changes
7
+ * Minor version functionality added in a backwards-compatible manner
8
+ * Patch version for backwards-compatible bug fixes
9
+ * Exception: Versions < 1.0 may introduce backwards-incompatible changes in a
10
+ minor version.
11
+
12
+ To bump the version, edit `lib/mdl/version.rb` and commit to the master
13
+ branch.
14
+
15
+ Next, run `rake release`. This will:
16
+
17
+ * Tag vX.Y.Z in git and push it.
18
+ * Upload the new gem to rubygems.org
data/lib/mdl/doc.rb CHANGED
@@ -28,14 +28,6 @@ module MarkdownLint
28
28
  # Create a new document given a string containing the markdown source
29
29
 
30
30
  def initialize(text)
31
- # Workaround for the following two issues:
32
- # https://github.com/mivok/markdownlint/issues/52
33
- # https://github.com/gettalong/kramdown/issues/158
34
- # Unfortunately this forces all input text back into ascii, which may
35
- # be problematic for any rules that make use of non-ascii characters, so
36
- # we should remove this if it no longer becomes necessary to do so.
37
- text.encode!("ASCII", invalid: :replace, undef: :replace, replace: '')
38
-
39
31
  @lines = text.split("\n")
40
32
  @parsed = Kramdown::Document.new(text, :input => 'MarkdownLint')
41
33
  @elements = @parsed.root.children
@@ -159,15 +151,15 @@ module MarkdownLint
159
151
  raise "list_style called with non-list element"
160
152
  end
161
153
  line = element_line(item).strip
162
- if line.start_with?("*")
154
+ if line.start_with?('*')
163
155
  :asterisk
164
- elsif line.start_with?("+")
156
+ elsif line.start_with?('+')
165
157
  :plus
166
- elsif line.start_with?("-")
158
+ elsif line.start_with?('-')
167
159
  :dash
168
- elsif line.match("[0-9]+\.")
160
+ elsif line.match('[0-9]+\.')
169
161
  :ordered
170
- elsif line.match("[0-9]+\)")
162
+ elsif line.match('[0-9]+\)')
171
163
  :ordered_paren
172
164
  else
173
165
  :unknown
@@ -14,14 +14,6 @@ module Kramdown
14
14
  @block_parsers.insert(i, :codeblock_fenced_gfm)
15
15
  end
16
16
 
17
- # Add location information to text elements
18
- def add_text(text, tree = @tree, type = @text_type)
19
- super
20
- if tree.children.last
21
- tree.children.last.options[:location] = @src.current_line_number
22
- end
23
- end
24
-
25
17
  # Regular kramdown parser, but with GFM style fenced code blocks
26
18
  FENCED_CODEBLOCK_MATCH = Kramdown::Parser::GFM::FENCED_CODEBLOCK_MATCH
27
19
  end
data/lib/mdl/rules.rb CHANGED
@@ -161,7 +161,8 @@ rule "MD014", "Dollar signs used before commands without showing output" do
161
161
  tags :code
162
162
  check do |doc|
163
163
  doc.find_type_elements(:codeblock).select{
164
- |e| not e.value.split(/\n+/).map{|l| l.match(/^\$\s/)}.include?(nil)
164
+ |e| not e.value.empty? and
165
+ not e.value.split(/\n+/).map{|l| l.match(/^\$\s/)}.include?(nil)
165
166
  }.map{|e| doc.element_linenumber(e)}
166
167
  end
167
168
  end
@@ -391,3 +392,53 @@ rule "MD030", "Spaces after list markers" do
391
392
  errors
392
393
  end
393
394
  end
395
+
396
+ rule "MD031", "Fenced code blocks should be surrounded by blank lines" do
397
+ tags :code, :blank_lines
398
+ check do |doc|
399
+ errors = []
400
+ # Some parsers (including kramdown) have trouble detecting fenced code
401
+ # blocks without surrounding whitespace, so examine the lines directly.
402
+ in_code = false
403
+ lines = [ "" ] + doc.lines + [ "" ]
404
+ lines.each_with_index do |line, linenum|
405
+ if line.strip.match(/^(```|~~~)/)
406
+ in_code = !in_code
407
+ if (in_code and not lines[linenum - 1].empty?) or
408
+ (not in_code and not lines[linenum + 1].empty?)
409
+ errors << linenum
410
+ end
411
+ end
412
+ end
413
+ errors
414
+ end
415
+ end
416
+
417
+ rule "MD032", "Lists should be surrounded by blank lines" do
418
+ tags :bullet, :ul, :ol, :blank_lines
419
+ check do |doc|
420
+ errors = []
421
+ # Some parsers (including kramdown) have trouble detecting lists
422
+ # without surrounding whitespace, so examine the lines directly.
423
+ in_list = false
424
+ in_code = false
425
+ prev_line = ""
426
+ doc.lines.each_with_index do |line, linenum|
427
+ if not in_code
428
+ list_marker = line.strip.match(/^([\*\+\-]|(\d+\.))\s/)
429
+ if list_marker and not in_list and not prev_line.match(/^($|\s)/)
430
+ errors << linenum + 1
431
+ elsif not list_marker and in_list and not line.match(/^($|\s)/)
432
+ errors << linenum
433
+ end
434
+ in_list = list_marker
435
+ end
436
+ if line.strip.match(/^(```|~~~)/)
437
+ in_code = !in_code
438
+ in_list = false
439
+ end
440
+ prev_line = line
441
+ end
442
+ errors.uniq
443
+ end
444
+ end
data/lib/mdl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module MarkdownLint
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
data/mdl.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.required_ruby_version = '>= 1.9.2'
22
22
 
23
- spec.add_dependency 'kramdown', '~> 1.4', '>= 1.4.0'
23
+ spec.add_dependency 'kramdown', '~> 1.5', '>= 1.5.0'
24
24
  spec.add_dependency 'mixlib-config', '~> 2.1', '>= 2.1.0'
25
25
  spec.add_dependency 'mixlib-cli', '~> 1.5', '>= 1.5.0'
26
26
 
@@ -20,3 +20,14 @@ The following code block uses variable names, and likewise shouldn't fire:
20
20
 
21
21
  $foo = 'bar';
22
22
  $baz = 'qux';
23
+
24
+ The following code block doesn't have any dollar signs, and shouldn't fire:
25
+
26
+ ls foo
27
+ cat bar
28
+
29
+ The following (fenced) code block doesn't have any content at all, and
30
+ shouldn't fire:
31
+
32
+ ```
33
+ ```
@@ -0,0 +1,42 @@
1
+ ```
2
+ code at start of file
3
+ ```
4
+
5
+ text
6
+
7
+ ```ruby
8
+ code
9
+ ```
10
+
11
+ text
12
+ ``` {MD031}
13
+ code
14
+ ``` {MD031}
15
+ text
16
+
17
+ ```
18
+ code
19
+ ``` {MD031}
20
+ text
21
+
22
+ text
23
+ ``` {MD031}
24
+ code
25
+ ```
26
+
27
+ text
28
+
29
+ ```js
30
+ code
31
+ code
32
+ code
33
+ ```
34
+
35
+ ```html
36
+ ```
37
+
38
+ text
39
+
40
+ ```
41
+ code at end of file without newline
42
+ ```
@@ -0,0 +1,75 @@
1
+ * list (on first line)
2
+
3
+ text
4
+
5
+ * list
6
+
7
+ text
8
+ * list {MD032}
9
+ text
10
+ + list {MD032}
11
+ text
12
+ - list {MD032}
13
+ text
14
+ 1. list {MD032}
15
+ text
16
+
17
+ * list
18
+ * list {MD032}
19
+ text
20
+
21
+ text
22
+ 10. list {MD032}
23
+ 20. list
24
+
25
+ text
26
+
27
+ * list
28
+ * list
29
+ * list
30
+
31
+ text
32
+
33
+ * list
34
+ with hanging indent
35
+ * list
36
+ with hanging indent
37
+ * list
38
+ with hanging indent
39
+
40
+ Note: list without hanging indent violates MD032
41
+
42
+ * list
43
+
44
+ item with blank lines
45
+
46
+ * list
47
+
48
+ item with blank lines
49
+
50
+ text
51
+
52
+ ```js
53
+ /*
54
+ * code block
55
+ * not a list
56
+ */
57
+ ```
58
+
59
+ text
60
+
61
+ * list {MD032}
62
+ ``` {MD031}
63
+ code
64
+ ```
65
+
66
+ text
67
+
68
+ ```
69
+ code
70
+ ``` {MD031}
71
+ * list {MD032}
72
+
73
+ text
74
+
75
+ * list (on last line without newline)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Harrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-07 00:00:00.000000000 Z
11
+ date: 2015-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.4'
19
+ version: '1.5'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 1.4.0
22
+ version: 1.5.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: '1.4'
29
+ version: '1.5'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 1.4.0
32
+ version: 1.5.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: mixlib-config
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -142,8 +142,10 @@ files:
142
142
  - Rakefile
143
143
  - bin/mdl
144
144
  - docs/RULES.md
145
+ - docs/configuration.md
145
146
  - docs/creating_rules.md
146
147
  - docs/creating_styles.md
148
+ - docs/rolling_a_release.md
147
149
  - example/markdown_spec.md
148
150
  - lib/mdl.rb
149
151
  - lib/mdl/cli.rb
@@ -174,6 +176,7 @@ files:
174
176
  - test/rule_tests/consistent_bullet_styles_plus.md
175
177
  - test/rule_tests/empty_doc.md
176
178
  - test/rule_tests/fenced_code_blocks.md
179
+ - test/rule_tests/fenced_code_without_blank_lines.md
177
180
  - test/rule_tests/first_header_bad_atx.md
178
181
  - test/rule_tests/first_header_bad_setext.md
179
182
  - test/rule_tests/first_header_good_atx.md
@@ -205,6 +208,7 @@ files:
205
208
  - test/rule_tests/incorrect_header_atx_style.rb
206
209
  - test/rule_tests/incorrect_header_setext.md
207
210
  - test/rule_tests/incorrect_header_setext_style.rb
211
+ - test/rule_tests/lists_without_blank_lines.md
208
212
  - test/rule_tests/long_lines.md
209
213
  - test/rule_tests/long_lines_100.md
210
214
  - test/rule_tests/long_lines_100_style.rb
@@ -244,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
244
248
  version: '0'
245
249
  requirements: []
246
250
  rubyforge_project:
247
- rubygems_version: 2.2.1
251
+ rubygems_version: 2.4.4
248
252
  signing_key:
249
253
  specification_version: 4
250
254
  summary: Markdown lint tool
@@ -264,6 +268,7 @@ test_files:
264
268
  - test/rule_tests/consistent_bullet_styles_plus.md
265
269
  - test/rule_tests/empty_doc.md
266
270
  - test/rule_tests/fenced_code_blocks.md
271
+ - test/rule_tests/fenced_code_without_blank_lines.md
267
272
  - test/rule_tests/first_header_bad_atx.md
268
273
  - test/rule_tests/first_header_bad_setext.md
269
274
  - test/rule_tests/first_header_good_atx.md
@@ -295,6 +300,7 @@ test_files:
295
300
  - test/rule_tests/incorrect_header_atx_style.rb
296
301
  - test/rule_tests/incorrect_header_setext.md
297
302
  - test/rule_tests/incorrect_header_setext_style.rb
303
+ - test/rule_tests/lists_without_blank_lines.md
298
304
  - test/rule_tests/long_lines.md
299
305
  - test/rule_tests/long_lines_100.md
300
306
  - test/rule_tests/long_lines_100_style.rb
@@ -311,4 +317,3 @@ test_files:
311
317
  - test/setup_tests.rb
312
318
  - test/test_ruledocs.rb
313
319
  - test/test_rules.rb
314
- has_rdoc: