metanorma-bipm 2.6.3 → 2.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 205fd9f76c51e56ca1a9ad226a3826c6d1d53223e67f2c4eb2328b845c8f6c7f
4
- data.tar.gz: 240426d2487d51cdb00864a1d47e73d2265eab2d921aad53ce30f2cb9510de61
3
+ metadata.gz: 77b04f5ff90d804819c75403f23f4b4dbf79d00ea133f514898fca0dac906f47
4
+ data.tar.gz: 77ed2c800f016c230684d7a339cb13f3583c9c2a97c9435c98ddaab3a004ce31
5
5
  SHA512:
6
- metadata.gz: 9ef9e81c0c40b06723046ccbebfc660f7154811a487e365bc1993d8ee350c1c67390b07aa0b595d125fdd2a82db25bb5d51e7644fadbec5960ead34cf829dab2
7
- data.tar.gz: 4d456540b3e439e459456151d7053874a6b94dd352cbc9d19bf2370cfddbd824e88b292835a71c2b7a90a1bb04caf10ed463d89c81f3dcf434bf8ef1f00cd85c
6
+ metadata.gz: 5143b13be29637770284c6c423dd03e0ecbae17a98c6b88a8c23e4d1a36e356978bb5fd0311ba7248c809e2a00d3e3736d23a1f45a4b919b89e8dbabee3ab34a
7
+ data.tar.gz: a34427e2b643fc0bec34425ba29575375db54d111662186238a75e0c4a8c8c85b9c2926bec334e85f439495a13d74c6373ef4bddc4adac6a12f9454c2a4565fe
@@ -776,7 +776,6 @@
776
776
  <xsl:otherwise>
777
777
  <xsl:apply-templates select="." mode="fn_to_xref"/> <!-- displays asterisks with link to side note -->
778
778
  <xsl:call-template name="fn_to_note_side"/> <!-- convert footnote to side note with asterisk at start -->
779
-
780
779
  </xsl:otherwise>
781
780
  </xsl:choose>
782
781
  </xsl:template>
@@ -887,9 +886,7 @@
887
886
  <!-- move all footnotes in the current list (not only current list item) into first 'li' -->
888
887
  <xsl:variable name="curr_list_id" select="../@id"/>
889
888
  <xsl:for-each select="..//bipm:fn[ancestor::bipm:ol[1]/@id = $curr_list_id or ancestor::bipm:ul[1]/@id = $curr_list_id]">
890
-
891
889
  <xsl:call-template name="fn_to_note_side"/>
892
-
893
890
  </xsl:for-each>
894
891
 
895
892
  </xsl:otherwise>
@@ -910,24 +907,32 @@
910
907
  </xsl:template>
911
908
 
912
909
  <xsl:template name="fn_to_note_side">
913
- <xsl:element name="note_side" namespace="https://www.metanorma.org/ns/standoc">
910
+ <xsl:variable name="target" select="@target"/>
911
+ <xsl:choose>
912
+ <!-- skip side note, see the comment https://github.com/metanorma/isodoc/issues/658#issuecomment-2768874528: -->
913
+ <!-- every repeated footnote is only rendered at the first instance -->
914
+ <xsl:when test="preceding::*[@target = $target]"/>
915
+ <xsl:otherwise>
916
+ <xsl:element name="note_side" namespace="https://www.metanorma.org/ns/standoc">
914
917
 
915
- <xsl:attribute name="id">
916
- <xsl:value-of select="@target"/>
917
- </xsl:attribute>
918
+ <xsl:attribute name="id">
919
+ <xsl:value-of select="@target"/>
920
+ </xsl:attribute>
918
921
 
919
- <xsl:variable name="curr_id" select="@target"/>
922
+ <xsl:variable name="curr_id" select="@target"/>
920
923
 
