isodoc 2.3.1 → 2.3.2

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: 1cfc6c450ad2b744b1669dcdbc33ec716c9f1bb2ab8b0923a4e77f17123c9c3b
4
- data.tar.gz: 98efcb5075af4c7a941a7d6855ca074be4ad9e89fc0b9d20f5c7ef96da97b03b
3
+ metadata.gz: e09ef612cbed34d00104fae8b5aa9d6d4f17898cfbf4cae3255fdbb6218f402b
4
+ data.tar.gz: b91758dc84682c50def94dd0904de92deb862fc1ffcd5c2af81f635fabece882
5
5
  SHA512:
6
- metadata.gz: d398f662be10cc30b34205c10346d040f36f2217fa6a026304cf8015312f9227e799f4687b044f226ac6884307a03177e184cf5c2a99cad5ed06dd83050ba836
7
- data.tar.gz: f67b3a92994c67c13565a91e822b205e3c2f93f9dacc32effcbf8d35c85ed7f20eb2be85a6f32cd0f2d319e5a6e2f5f3d6948ed1217d18c2535e98ceb8ca08f7
6
+ metadata.gz: c61751e1d304d84e32d26626b03849d26c479f6422636665352415eba04be416cc431786e05a45a88329c73e67096f10f3a27465c94c0bac73fa96caad98d3b7
7
+ data.tar.gz: 9c6f2492605198aad0d0548de81d69fb7cac42efcaab0d4ee9bf4c1afd0a9eef5bdf1d8317cf3df3d785d42d0e8cec69f0a480acb0c505f8bf6d1e03222eb993
data/isodoc.gemspec CHANGED
@@ -43,7 +43,7 @@ Gem::Specification.new do |spec|
43
43
  spec.add_dependency "mn2pdf"
44
44
  spec.add_dependency "mn-requirements", "~> 0.1.7"
45
45
  spec.add_dependency "relaton-cli"
46
- spec.add_dependency "relaton-render", "~> 0.5.0"
46
+ spec.add_dependency "relaton-render", "~> 0.5.2"
47
47
  spec.add_dependency "roman-numerals"
48
48
  spec.add_dependency "thread_safe"
49
49
  spec.add_dependency "twitter_cldr", ">= 6.6.0"
@@ -60,14 +60,17 @@ module IsoDoc
60
60
  "#{url}##{anchor.text.strip}"
61
61
  end
62
62
 
63
- def eref_url(bibitemid)
64
- return nil if @bibitems.nil? || @bibitems[bibitemid].nil?
63
+ def eref_url(id)
64
+ @bibitems.nil? and return nil
65
65
 
66
- url = @bibitems[bibitemid].at(ns("./uri[@type = 'citation']")) and
66
+ b = @bibitems[id]
67
+ b.nil? and return nil
68
+
69
+ url = b.at(ns("./uri[@type = 'citation'][@language = '#{@lang}']")) and
67
70
  return url.text
68
- @bibitems[bibitemid]["hidden"] == "true" and
69
- return @bibitems[bibitemid].at(ns("./uri"))&.text
70
- "##{bibitemid}"
71
+ url = b.at(ns("./uri[@type = 'citation']")) and return url.text
72
+ b["hidden"] == "true" and return b.at(ns("./uri"))&.text
73
+ "##{id}"
71
74
  end
72
75
 
73
76
  def eref_parse(node, out)
@@ -101,10 +104,9 @@ module IsoDoc
101
104
 
102
105
  def stem_parse(node, out)
103
106
  ooml = case node["type"]
104
- when "AsciiMath"
105
- "#{@openmathdelim}#{HTMLEntities.new.encode(node.text)}"\
106
- "#{@closemathdelim}"
107
- when "MathML" then node.first_element_child.to_s
107
+ when "AsciiMath" then asciimath_parse(node)
108
+ when "MathML" then mathml_parse(node)
109
+ when "LaTeX" then latexmath_parse(node)
108
110
  else HTMLEntities.new.encode(node.text)
109
111
  end
