Sha256: 7e79d9cc6f4a87c359586ecba96bffa7cd88fb82fa08d750105dadd1c294a8b1
Contents?: true
Size: 1.03 KB
Versions: 5
Compression:
Stored size: 1.03 KB
Contents
module Coradoc::Input::HTML module Converters class H < Base def to_coradoc(node, state = {}) id = node["id"] internal_anchor = treat_children_anchors(node, state) if id.to_s.empty? && internal_anchor.size.positive? if internal_anchor.first.respond_to? :id id = internal_anchor.first.id end end level = node.name[/\d/].to_i content = treat_children_no_anchors(node, state) Coradoc::Element::Title.new(content, level, id: id) end def treat_children_no_anchors(node, state) node.children.reject { |a| a.name == "a" }.map do |child| treat_coradoc(child, state) end end def treat_children_anchors(node, state) node.children.select { |a| a.name == "a" }.map do |child| treat_coradoc(child, state) end end end register :h1, H.new register :h2, H.new register :h3, H.new register :h4, H.new register :h5, H.new register :h6, H.new end end
Version data entries
5 entries across 5 versions & 1 rubygems