Sha256: d20872824bf84671bab7ca49ee4a02b7362445cc7333af188967c2781d6d201b

Contents?: true

Size: 1000 Bytes

Versions: 2

Compression:

Stored size: 1000 Bytes

Contents

class Html2Doc
  class IsoDIS < ::Html2Doc
    def list2para(list)
      return if list.xpath("./li").empty?

      list.xpath("./li").each do |l|
        l.name = "p"
        if m = /level(\d) lfo/.match(l["style"])
          l["class"] = list2para_style(list.name, m[1])
          l.xpath("./p").each do |p|
            p["class"] = list2para_style(list.name, m[1])
          end
        end
        l&.first_element_child&.name == "p" and
          l.first_element_child.replace(l.first_element_child.children)
      end
      list.replace(list.children)
    end

    def list2para_style(listtype, depth)
      case listtype
      when "ul"
        case depth
        when "1" then "ListContinue1"
        when "2", "3", "4" then "MsoListContinue#{depth}"
        else "MsoListContinue5"
        end
      when "ol"
        case depth
        when "1" then "ListNumber1"
        when "2", "3", "4" then "MsoListNumber#{depth}"
        else "MsoListNumber5"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metanorma-iso-2.1.1 lib/html2doc/lists.rb
metanorma-iso-2.1.0 lib/html2doc/lists.rb