110
112
  out.span **{ class: "stem" } do |span|
@@ -112,6 +114,24 @@ module IsoDoc
112
114
  end
113
115
  end
114
116
 
117
+ MATHML = { "m" => "http://www.w3.org/1998/Math/MathML" }.freeze
118
+
119
+ def mathml_parse(node)
120
+ node.at("./m:math", MATHML)&.to_xml
121
+ end
122
+
123
+ def asciimath_parse(node)
124
+ a = node.at(ns("./asciimath"))&.text || node.text
125
+
126
+ "#{@openmathdelim}#{HTMLEntities.new.encode(a)}"\
127
+ "#{@closemathdelim}"
128
+ end
129
+
130
+ def latexmath_parse(node)
131
+ a = node.at(ns("./latexmath"))&.text || node.text
132
+ HTMLEntities.new.encode(a)
133
+ end
134
+
115
135
  def image_title_parse(out, caption)
116
136
  unless caption.nil?
117
137
  out.p **{ class: "FigureTitle", style: "text-align:center;" } do |p|
@@ -56,15 +56,14 @@ module IsoDoc
56
56
  ret.empty? and
57
57
  ret = bib.xpath(ns("./docidentifier[@primary = 'true']"))
58
58
  ret.empty? and
59
- ret = bib.at(ns("./docidentifier[not(@type = 'DOI' or "\
60
- "@type = 'metanorma' "\
61
- "or @type = 'metanorma-ordinal' or "\
62
- "@type = 'ISSN' or @type = 'ISBN')]"\
63
- "[@language = '#{@lang}']")) ||
64
- bib.at(ns("./docidentifier[not(@type = 'DOI' or "\
65
- "@type = 'metanorma' "\
66
- "or @type = 'metanorma-ordinal' or "\
67
- "@type = 'ISSN' or @type = 'ISBN')]"))
59
+ ret = bib.at(ns(<<~XPATH,
60
+ ./docidentifier[not(@type = 'DOI' or @type = 'metanorma' or @type = 'metanorma-ordinal' or @type = 'ISSN' or @type = 'ISBN')][@language = '#{@lang}']
61
+ XPATH
62
+ )) ||
63
+ bib.at(ns(<<~XPATH,
64
+ ./docidentifier[not(@type = 'DOI' or @type = 'metanorma' or @type = 'metanorma-ordinal' or @type = 'ISSN' or @type = 'ISBN')]
65
+ XPATH
66
+ ))
68
67
  ret
69
68
  end
70
69
 
@@ -210,7 +209,7 @@ module IsoDoc
210
209
  page_break(out)
211
210
  out.div do |div|
212
211
  div.h1 **{ class: "Section3" } do |h1|
213
- f&.at(ns("./title"))&.children&.each { |c2| parse(c2, h1) }
212
+ f.at(ns("./title"))&.children&.each { |c2| parse(c2, h1) }
214
213
  end
215
214
  biblio_list(f, div, true)
216
215
  end
@@ -53,7 +53,13 @@ module IsoDoc
53
53
 
54
54
  lbl = @xrefs.anchor(elem["id"], :label, false) or return
55
55
  prefix_name(elem, block_delim,
56
- l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
56
+ l10n("#{figure_label(elem)} #{lbl}"), "name")
57
+ end
58
+
59
+ def figure_label(elem)
60
+ klass = elem["class"] || "figure"
61
+ klasslbl = @i18n.get[klass] || klass
62
+ lower2cap klasslbl
57
63
  end
58
64
 
59
65
  def eps2svg(img)
@@ -101,14 +101,19 @@ module IsoDoc
101
101
  pref = nil
102
102
  term.xpath(ns("./preferred[expression/name]")).each_with_index do |p, i|
103
103
  if i.zero? then pref = p
104
- elsif merge_preferred_eligible?(pref, p)
105
- pref.at(ns("./expression/name")) <<
106
- l10n("; #{p.at(ns('./expression/name')).children.to_xml}")
107
- p.remove
104
+ else merge_second_preferred1(pref, p)
108
105
  end
