isodoc 2.9.3 → 2.9.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: 03204b29c322d499b52efcfd302668356cc8ba422d42748dda089eaa39f5c6dc
4
- data.tar.gz: 2757e0f765b4b83a50f0a88fbbaf3396da2015361c799a92ede42a4b5dcda854
3
+ metadata.gz: fa1b06e38f973ba312a0f2d90d306c7ffb34e377f2fcc4a59c42775ba9f2a927
4
+ data.tar.gz: b74dcbe6b71b90da2ec4f205754bb08028d5bd1d45f085f7e35d6c3c47dc55cc
5
5
  SHA512:
6
- metadata.gz: 9e2c0e97b4a59bcd5597037e5bcd9a719c9cfcbc60dfd765dbfac4d24408f686e8e13c44e5da0f61b847809ecf5a2d83b5c27baed8a3cd28522e7d5bfa230f9e
7
- data.tar.gz: 2b2225a8d1cb5891f0dac44b6be35d075323aaa7ee8792d6b879e4f7a768ac24faec07c3e6d2fc3734fbfeabcbeb1f5f5a7cec8540bfcaa3420d931aebf96d60
6
+ metadata.gz: 9cbe711521cc25e29f1879fa47ca42347a5ecfc0f94526166a4acb73f5787d5a5d577d68e3fe756cedce0c862b4aebfb54022fea51f296cbbeeff173e2ad5521
7
+ data.tar.gz: a07f6c1bdd5457be3cad8fececa4974de6bc95a952c73e31b718e22606a6d4c6807293729a784d55655a4419e10486c7de171dd1630ceb2f275605b263955e5d
@@ -58,7 +58,7 @@ module IsoDoc
58
58
  end
59
59
 
60
60
  def note_p_parse(node, div)
61
- name = node&.at(ns("./name"))&.remove
61
+ name = node.at(ns("./name"))&.remove
62
62
  div.p do |p|
63
63
  name and p.span class: "note_label" do |s|
64
64
  name.children.each { |n| parse(n, s) }
@@ -71,10 +71,9 @@ module IsoDoc
71
71
  end
72
72
 
73
73
  def note_parse1(node, div)
74
- name = node.at(ns("./name"))&.remove
75
- name and div.p do |p|
74
+ name = node.at(ns("./name")) and div.p do |p|
76
75
  p.span class: "note_label" do |s|
77
- name.children.each { |n| parse(n, s) }
76
+ name.remove.children.each { |n| parse(n, s) }
78
77
  s << note_delim
79
78
  end
80
79
  insert_tab(p, 1)
@@ -84,6 +83,7 @@ module IsoDoc
84
83
 
85
84
  def keep_style(node)
86
85
  ret = ""
86
+ node["style"] and ret += "#{node['style']};"
87
87
  node["keep-with-next"] == "true" and
88
88
  ret += "page-break-after: avoid;"
89
89
  node["keep-lines-together"] == "true" and
@@ -152,7 +152,7 @@ module IsoDoc
152
152
  "//bibliography/references[@normative = 'true'] | " \
153
153
  "//bibliography/clause[.//references[@normative = 'true']] | " \
154
154
  "//sections/references[@normative = 'true'] | " \
155
- "//sections/clause[.//references[@normative = 'true']]"
155
+ "//sections/clause[not(@type)][.//references[@normative = 'true']]"
156
156
  end
157
157
 
158
158
  def norm_ref(node, out)
@@ -214,7 +214,6 @@ module IsoDoc
214
214
  note table figure sourcecode).freeze
215
215
 
216
216
  def labelled_ancestor(elem)
217
- #require "debug"; binding.b
218
217
  #!elem.path.gsub(/\[\d+\]/, "").split(%r{/})[1..-1]
219
218
  !elem.ancestors.map(&:name)
220
219
  .intersection(LABELLED_ANCESTOR_ELEMENTS).empty?
@@ -2,6 +2,13 @@ require "metanorma-utils"
2
2
 
3
3
  module IsoDoc
4
4
  class PresentationXMLConvert < ::IsoDoc::Convert
