isodoc 3.4.1 → 3.4.2

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: 18d33859f89e36a66412218c04370f02c727fe131dd91b73fd3671ab25cf228f
4
- data.tar.gz: cc2996c38878a5acacf24932cf2719a1bef922cea11cf5c26411172e9a93032a
3
+ metadata.gz: 66420421669f651f0c898afd16ed5ccdb1fbb4114531f72ed846d179ced88d9f
4
+ data.tar.gz: a2f42bfa3a386d66d78a360cb57a28e29cce05d70b8f18d84acdd995704b0090
5
5
  SHA512:
6
- metadata.gz: dde602b7132920dff5599dc3da2bb0de9ef027f5b3dd703fadc190adec9fab8e26901798bc208d3b3d279b57c5d19fa7ccbe885c37591da875e79f8dd5c364d4
7
- data.tar.gz: 8d67a2d2518105cf854c7bb7f21a841de922785b0c77060e6002e6023c8de2b14efb8a9cbea25d140101183349b4b346287332eeb230b0c33aa5e0db3dcb3321
6
+ metadata.gz: ec7e84f1d6ab621b275c76e94781fc9b539bdd2e6656551efd617832de24a94f753aaaf1951a3a3fa7d42a983c5ced677e4fde1edf4477d029cafa0151a3185e
7
+ data.tar.gz: 9bb6ad10f0260df9f7994a94cfadd58a67cbc6b547ec17294ee09226e9a01997f9f9a2f1b744ae58338803947160155b15ca69d425848b35b6a88615ef5105fb
@@ -88,7 +88,7 @@ module IsoDoc
88
88
  def bibrenderer(options = {})
89
89
  ::Relaton::Render::IsoDoc::General
90
90
  .new(options.merge(language: @lang, script: @script,
91
- i18nhash: @i18n.get))
91
+ i18nhash: @i18n.get, config: @relatonrenderconfig))
92
92
  end
93
93
 
94
94
  def convert1_namespaces(html)
@@ -4,9 +4,9 @@ module IsoDoc
4
4
  module Function
5
5
  module Inline
6
6
  def link_parse(node, out)
7
- url = node["target"]
8
- node["update-type"] == "true" and url = suffix_url(url)
9
- out.a **attr_code(href: url, title: node["alt"]) do |l|
7
+ url = link_parse_url(node)
8
+ out.a **attr_code(href: url, title: node["alt"],
9
+ class: node["style"]) do |l|
10
10
  if node.elements.empty? && node.text.strip.empty?
11
11
  l << @c.encode(node["target"].sub(/^mailto:/, ""), :basic,
12
12
  :hexadecimal)
@@ -15,6 +15,12 @@ module IsoDoc
15
15
  end
16
16
  end
17
17
 
18
+ def link_parse_url(node)
19
+ url = node["target"]
20
+ node["update-type"] == "true" and url = suffix_url(url)
21
+ url
22
+ end
23
+
18
24
  # Presentation XML classes which we need not pass on to HTML or DOC
19
25
  SPAN_UNWRAP_CLASSES =