109
106
  end
110
107
  end
111
108
 
109
+ def merge_second_preferred1(pref, second)
110
+ if merge_preferred_eligible?(pref, second)
111
+ n1 = pref.at(ns("./expression/name"))
112
+ n2 = second.remove.at(ns("./expression/name"))
113
+ n1.children = l10n("#{n1.children.to_xml}; #{n2.children.to_xml}")
114
+ end
115
+ end
116
+
112
117
  def merge_preferred_eligible?(first, second)
113
118
  firstex = first.at(ns("./expression")) || {}
114
119
  secondex = second.at(ns("./expression")) || {}
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.3.1".freeze
2
+ VERSION = "2.3.2".freeze
3
3
  end
@@ -42,8 +42,7 @@ module IsoDoc
42
42
  .gsub(/-DOUBLE_HYPHEN_ESCAPE-/, "--")
43
43
  @wordstylesheet = wordstylesheet_update
44
44
  Html2Doc.new(
45
- filename: filename,
46
- imagedir: @localdir,
45
+ filename: filename, imagedir: @localdir,
47
46
  stylesheet: @wordstylesheet&.path,
48
47
  header_file: header&.path, dir: dir,
49
48
  asciimathdelims: [@openmathdelim, @closemathdelim],
@@ -110,8 +109,8 @@ module IsoDoc
110
109
  t.xpath(".//tr").each_with_index do |tr, r|
111
110
  tr.xpath("./td | ./th").each_with_index do |td, _i|
112
111
  x = 0
113
- rs = td&.attr("rowspan")&.to_i || 1
114
- cs = td&.attr("colspan")&.to_i || 1
112
+ rs = td.attr("rowspan")&.to_i || 1
113
+ cs = td.attr("colspan")&.to_i || 1
115
114
  while cells2d[r][x]
116
115
  x += 1
117
116
  end
@@ -20,22 +20,38 @@ module IsoDoc
20
20
  idx
21
21
  end
22
22
 
23
+ FIGURE_NO_CLASS = <<~XPATH.freeze
24
+ .//figure[not(@class)] | .//figure[@class = 'pseudocode'] | .//sourcecode[not(ancestor::example)]
25
+ XPATH
26
+
23
27
  def sequential_figure_names(clause)
24
28
  c = Counter.new
25
29
  j = 0
26
- clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
27
- .noblank.each do |t|
30
+ clause.xpath(ns(FIGURE_NO_CLASS)).noblank.each do |t|
28
31
  j = subfigure_increment(j, c, t)
29
- sequential_figure_body(j, c, t)
32
+ sequential_figure_body(j, c, t, "figure")
33
+ end
34
+ sequential_figure_class_names(clause)
35
+ end
36
+
37
+ def sequential_figure_class_names(clause)
38
+ c = {}
39
+ j = 0
40
+ clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]"))
41
+ .each do |t|
42
+ c[t["class"]] ||= Counter.new
43
+ j = subfigure_increment(j, c[t["class"]], t)
44
+ sequential_figure_body(j, c[t["class"]], t, t["class"])
30
45
  end
31
46
  end
32
47
 
33
- def sequential_figure_body(subfignum, counter, block)
48
+ def sequential_figure_body(subfignum, counter, block, klass)
34
49
  label = counter.print
35
50
  label &&= label + (subfignum.zero? ? "" : "-#{subfignum}")
36
51
 
37
52
  @anchors[block["id"]] = anchor_struct(
38
- label, nil, @labels["figure"], "figure", block["unnumbered"]
53
+ label, nil, @labels[klass] || klass.capitalize, klass,
54
+ block["unnumbered"]
39
55
  )
40
56
  end
41
57
 
@@ -134,21 +150,32 @@ module IsoDoc
134
150
  def hierarchical_figure_names(clause, num)
135
151
  c = Counter.new
136
152
  j = 0
