isodoc 2.3.0 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/isodoc.gemspec +1 -1
- data/lib/isodoc/convert.rb +2 -2
- data/lib/isodoc/function/inline.rb +30 -10
- data/lib/isodoc/function/references.rb +9 -10
- data/lib/isodoc/init.rb +2 -2
- data/lib/isodoc/metadata.rb +2 -1
- data/lib/isodoc/presentation_function/image.rb +7 -1
- data/lib/isodoc/presentation_function/terms.rb +9 -4
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/postprocess.rb +3 -4
- data/lib/isodoc/xref/xref_gen_seq.rb +39 -12
- data/lib/isodoc/xref.rb +1 -0
- data/lib/isodoc-yaml/i18n-ar.yaml +1 -0
- data/lib/isodoc-yaml/i18n-de.yaml +1 -0
- data/lib/isodoc-yaml/i18n-en.yaml +1 -0
- data/lib/isodoc-yaml/i18n-es.yaml +1 -0
- data/lib/isodoc-yaml/i18n-fr.yaml +1 -0
- data/lib/isodoc-yaml/i18n-ru.yaml +1 -0
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e09ef612cbed34d00104fae8b5aa9d6d4f17898cfbf4cae3255fdbb6218f402b
|
4
|
+
data.tar.gz: b91758dc84682c50def94dd0904de92deb862fc1ffcd5c2af81f635fabece882
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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"
|
data/lib/isodoc/convert.rb
CHANGED
@@ -204,8 +204,8 @@ module IsoDoc
|
|
204
204
|
filename, dir = init_file(input_filename, debug)
|
205
205
|
docxml.root.default_namespace = ""
|
206
206
|
convert_i18n_init(docxml)
|
207
|
-
metadata_init(@lang, @script, @i18n)
|
208
|
-
xref_init(@lang, @script, self, @i18n, {})
|
207
|
+
metadata_init(@lang, @script, @locale, @i18n)
|
208
|
+
xref_init(@lang, @script, self, @i18n, {locale: @locale})
|
209
209
|
[docxml, filename, dir]
|
210
210
|
end
|
211
211
|
|
@@ -60,14 +60,17 @@ module IsoDoc
|
|
60
60
|
"#{url}##{anchor.text.strip}"
|
61
61
|
end
|
62
62
|
|
63
|
-
def eref_url(
|
64
|
-
|
63
|
+
def eref_url(id)
|
64
|
+
@bibitems.nil? and return nil
|
65
65
|
|
66
|
-
|
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
|
-
@
|
69
|
-
|
70
|
-
"##{
|
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
|
-
|
106
|
-
|
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(
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
212
|
+
f.at(ns("./title"))&.children&.each { |c2| parse(c2, h1) }
|
214
213
|
end
|
215
214
|
biblio_list(f, div, true)
|
216
215
|
end
|
data/lib/isodoc/init.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
class Convert < ::IsoDoc::Common
|
3
|
-
def metadata_init(lang, script, i18n)
|
4
|
-
@meta = Metadata.new(lang, script, i18n)
|
3
|
+
def metadata_init(lang, script, locale, i18n)
|
4
|
+
@meta = Metadata.new(lang, script, locale, i18n)
|
5
5
|
end
|
6
6
|
|
7
7
|
def xref_init(lang, script, _klass, i18n, options)
|
data/lib/isodoc/metadata.rb
CHANGED
@@ -15,11 +15,12 @@ module IsoDoc
|
|
15
15
|
@i18n.l10n(expr, lang, script, locale)
|
16
16
|
end
|
17
17
|
|
18
|
-
def initialize(lang, script, i18n, fonts_options = {})
|
18
|
+
def initialize(lang, script, locale, i18n, fonts_options = {})
|
19
19
|
@metadata = { lang: lang, script: script }
|
20
20
|
DATETYPES.each { |w| @metadata["#{w.gsub(/-/, '_')}date".to_sym] = "XXX" }
|
21
21
|
@lang = lang
|
22
22
|
@script = script
|
23
|
+
@locale = locale
|
23
24
|
@c = HTMLEntities.new
|
24
25
|
@i18n = i18n
|
25
26
|
@labels = @i18n.get
|
@@ -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("#{
|
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
|
-
|
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")) || {}
|
data/lib/isodoc/version.rb
CHANGED
@@ -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
|
114
|
-
cs = td
|
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(
|
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[
|
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(
|
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"]] =
|
151
|
-
|
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)
|
data/lib/isodoc/xref.rb
CHANGED
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.
|
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-
|
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.
|
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.
|
166
|
+
version: 0.5.2
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: roman-numerals
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|