Class: Marcdouane::Rules::ConsistentHeaderStyle
- Defined in:
- lib/marcdouane/rules/consistent_header_style.rb
Constant Summary collapse
- ERROR_MESSAGE =
"Use a unique, consistent header style"
Instance Attribute Summary
Attributes inherited from Rule
Instance Method Summary collapse
Methods inherited from Rule
#error!, #identifier, #initialize, #line_number_from_byte_range
Constructor Details
This class inherits a constructor from Marcdouane::Rules::Rule
Instance Method Details
#check! ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/marcdouane/rules/consistent_header_style.rb', line 8 def check! reference_style, style = nil source = @markdown.source.lines.dup @markdown.on(:heading) do |header| line_number = line_number_from_byte_range(header.byte_range) raw_line = source[line_number] if raw_line.start_with?("#") style = :normal else style = :underline end reference_style ||= style if reference_style != style error!(line_number) end end @markdown.walk end |