20
26
  %w[fmt-caption-label fmt-label-delim fmt-caption-delim fmt-autonum-delim
@@ -213,30 +219,6 @@ module IsoDoc
213
219
  children_parse(node, s)
214
220
  end
215
221
  end
216
-
217
- def fmt_concept_parse(node, out)
218
- children_parse(node, out)
219
- end
220
-
221
- def fmt_date_parse(node, out)
222
- children_parse(node, out)
223
- end
224
-
225
- def fmt_fn_label_parse(node, out)
226
- children_parse(node, out)
227
- end
228
-
229
- def fmt_footnote_container_parse(node, out)
230
- children_parse(node, out)
231
- end
232
-
233
- def fmt_annotation_start_parse(node, out)
234
- children_parse(node, out)
235
- end
236
-
237
- def fmt_annotation_end_parse(node, out)
238
- children_parse(node, out)
239
- end
240
222
  end
241
223
  end
242
224
  end
@@ -98,6 +98,31 @@ module IsoDoc
98
98
  def semx_sourcecode_parse(node, out); end
99
99
  def annotation_note_parse(node, out); end
100
100
  def semx_source_parse(node, out); end
101
+
102
+ def fmt_concept_parse(node, out)
103
+ children_parse(node, out)
104
+ end
105
+
106
+ def fmt_date_parse(node, out)
107
+ children_parse(node, out)
108
+ end
109
+
110
+ def fmt_fn_label_parse(node, out)
111
+ children_parse(node, out)
112
+ end
113
+
114
+ def fmt_footnote_container_parse(node, out)
115
+ children_parse(node, out)
116
+ end
117
+
118
+ def fmt_annotation_start_parse(node, out)
119
+ children_parse(node, out)
120
+ end
121
+
122
+ def fmt_annotation_end_parse(node, out)
123
+ children_parse(node, out)
124
+ end
125
+
101
126
  end
102
127
  end
103
128
  end
@@ -57,6 +57,7 @@ module IsoDoc
57
57
  @meta.url isoxml, out
58
58
  @meta.keywords isoxml, out
59
59
  @meta.note isoxml, out
60
+ @meta.images isoxml, out
60
61
  @meta.presentation isoxml, out
61
62
  @meta.get
62
63
  end
data/lib/isodoc/init.rb CHANGED
@@ -80,6 +80,7 @@ module IsoDoc
80
80
  @script = options[:script] || "Latn"
81
81
  @locale = options[:locale]
82
82
  @localizenumber = options[:localizenumber]
83
+ @relatonrenderconfig = options[:relatonrenderconfig]
83
84
  end
84
85
 
85
86
  def init_locations(options)
@@ -186,7 +187,7 @@ module IsoDoc
186
187
  def omit_docid_prefix(prefix)
187
188
  prefix.nil? || prefix.empty? and return true
188
189
  %w(ISO IEC IEV ITU W3C BIPM csd metanorma repository metanorma-ordinal
189
- title).include? prefix
190
+ author-date title).include? prefix
190
191
  end
191
192
 
192
193
  def connectives_spans(text)
@@ -9,7 +9,7 @@ module IsoDoc
9
9
  Common::ns(xpath)
10
10
  end
11
11
 
12
- def l10n(expr, lang = @lang, script = @script, opt = {})
12
+ def l10n(expr, lang = @lang, script = @script, opt = {})
13
13
  opt[:locale] ||= @locale
14
14
  @i18n.l10n(expr, lang, script, opt)
15
15
  end
@@ -182,6 +182,9 @@ module IsoDoc
182
182
  set(:title_footnote, ret)
183
183
  end
184
184
 
185
+ def images(_isoxml, _out)
186
+ end
187
+
185
188
  def code_css(isoxml, _out)
186
189
  c = isoxml.at(ns("//metanorma-extension/source-highlighter-css")) or return
187
190
  set(:code_css, c.text)
@@ -66,8 +66,8 @@ module IsoDoc
66
66
  logos = []
67
67
  agency_data(xml).each do |org|
68
68
  agency1 = org[:abbr] || org[:name]
69
- org[:name] and publisher << org[:name]
70
- org[:logo] and logos << org[:logo]
69
+ org[:name] && !org[:name].empty? and publisher << org[:name]
70
+ org[:logo] && !org[:logo].empty? and logos << org[:logo]
71
71
  agency = iso?(org) ? "ISO/#{agency}" : "#{agency}#{agency1}/"
72
72
  end
73
73
  [agency.sub(%r{/$}, ""), publisher, logos]
@@ -28,20 +28,21 @@ module IsoDoc
28
28
 
29
29
  # returns [metanorma, non-metanorma, DOI/ISSN/ISBN] identifiers
30
30
  def bibitem_ref_code(bib)
31
- id, id1, id2, id3 = bibitem_ref_code_prep(bib)
32
- id || id1 || id2 || id3 and return [id, id1, id2, id3]
33
- bib["suppress_identifier"] == "true" and return [nil, nil, nil, nil]
31
+ ret = bibitem_ref_code_prep(bib)
32
+ ret.all?(&:nil?) or return ret
33
+ bib["suppress_identifier"] == "true" and return [nil, nil, nil, nil, nil]
34
34
  # [nil, no_identifier(bib), nil, nil]
35
- [nil, nil, nil, nil]
35
+ [nil, nil, nil, nil, nil]
36
36
  end
37
37
 
38
38
  def bibitem_ref_code_prep(bib)
