Class: Mdlint::Linter::Rules::JapaneseSpacing

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

Constant Summary

Constants included from JapaneseHelpers

Mdlint::Linter::Rules::JapaneseHelpers::CJK, Mdlint::Linter::Rules::JapaneseHelpers::JAPANESE

Instance Attribute Summary

Attributes inherited from Mdlint::Linter::Rule

#violations

Instance Method Summary collapse

Methods included from JapaneseHelpers

#each_inline, #line_for, #prose_content

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



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/mdlint/linter/rules/japanese.rb', line 37

def check(tokens, _source)
  each_inline(tokens) do |token|
    content = prose_content(token)
    next unless content.match?(JAPANESE)
    next unless content.match?(/(?:#{JAPANESE})[A-Za-z0-9]|[A-Za-z0-9](?:#{JAPANESE})/)

    add_violation(
      message: "Add a space between Japanese and ASCII text",
      line: line_for(token),
      fixable: false
    )
  end
  @violations
end