Method: MarkdownLint::Doc#matching_text_element_lines
- Defined in:
- lib/mdl/doc.rb
#matching_text_element_lines(re, exclude_nested = [:a]) ⇒ Object
Returns line numbers for lines that match the given regular expression. Only considers text inside of ‘text’ elements (i.e. regular markdown text and not code/links or other elements).
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/mdl/doc.rb', line 229 def matching_text_element_lines(re, exclude_nested=[:a]) matches = [] find_type_elements_except(:text, exclude_nested).each do |e| first_line = e.[:location] # We'll error out if kramdown doesn't have location information for # the current element. It's better to just not match in these cases # rather than crash. next if first_line.nil? lines = e.value.split("\n") lines.each_with_index do |l, i| matches << first_line + i if re.match(l) end end matches end |