137
- clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
138
- .noblank.each do |t|
153
+ clause.xpath(ns(FIGURE_NO_CLASS)).noblank.each do |t|
139
154
  # next if labelled_ancestor(t) && t.ancestors("figure").empty?
140
-
141
155
  j = subfigure_increment(j, c, t)
142
- hierarchical_figure_body(num, j, c, t)
156
+ hierarchical_figure_body(num, j, c, t, "figure")
157
+ end
158
+ hierarchical_figure_class_names(clause, num)
159
+ end
160
+
161
+ def hierarchical_figure_class_names(clause, num)
162
+ c = {}
163
+ j = 0
164
+ clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]"))
165
+ .noblank.each do |t|
166
+ c[t["class"]] ||= Counter.new
167
+ j = subfigure_increment(j, c[t["class"]], t)
168
+ hierarchical_figure_body(num, j, c[t["class"]], t, t["class"])
143
169
  end
144
170
  end
145
171
 
146
- def hierarchical_figure_body(num, subfignum, counter, block)
172
+ def hierarchical_figure_body(num, subfignum, counter, block, klass)
147
173
  label = "#{num}#{hiersep}#{counter.print}" +
148
174
  (subfignum.zero? ? "" : "#{hierfigsep}#{subfignum}")
149
175
 
150
- @anchors[block["id"]] = anchor_struct(label, nil, @labels["figure"],
151
- "figure", block["unnumbered"])
176
+ @anchors[block["id"]] =
177
+ anchor_struct(label, nil, @labels[klass] || klass.capitalize,
178
+ klass, block["unnumbered"])
152
179
  end
153
180
 
154
181
  def hierarchical_table_names(clause, num)
@@ -48,6 +48,7 @@ termnote: ملاحظة % للقيد
48
48
  list: قائمة
49
49
  deflist: قائمة تعريف
50
50
  figure: شكل
51
+ diagram: رسم بياني
51
52
  formula: معادلة
52
53
  inequality: عدم مساواة
53
54
  table: جدول
@@ -54,6 +54,7 @@ termnote: Hinweis % zum Eintrag
54
54
  list: Liste
55
55
  deflist: Definitionsliste
56
56
  figure: Abbildung
57
+ diagram: Diagramm
57
58
  formula: Formel
58
59
  inequality: Formel
59
60
  table: Tabelle
@@ -54,6 +54,7 @@ termnote: Note % to entry
54
54
  list: List
55
55
  deflist: Definition List
56
56
  figure: Figure
57
+ diagram: Diagram
57
58
  formula: Formula
58
59
  inequality: Formula
59
60
  table: Table
@@ -54,6 +54,7 @@ termnote: Nota % a la entrada
54
54
  list: Lista
55
55
  deflist: Lista de definiciones
56
56
  figure: Figura
57
+ diagram: Diagrama
57
58
  formula: Fórmula
58
59
  inequality: Fórmula
59
60
  table: Tabla
@@ -49,6 +49,7 @@ note: NOTE
49
49
  note_xref: Note
50
50
  termnote: Note % à l’article
51
51
  figure: Figure
52
+ diagram: Diagramme
52
53
  formula: Formule
53
54
  inequality: Formule
54
55
  list: Liste
@@ -59,6 +59,7 @@ termnote: Примечание % к определению
59
59
  list: Список
60
60
  deflist: Список определений
61
61
  figure: Рисунок
62
+ diagram: Диаграмма
62
63
  formula: Формула
63
64
  inequality: Формула
64
65
  table: Таблица
@@ -47,6 +47,7 @@ note: 注
47
47
  note_xref: 注
48
48
  termnote: 注%
49
49
  figure: 图
50
+ diagram: 图表
50
51
  formula: 公式
51
52
  inequality: 公式
52
53
  list: 列项
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.3.1
4
+ version: 2.3.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: 2022-09-26 00:00:00.000000000 Z
11
+ date: 2022-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 0.5.0
159
+ version: 0.5.2
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 0.5.0
166
+ version: 0.5.2
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: roman-numerals
169
169
  requirement: !ruby/object:Gem::Requirement