metanorma-itu 2.5.6 → 2.5.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,17 +6,7 @@ require_relative "presentation_bibdata"
6
6
  require_relative "presentation_preface"
7
7
  require_relative "presentation_ref"
8
8
  require_relative "presentation_contribution"
9
-
10
- module Nokogiri
11
- module XML
12
- class Node
13
- def traverse_topdown(&block)
14
- yield(self)
15
- children.each { |j| j.traverse_topdown(&block) }
16
- end
17
- end
18
- end
19
- end
9
+ require_relative "../../nokogiri/xml"
20
10
 
21
11
  module IsoDoc
22
12
  module Itu
@@ -31,11 +21,33 @@ module IsoDoc
31
21
  end
32
22
 
33
23
  def origin(docxml)
34
- docxml.xpath(ns("//origin[not(termref)]")).each { |f| eref1(f) }
24
+ docxml.xpath(ns("//origin[not(termref)]")).each do |f|
25
+ f["citeas"] = bracket_opt(f["citeas"])
26
+ eref1(f)
27
+ end
35
28
  end
36
29
 
37
30
  def quotesource(docxml)
38
- docxml.xpath(ns("//quote/source")).each { |f| eref1(f) }
31
+ docxml.xpath(ns("//quote//source")).each { |f| eref1(f) }
32
+ end
33
+
34
+ def bracket_opt(text)
35
+ text.nil? and return
36
+ /^\[.+\]$/.match?(text) and return text
37
+ "[#{text}]"
38
+ end
39
+
40
+ def designation1(desgn)
41
+ super
42
+ desgn.name == "preferred" or return
43
+ desgn.children = l10n "#{to_xml desgn.children}:"
44
+ end
45
+
46
+ def termsource1(elem)
47
+ while elem&.next_element&.name == "termsource"
48
+ elem << "; #{to_xml(elem.next_element.remove.children)}"
49
+ end
50
+ elem.children = l10n(to_xml(elem.children).strip)
39
51
  end
40
52
 
41
53
  def eref1(elem)
@@ -47,6 +59,13 @@ module IsoDoc
47
59
  super
48
60
  end
49
61
 
62
+ def note_delim(elem)
63
+ if elem.at(ns("./*[local-name() != 'name'][1]"))&.name == "p"
64
+ "\u00a0\u2013\u00a0"
65
+ else ""
66
+ end
67
+ end
68
+
50
69
  def table1(elem)
51
70
  elem.xpath(ns("./name | ./thead/tr/th")).each do |n|
52
71
  capitalise_unless_text_transform(n)
@@ -66,6 +85,10 @@ module IsoDoc
66
85
  end
67
86
  end
68
87
 
88
+ def table_fn1(_table, fnote, _idx)
89
+ fnote["reference"] += ")"
90
+ end
91
+
69
92
  def get_eref_linkend(node)
70
93
  non_locality_elems(node).select do |c|
71
94
  !c.text? || /\S/.match(c)
@@ -103,12 +126,28 @@ module IsoDoc
103
126
  end
104
127
 
105
128
  def annex1(elem)
106
- @doctype == "resolution" or return super
129
+ if @doctype == "resolution"
130
+ annex1_resolution(elem)
131
+ else
132
+ super
133
+ annex1_non_resolution(elem)
134
+ end
135
+ end
136
+
137
+ def annex1_resolution(elem)
107
138
  elem.elements.first.previous = annex1_supertitle(elem)
108
139
  t = elem.at(ns("./title")) and
109
140
  t.children = "<strong>#{to_xml(t.children)}</strong>"
110
141
  end
111
142
 
