isodoc 2.10.6 → 2.10.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9d6fb9b45b43931c09ae2961532d650434c834c94adf40ae698afdab0098dfd
4
- data.tar.gz: eebae6b266587daad1ed883ff44a69914dece3ccfbf34e5135b811536f8b276e
3
+ metadata.gz: 8dfe3b646b2b65d551ff524de95c5960c5dc0d9e607a40b59948deb10832f659
4
+ data.tar.gz: 5230ba55bdba86b34080a412366c26e347f5284151d6099cee23446da6eddfd3
5
5
  SHA512:
6
- metadata.gz: cb7fca64087faf90b1581e9bbeed9809f2ce4253b876eaf8374450cd4fc2c44a5dece2d91febdd0b70914a98ceefaa3f16887303167d378f6ef0d2a83c223041
7
- data.tar.gz: f190c3e9d07ff55030a409a7455e79d7f5bcf6813e0c5b0034f632616e78460539c9472a1df9983a574537357c69df0007a0cd308f67f974ffa294602ca2345d
6
+ metadata.gz: 02e6090e1a7c726ff5024b62f42606aad5ec942e1d8ecd63d576b975d4103b6adfa0cb211d226902f4003e1ad4bec6a00a81ea92edb99c8f1626e6941db8b0fd
7
+ data.tar.gz: ffa9b8ee9be5501fd29cd638b1cde09287f2111a3d6d3a302484e92f2f0d5a035d3765f97d80207edd4119825ebd796f98bde1010eb072ecc16bada797bff310
data/isodoc.gemspec CHANGED
@@ -55,5 +55,6 @@ Gem::Specification.new do |spec|
55
55
  spec.add_development_dependency "sassc", "~> 2.4.0"
56
56
  spec.add_development_dependency "simplecov", "~> 0.15"
57
57
  spec.add_development_dependency "timecop", "~> 0.9"
58
+ spec.add_development_dependency "xml-c14n"
58
59
  # spec.metadata["rubygems_mfa_required"] = "true"
59
60
  end
@@ -213,10 +213,9 @@ module IsoDoc
213
213
  %w(example requirement recommendation permission
214
214
  note table figure sourcecode).freeze
215
215
 
216
- def labelled_ancestor(elem)
217
- #!elem.path.gsub(/\[\d+\]/, "").split(%r{/})[1..-1]
216
+ def labelled_ancestor(elem, exceptions = [])
218
217
  !elem.ancestors.map(&:name)
219
- .intersection(LABELLED_ANCESTOR_ELEMENTS).empty?
218
+ .intersection(LABELLED_ANCESTOR_ELEMENTS - exceptions).empty?
220
219
  end
221
220
 
222
221
  def emf?(type)
@@ -14,7 +14,7 @@ module IsoDoc
14
14
  end
15
15
 
16
16
  def initialize(lang, script, locale, i18n, fonts_options = {})
17
- @metadata = { lang: lang, script: script }
17
+ @metadata = { lang:, script: }
18
18
  DATETYPES.each { |w| @metadata["#{w.gsub('-', '_')}date".to_sym] = "XXX" }
19
19
  @lang = lang
20
20
  @script = script
@@ -29,10 +29,6 @@ module IsoDoc
29
29
  @metadata
30
30
  end
31
31
 
32
- def labels
33
- @labels
34
- end
35
-
36
32
  def set(key, value)
37
33
  @metadata[key] = value
38
34
  end
@@ -44,12 +40,12 @@ module IsoDoc
44
40
  end
45
41
 
46
42
  def doctype(isoxml, _out)
47
- b = isoxml&.at(ns("//bibdata/ext/doctype#{NOLANG}"))&.text || return
48
- set(:doctype, status_print(b))
49
- b1 = isoxml&.at(ns("//bibdata/ext/doctype#{currlang}"))&.text || b
50
- set(:doctype_display, status_print(b1))
51
- b = isoxml&.at(ns("//bibdata/ext/subdoctype#{NOLANG}"))&.text || return
52
- set(:subdoctype, status_print(b))
43
+ b = isoxml.at(ns("//bibdata/ext/doctype#{NOLANG}")) || return
44
+ set(:doctype, status_print(b.text))
45
+ b1 = isoxml.at(ns("//bibdata/ext/doctype#{currlang}")) || b
46
+ set(:doctype_display, status_print(b1.text))
47
+ b = isoxml.at(ns("//bibdata/ext/subdoctype#{NOLANG}")) || return
48
+ set(:subdoctype, status_print(b.text))
53
49
  end
