lib/metanorma/sectionsplit.rb in metanorma-1.3.8 vs lib/metanorma/sectionsplit.rb in metanorma-1.3.9
- old
+ new
@@ -44,12 +44,11 @@
end
end
def coll_cover
<<~COVER
- <html>
- <head/>
+ <html><head/>
<body>
<h1>{{ doctitle }}</h1>
<h2>{{ docnumber }}</h2>
<nav>{{ labels["navigation"] }}</nav>
</body>
@@ -100,21 +99,10 @@
outname = "#{file}.xml"
File.open(File.join(@splitdir, outname), "w:UTF-8") { |f| f.write(out) }
outname
end
- # def xref_preprocess(xml)
- # svg_preprocess(xml)
- # key = (0...8).map { rand(65..90).chr }.join # random string
- # xml.root["type"] = key # to force recognition of internal refs
- # refs = eref_to_internal_eref(xml, key)
- # refs += xref_to_internal_eref(xml, key)
- # ins = new_hidden_ref(xml)
- # copy_repo_items_biblio(ins, xml)
- # insert_indirect_biblio(ins, refs, key)
- # end
-
def xref_preprocess(xml)
svg_preprocess(xml)
key = (0...8).map { rand(65..90).chr }.join # random string
xml.root["type"] = key # to force recognition of internal refs
key
@@ -134,11 +122,11 @@
s.xpath(".//m:a", "m" => "http://www.w3.org/2000/svg").each do |a|
next unless /^#/.match? a["href"]
a["href"] = a["href"].sub(/^#/, "")
m << "<target href='#{a['href']}'>"\
- "<xref target='#{a['href']}'/></target>"
+ "<xref target='#{a['href']}'/></target>"
end
end
end
def svgmap_wrap(svg)
@@ -222,13 +210,11 @@
end
end
def recursive_string_keys(hash)
case hash
- when Hash then Hash[
- hash.map { |k, v| [k.to_s, recursive_string_keys(v)] }
- ]
+ when Hash then hash.map { |k, v| [k.to_s, recursive_string_keys(v)] }.to_h
when Enumerable then hash.map { |v| recursive_string_keys(v) }
else
hash
end
end
@@ -244,25 +230,23 @@
def collectionyaml(files, xml)
ret = {
directives: ["presentation-xml", "bare-after-first"],
bibdata: {
title: {
- type: "title-main",
- language: @lang,
- content: xml.at(ns("//bibdata/title")).text,
+ type: "title-main", language: @lang,
+ content: xml.at(ns("//bibdata/title")).text
},
type: "collection",
docid: {
type: xml.at(ns("//bibdata/docidentifier/@type")).text,
id: xml.at(ns("//bibdata/docidentifier")).text,
},
},
manifest: {
- level: "collection",
- title: "Collection",
+ level: "collection", title: "Collection",
docref: files.sort_by { |f| f[:order] }.each.map do |f|
{ fileref: f[:url], identifier: f[:title] }
- end,
+ end
},
}
recursive_string_keys(ret).to_yaml
end
end