diff --git a/lib/html2doc/ieee/lists.rb b/lib/html2doc/ieee/lists.rb index 9da8b17..040f0f8 100644 --- a/lib/html2doc/ieee/lists.rb +++ b/lib/html2doc/ieee/lists.rb @@ -50,7 +50,8 @@ def list2para1(list, level, type) l["class"] ||= list_style(type, level, "Middle") next unless l&.first_element_child&.name == "p" - l["style"] += (l.first_element_child["style"]&.sub(/mso-list[^;]+;/, "") || "") + l["style"] += + l.first_element_child["style"]&.sub(/mso-list[^;]+;/, "") || "" l.first_element_child.replace(l.first_element_child.children) end list.replace(list.children) diff --git a/lib/isodoc/ieee/metadata.rb b/lib/isodoc/ieee/metadata.rb index 4b0e3f0..446379a 100644 --- a/lib/isodoc/ieee/metadata.rb +++ b/lib/isodoc/ieee/metadata.rb @@ -10,15 +10,6 @@ def initialize(lang, script, i18n, fonts_options = {}) logos end - def logos - here = File.join(File.dirname(__FILE__), "html") - %i(wp_image001_emz wp_image003_emz wp_image008_emz) - .each do |w| - img = w.to_s.sub("_emz", ".emz") - set(w, File.expand_path(File.join(here, img))) - end - end - def logos here = File.join(File.dirname(__FILE__), "html") suffix = ".emz" @@ -33,7 +24,7 @@ def logos def bibdate(isoxml, _out) isoxml.xpath(ns("//bibdata/date[@format = 'ddMMMyyyy']")).each do |d| - set("#{d['type'].gsub('-', '_')}date".to_sym, Common::date_range(d)) + set("#{d['type'].tr('-', '_')}date".to_sym, Common::date_range(d)) end draft = isoxml.at(ns("//bibdata/date[@type = 'issued']")) || isoxml.at(ns("//bibdata/date[@type = 'circulated']")) || diff --git a/lib/isodoc/ieee/presentation_ref.rb b/lib/isodoc/ieee/presentation_ref.rb index 5e223aa..300b1d0 100644 --- a/lib/isodoc/ieee/presentation_ref.rb +++ b/lib/isodoc/ieee/presentation_ref.rb @@ -45,15 +45,36 @@ def references_render(docxml) super end + KEEP_BIBRENDER_XPATH = + "./docidentifier | ./uri | ./note | ./title | ./biblio-tag".freeze + def bibrender_relaton(xml, renderings) f = renderings[xml["id"]][:formattedref] fn = availability_note(xml) f &&= "#{f}#{fn}" - keep = "./docidentifier | ./uri | ./note | ./title | ./biblio-tag" - xml.children = "#{f}#{xml.xpath(ns(keep)).to_xml}" + xml.children = "#{f}#{xml.xpath(ns(KEEP_BIBRENDER_XPATH)).to_xml}" + author_date(xml, renderings) @author[xml["id"]] = renderings[xml["id"]][:author] end + def author_date(xml, renderings) + author_date?(xml) or return + cit = renderings[xml["id"]][:citation] + xml << "#{cit}" + xml.at(ns("./biblio-tag"))&.remove + xml << "#{cit}, " + end + + def author_date?(xml) + ret = !xml["type"] + ret ||= %w(standard techreport website webresource) + .include?(xml["type"]) + ret ||= xml.at(".//ancestor::xmlns:references[@normative = 'false']") + ret ||= xml.at(ns("./docidentifier[@type = 'metanorma']")) + ret and return false + true + end + def creatornames(bibitem) ::Relaton::Render::IEEE::General .new(language: @lang, i18nhash: @i18n.get, diff --git a/lib/isodoc/ieee/presentation_terms.rb b/lib/isodoc/ieee/presentation_terms.rb index 890e736..21439ac 100644 --- a/lib/isodoc/ieee/presentation_terms.rb +++ b/lib/isodoc/ieee/presentation_terms.rb @@ -86,7 +86,7 @@ def term_related_reorder(coll) ins = coll.first.previous_element ret = sort_related(coll) coll.each(&:remove) - ret.reverse.each { |t| ins.next = t } + ret.reverse_each { |t| ins.next = t } ins.parent.xpath(ns("./related")) end @@ -144,7 +144,7 @@ def term_reorder1(terms) coll = terms.xpath(ns("./term")) ret = sort_terms(coll) coll.each(&:remove) - ret.reverse.each { |t| ins.next = t } + ret.reverse_each { |t| ins.next = t } end def sort_terms(terms) diff --git a/lib/isodoc/ieee/presentation_xml_convert.rb b/lib/isodoc/ieee/presentation_xml_convert.rb index 87fdfc2..2de1df2 100644 --- a/lib/isodoc/ieee/presentation_xml_convert.rb +++ b/lib/isodoc/ieee/presentation_xml_convert.rb @@ -63,13 +63,17 @@ def anchor_linkend1(node) capitalise_xref(node, linkend, anchor_value(node["target"])) end + def eref_locality_populate(type, node, number) + type == "page" and return "" + super + end + def block_delim "—" end def note1(elem) - return if elem.parent.name == "bibitem" || elem["notag"] == "true" - + elem.parent.name == "bibitem" || elem["notag"] == "true" and return n = @xrefs.get[elem["id"]] lbl = if n.nil? || n[:label].nil? || n[:label].empty? then @i18n.note else l10n("#{@i18n.note} #{n[:label]}") diff --git a/spec/isodoc/refs_spec.rb b/spec/isodoc/refs_spec.rb index 3016993..ca4f948 100644 --- a/spec/isodoc/refs_spec.rb +++ b/spec/isodoc/refs_spec.rb @@ -252,9 +252,6 @@ INPUT - # https://doi.org/10.1017/9781108877831 - # - presxml = <<~PRESXML Contents @@ -265,7 +262,7 @@

ISO 639:1967 ISO 639-2:1998 - https://doi.org/10.1017/9781108877831 + Aluffi, Anderson, Hering, Mustaţă and Payne 2022a REF4 ISO 639:1967 [B3] Aluffi, Anderson, Hering, Mustaţă and Payne [B2] @@ -321,7 +318,8 @@

IEEE 194-1977 has been withdrawn; however, copies can be obtained from Global Engineering, 15 Inverness Way East, Englewood, CO 80112-5704, USA, tel. (303) 792-2181 (http://global.ihs.com/).

- + Aluffi, Anderson, Hering, Mustaţă and Payne 2022a + Aluffi, Anderson, Hering, Mustaţă and Payne 2022a, Indiana Jones and the Last Crusade. @@ -520,4 +518,73 @@ expect(Xml::C14n.format(strip_guid(out.to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end + + it "removes page locality" do + input = <<~INPUT + + + + Clause +

+ + 49 + + + 49 + + + 49 + + + 49 + +

+
+
+ + + Normative References + + Title 1 + IETF 6281 + + + Title 1 + Johns 2022 + + + +
+ INPUT + presxml = <<~PRESXML + + + 2. + <tab/> + Clause + +

+ + IETF  + 6281 + , 4–9 + + + IETF  + 6281 + , Figure 4–9 + + Johns 2022, 4–9 + Johns 2022, Figure 4–9 +

+
+ PRESXML + out = Nokogiri::XML( + IsoDoc::IEEE::PresentationXMLConvert.new(presxml_options) + .convert("test", input, true), + ) + out = out.at("//xmlns:clause[@id = 'A']") + expect(Xml::C14n.format(strip_guid(out.to_xml))) + .to be_equivalent_to Xml::C14n.format(presxml) + end end diff --git a/spec/isodoc/terms_spec.rb b/spec/isodoc/terms_spec.rb index fc4a0ba..cfa7698 100644 --- a/spec/isodoc/terms_spec.rb +++ b/spec/isodoc/terms_spec.rb @@ -302,13 +302,14 @@ expect(Xml::C14n.format(strip_guid(IsoDoc::IEEE::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(presxml) + .convert("test", input, true)))) + .to be_equivalent_to Xml::C14n.format(presxml) expect(Xml::C14n.format(Nokogiri::XML(IsoDoc::IEEE::HtmlConvert.new({}) .convert("test", presxml, true)) .at("//body").to_xml)).to be_equivalent_to Xml::C14n.format(html) expect(Xml::C14n.format(Nokogiri::XML(IsoDoc::IEEE::WordConvert.new({}) .convert("test", presxml, true)) - .at("//body").to_xml)).to be_equivalent_to Xml::C14n.format(word) + .at("//body").to_xml)).to be_equivalent_to Xml::C14n.format(word) end it "sorts terms" do @@ -417,7 +418,8 @@ OUTPUT expect(Xml::C14n.format(strip_guid(IsoDoc::IEEE::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(output) + .convert("test", input, true)))) + .to be_equivalent_to Xml::C14n.format(output) end it "processes IsoXML term with multiple paragraph definitions" do @@ -478,7 +480,8 @@ PRESXML expect(Xml::C14n.format(strip_guid(IsoDoc::IEEE::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(presxml) + .convert("test", input, true)))) + .to be_equivalent_to Xml::C14n.format(presxml) end it "processes IsoXML term with multiple definitions" do @@ -564,7 +567,8 @@ PRESXML expect(Xml::C14n.format(strip_guid(IsoDoc::IEEE::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(presxml) + .convert("test", input, true)))) + .to be_equivalent_to Xml::C14n.format(presxml) input = <<~INPUT @@ -652,7 +656,8 @@ PRESXML expect(Xml::C14n.format(strip_guid(IsoDoc::IEEE::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(presxml) + .convert("test", input, true)))) + .to be_equivalent_to Xml::C14n.format(presxml) end it "processes IsoXML term with multiple preferred or preferred and admitted terms" do @@ -801,7 +806,8 @@ PRESXML expect(Xml::C14n.format(strip_guid(IsoDoc::IEEE::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(presxml) + .convert("test", input, true)))) + .to be_equivalent_to Xml::C14n.format(presxml) end it "processes IsoXML term with grammatical information" do @@ -870,7 +876,8 @@ PRESXML expect(Xml::C14n.format(strip_guid(IsoDoc::IEEE::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(presxml) + .convert("test", input, true)))) + .to be_equivalent_to Xml::C14n.format(presxml) end it "processes IsoXML term with empty or graphical designations" do @@ -919,7 +926,8 @@ PRESXML expect(Xml::C14n.format(strip_guid(IsoDoc::IEEE::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(presxml) + .convert("test", input, true)))) + .to be_equivalent_to Xml::C14n.format(presxml) end it "processes IsoXML term with nonverbal definitions" do @@ -1031,8 +1039,9 @@ PRESXML expect(Xml::C14n.format(strip_guid(IsoDoc::IEEE::PresentationXMLConvert -.new(presxml_options) - .convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(presxml) + .new(presxml_options) + .convert("test", input, true)))) + .to be_equivalent_to Xml::C14n.format(presxml) end it "processes related terms and admitted terms" do @@ -1147,7 +1156,8 @@ OUTPUT expect(Xml::C14n.format(strip_guid(IsoDoc::IEEE::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(output) + .convert("test", input, true)))) + .to be_equivalent_to Xml::C14n.format(output) end it "processes missing related terms" do @@ -1218,7 +1228,8 @@
OUTPUT expect(Xml::C14n.format(strip_guid(IsoDoc::IEEE::PresentationXMLConvert -.new(presxml_options) - .convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(output) + .new(presxml_options) + .convert("test", input, true)))) + .to be_equivalent_to Xml::C14n.format(output) end end