From ebf9894050f10ded94db5c27b5b33685e713c1fa Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Wed, 16 Aug 2023 01:02:21 +1000 Subject: [PATCH] do not conflate variant strings in Presentation XML under bibdata, for downstream metadata differentiation: https://github.com/metanorma/metanorma-jis/issues/103 --- lib/isodoc/presentation_function/inline.rb | 13 +++++++------ spec/isodoc/inline_spec.rb | 12 ++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/isodoc/presentation_function/inline.rb b/lib/isodoc/presentation_function/inline.rb index d3f44964..cbeb38e2 100644 --- a/lib/isodoc/presentation_function/inline.rb +++ b/lib/isodoc/presentation_function/inline.rb @@ -64,15 +64,16 @@ def xref1(node) get_linkend(node) end - def variant(docxml) - docxml.xpath(ns("//variant")).each { |f| variant1(f) } - docxml.xpath(ns("//variant[@remove = 'true']")).each(&:remove) - docxml.xpath(ns("//variant")).each do |v| - next unless v&.next&.name == "variant" + def variant(xml) + b = xml.xpath(ns("//bibdata//variant")) + (xml.xpath(ns("//variant")) - b).each { |f| variant1(f) } + (xml.xpath(ns("//variant[@remove = 'true']")) - b).each(&:remove) + (xml.xpath(ns("//variant")) - b).each do |v| + next unless v.next&.name == "variant" v.next = "/" end - docxml.xpath(ns("//variant")).each { |f| f.replace(f.children) } + (xml.xpath(ns("//variant")) - b).each { |f| f.replace(f.children) } end def variant1(node) diff --git a/spec/isodoc/inline_spec.rb b/spec/isodoc/inline_spec.rb index 5be457cc..98612e60 100644 --- a/spec/isodoc/inline_spec.rb +++ b/spec/isodoc/inline_spec.rb @@ -1717,6 +1717,12 @@ en + + + + AB + + <variant lang="en" script="Latn">ABC</variant><variant lang="fr" script="Latn">DEF</variant> @@ -1735,6 +1741,12 @@ en + + + + AB + + Table of contents