39
- id = bib.at(ns("./docidentifier[@type = 'metanorma']")) ||
40
- bib.at(ns("./docidentifier[@type = 'title']"))
39
+ id = bib.at(ns("./docidentifier[@type = 'metanorma']"))
41
40
  id1 = pref_ref_code(bib)
42
- id2 = bib.at(ns("./docidentifier[#{SKIP_DOCID}]"))
41
+ id2 = bib.at(ns("./docidentifier[#{SERIAL_NUM_DOCID}]"))
43
42
  id3 = bib.at(ns("./docidentifier[@type = 'metanorma-ordinal']"))
44
- [id, id1, id2, id3]
43
+ id4 = bib.at(ns("./docidentifier[@type = 'title']")) ||
44
+ bib.at(ns("./docidentifier[@type = 'author-date']"))
45
+ [id, id1, id2, id3, id4]
45
46
  end
46
47
 
47
48
  def no_identifier(bib)
@@ -64,6 +65,12 @@ module IsoDoc
64
65
  num
65
66
  end
66
67
 
68
+ def bracket(num)
69
+ num.nil? and return nil
70
+ num = xml_to_string_skip_fn(num).sub(/^\[/, "").sub(/\]$/, "")
71
+ "[#{num}]"
72
+ end
73
+
67
74
  def unbracket1(ident)
68
75
  ident.nil? and return nil
69
76
  ident.is_a?(String) or ident = xml_to_string_skip_fn(ident)
@@ -78,10 +85,11 @@ module IsoDoc
78
85
  end
79
86
 
80
87
  def render_identifier(ident)
81
- { metanorma: bracket_if_num(ident[0]),
88
+ { metanorma: bracket(ident[0]),
82
89
  sdo: unbracket(ident[1]),
83
90
  doi: unbracket(ident[2]),
84
- ordinal: bracket_if_num(ident[3]) }
91
+ ordinal: bracket(ident[3]),
92
+ content: unbracket(ident[4]) }
85
93
  end
86
94
  end
87
95
  end
@@ -93,6 +93,8 @@ module IsoDoc
93
93
  get_linkend(node)
94
94
  end
95
95
 
96
+ def link(xml); end
97
+
96
98
  # there should be no //variant in bibdata now
97
99
  def variant(xml)
98
100
  b = xml.xpath(ns("//bibdata//variant"))
@@ -20,10 +20,10 @@ module IsoDoc
20
20
  end
21
21
 
22
22
  def reference_name(ref)
23
- ids = bibitem_ref_code(ref)
24
- identifiers = render_identifier(ids)
25
- reference = docid_l10n(identifiers[:metanorma] || identifiers[:sdo] ||
26
- identifiers[:ordinal] || identifiers[:doi])
23
+ identifiers = render_identifier(bibitem_ref_code(ref))
24
+ reference = docid_l10n(identifiers[:content] || identifiers[:metanorma] ||
25
+ identifiers[:sdo] || identifiers[:ordinal] ||
26
+ identifiers[:doi])
27
27
  @xrefs.get[ref["id"]] = { xref: esc(reference) }
28
28
  end
29
29
 
@@ -164,31 +164,31 @@ module IsoDoc
164
164
  datefn = date_note_process(bib)
165
165
  ids = bibitem_ref_code(bib)
166
166
  idents = render_identifier(ids)