921
- <xsl:element name="sup_fn" namespace="https://www.metanorma.org/ns/standoc">
922
- <!-- <xsl:value-of select="concat('(',$number,')')"/> -->
923
- <!-- https://github.com/metanorma/isodoc/issues/658#issuecomment-2726450824 -->
924
- <xsl:apply-templates select="*[local-name() = 'fmt-fn-label']/node()" mode="flatxml"/>
925
- </xsl:element>
926
- <xsl:text> </xsl:text>
924
+ <xsl:element name="sup_fn" namespace="https://www.metanorma.org/ns/standoc">
925
+ <!-- <xsl:value-of select="concat('(',$number,')')"/> -->
926
+ <!-- https://github.com/metanorma/isodoc/issues/658#issuecomment-2726450824 -->
927
+ <xsl:apply-templates select="*[local-name() = 'fmt-fn-label']/node()" mode="flatxml"/>
928
+ </xsl:element>
929
+ <xsl:text> </xsl:text>
927
930
 
928
- <!-- <xsl:apply-templates mode="flatxml"/> -->
929
- <xsl:apply-templates select="$footnotes/*[local-name() = 'fmt-fn-body'][@id = $curr_id]/node()" mode="flatxml"/>
930
- </xsl:element>
931
+ <!-- <xsl:apply-templates mode="flatxml"/> -->
932
+ <xsl:apply-templates select="$footnotes/*[local-name() = 'fmt-fn-body'][@id = $curr_id]/node()" mode="flatxml"/>
933
+ </xsl:element>
934
+ </xsl:otherwise>
935
+ </xsl:choose>
931
936
  </xsl:template>
932
937
 
933
938
  <!-- remove latest elements (after li), because they moved into latest 'li' -->
@@ -776,7 +776,6 @@
776
776
  <xsl:otherwise>
777
777
  <xsl:apply-templates select="." mode="fn_to_xref"/> <!-- displays asterisks with link to side note -->
778
778
  <xsl:call-template name="fn_to_note_side"/> <!-- convert footnote to side note with asterisk at start -->
779
-
780
779
  </xsl:otherwise>
781
780
  </xsl:choose>
782
781
  </xsl:template>
@@ -887,9 +886,7 @@
887
886
  <!-- move all footnotes in the current list (not only current list item) into first 'li' -->
888
887
  <xsl:variable name="curr_list_id" select="../@id"/>
889
888
  <xsl:for-each select="..//bipm:fn[ancestor::bipm:ol[1]/@id = $curr_list_id or ancestor::bipm:ul[1]/@id = $curr_list_id]">
890
-
891
889
  <xsl:call-template name="fn_to_note_side"/>
892
-
893
890
  </xsl:for-each>
894
891
 
895
892
  </xsl:otherwise>
@@ -910,24 +907,32 @@
910
907
  </xsl:template>
911
908
 
912
909
  <xsl:template name="fn_to_note_side">
913
- <xsl:element name="note_side" namespace="https://www.metanorma.org/ns/standoc">
910
+ <xsl:variable name="target" select="@target"/>
911
+ <xsl:choose>
912
+ <!-- skip side note, see the comment https://github.com/metanorma/isodoc/issues/658#issuecomment-2768874528: -->
913
+ <!-- every repeated footnote is only rendered at the first instance -->
914
+ <xsl:when test="preceding::*[@target = $target]"/>
915
+ <xsl:otherwise>
916
+ <xsl:element name="note_side" namespace="https://www.metanorma.org/ns/standoc">
914
917
 
915
- <xsl:attribute name="id">
916
- <xsl:value-of select="@target"/>
917
- </xsl:attribute>
918
+ <xsl:attribute name="id">
919
+ <xsl:value-of select="@target"/>
920
+ </xsl:attribute>
918
921
 
919
- <xsl:variable name="curr_id" select="@target"/>
922
+ <xsl:variable name="curr_id" select="@target"/>
920
923
 
921
- <xsl:element name="sup_fn" namespace="https://www.metanorma.org/ns/standoc">
922
- <!-- <xsl:value-of select="concat('(',$number,')')"/> -->
923
- <!-- https://github.com/metanorma/isodoc/issues/658#issuecomment-2726450824 -->
924
- <xsl:apply-templates select="*[local-name() = 'fmt-fn-label']/node()" mode="flatxml"/>
925
- </xsl:element>
926
- <xsl:text> </xsl:text>
924
+ <xsl:element name="sup_fn" namespace="https://www.metanorma.org/ns/standoc">
925
+ <!-- <xsl:value-of select="concat('(',$number,')')"/> -->
926
+ <!-- https://github.com/metanorma/isodoc/issues/658#issuecomment-2726450824 -->
927
+ <xsl:apply-templates select="*[local-name() = 'fmt-fn-label']/node()" mode="flatxml"/>
928
+ </xsl:element>
929
+ <xsl:text> </xsl:text>
927
930
 
