Skip to content

Commit

Permalink
do not conflate variant strings in Presentation XML under bibdata, fo…
Browse files Browse the repository at this point in the history
…r downstream metadata differentiation: metanorma/metanorma-jis#103
  • Loading branch information
opoudjis committed Aug 15, 2023
1 parent 81bf9cf commit ebf9894
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/isodoc/presentation_function/inline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions spec/isodoc/inline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,12 @@
<bibdata>
<language>en</language>
<script>Latn</script>
<contributor>
<role type="author"/>
<organization>
<name><variant language="en">A</variant><variant language="fr">B</variant></name>
</organization>
</contributor>
</bibdata>
<preface>
<clause id="A"><title><variant lang="en" script="Latn">ABC</variant><variant lang="fr" script="Latn">DEF</variant></title></clause>
Expand All @@ -1735,6 +1741,12 @@
<bibdata>
<language current='true'>en</language>
<script current='true'>Latn</script>
<contributor>
<role type="author"/>
<organization>
<name><variant language="en">A</variant><variant language="fr">B</variant></name>
</organization>
</contributor>
</bibdata>
<preface>
<clause type="toc" id="_" displayorder="1"> <title depth="1">Table of contents</title> </clause>
Expand Down

0 comments on commit ebf9894

Please sign in to comment.