mdl 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb98b688ab9d9dc7bac3c169f20fefc7c0cb27ce5bf574bec52053d592b7a9c7
4
- data.tar.gz: 873df51b4011d23617c1d73ab47a1928765fee0502b6f58853e2932bb3d5ec59
3
+ metadata.gz: ce6e17c304d4a4d4ca5b98216786a517a7a121f13bd3e4c96b0be1f3dc3c7fb7
4
+ data.tar.gz: 66fad7cfe37a2eb2b300a4957f5773ed97096cc5623fe54dfce33182aa1961f3
5
5
  SHA512:
6
- metadata.gz: fea533cf2d4a61c4da291a094e3f94080acee8837919935e789e1b39c98d8bcc416cb9fcb143a10a1f63738ee993d3fe5ce89ca3dc664a9a11712796db8dbc4d
7
- data.tar.gz: 8dc7470f981b1267dddb1f668afc4f85c742d6c467ae9a31bcaf24618792d6d9c7792a328ff3258d8efd071d9592b4a84600a2825e787b26d1cb5f7e979989af
6
+ metadata.gz: 24729a6e51b0d14ce062a1450975a7a25171a99058748b4a9318be53400d0414156f2199961472c1df5d60b7bcc6460449af01a56355360e867e8bd8b3f5ea9f
7
+ data.tar.gz: 272b422026df12ed0c30ce97f390468817867a2a649f4a37d6f1b438a08f8b3bf2e81ebecc509cb1bd553d052b1543d9130cd142be2bacd0f11637b69f9e0599
data/lib/mdl/rules.rb CHANGED
@@ -799,92 +799,3 @@ rule 'MD047', 'File should end with a single newline character' do
799
799
  error_lines
800
800
  end
801
801
  end
802
-
803
- rule 'MD055', 'Table row doesn\'t begin/end with pipes' do
804
- tags :tables
805
- aliases 'table-rows-start-and-end-with-pipes'
806
- check do |doc|
807
- error_lines = []
808
- tables = doc.find_type_elements(:table)
809
- lines = doc.lines
810
-
811
- tables.each do |table|
812
- table_pos = table.options[:location] - 1
813
- table_rows = get_table_rows(lines, table_pos)
814
-
815
- table_rows.each_with_index do |line, index|
816
- if line.length < 2 || line[0] != '|' || line[-1] != '|'
817
- error_lines << (table_pos + index + 1)
818
- end
819
- end
820
- end
821
-
822
- error_lines
823
- end
824
- end
825
-
826
- rule 'MD056', 'Table has inconsistent number of columns' do
827
- tags :tables
828
- aliases 'inconsistent-columns-in-table'
829
- check do |doc|
830
- error_lines = []
831
- tables = doc.find_type_elements(:table)
832
- lines = doc.lines
833
-
834
- tables.each do |table|
835
- table_pos = table.options[:location] - 1
836
- table_rows = get_table_rows(lines, table_pos)
837
-
838
- num_headings = number_of_columns_in_a_table_row(lines[table_pos])
839
-
840
- table_rows.each_with_index do |line, index|
841
- if number_of_columns_in_a_table_row(line) != num_headings
842
- error_lines << (table_pos + index + 1)
843
- end
844
- end
845
- end
846
-
847
- error_lines
848
- end
849
- end
850
-
851
- rule 'MD057', 'Table has missing or invalid header separation (second row)' do
852
- tags :tables
853
- aliases 'table-invalid-second-row'
854
- check do |doc|
855
- error_lines = []
856
- tables = doc.find_type_elements(:table)
857
- lines = doc.lines
858
-
859
- tables.each do |table|
860
- second_row = ''
861
-
862
- # line number of table start (1-indexed)
863
- # which is equal to second row's index (0-indexed)
864
- line_num = table.options[:location]
865
- second_row = lines[line_num] if line_num < lines.length
866
-
867
- # This pattern matches if
868
- # 1) The row starts and stops with | characters
869
- # 2) Only consists of characters '|', '-', ':' and whitespace
870
- # 3) Each section between the separators (i.e. '|')
871
- # a) has at least three consecutive dashes
872
- # b) can have whitespace at the beginning or the end
873
- # c) can have colon before and/or after dashes (for alignment)
874
- # Some examples:
875
- # |-----|----|-------| --> matches
876
- # |:---:|:---|-------| --> matches
877
- # | :------: | ----| --> matches
878
- # | - - - | - - - | --> does NOT match
879
- # |::---| --> does NOT match
880
- # |----:|:--|----| --> does NOT match
881
- pattern = /^(\|\s*:?-{3,}:?\s*)+\|$/
882
- unless second_row.match(pattern)
883
- # Second row is not in the form described by the pattern
884
- error_lines << (line_num + 1)
885
- end
886
- end
887
-
888
- error_lines
889
- end
890
- end
data/lib/mdl/ruleset.rb CHANGED
@@ -48,67 +48,6 @@ module MarkdownLint
48
48
  def docs_url
