lib/asciidoctor/iso/cleanup.rb in metanorma-iso-1.5.11 vs lib/asciidoctor/iso/cleanup.rb in metanorma-iso-1.5.12

- old
+ new

@@ -127,8 +127,41 @@ def boilerplate_file(xmldoc) file = @lang == "fr" ? "boilerplate-fr.xml" : "boilerplate.xml" File.join(@libdir, file) end + + def footnote_cleanup(xmldoc) + unpub_footnotes(xmldoc) + super + end + + def unpub_footnotes(xmldoc) + xmldoc.xpath("//bibitem/note[@type = 'Unpublished-Status']").each do |n| + id = n.parent["id"] + e = xmldoc.at("//eref[@bibitemid = '#{id}']") or next + e.next = n.dup + e.next.name = "fn" + e.next.delete("format") + e.next.delete("type") + end + end + + def bibitem_cleanup(xmldoc) + super + unpublished_note(xmldoc) + end + + def unpublished_note(xmldoc) + xmldoc.xpath("//bibitem[not(note[@type = 'Unpublished-Status'])]").each do |b| + next if pub_class(b) > 2 + next unless s = b.at("./status/stage") and s.text.to_i < 60 + id = b.at("docidentifier").text + b.at("./language | ./script | ./abstract | ./status").previous = <<~NOTE + <note type="Unpublished-Status"> + <p>#{@i18n.under_preparation.sub(/%/, id)}</p></note> + NOTE + end + end end end end