5
+ def citeas(xmldoc)
6
+ xmldoc.xpath(ns("//eref | //origin | //quote/source")).each do |e|
7
+ e["bibitemid"] && e["citeas"] or next
8
+ a = @xrefs.anchor(e["bibitemid"], :xref, false) and e["citeas"] = a
9
+ end
10
+ end
11
+
5
12
  def expand_citeas(text)
6
13
  text.nil? and return text
7
14
  HTMLEntities.new.decode(text.gsub("&amp;#x", "&#"))
@@ -40,7 +47,6 @@ module IsoDoc
40
47
  (refs.size > 1 &&
41
48
  refs.all? { |r| r.name == "localityStack" } &&
42
49
  refs.all? { |r| r.xpath(ns("./locality")).size == 1 }) or return false
43
-
44
50
  first = refs.first.at(ns("./locality/@type")).text
45
51
  refs.all? do |r|
46
52
  r.at(ns("./locality/@type")).text == first
@@ -97,8 +103,7 @@ module IsoDoc
97
103
  added = eref_locality_stack(r, i, target, node)
98
104
  added.empty? and next
99
105
  added.each { |a| m << a }
100
- next if i == refs.size - 1
101
-
106
+ i == refs.size - 1 and next
102
107
  m << eref_locality_delimiter(r)
103
108
  end
104
109
  ret.empty? ? ret : [", "] + ret
@@ -156,8 +161,7 @@ module IsoDoc
156
161
 
157
162
  # def eref_localities1(target, type, from, upto, node, lang = "en")
158
163
  def eref_localities1(opt)
159
- return nil if opt[:type] == "anchor"
160
-
164
+ opt[:type] == "anchor" and return nil
161
165
  opt[:lang] == "zh" and
162
166
  # return l10n(eref_localities1_zh(target, type, from, upto, node))
163
167
  return l10n(eref_localities1_zh(opt))
@@ -168,8 +172,7 @@ module IsoDoc
168
172
  end
169
173
 
170
174
  def eref_locality_populate(type, node, number)
171
- return "" if node["droploc"] == "true"
172
-
175
+ node["droploc"] == "true" and return ""
173
176
  loc = type.sub(/^locality:/, "")
174
177
  ret = @i18n.locality[loc] || loc
175
178
  number == "pl" and ret = @i18n.inflect(ret, number: "pl")
@@ -206,9 +209,8 @@ module IsoDoc
206
209
  end
207
210
 
208
211
  def suffix_url(url)