928
- <!-- <xsl:apply-templates mode="flatxml"/> -->
929
- <xsl:apply-templates select="$footnotes/*[local-name() = 'fmt-fn-body'][@id = $curr_id]/node()" mode="flatxml"/>
930
- </xsl:element>
931
+ <!-- <xsl:apply-templates mode="flatxml"/> -->
932
+ <xsl:apply-templates select="$footnotes/*[local-name() = 'fmt-fn-body'][@id = $curr_id]/node()" mode="flatxml"/>
933
+ </xsl:element>
934
+ </xsl:otherwise>
935
+ </xsl:choose>
931
936
  </xsl:template>
932
937
 
933
938
  <!-- remove latest elements (after li), because they moved into latest 'li' -->
@@ -776,7 +776,6 @@
776
776
  <xsl:otherwise>
777
777
  <xsl:apply-templates select="." mode="fn_to_xref"/> <!-- displays asterisks with link to side note -->
778
778
  <xsl:call-template name="fn_to_note_side"/> <!-- convert footnote to side note with asterisk at start -->
779
-
780
779
  </xsl:otherwise>
781
780
  </xsl:choose>
782
781
  </xsl:template>
@@ -887,9 +886,7 @@
887
886
  <!-- move all footnotes in the current list (not only current list item) into first 'li' -->
888
887
  <xsl:variable name="curr_list_id" select="../@id"/>
889
888
  <xsl:for-each select="..//bipm:fn[ancestor::bipm:ol[1]/@id = $curr_list_id or ancestor::bipm:ul[1]/@id = $curr_list_id]">
890
-
891
889
  <xsl:call-template name="fn_to_note_side"/>
892
-
893
890
  </xsl:for-each>
894
891
 
895
892
  </xsl:otherwise>
@@ -910,24 +907,32 @@
910
907
  </xsl:template>
911
908
 
912
909
  <xsl:template name="fn_to_note_side">
913
- <xsl:element name="note_side" namespace="https://www.metanorma.org/ns/standoc">
910
+ <xsl:variable name="target" select="@target"/>
911
+ <xsl:choose>
912
+ <!-- skip side note, see the comment https://github.com/metanorma/isodoc/issues/658#issuecomment-2768874528: -->
913
+ <!-- every repeated footnote is only rendered at the first instance -->
914
+ <xsl:when test="preceding::*[@target = $target]"/>
915
+ <xsl:otherwise>
916
+ <xsl:element name="note_side" namespace="https://www.metanorma.org/ns/standoc">
914
917
 
915
- <xsl:attribute name="id">
916
- <xsl:value-of select="@target"/>
917
- </xsl:attribute>
918
+ <xsl:attribute name="id">
919
+ <xsl:value-of select="@target"/>
920
+ </xsl:attribute>
918
921
 
919
- <xsl:variable name="curr_id" select="@target"/>
922
+ <xsl:variable name="curr_id" select="@target"/>
920
923
 
921
- <xsl:element name="sup_fn" namespace="https://www.metanorma.org/ns/standoc">
922
- <!-- <xsl:value-of select="concat('(',$number,')')"/> -->
923
- <!-- https://github.com/metanorma/isodoc/issues/658#issuecomment-2726450824 -->
924
- <xsl:apply-templates select="*[local-name() = 'fmt-fn-label']/node()" mode="flatxml"/>
925
- </xsl:element>
926
- <xsl:text> </xsl:text>
924
+ <xsl:element name="sup_fn" namespace="https://www.metanorma.org/ns/standoc">
925
+ <!-- <xsl:value-of select="concat('(',$number,')')"/> -->
926
+ <!-- https://github.com/metanorma/isodoc/issues/658#issuecomment-2726450824 -->
927
+ <xsl:apply-templates select="*[local-name() = 'fmt-fn-label']/node()" mode="flatxml"/>
928
+ </xsl:element>
929
+ <xsl:text> </xsl:text>
927
930
 
