Class: Mdlint::Linter::Rules::JapaneseWidth

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



184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/mdlint/linter/rules/japanese.rb', line 184

def check(tokens, _source)
  each_inline(tokens) do |token|
    content = prose_content(token)
    next unless content.match?(JAPANESE)
    next unless content.match?(/[()\[\]{},.!?;:]/)

    add_violation(
      message: "Use full-width brackets and punctuation in Japanese prose",
      line: line_for(token),
      fixable: false
    )
  end
  @violations
end