lib/isodoc/ieee/word_authority.rb in metanorma-ieee-0.0.1 vs lib/isodoc/ieee/word_authority.rb in metanorma-ieee-0.0.2
- old
+ new
@@ -123,10 +123,14 @@
def feedback_style(docxml)
docxml.at("//div[@class = 'boilerplate-feedback']")&.xpath("./div")
&.each_with_index do |div, i|
i.zero? or div.elements.first.previous = "<p> </p>"
+ i == 4 and
+ div.xpath(".//p[br]").each do |p|
+ p.replace(p.to_xml.gsub(%r{<br/>}, "</p><p>"))
+ end
feedback_style1(div, i)
end
end
def feedback_style1(div, idx)
@@ -151,9 +155,59 @@
(1..2).each do |i|
auth&.xpath(".//h#{i}")&.each do |h|
h.name = "p"
h["class"] = "IEEEStdsLevel#{i}frontmatter"
end
+ end
+ end
+
+ def abstract_cleanup(docxml)
+ dest = docxml.at("div[@id = 'abstract-destination']") or return
+ if f = docxml.at("//div[@class = 'abstract']")
+ f.previous_element.remove
+ abstract_cleanup1(f, dest)
+ f.remove
+ elsif f = docxml.at("//div[@type = 'scope']")
+ abstract_cleanup1(f, dest)
+ abstract_header(dest)
+ end
+ end
+
+ def abstract_cleanup1(source, dest)
+ source.elements.reject { |e| %w(h1 h2).include?(e.name) }.each do |e|
+ e1 = e.dup
+ e1.xpath(".//p").each do |p|
+ p["style"] ||= ""
+ p["style"] = 'font-family: "Arial", sans-serif;' + p["style"]
+ end
+ %w(ul ol).include?(e1.name) or e1["class"] = "IEEEStdsAbstractBody"
+ dest << e1
+ end
+ end
+
+ def abstract_header(dest)
+ dest.elements.first.children.first.previous =
+ "<span class='IEEEStdsAbstractHeader'><span lang='EN-US'>"\
+ "Abstract:</span></span> "
+ end
+
+ def introduction_cleanup(docxml)
+ dest = docxml.at("div[@id = 'introduction-destination']") or return
+ unless i = docxml.at("//h1[@class = 'IntroTitle']")&.parent
+ dest.parent.remove
+ return
+ end
+ introduction_cleanup1(i, dest)
+ end
+
+ def introduction_cleanup1(intro, dest)
+ docxml = intro.document
+ intro.previous_element.remove
+ dest.replace(intro.remove)
+ i = docxml.at("//h1[@class = 'IntroTitle']")
+ if i.next_element.name == "div" &&
+ i.next_element["class"] == "IEEEStdsIntroduction"
+ i.next_element.name = "p"
end
end
end
end
end