928
- <!-- <xsl:apply-templates mode="flatxml"/> -->
929
- <xsl:apply-templates select="$footnotes/*[local-name() = 'fmt-fn-body'][@id = $curr_id]/node()" mode="flatxml"/>
930
- </xsl:element>
931
+ <!-- <xsl:apply-templates mode="flatxml"/> -->
932
+ <xsl:apply-templates select="$footnotes/*[local-name() = 'fmt-fn-body'][@id = $curr_id]/node()" mode="flatxml"/>
933
+ </xsl:element>
934
+ </xsl:otherwise>
935
+ </xsl:choose>
931
936
  </xsl:template>
932
937
 
933
938
  <!-- remove latest elements (after li), because they moved into latest 'li' -->
@@ -776,7 +776,6 @@
776
776
  <xsl:otherwise>
777
777
  <xsl:apply-templates select="." mode="fn_to_xref"/> <!-- displays asterisks with link to side note -->
778
778
  <xsl:call-template name="fn_to_note_side"/> <!-- convert footnote to side note with asterisk at start -->
779
-
780
779
  </xsl:otherwise>
781
780
  </xsl:choose>
782
781
  </xsl:template>
@@ -887,9 +886,7 @@
887
886
  <!-- move all footnotes in the current list (not only current list item) into first 'li' -->
888
887
  <xsl:variable name="curr_list_id" select="../@id"/>
889
888
  <xsl:for-each select="..//bipm:fn[ancestor::bipm:ol[1]/@id = $curr_list_id or ancestor::bipm:ul[1]/@id = $curr_list_id]">
890
-
891
889
  <xsl:call-template name="fn_to_note_side"/>
892
-
893
890
  </xsl:for-each>
894
891
 
895
892
  </xsl:otherwise>
@@ -910,24 +907,32 @@
910
907
  </xsl:template>
911
908
 
912
909
  <xsl:template name="fn_to_note_side">
913
- <xsl:element name="note_side" namespace="https://www.metanorma.org/ns/standoc">
910
+ <xsl:variable name="target" select="@target"/>
911
+ <xsl:choose>
912
+ <!-- skip side note, see the comment https://github.com/metanorma/isodoc/issues/658#issuecomment-2768874528: -->
913
+ <!-- every repeated footnote is only rendered at the first instance -->
914
+ <xsl:when test="preceding::*[@target = $target]"/>
915
+ <xsl:otherwise>
916
+ <xsl:element name="note_side" namespace="https://www.metanorma.org/ns/standoc">
914
917
 
915
- <xsl:attribute name="id">
916
- <xsl:value-of select="@target"/>
917
- </xsl:attribute>
918
+ <xsl:attribute name="id">
919
+ <xsl:value-of select="@target"/>
920
+ </xsl:attribute>
918
921
 
919
- <xsl:variable name="curr_id" select="@target"/>
922
+ <xsl:variable name="curr_id" select="@target"/>
920
923
 
921
- <xsl:element name="sup_fn" namespace="https://www.metanorma.org/ns/standoc">
922
- <!-- <xsl:value-of select="concat('(',$number,')')"/> -->
923
- <!-- https://github.com/metanorma/isodoc/issues/658#issuecomment-2726450824 -->
924
- <xsl:apply-templates select="*[local-name() = 'fmt-fn-label']/node()" mode="flatxml"/>
925
- </xsl:element>
926
- <xsl:text> </xsl:text>
924
+ <xsl:element name="sup_fn" namespace="https://www.metanorma.org/ns/standoc">
925
+ <!-- <xsl:value-of select="concat('(',$number,')')"/> -->
926
+ <!-- https://github.com/metanorma/isodoc/issues/658#issuecomment-2726450824 -->
927
+ <xsl:apply-templates select="*[local-name() = 'fmt-fn-label']/node()" mode="flatxml"/>
928
+ </xsl:element>
929
+ <xsl:text> </xsl:text>
927
930
 
