Module: Mdlint::Linter::Rules::JapaneseHelpers
- Included in:
- JapaneseCommaCount, JapaneseDuplicateParticle, JapanesePunctuation, JapaneseSentenceLength, JapaneseSpacing, JapaneseStyle, JapaneseWidth
- Defined in:
- lib/mdlint/linter/rules/japanese.rb,
sig/internal.rbs
Constant Summary collapse
- CJK =
/[\p{Han}\p{Hiragana}\p{Katakana}\p{Hangul}]/- JAPANESE =
/[\p{Han}\p{Hiragana}\p{Katakana}]/
Instance Method Summary collapse
- #each_inline(tokens) {|token| ... } ⇒ Object
- #line_for(token) ⇒ Integer
- #prose_content(token) ⇒ String
Instance Method Details
#each_inline(tokens) {|token| ... } ⇒ Object
12 13 14 15 16 |
# File 'lib/mdlint/linter/rules/japanese.rb', line 12 def each_inline(tokens) tokens.each do |token| yield token if token.type == :inline end end |
#line_for(token) ⇒ Integer
24 25 26 |
# File 'lib/mdlint/linter/rules/japanese.rb', line 24 def line_for(token) (token.map&.first || 0) + 1 end |
#prose_content(token) ⇒ String
18 19 20 21 22 |
# File 'lib/mdlint/linter/rules/japanese.rb', line 18 def prose_content(token) token.children.filter_map do |child| child.content if %i[text html_inline softbreak hardbreak].include?(child.type) end.join end |