167
- ret = if biblio then biblio_ref_entry_code(ordinal, idents, ids,
167
+ ret = if biblio then biblio_ref_entry_code(ordinal, idents,
168
168
  standard, datefn, bib)
169
- else norm_ref_entry_code(ordinal, idents, ids, standard, datefn,
170
- bib)
169
+ else norm_ref_entry_code(ordinal, idents, standard, datefn, bib)
171
170
  end
172
171
  bib.add_first_child("<biblio-tag>#{@i18n.l10n(ret)}</biblio-tag>")
173
172
  end
174
173
 
175
- def norm_ref_entry_code(_ordinal, idents, _ids, _standard, datefn, _bib)
176
- ret = (idents[:ordinal] || idents[:metanorma] || idents[:sdo]).to_s
174
+ def norm_ref_entry_code(_ordinal, ids, _standard, datefn, _bib)
175
+ ret = (ids[:ordinal] || ids[:content] || ids[:metanorma] || ids[:sdo]).to_s
177
176
  ret = esc(ret)
178
- (idents[:ordinal] || idents[:metanorma]) && idents[:sdo] and
179
- ret += ", #{esc idents[:sdo]}"
177
+ (ids[:ordinal] || ids[:metanorma]) && ids[:sdo] and
178
+ ret += ", #{esc ids[:sdo]}"
180
179
  ret += datefn
181
180
  ret.empty? and return ret
182
- idents[:sdo] and ret += ","
181
+ ids[:sdo] and ret += ","
183
182
  ret.sub(",", "").strip.empty? and return ""
184
183
  "#{ret} "
185
184
  end
186
185
 
187
186
  # if ids is just a number, only use that ([1] Non-Standard)
188
187
  # else, use both ordinal, as prefix, and ids
189
- def biblio_ref_entry_code(ordinal, ids, _id, _standard, datefn, _bib)
188
+ def biblio_ref_entry_code(ordinal, ids, _standard, datefn, _bib)
190
189
  # standard and id = nil
191
- ret = esc(ids[:ordinal]) || esc(ids[:metanorma]) || "[#{esc ordinal.to_s}]"
190
+ ret = esc(ids[:ordinal]) || esc(ids[:content]) || esc(ids[:metanorma]) ||
191
+ "[#{esc ordinal.to_s}]"
192
192
  if ids[:sdo] && !ids[:sdo].empty?
193
193
  ret = prefix_bracketed_ref(ret)
194
194
  ret += "#{esc ids[:sdo]}#{datefn}, "
@@ -223,15 +223,16 @@ module IsoDoc
223
223
  bib["hidden"] == "true"
224
224
  end
225
225
 
226
- SKIP_DOCID = <<~XPATH.strip.freeze
226
+ # DOI, ISSN, ISBN cover term
227
+ SERIAL_NUM_DOCID = <<~XPATH.strip.freeze
227
228
  @type = 'DOI' or @type = 'doi' or @type = 'ISSN' or @type = 'issn' or @type = 'ISBN' or @type = 'isbn' or starts-with(@type, 'ISSN.') or starts-with(@type, 'ISBN.') or starts-with(@type, 'issn.') or starts-with(@type, 'isbn.')
228
229
  XPATH
229
230
 
230
231
  def standard?(bib)
231
232
  ret = false
232
233
  bib.xpath(ns("./docidentifier")).each do |id|
233
- id["type"].nil? ||
234
- id.at(".//self::*[#{SKIP_DOCID} or @type = 'metanorma']") and next
234
+ id["type"].nil? || id.at(".//self::*[#{SERIAL_NUM_DOCID} or "\
235
+ "@type = 'metanorma']") and next
235
236
  ret = true
236
237
  end
237
238
  ret
@@ -119,7 +119,8 @@ module IsoDoc
119
119
  eref docxml # feeds eref2link
120
120
  origin docxml # feeds eref2link
121
121
  concept docxml
122
- eref2link docxml
122
+ eref2link docxml # feeds link
123
+ link docxml
123
124
  mathml docxml
124
125
  ruby docxml
125
126
  variant docxml
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "3.4.1".freeze
2
+ VERSION = "3.4.2".freeze
3
3
  end
@@ -162,7 +162,6 @@ module IsoDoc
162
162
  xref = labelled_autonum(@labels["clause"], num)
163
163
  label = num
164
164
  c = clause_title(clause) and title = semx(clause, c, "title")
165
- #clause["id"] ||= "_#{UUIDTools::UUID.random_create}"
166
165
  @anchors[clause["id"]] =
167
166
  { label:, xref:, title:, level:, type: "clause",
168
167
  elem: @labels["clause"] }
@@ -184,7 +183,6 @@ module IsoDoc
184
183
  level == 1 && clause.name == "annex" and
185
184
  label = annex_name_lbl(clause, label)
186
185
  c = clause_title(clause) and title = semx(clause, c, "title")
187
- #clause["id"] ||= "_#{UUIDTools::UUID.random_create}"
188
186
  @anchors[clause["id"]] =
189
187
  { label:, xref: labelled_autonum(@labels["annex"], num), title:,
190
188
  elem: @labels["annex"], type: "clause",
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: 3.4.1
4
+ version: 3.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-11-17 00:00:00.000000000 Z
11
+ date: 2025-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64