928
- <!-- <xsl:apply-templates mode="flatxml"/> -->
929
- <xsl:apply-templates select="$footnotes/*[local-name() = 'fmt-fn-body'][@id = $curr_id]/node()" mode="flatxml"/>
930
- </xsl:element>
931
+ <!-- <xsl:apply-templates mode="flatxml"/> -->
932
+ <xsl:apply-templates select="$footnotes/*[local-name() = 'fmt-fn-body'][@id = $curr_id]/node()" mode="flatxml"/>
933
+ </xsl:element>
934
+ </xsl:otherwise>
935
+ </xsl:choose>
931
936
  </xsl:template>
932
937
 
933
938
  <!-- remove latest elements (after li), because they moved into latest 'li' -->
@@ -6,15 +6,6 @@ module IsoDoc
6
6
  @iso.middle_title(docxml)
7
7
  end
8
8
 
9
- # KILL
10
- def table1x(elem)
11
- table_fn(elem)
12
- labelled_ancestor(elem) || elem["unnumbered"] and return
13
- n = @xrefs.anchor(elem["id"], :label, false)
14
- prefix_name(elem, ".<tab/>",
15
- l10n("#{@i18n.table.capitalize} #{n}"), "name")
16
- end
17
-
18
9
  def table_delim
19
10
  l10n("x.<tab/>").sub("x", "") # force French " .</tab>"
20
11
  end
@@ -46,6 +37,34 @@ module IsoDoc
46
37
  else @i18n.prefacenote
47
38
  end
48
39
  end
40
+
41
+ def termsource_label(elem, sources)
42
+ elem.replace(l10n("[#{termsource_adapt(elem['status'])} #{sources}]"))
43
+ end
44
+
45
+ def termsource_adapt(status)
46
+ case status
47
+ when "adapted" then @i18n.adapted_from
48
+ when "modified" then @i18n.modified_from
49
+ else ""
50
+ end
51
+ end
52
+
53
+ def termsource(docxml)
54
+ termsource_insert_empty_modification(docxml)
55
+ super
56
+ end
57
+
58
+ def termsource_insert_empty_modification(docxml)
59
+ docxml.xpath("//xmlns:termsource[@status = 'modified']" \
60
+ "[not(xmlns:modification)]").each do |f|
61
+ f << "<modification/>"
62
+ end
63
+ end
64
+
65
+ def termsource_modification(elem)
66
+ termsource_add_modification_text(elem.at(ns("./modification")))
67
+ end
49
68
  end
50
69
  end
51
70
  end