143
+ def annex1_non_resolution(elem)
144
+ info = elem["obligation"] == "informative"
145
+ ins = elem.at(ns("./title"))
146
+ p = (info ? @i18n.inform_annex : @i18n.norm_annex)
147
+ .sub("%", @i18n.doctype_dict[@meta.get[:doctype_original]] || "")
148
+ ins.next = %(<p class="annex_obligation">#{p}</p>)
149
+ end
150
+
112
151
  def annex1_supertitle(elem)
113
152
  lbl = @xrefs.anchor(elem["id"], :label)
114
153
  res = elem.at(ns("//bibdata/title[@type = 'resolution']"))
@@ -189,11 +228,6 @@ module IsoDoc
189
228
  ret
190
229
  end
191
230
 
192
- def block(docxml)
193
- super
194
- dl docxml
195
- end
196
-
197
231
  def dl(xml)
198
232
  (xml.xpath(ns("//dl")) -
199
233
  xml.xpath(ns("//table//dl | //figure//dl | //formula//dl")))
@@ -208,6 +242,10 @@ module IsoDoc
208
242
  '<colgroup><col width="20%"/><col width="80%"/></colgroup>'
209
243
  end
210
244
 
245
+ def termnote_delim(_elem)
246
+ " &#x2013; "
247
+ end
248
+
211
249
  include Init
212
250
  end
213
251
  end
@@ -5,7 +5,7 @@ require "fileutils"
5
5
  module IsoDoc
6
6
  module Itu
7
7
  module BaseConvert
8
- def nonstd_bibitem(list, bibitem, _ordinal, biblio)
8
+ def bibitem_entry(list, bibitem, _ordinal, biblio)
9
9
  list.tr **attr_code(iso_bibitem_entry_attrs(bibitem, biblio)) do |ref|
10
10
  ref.td style: "vertical-align:top" do |td|
11
11
  tag = bibitem.at(ns("./biblio-tag"))
@@ -15,20 +15,15 @@ module IsoDoc
15
15
  end
16
16
  end
17
17
 
18
- def std_bibitem_entry(list, bibitem, ordinal, biblio)
19
- nonstd_bibitem(list, bibitem, ordinal, biblio)
20
- end
21
-
22
18
  def biblio_list(clause, div, biblio)
23
19
  div.table class: "biblio", border: "0" do |t|
24
20
  i = 0
25
21
  t.tbody do |tbody|
26
22
  clause.elements.each do |b|
27
23
  if b.name == "bibitem"
28
- next if implicit_reference(b)
29
-
24
+ b["hidden"] == "true" and next
30
25
  i += 1
31
- nonstd_bibitem(tbody, b, i, biblio)
26
+ bibitem_entry(tbody, b, i, biblio)
32
27
  else
33
28
  unless %w(title clause references).include? b.name
34
29
  tbody.tx { |tx| parse(b, tx) }
@@ -37,30 +32,7 @@ module IsoDoc
37
32
  end
38
33
  end
39
34
  end
40
- clause.xpath(ns("./clause | ./references")).each do |x|
41
- parse(x, div)
42
- end
43
- end
44
-
45
- def bracket_if_num(num)
46
- return nil if num.nil?
47
-
48
- num = num.text.sub(/^\[/, "").sub(/\]$/, "")
49
- "[#{num}]"
50
- end
51
-
52
- def pref_ref_code(bibitem)
53
- ret = bibitem.xpath(ns("./docidentifier[@type = 'ITU']"))
54
- ret.empty? and ret = super
55
- ret
56
- end
57
-
58
- def unbracket(ident)
59
- if ident.respond_to?(:size)
60
- ident.map { |x| unbracket1(x) }.join("&#xA0;| ")
61
- else
62
- unbracket1(ident)
63
- end
35
+ clause.xpath(ns("./clause | ./references")).each { |x| parse(x, div) }
64
36
  end
65
37
  end
66
38
  end
@@ -8,8 +8,7 @@ module IsoDoc
8
8
  insert_tab(b, 1)
9
9
  node&.at(ns("./preferred"))&.children&.each { |n| parse(n, b) }
10
10
  end
11
- p << ": "
12
- source and p << "#{bracket_opt(source.value)} "
11
+ source and p << "#{source.value} "
13
12
  end
14
13
  defn&.children&.each { |n| parse(n, div) }
15
14
  end
@@ -19,7 +18,6 @@ module IsoDoc
19
18
  source = node.at(ns("./termsource/origin/@citeas"))
20
19
  out.div **attr_code(id: node["id"]) do |div|
21
20
  termdef_parse1(node, div, defn, source)
22
- set_termdomain("")
23
21
  node.children.each do |n|
24
22
  next if %w(preferred definition termsource title
25
23
  name).include? n.name
@@ -28,17 +26,6 @@ module IsoDoc
28
26
  end
29
27
  end
30
28
  end
31
-
32
- def bracket_opt(text)
33
- return text if text.nil?
34
- return text if /^\[.+\]$/.match?(text)
35
-
36
- "[#{text}]"
37
- end
38
-
39
- def termnote_delim
40
- " &#x2013; "
41
- end
42
29
  end
43
30
  end
44
31
  end
@@ -25,8 +25,8 @@ module IsoDoc
25
25
 
26
26
  def word_footnote_cleanup(docxml)
27
27
  docxml.xpath("//aside").each do |a|
28
- a.first_element_child.children.first.previous =
29
- '<span style="mso-tab-count:1"/>'
28
+ a.first_element_child.
29
+ add_first_child '<span style="mso-tab-count:1"/>'
30
30
  end
31
31
  end
32
32
 
@@ -50,7 +50,7 @@ module IsoDoc
50
50
  parse(node.at(ns("./stem")), div)
51
51
  if lbl = node&.at(ns("./name"))&.text
52
52
  insert_tab(div, 1)
53
- div << "(#{lbl})"
53
+ div << lbl
54
54
  end
55
55
  end
56
56
  end
@@ -91,12 +91,6 @@ module IsoDoc
91
91
  end
92
92
  end
93
93
 
94
- def reference_names(ref)
95
- super
96
- @anchors[ref["id"]] =
97
- { xref: @anchors[ref["id"]][:xref].sub(/^\[/, "").sub(/\]$/, "") }
98
- end
99
-
100
94
  def termnote_anchor_names(docxml)
101
95
  docxml.xpath(ns("//term[termnote]")).each do |t|
102
96
  c = Counter.new
@@ -17,7 +17,7 @@
17
17
  these elements; we just want one namespace for any child grammars
18
18
  of this.
19
19
  -->
20
- <!-- VERSION v1.3.4 -->
20
+ <!-- VERSION v1.4.0 -->
21
21
  <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
22
22
  <include href="reqt.rng"/>
23
23
  <include href="basicdoc.rng">
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Itu
3
- VERSION = "2.5.6".freeze
3
+ VERSION = "2.5.8".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,10 @@
1
+ module Nokogiri
2
+ module XML
3
+ class Node
4
+ def traverse_topdown(&block)
5
+ yield(self)
6
+ children.each { |j| j.traverse_topdown(&block) }
7
+ end
8
+ end
9
+ end
10
+ end
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ["lib"]
26
26
  spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
27
27
 
28
- spec.add_dependency "metanorma-standoc", "~> 2.9.3"
28
+ spec.add_dependency "metanorma-standoc", "~> 2.10.0"
29
29
  spec.add_dependency "pubid"
30
30
  spec.add_dependency "twitter_cldr", ">= 3.0.0"
31
31
  spec.add_dependency "tzinfo-data" # we need this for windows only
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-itu
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.6
4
+ version: 2.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-28 00:00:00.000000000 Z
11
+ date: 2024-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.9.3
19
+ version: 2.10.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.9.3
26
+ version: 2.10.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pubid
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -339,6 +339,7 @@ files:
339
339
  - lib/metanorma/itu/reqt.rng
340
340
  - lib/metanorma/itu/validate.rb
341
341
  - lib/metanorma/itu/version.rb
342
+ - lib/nokogiri/xml.rb
342
343
  - lib/relaton/render/config.yml
343
344
  - lib/relaton/render/general.rb
344
345
  - lib/relaton/render/parse.rb