49
49
  @generate_docs&.call(id, description)
50
50
  end
51
-
52
- # This method calculates the number of columns in a table row
53
- #
54
- # @param [String] table_row A row of the table in question.
55
- # @return [Numeric] Number of columns in the row
56
- def number_of_columns_in_a_table_row(table_row)
57
- columns = table_row.strip.split('|')
58
-
59
- if columns.empty?
60
- # The stripped line consists of zero or more pipe characters
61
- # and nothing more.
62
- #
63
- # Examples of stripped rows:
64
- # '||' --> one column
65
- # '|||' --> two columns
66
- # '|' --> zero columns
67
- [0, table_row.count('|') - 1].max
68
- else
69
- # Number of columns is the number of splited
70
- # segments with pipe separator. The first segment
71
- # is ignored when it's empty string because
72
- # someting like '|1|2|' is split into ['', '1', '2']
73
- # when using split('|') function.
74
- #
75
- # Some examples:
76
- # '|foo|bar|' --> two columns
77
- # ' |foo|bar|' --> two columns
78
- # '|foo|bar' --> two columns
79
- # 'foo|bar' --> two columns
80
- columns.size - (columns[0].empty? ? 1 : 0)
81
- end
82
- end
83
-
84
- # This method returns all the rows of a table
85
- #
86
- # @param [Array<String>] lines Lines of a doc as an array
87
- # @param [Numeric] pos Position/index of the table in the array
88
- # @return [Array<String>] Rows of the table in an array
89
- def get_table_rows(lines, pos)
90
- table_rows = []
91
- while pos < lines.length
92
- line = lines[pos]
93
-
94
- # If the previous line is a table and the current line
95
- # 1) includes pipe character
96
- # 2) does not start with code block identifiers
97
- # a) >= 4 spaces
98
- # b) < 4 spaces and ``` right after
99
- #
100
- # it is possibly a table row
101
- unless line.include?('|') && !line.start_with?(' ') &&
102
- !line.strip.start_with?('```')
103
- break
104
- end
105
-
106
- table_rows << line
107
- pos += 1
108
- end
109
-
110
- table_rows
111
- end
112
51
  end
113
52
 
114
53
  # defines a ruleset
data/lib/mdl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module MarkdownLint
2
- VERSION = '0.13.0'.freeze
2
+ VERSION = '0.14.0'.freeze
3
3
  end
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.13.0
4
+ version: 0.14.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: 2023-10-02 00:00:00.000000000 Z
11
+ date: 2025-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -220,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
220
  - !ruby/object:Gem::Version
221
221
  version: '0'
222
222
  requirements: []
223
- rubygems_version: 3.3.15
223
+ rubygems_version: 3.5.22
224
224
  signing_key:
225
225
  specification_version: 4
226
226
  summary: Markdown lint tool