@@ -0,0 +1,112 @@
1
+ module IsoDoc
2
+ module Bipm
3
+ class PresentationXMLConvert < IsoDoc::Generic::PresentationXMLConvert
4
+ def fn_label_brackets(fnote)
5
+ "<sup><span class='fmt-label-delim'>(</span>" \
6
+ "#{fn_label(fnote)}" \
7
+ "<span class='fmt-label-delim'>)</span></sup>"
8
+ end
9
+
10
+ def fn_ref_label(fnote)
11
+ if @jcgm then iso_fn_ref_label(fnote)
12
+ else fn_label_brackets(fnote)
13
+ end
14
+ end
15
+
16
+ # copied from ISO
17
+ def iso_fn_ref_label(fnote)
18
+ if fnote.ancestors("table, figure").empty? ||
19
+ !fnote.ancestors("name, fmt-name").empty?
20
+ "<sup>#{fn_label(fnote)}" \
21
+ "<span class='fmt-label-delim'>)</span></sup>"
22
+ else
23
+ "<sup>#{fn_label(fnote)}</sup>"
24
+ end
25
+ end
26
+
27
+ def fn_body_label(fnote)
28
+ if @jcgm then super
29
+ else fn_label_brackets(fnote)
30
+ end
31
+ end
32
+
33
+ # explode out all the subclauses into separate entries
34
+ # assume no hanging clauses
35
+ def sort_footnote_sections(docxml)
36
+ ret = super
37
+ ret.flat_map do |x|
38
+ explode_subclauses(x)
39
+ end
40
+ end
41
+
42
+ def explode_subclauses(clause)
43
+ clause.at(ns(".//clause")) or return [clause]
44
+ (clause.xpath(ns(".//clause")) - clause.xpath(ns(".//clause//clause")))
45
+ .map { |x| explode_subclauses(x) }
46
+ .flatten.unshift(clause)
47
+ end
48
+
49
+ # quote/table/fn references are not unique within quote
50
+ # if there are multiple tables
51
+ def renumber_document_footnote_key(fnote)
52
+ key = fnote["reference"]
53
+ !@jcgm && (t = fnote.at("./ancestor::xmlns:table")) and
54
+ key = "#{t['id']} #{key}"
55
+ key
56
+ end
57
+
58
+ def renumber_document_footnote(fnote, idx, seen)
59
+ fnote["original-reference"] = fnote["reference"]
60
+ key = renumber_document_footnote_key(fnote)
61
+ if seen[key]
62
+ fnote["reference"] = seen[fnote["reference"]]
63
+ else
64
+ seen[key] = idx
65
+ fnote["reference"] = idx
66
+ idx += 1
67
+ end
68
+ idx
69
+ end
70
+
71
+ def document_footnotes(docxml)
72
+ @jcgm and return super
73
+ sects = sort_footnote_sections(docxml)
74
+ excl = non_document_footnotes(docxml)
75
+ fns = filter_document_footnotes(sects, excl)
76
+ sects.each_with_index do |s, i|
77
+ ret = footnote_collect(renumber_document_footnotes(fns[i], 1))
78
+ f = footnote_container(fns[i], ret) and s << f
79
+ end
80
+ end
81
+
82
+ def filter_document_footnotes(sects, excl)
83
+ sects.each_with_object([]) do |s, m|
84
+ docfns = s.xpath(ns(".//fn")) - excl - s.xpath(ns(".//clause//fn"))
85
+ m << docfns
86
+ end
87
+ end
88
+
89
+ def renumber_document_footnotes(fns, idx)
90
+ @jcgm and return super
91
+ fns.each_with_object({}) do |f, seen|
92
+ idx = renumber_document_footnote(f, idx, seen)
93
+ end
94
+ fns
95
+ end
96
+
97
+ def table_fn(elem)
98
+ !@jcgm && !elem.ancestors("quote").empty? and return
99
+ super
100
+ end
101
+
102
+ def non_document_footnotes(docxml)
103
+ table_fns = docxml.xpath(ns("//table//fn")) -
104
+ docxml.xpath(ns("//table/name//fn"))
105
+ @jcgm or table_fns -= docxml.xpath(ns("//quote//table//fn"))
106
+ fig_fns = docxml.xpath(ns("//figure//fn")) -
107
+ docxml.xpath(ns("//figure/name//fn"))
108
+ table_fns + fig_fns
109
+ end
110
+ end
111
+ end
112
+ end
@@ -6,6 +6,7 @@ require_relative "doccontrol"
6
6
  require_relative "../../relaton/render/general"
7
7
  require_relative "presentation_blocks"
8
8
  require_relative "presentation_biblio"
9
+ require_relative "presentation_footnotes"
9
10
 
10
11
  module IsoDoc
11
12
  module Bipm
@@ -139,34 +140,6 @@ module IsoDoc
139
140
  end
140
141
  end
141
142
 
142
- def termsource_label(elem, sources)
143
- elem.replace(l10n("[#{termsource_adapt(elem['status'])} #{sources}]"))
144
- end
145
-
146
- def termsource_adapt(status)
147
- case status
148
- when "adapted" then @i18n.adapted_from
149
- when "modified" then @i18n.modified_from
150
- else ""
151
- end
152
- end
153
-
154
- def termsource(docxml)
155
- termsource_insert_empty_modification(docxml)
156
- super
157
- end
158
-
159
- def termsource_insert_empty_modification(docxml)
160
- docxml.xpath("//xmlns:termsource[@status = 'modified']" \
161
- "[not(xmlns:modification)]").each do |f|
162
- f << "<modification/>"
163
- end
164
- end
165
-
166
- def termsource_modification(elem)
167
- termsource_add_modification_text(elem.at(ns("./modification")))
168
- end
169
-
170
143
  def enable_indexsect
171
144
  true
172
145
  end
@@ -185,101 +158,6 @@ module IsoDoc
185
158
  @xrefs.bookmark_anchor_names(docxml)
186
159
  end
187
160
 