54
50
 
55
51
  def docstatus(xml, _out)
@@ -59,11 +55,11 @@ module IsoDoc
59
55
  s1 = xml.at(ns("//bibdata/status/stage#{currlang}")) || s
60
56
  set(:stage, status_print(s.text))
61
57
  s1 and set(:stage_display, status_print(s1.text))
62
- (i = xml&.at(ns("//bibdata/status/substage#{NOLANG}"))&.text) and
58
+ (i = xml.at(ns("//bibdata/status/substage#{NOLANG}"))&.text) and
63
59
  set(:substage, i)
64
- (i1 = xml&.at(ns("//bibdata/status/substage#{currlang}"))&.text || i) and
60
+ (i1 = xml.at(ns("//bibdata/status/substage#{currlang}"))&.text || i) and
65
61
  set(:substage_display, i1)
66
- (i2 = xml&.at(ns("//bibdata/status/iteration"))&.text) and
62
+ (i2 = xml.at(ns("//bibdata/status/iteration"))&.text) and
67
63
  set(:iteration, i2)
68
64
  set(:unpublished, unpublished(s.text))
69
65
  unpublished(s.text) && set(:stageabbr, stage_abbr(s.text))
@@ -67,20 +67,15 @@ module IsoDoc
67
67
  publisher = []
68
68
  xml.xpath(ns("//bibdata/contributor[xmlns:role/@type = 'publisher']/" \
69
69
  "organization")).each do |org|
70
- name = extract_variant(org.at(ns("./name")))
71
- agency1 = org.at(ns("./abbreviation"))&.text || name
72
- publisher << name if name
70
+ name = org.at(ns("./name[@language = '#{@lang}']")) ||
71
+ org.at(ns("./name"))
72
+ agency1 = org.at(ns("./abbreviation"))&.text || name&.text
73
+ publisher << name.text if name
73
74
  agency = iso?(org) ? "ISO/#{agency}" : "#{agency}#{agency1}/"
74
75
  end
75
76
  [agency, publisher]
76
77
  end
77
78
 
78
- def extract_variant(node)
79
- node.nil? and return node
80
- x = node.at(ns("./variant[@language = '#{@lang}']")) and node = x
81
- node.text
82
- end
83
-
84
79
  def agency(xml)
85
80
  agency, publisher = agency1(xml)
86
81
  set(:agency, agency.sub(%r{/$}, ""))
@@ -38,9 +38,9 @@ module IsoDoc
38
38
  ret = resolve_eref_connectives(eref_locality_stacks(refs, target,
39
39
  node))
40
40
  node.delete("droploc") unless droploc
41
- eref_localities1({ target: target, number: "pl",
41
+ eref_localities1({ target:, number: "pl",
42
42
  type: refs.first.at(ns("./locality/@type")).text,
43
- from: l10n(ret[1..-1].join), node: node, lang: @lang })
43
+ from: l10n(ret[1..-1].join), node:, lang: @lang })
44
44
  end
45
45
 
46
46
  def can_conflate_eref_rendering?(refs)
@@ -143,9 +143,9 @@ module IsoDoc
143
143
  def eref_localities0(ref, _idx, target, node)
144
144
  if ref["type"] == "whole" then @i18n.wholeoftext
145
145
  else
