lib/html2doc/lists.rb in html2doc-0.8.8 vs lib/html2doc/lists.rb in html2doc-0.8.9
- old
+ new
@@ -1,10 +1,9 @@
require "uuidtools"
require "asciimath"
require "htmlentities"
require "nokogiri"
-require "xml/xslt"
require "pp"
module Html2Doc
def self.style_list(li, level, liststyle, listnumber)
return unless liststyle
@@ -27,11 +26,11 @@
end
end
def self.list2para(u)
return if u.xpath("./li").empty?
- u.xpath("./li").last["class"] = "MsoListParagraphCxSpLast"
- u.xpath("./li").first["class"] = "MsoListParagraphCxSpFirst"
+ u.xpath("./li").first["class"] ||= "MsoListParagraphCxSpFirst"
+ u.xpath("./li").last["class"] ||= "MsoListParagraphCxSpLast"
u.xpath("./li/p").each { |p| p["class"] ||= "MsoListParagraphCxSpMiddle" }
u.xpath("./li").each do |l|
l.name = "p"
l["class"] ||= "MsoListParagraphCxSpMiddle"
l&.first_element_child&.name == "p" and l.first_element_child.replace(l.first_element_child.children)