209
- return url if url.nil? || %r{^https?://|^#}.match?(url)
210
- return url unless File.extname(url).empty?
211
-
212
+ url.nil? || %r{^https?://|^#}.match?(url) and return url
213
+ File.extname(url).empty? or return url
212
214
  url.sub(/#{File.extname(url)}$/, ".html")
213
215
  end
214
216
 
@@ -221,10 +223,10 @@ module IsoDoc
221
223
  end
222
224
 
223
225
  def eref_url(id)
224
- @bibitems.nil? and return nil
225
- b = @bibitems[id] or return nil
226
- url = (b.at(ns("./uri[@type = 'citation'][@language = '#{@lang}']")) ||
227
- b.at(ns("./uri[@type = 'citation']"))) and return url.text
226
+ @bibitem_lookup.nil? and return nil
227
+ b = @bibitem_lookup[id] or return nil
228
+ url = b.at(ns("./uri[@type = 'citation'][@language = '#{@lang}']")) ||
229
+ b.at(ns("./uri[@type = 'citation']")) and return url.text
228
230
  b["hidden"] == "true" and return b.at(ns("./uri"))&.text
229
231
  "##{id}"
230
232
  end
@@ -164,7 +164,7 @@ module IsoDoc
164
164
 
165
165
  def termsource_add_modification_text(mod)
166
166
  mod or return
167
- mod.text.strip.empty? or mod.previous = " &#x2013; "
167
+ mod.text.strip.empty? or mod.previous = " &#x2014; "
168
168
  mod.elements.size == 1 and
169
169
  mod.elements[0].replace(mod.elements[0].children)
170
170
  mod.replace(mod.children)
@@ -4,7 +4,8 @@ module IsoDoc
4
4
  prefix_container?(container, node) or return linkend
5
5
  container_container = @xrefs.anchor(container, :container, false)
6
6
  container_label =
7
- prefix_container(container_container, anchor_xref(node, container),
7
+ prefix_container(container_container,
8
+ anchor_xref(node, container, container: true),
8
9
  node, target)
9
10
  l10n(@i18n.nested_xref.sub("%1", container_label)
10
11
  .sub("%2", linkend))
@@ -40,8 +41,8 @@ module IsoDoc
40
41
  capitalise_xref(node, linkend, anchor_value(node["target"]))
41
42
  end
42
43
 
43
- def anchor_xref(node, target)
44
- x = @xrefs.anchor(target, :xref)
44
+ def anchor_xref(node, target, container: false)
45
+ x = anchor_xref_short(node, target, container)
45
46
  t = @xrefs.anchor(target, :title)
46
47
  ret = case node["style"]
47
48
  when "basic" then t
@@ -52,9 +53,15 @@ module IsoDoc
52
53
  ret || x
53
54
  end
54
55
 
56
+ def anchor_xref_short(node, target, container)
57
+ if (l = node["label"]) && !container
58
+ @i18n.l10n("#{l} #{anchor_value(target)}")
59
+ else @xrefs.anchor(target, :xref)
60
+ end
61
+ end
62
+
55
63
  def anchor_xref_full(num, title)
56
64
  (!title.nil? && !title.empty?) or return nil
57
-
58
65
  l10n("#{num}, #{title}")
59
66
  end
60
67
 
@@ -77,7 +84,8 @@ module IsoDoc
77
84
  capitalise_xref(node, linkend, anchor_value(node["target"]))
78
85
  end
79
86
 
80
- # Note % to entry and Note % to entry: cannot conflate as Note % to entry 1 and 2
87
+ # Note % to entry and Note % to entry:
88
+ # cannot conflate as Note % to entry 1 and 2
81
89
  # So Notes 1 and 3, but Note 1 to entry and Note 3 to entry
82
90
  def combine_conflated_xref_locations(locs)
83
91
  out = if locs.any? { |l| l[:elem]&.include?("%") }
@@ -123,8 +131,7 @@ module IsoDoc
123
131
  end
124
132
 
125
133
  def combine_conn(list)
126
- return list.first[:label] if list.size == 1
127
-
134
+ list.size == 1 and list.first[:label]
128
135
  if list[1..-1].all? { |l| l[:conn] == "and" }
129
136
  @i18n.boolean_conj(list.map { |l| loc2xref(l) }, "and")
130
137
  elsif list[1..-1].all? { |l| l[:conn] == "or" }
@@ -154,7 +161,6 @@ module IsoDoc
154
161
  linktext[0, 1].match?(/\p{Upper}/) and return linkend
155
162
  node["case"] and
156
163
  return Common::case_with_markup(linkend, node["case"], @script)
157
-
158
164
  capitalise_xref1(node, linkend)
159
165
  end
160
166
 
@@ -21,7 +21,6 @@ module IsoDoc
21
21
  def convert1(docxml, _filename, _dir)
22
22
  docid_prefixes(docxml) # feeds @xrefs.parse citation processing
23
23
  @xrefs.parse docxml
24
- bibitem_lookup(docxml)
25
24
  info docxml, nil
26
25
  conversions(docxml)
27
26
  docxml.root["type"] = "presentation"
@@ -29,7 +28,7 @@ module IsoDoc
29
28
  end
30
29
 
31
30
  def bibitem_lookup(docxml)
32
- @bibitems = docxml.xpath(ns("//references/bibitem"))
31
+ @bibitem_lookup ||= docxml.xpath(ns("//references/bibitem"))
33
32
  .each_with_object({}) do |b, m|
34
33
  m[b["id"]] = b
35
34
  end
@@ -83,10 +82,12 @@ module IsoDoc
83
82
  end
84
83
 
85
84
  def inline(docxml)
85
+ bibitem_lookup(docxml) # feeds citeas
86
+ citeas docxml # feeds xref, eref, origin, quotesource
86
87
  xref docxml
87
- eref docxml # feeds docxml
88
- origin docxml # feeds docxml
89
- quotesource docxml # feeds docxml
88
+ eref docxml # feeds eref2link
89
+ origin docxml # feeds eref2link
90
+ quotesource docxml # feeds eref2link
90
91
  eref2link docxml
91
92
  mathml docxml
92
93
  ruby docxml
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.9.3".freeze
2
+ VERSION = "2.9.4".freeze
3
3
  end
@@ -88,8 +88,7 @@ module IsoDoc
88
88
  end
89
89
 
90
90
  def generate_header(filename, _dir)
91
- return nil unless @header
92
-
91
+ @header or return nil
93
92
  template = IsoDoc::Common.liquid(File.read(@header, encoding: "UTF-8"))
94
93
  meta = @meta.get.merge(@labels ? { labels: @labels } : {})
95
94
  .merge(@meta.labels ? { labels: @meta.labels } : {})
@@ -5,6 +5,7 @@ abbrev: الاختصارات
5
5
  symbols: الرموز
6
6
  table_of_contents: جدول المحتويات
7
7
  introduction: مقدمة
8
+ section: قسم
8
9
  foreword: تمهيد
9
10
  abstract: ملخص
10
11
  acknowledgements: شكر
@@ -4,6 +4,7 @@ symbolsabbrev: Symbole und abgekürzte Begriffe
4
4
  abbrev: Abgekürzte Begriffe
5
5
  symbols: Symbole
6
6
  table_of_contents: Inhaltsübersicht
7
+ section: Abschnitt
7
8
  introduction: Einführung
8
9
  foreword: Vorwort
9
10
  abstract: Abstrakt
@@ -15,6 +15,7 @@ termsdefabbrev: Terms, definitions and abbreviated terms
15
15
  normref: Normative references
16
16
  bibliography: Bibliography
17
17
  preface: Preface
18
+ section: Section
18
19
  clause: Clause
19
20
  annex: Annex
20
21
  appendix: Appendix
@@ -14,6 +14,7 @@ termsdefsymbols: Términos, definiciones y símbolos
14
14
  termsdefabbrev: Términos, definiciones y términos abreviados
15
15
  normref: Referencias normativas
16
16
  bibliography: Bibliografía
17
+ section: Sección
17
18
  clause: Cláusula
18
19
  annex: Anexo
19
20
  appendix: Apéndice
@@ -15,6 +15,7 @@ termsdefabbrev: Termes, définitions et termes abrégés
15
15
  normref: Références normatives
16
16
  bibliography: Bibliographie
17
17
  preface: Préface
18
+ section: Section
18
19
  clause: Article
19
20
  annex: Annexe
20
21
  appendix: Appendice
@@ -15,6 +15,7 @@ termsdefabbrev: 用語及び定義並びに略語
15
15
  normref: 引用規格
16
16
  bibliography: 参考文献
17
17
  preface: Preface
18
+ section: Section
18
19
  clause: 箇条
19
20
  annex: 附属書
20
21
  appendix: Appendix
@@ -14,6 +14,7 @@ termsdefsymbols: Термины, определения и символы
14
14
  termsdefabbrev: Термины, определения и сокращенные термины
15
15
  normref: Нормативные ссылки
16
16
  bibliography: Библиография
17
+ section: Раздел
17
18
  clause: Пункт
18
19
  annex: Дополнение
19
20
  appendix: Приложение
@@ -15,6 +15,7 @@ termsdefabbrev: 术语、定义、符号和缩略语
15
15
  normref: 规范性引用文件
16
16
  bibliography: 参考文献
17
17
  preface: 序言
18
+ section: 条
18
19
  clause: 条
19
20
  annex: 附件
20
21
  appendix: 附录
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isodoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.3
4
+ version: 2.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-10 00:00:00.000000000 Z
11
+ date: 2024-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: html2doc