146
- eref_localities1({ target: target, type: ref["type"], number: "sg",
146
+ eref_localities1({ target:, type: ref["type"], number: "sg",
147
147
  from: ref.at(ns("./referenceFrom"))&.text,
148
- upto: ref.at(ns("./referenceTo"))&.text, node: node,
148
+ upto: ref.at(ns("./referenceTo"))&.text, node:,
149
149
  lang: @lang })
150
150
  end
151
151
  end
@@ -38,23 +38,26 @@ module IsoDoc
38
38
 
39
39
  svg = Base64.strict_decode64(elem["src"]
40
40
  .sub(%r{^data:image/svg\+xml;(charset=[^;]+;)?base64,}, ""))
41
- x = Nokogiri::XML.fragment(svg.sub(/<\?xml[^>]*>/, "")) do |config|
42
- config.huge
43
- end
41
+ x = Nokogiri::XML.fragment(svg.sub(/<\?xml[^>]*>/, ""), &:huge)
44
42
  elem["src"] = ""
45
43
  elem.children = x
46
44
  end
47
45
 
48
46
  def figure1(elem)
49
- return sourcecode1(elem) if elem["class"] == "pseudocode" ||
50
- elem["type"] == "pseudocode"
51
- return if elem.at(ns("./figure")) && !elem.at(ns("./name"))
52
-
47
+ elem["class"] == "pseudocode" || elem["type"] == "pseudocode" and
48
+ return sourcecode1(elem)
49
+ figure_label?(elem) or return nil
53
50
  lbl = @xrefs.anchor(elem["id"], :label, false) or return
51
+ # no xref, no label: this can be set in xref
54
52
  prefix_name(elem, block_delim,
55
53
  l10n("#{figure_label(elem)} #{lbl}"), "name")
56
54
  end
57
55
 
56
+ def figure_label?(elem)
57
+ elem.at(ns("./figure")) && !elem.at(ns("./name")) and return false
58
+ true
59
+ end
60
+
58
61
  def figure_label(elem)
59
62
  klass = elem["class"] || "figure"
60
63
  klasslbl = @i18n.get[klass] || klass
@@ -64,6 +64,7 @@ module IsoDoc
64
64
  get_linkend(node)
65
65
  end
66
66
 
67
+ # there should be no //variant in bibdata now
67
68
  def variant(xml)
68
69
  b = xml.xpath(ns("//bibdata//variant"))
69
70
  (xml.xpath(ns("//variant")) - b).each { |f| variant1(f) }
@@ -22,7 +22,7 @@ module IsoDoc
22
22
  end
23
23
 
24
24
  def save_attachment(attachment, dir)
25
- n = File.join(dir, attachment["name"])
25
+ n = File.join(dir, File.basename(attachment["name"]))
26
26
  c = attachment.text.sub(%r{^data:[^;]+;(?:charset=[^;]+;)?base64,}, "")
27
27
  File.open(n, "wb") { |f| f.write(Base64.strict_decode64(c)) }
28
28
  end
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.10.6".freeze
2
+ VERSION = "2.10.7".freeze
3
3
  end
@@ -137,15 +137,16 @@ module IsoDoc
137
137
  c = Counter.new(list["start"] ? list["start"].to_i - 1 : 0)
138
138
  list.xpath(ns("./li")).each do |li|
139
139
  bare_label, label =
140
- list_item_value(li, c, depth, { list_anchor: list_anchor, prev_label: prev_label,
140
+ list_item_value(li, c, depth, { list_anchor:, prev_label:,
141
141
  refer_list: depth == 1 ? refer_list : nil })
142
142
  li["id"] and @anchors[li["id"]] =
143
143
  { label: bare_label, bare_xref: "#{label})",
144
144
  xref: "#{label})",
145
- type: "listitem", refer_list: refer_list,
145
+ type: "listitem", refer_list:,
146
146
  container: list_anchor[:container] }
147
147
  (li.xpath(ns(".//ol")) - li.xpath(ns(".//ol//ol"))).each do |ol|
148
- list_item_anchor_names(ol, list_anchor, depth + 1, label, refer_list)
148
+ list_item_anchor_names(ol, list_anchor, depth + 1, label,
149
+ refer_list)
149
150
  end
150
151
  end
151
152
  end
@@ -227,7 +228,7 @@ module IsoDoc
227
228
  def bookmark_anchor_names(xml)
228
229
  xml.xpath(ns(".//bookmark")).noblank.each do |n|
229
230
  _parent, id = id_ancestor(n)
230
- #container = bookmark_container(parent)
231
+ # container = bookmark_container(parent)
231
232
  @anchors[n["id"]] = { type: "bookmark", label: nil, value: nil,
232
233
  xref: @anchors.dig(id, :xref) || "???",
233
234
  container: @anchors.dig(id, :container) }
@@ -28,6 +28,7 @@ module IsoDoc
28
28
  c = Counter.new
29
29
  j = 0
30
30
  clause.xpath(ns(self.class::FIGURE_NO_CLASS)).noblank.each do |t|
31
+ # labelled_ancestor(t, %w(figure)) and next # disable nested figure labelling
31
32
  j = subfigure_increment(j, c, t)
32
33
  sequential_figure_body(j, c, t, "figure", container:)
33
34
  end
@@ -40,6 +41,7 @@ module IsoDoc
40
41
  clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]"))
41
42
  .each do |t|
42
43
  c[t["class"]] ||= Counter.new
44
+ # labelled_ancestor(t, %w(figure)) and next
43
45
  j = subfigure_increment(j, c[t["class"]], t)
44
46
  sequential_figure_body(j, c[t["class"]], t, t["class"],
45
47
  container:)
@@ -157,7 +159,7 @@ container: false)
157
159
  c = Counter.new
158
160
  j = 0
159
161
  clause.xpath(ns(self.class::FIGURE_NO_CLASS)).noblank.each do |t|
160
- # next if labelled_ancestor(t) && t.ancestors("figure").empty?
162
+ # labelled_ancestor(t, %w(figure)) and next
161
163
  j = subfigure_increment(j, c, t)
162
164
  hierarchical_figure_body(num, j, c, t, "figure")
163
165
  end
@@ -169,6 +171,7 @@ container: false)
169
171
  j = 0
170
172
  clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]"))
