Class: Marcdouane::Rules::SingleTopLevelHeader
- Defined in:
- lib/marcdouane/rules/single_top_level_header.rb
Overview
Ensure that there is only a single top-level header in the file.
Constant Summary collapse
- ERROR_MESSAGE =
"A top-level header is already present"
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
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/marcdouane/rules/single_top_level_header.rb', line 9 def check! previously_seen = false @markdown.on(:heading) do |header| if header.level == 1 if previously_seen error!(line_number_from_byte_range(header.byte_range)) else previously_seen = true end end end @markdown.walk end |