Sha256: c7def8321ccd3d9df98799e1757e7441cc68e71d7b88e91e64f2ba602ca21085
Contents?: true
Size: 1.71 KB
Versions: 3
Compression:
Stored size: 1.71 KB
Contents
module IsoDoc class Convert def ul_parse(node, out) out.ul do |ul| node.children.each { |n| parse(n, ul) } end end OL_STYLE = { arabic: "1", roman: "i", alphabet: "a", roman_upper: "I", alphabet_upper: "A", }.freeze def ol_style(type) type = :alphabet unless type OL_STYLE[type.to_sym] end # We don't really want users to specify type of ordered list; # we will use a fixed hierarchy as practiced by ISO (though not # fully spelled out): a) 1) i) A) I) # def ol_depth(node) depth = node.ancestors("ul, ol").size + 1 type = :alphabet type = :arabic if [2, 7].include? depth type = :roman if [3, 8].include? depth type = :alphabet_upper if [4, 9].include? depth type = :roman_upper if [5, 10].include? depth ol_style(type) end def ol_parse(node, out) # style = ol_style(node["type"]) style = ol_depth(node) out.ol **attr_code(type: style) do |ol| node.children.each { |n| parse(n, ol) } end end def li_parse(node, out) out.li do |li| node.children.each { |n| parse(n, li) } end end def dt_parse(dt, term) if dt.elements.empty? term.p **attr_code(class: note? ? "Note" : nil) do |p| p << dt.text end else dt.children.each { |n| parse(n, term) } end end def dl_parse(node, out) out.dl do |v| node.elements.each_slice(2) do |dt, dd| v.dt do |term| dt_parse(dt, term) end v.dd do |listitem| dd.children.each { |n| parse(n, listitem) } end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
isodoc-0.5.8 | lib/isodoc/lists.rb |
isodoc-0.5.7 | lib/isodoc/lists.rb |
isodoc-0.5.5 | lib/isodoc/lists.rb |