188
- def fn_label_brackets(fnote)
189
- "<sup><span class='fmt-label-delim'>(</span>" \
190
- "#{fn_label(fnote)}" \
191
- "<span class='fmt-label-delim'>)</span></sup>"
192
- end
193
-
194
- def fn_ref_label(fnote)
195
- if @jcgm then iso_fn_ref_label(fnote)
196
- else fn_label_brackets(fnote)
197
- end
198
- end
199
-
200
- # copied from ISO
201
- def iso_fn_ref_label(fnote)
202
- if fnote.ancestors("table, figure").empty? ||
203
- !fnote.ancestors("name, fmt-name").empty?
204
- "<sup>#{fn_label(fnote)}" \
205
- "<span class='fmt-label-delim'>)</span></sup>"
206
- else
207
- "<sup>#{fn_label(fnote)}</sup>"
208
- end
209
- end
210
-
211
- def fn_body_label(fnote)
212
- if @jcgm then super
213
- else fn_label_brackets(fnote)
214
- end
215
- end
216
-
217
- # explode out all the subclauses into separate entries
218
- # assume no hanging clauses
219
- def sort_footnote_sections(docxml)
220
- ret = super
221
- ret.flat_map do |x|
222
- clauses = x.xpath(ns(".//clause[not(./clause)]"))
223
- clauses.empty? ? [x] : clauses.to_a
224
- end
225
- end
226
-
227
- # quote/table/fn references are not unique within quote
228
- # if there are multiple tables
229
- def renumber_document_footnote_key(fnote)
230
- key = fnote["reference"]
231
- !@jcgm && (t = fnote.at("./ancestor::xmlns:table")) and
232
- key = "#{t['id']} #{key}"
233
- key
234
- end
235
-
236
- def renumber_document_footnote(fnote, idx, seen)
237
- fnote["original-reference"] = fnote["reference"]
238
- key = renumber_document_footnote_key(fnote)
239
- if seen[key]
240
- fnote["reference"] = seen[fnote["reference"]]
241
- else
242
- seen[key] = idx
243
- fnote["reference"] = idx
244
- idx += 1
245
- end
246
- idx
247
- end
248
-
249
- def document_footnotes(docxml)
250
- @jcgm and return super
251
- sects = sort_footnote_sections(docxml)
252
- excl = non_document_footnotes(docxml)
253
- fns = filter_document_footnotes(sects, excl)
254
- #sects.select { |s| s.at(ns(".//fn")) }.each_with_index do |s, i|
255
- sects.each_with_index do |s, i|
256
- ret = footnote_collect(renumber_document_footnotes(fns[i], 1))
257
- f = footnote_container(fns[i], ret) and s << f
258
- end
259
- end
260
-
261
- def renumber_document_footnotes(fns, idx)
262
- @jcgm and return super
263
- fns.each_with_object({}) do |f, seen|
264
- idx = renumber_document_footnote(f, idx, seen)
265
- end
266
- fns
267
- end
268
-
269
- def table_fn(elem)
270
- !@jcgm && !elem.ancestors("quote").empty? and return
271
- super
272
- end
273
-
274
- def non_document_footnotes(docxml)
275
- table_fns = docxml.xpath(ns("//table//fn")) -
276
- docxml.xpath(ns("//table/name//fn"))
277
- @jcgm or table_fns -= docxml.xpath(ns("//quote//table//fn"))
278
- fig_fns = docxml.xpath(ns("//figure//fn")) -
279
- docxml.xpath(ns("//figure/name//fn"))
280
- table_fns + fig_fns
281
- end
282
-
283
161
  include Init
284
162
  end
285
163
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Bipm
3
- VERSION = "2.6.3".freeze
3
+ VERSION = "2.6.4".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-bipm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.3
4
+ version: 2.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-03-31 00:00:00.000000000 Z
11
+ date: 2025-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-generic
@@ -286,6 +286,7 @@ files:
286
286
  - lib/isodoc/bipm/pdf_convert.rb
287
287
  - lib/isodoc/bipm/presentation_biblio.rb
288
288
  - lib/isodoc/bipm/presentation_blocks.rb
289
+ - lib/isodoc/bipm/presentation_footnotes.rb
289
290
  - lib/isodoc/bipm/presentation_xml_convert.rb
290
291
  - lib/isodoc/bipm/xref.rb
291
292
  - lib/metanorma-bipm.rb