171
173
  .noblank.each do |t|
174
+ # labelled_ancestor(t, %w(figure)) and next
172
175
  c[t["class"]] ||= Counter.new
173
176
  j = subfigure_increment(j, c[t["class"]], t)
174
177
  hierarchical_figure_body(num, j, c[t["class"]], t, t["class"])
@@ -52,28 +52,28 @@ note: 注記
52
52
  note_xref: 注記
53
53
  termnote: 注釈%
54
54
  list: リスト
55
- deflist: Definition List
55
+ deflist: 定義リスト
56
56
  figure: 図
57
57
  diagram: Diagram
58
58
  formula: 式
59
- inequality: Formula
59
+ inequality:
60
60
  table: 表
61
- requirement: 要求事項
62
- recommendation: 推奨事項
63
- permission: 許容事項
61
+ requirement: 要求
62
+ recommendation: 推奨
63
+ permission: 許可
64
64
  box: Box
65
65
  index: 索引
66
66
  standard_no: 規格番号
67
67
  number: 番号
68
68
  # Modspec
69
- recommendationtest: Recommendation test
70
- requirementtest: Requirement test
71
- permissiontest: Permission test
72
- recommendationclass: Recommendations class
73
- requirementclass: Requirements class
74
- permissionclass: Permissions class
75
- abstracttest: Abstract test
76
- conformanceclass: Conformance class
69
+ recommendationtest: 推奨テスト
70
+ requirementtest: 要件テスト
71
+ permissiontest: 許可テスト
72
+ recommendationclass: 推奨群
73
+ requirementclass: 要件群
74
+ permissionclass: 許可群
75
+ abstracttest: 抽象テスト
76
+ conformanceclass: 適合性テスト群
77
77
  key: 記号説明
78
78
  example: 例
79
79
  example_xref: 例
@@ -110,12 +110,12 @@ month_november: November
110
110
  month_december: December
111
111
  obligation: Obligation
112
112
  admonition: {
113
- danger: Danger,
113
+ danger: 危険です,
114
114
  warning: 警告,
115
- caution: Caution,
116
- important: Important,
117
- safety precautions: Safety Precautions,
118
- editorial: Editorial Note
115
+ caution: 注意,
116
+ important: 重要,
117
+ safety precautions: 安全上の注意,
118
+ editorial: 編集者注
119
119
  }
120
120
  locality: {
121
121
  section: Section,
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.10.6
4
+ version: 2.10.7
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-07-22 00:00:00.000000000 Z
11
+ date: 2024-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -318,6 +318,20 @@ dependencies:
318
318
  - - "~>"
319
319
  - !ruby/object:Gem::Version
320
320
  version: '0.9'
321
+ - !ruby/object:Gem::Dependency
322
+ name: xml-c14n
323
+ requirement: !ruby/object:Gem::Requirement
324
+ requirements:
325
+ - - ">="
326
+ - !ruby/object:Gem::Version
327
+ version: '0'
328
+ type: :development
329
+ prerelease: false
330
+ version_requirements: !ruby/object:Gem::Requirement
331
+ requirements:
332
+ - - ">="
333
+ - !ruby/object:Gem::Version
334
+ version: '0'
321
335
  description: |
322
336
  isodoc converts documents in the IsoDoc document model into
323
337
  Microsoft Word and HTML.