Class: Mdlint::Linter::Rules::JapaneseDuplicateParticle

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



162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/mdlint/linter/rules/japanese.rb', line 162

def check(tokens, _source)
  each_inline(tokens) do |token|
    next unless prose_content(token).match?(/の[^。!?\n]{0,12}の|に[^。!?\n]{0,12}に/)

    add_violation(
      message: "Check repeated Japanese particles such as の or に",
      line: line_for(token),
      fixable: false
    )
  end
  @violations
end