Class: Mdlint::Linter::Rules::NoMultipleSpacesAfterBlockquote

Inherits:
Mdlint::Linter::Rule show all
Defined in:
lib/mdlint/linter/rules/source_style.rb,
sig/internal.rbs

Instance Attribute Summary

Attributes inherited from Mdlint::Linter::Rule

#violations

Instance Method Summary collapse

Methods inherited from Mdlint::Linter::Rule

#add_violation, inherited, #initialize

Constructor Details

This class inherits a constructor from Mdlint::Linter::Rule

Instance Method Details

#check(_tokens, source) ⇒ Object



107
108
109
110
111
112
113
114
# File 'lib/mdlint/linter/rules/source_style.rb', line 107

def check(_tokens, source)
  source.each_line.with_index(1) do |line, line_number|
    next unless line.chomp.match?(/\A {0,3}> {2,}/)

    add_violation(message: "Use one space after the blockquote marker", line: line_number, fixable: true)
  end
  @violations
end

#fix(_tokens, source) ⇒ Object



116
117
118
# File 'lib/mdlint/linter/rules/source_style.rb', line 116

def fix(_tokens, source)
  source.each_line.map { |line| line.sub(/\A( {0,3}>) {2,}/, '\\1 ') }.join
end