Class: Mdlint::Linter::Rules::NoSpaceInEmphasis

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

Constant Summary

Constants included from SourceStyleSupport

SourceStyleSupport::FENCE_REGEXP, SourceStyleSupport::LIST_MARKER_REGEXP

Instance Attribute Summary

Attributes inherited from Mdlint::Linter::Rule

#violations

Instance Method Summary collapse

Methods included from SourceStyleSupport

#fenced_lines, #inline_tokens, #line_is_blank?, #lines, #outside_fence?

Methods inherited from Mdlint::Linter::Rule

#add_violation, #fix, inherited, #initialize

Constructor Details

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

Instance Method Details

#check(_tokens, source) ⇒ Object



216
217
218
219
220
221
222
223
# File 'lib/mdlint/linter/rules/source_style.rb', line 216

def check(_tokens, source)
  source.each_line.with_index(1) do |line, line_number|
    next unless line.match?(/(?:\*\*|__|(?<!\*)\*)(?:\s+)[^\n]+?(?:\s+)(?:\*\*|__|(?<!\*)\*(?!\*))/)

    add_violation(message: "Remove spaces inside emphasis markers", line: line_number, fixable: false)
  end
  @violations
end