diff --git a/lib/metanorma/standoc/cleanup_bibdata.rb b/lib/metanorma/standoc/cleanup_bibdata.rb
index 3d187107..e156d021 100644
--- a/lib/metanorma/standoc/cleanup_bibdata.rb
+++ b/lib/metanorma/standoc/cleanup_bibdata.rb
@@ -7,6 +7,19 @@ def bibdata_cleanup(xmldoc)
bibdata_embed_hdr_cleanup(xmldoc) # feeds bibdata_embed_id_cleanup
bibdata_embed_id_cleanup(xmldoc)
biblio_indirect_erefs(xmldoc, @internal_eref_namespaces&.uniq)
+ coverpage_images(xmldoc)
+ end
+
+ def coverpage_images(xmldoc)
+ %w(coverpage-image innercoverpage-image tocside-image
+ backpage-image).each do |n|
+ xmldoc.xpath("//bibdata/ext/#{n}").each do |x|
+ ins = add_misc_container(xmldoc)
+ ins << "#{n}" \
+ "#{x.remove.children.to_xml}" \
+ ""
+ end
+ end
end
def bibdata_anchor_cleanup(xmldoc)
diff --git a/lib/metanorma/standoc/front.rb b/lib/metanorma/standoc/front.rb
index cfa4b9a9..9399521d 100644
--- a/lib/metanorma/standoc/front.rb
+++ b/lib/metanorma/standoc/front.rb
@@ -1,5 +1,4 @@
require "date"
-require "nokogiri"
require "htmlentities"
require "pathname"
require_relative "./front_contributor"
@@ -91,9 +90,7 @@ def metadata_date(node, xml)
a == "date" || /^date_\d+$/.match(a) or next
type, date = node.attr(a).split(/ /, 2)
type or next
- xml.date(type:) do |d|
- d.on date
- end
+ xml.date(type:) { |d| d.on date }
end
end
@@ -126,8 +123,7 @@ def metadata_relations(node, xml)
def relation_normalise(type)
type.sub(/-by$/, "By").sub(/-of$/, "Of").sub(/-from$/, "From")
- .sub(/-in$/, "In")
- .sub(/^has-([a-z])/) { "has#{$1.upcase}" }
+ .sub(/-in$/, "In").sub(/^has-([a-z])/) { "has#{$1.upcase}" }
end
def metadata_getrelation(node, xml, type, desc = nil)
@@ -193,6 +189,7 @@ def metadata_ext(node, ext)
metadata_flavor(node, ext)
metadata_committee(node, ext)
metadata_ics(node, ext)
+ metadata_coverpage_images(node, ext)
end
def metadata_doctype(node, xml)
@@ -220,9 +217,9 @@ def title_english(node, xml)
["en"].each do |lang|
at = { language: lang, format: "text/plain" }
xml.title **attr_code(at) do |t|
- t << (Metanorma::Utils::asciidoc_sub(node.attr("title") ||
- node.attr("title-en")) ||
- node.title)
+ title = Metanorma::Utils::asciidoc_sub(node.attr("title") ||
+ node.attr("title-en"))
+ t << (title || node.title)
end
end
end
@@ -234,6 +231,17 @@ def title_otherlangs(node, xml)
xml.title v, { language: titlelang, format: "text/plain" }
end
end
+
+ def metadata_coverpage_images(node, xml)
+ %w(coverpage-image innercoverpage-image tocside-image
+ backpage-image).each do |n|
+ if a = node.attr(n)
+ xml.send n do |c|
+ a.split(",").each { |x| c.image src: x }
+ end
+ end
+ end
+ end
end
end
end
diff --git a/spec/metanorma/base_spec.rb b/spec/metanorma/base_spec.rb
index 5188ab3c..6077d0bd 100644
--- a/spec/metanorma/base_spec.rb
+++ b/spec/metanorma/base_spec.rb
@@ -1378,6 +1378,74 @@
.to be_equivalent_to Xml::C14n.format(output)
end
+ it "populates cover images" do
+ input = <<~INPUT
+ = Document title
+ Author
+ :docfile: test.adoc
+ :nodoc:
+ :novalid:
+ :no-isobib:
+ :docnumber: 1000
+ :coverpage-image: images/image1.gif,images/image2.gif
+ :innercoverpage-image: images/image1.gif,images/image2.gif
+ :tocside-image: images/image1.gif,images/image2.gif
+ :backpage-image: images/image1.gif,images/image2.gif
+ INPUT
+ output = <<~OUTPUT
+
+
+ coverpage-image
+
+
+
+
+
+
+ innercoverpage-image
+
+
+
+
+
+
+ tocside-image
+
+
+
+
+
+
+ backpage-image
+
+
+
+
+
+
+ TOC Heading Levels
+ 2
+
+
+ HTML TOC Heading Levels
+ 2
+
+
+ DOC TOC Heading Levels
+ 2
+
+
+ PDF TOC Heading Levels
+ 2
+
+
+ OUTPUT
+ expect(Xml::C14n.format(strip_guid(Nokogiri::XML(Asciidoctor
+ .convert(input, *OPTIONS))
+ .at("//xmlns:metanorma-extension").to_xml)))
+ .to be_equivalent_to Xml::C14n.format(output)
+ end
+
it "reads scripts into blank HTML document" do
FileUtils.rm_f "test.html"
Asciidoctor.convert(<<~INPUT, *OPTIONS)