Class: Marko::Markup::TheSameId
- Defined in:
- lib/marko/markup/validator.rb
Instance Method Summary collapse
Methods inherited from Inspector
Instance Method Details
#report(errs) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/marko/markup/validator.rb', line 49 def report(errs) # the same id [ref] found twice # src/source2.md:22 >> ## header # src/source3.md:11 >> ## header errs.map{|id, nodes| sources = nodes.map{|n| " #{n[:origin]}\n"}.join "the same id [#{id}] found in\n#{sources}" } end |
#select(tree) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/marko/markup/validator.rb', line 42 def select(tree) fn = proc{|n, memo| memo[n.id] ||= []; memo[n.id] << n} tree .each_with_object({}, &fn) .select{|_, v| v.size > 1} end |