isodoc 2.10.5 → 2.10.6
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 +4 -4
- data/isodoc.gemspec +1 -0
- data/lib/isodoc/css.rb +2 -4
- data/lib/isodoc/function/blocks.rb +13 -2
- data/lib/isodoc/function/references.rb +15 -8
- data/lib/isodoc/function/section_titles.rb +8 -0
- data/lib/isodoc/function/to_word_html.rb +8 -0
- data/lib/isodoc/presentation_function/math.rb +32 -18
- data/lib/isodoc/presentation_function/refs.rb +10 -4
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/xref/xref_gen_seq.rb +14 -13
- data/lib/isodoc/xref/xref_util.rb +4 -3
- 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-ja.yaml +1 -0
- data/lib/isodoc-yaml/i18n-ru.yaml +1 -0
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9d6fb9b45b43931c09ae2961532d650434c834c94adf40ae698afdab0098dfd
|
4
|
+
data.tar.gz: eebae6b266587daad1ed883ff44a69914dece3ccfbf34e5135b811536f8b276e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb7fca64087faf90b1581e9bbeed9809f2ce4253b876eaf8374450cd4fc2c44a5dece2d91febdd0b70914a98ceefaa3f16887303167d378f6ef0d2a83c223041
|
7
|
+
data.tar.gz: f190c3e9d07ff55030a409a7455e79d7f5bcf6813e0c5b0034f632616e78460539c9472a1df9983a574537357c69df0007a0cd308f67f974ffa294602ca2345d
|
data/isodoc.gemspec
CHANGED
@@ -44,6 +44,7 @@ Gem::Specification.new do |spec|
|
|
44
44
|
spec.add_dependency "twitter_cldr", ">= 6.6.0"
|
45
45
|
spec.add_dependency "uuidtools"
|
46
46
|
|
47
|
+
spec.add_development_dependency "bigdecimal"
|
47
48
|
spec.add_development_dependency "debug"
|
48
49
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
49
50
|
spec.add_development_dependency "guard", "~> 2.14"
|
data/lib/isodoc/css.rb
CHANGED
@@ -90,16 +90,14 @@ module IsoDoc
|
|
90
90
|
|
91
91
|
# stripwordcss if HTML stylesheet, !stripwordcss if DOC stylesheet
|
92
92
|
def generate_css(filename, stripwordcss)
|
93
|
-
|
94
|
-
|
93
|
+
filename.nil? and return nil
|
95
94
|
filename = precompiled_style_or_original(filename)
|
96
95
|
stylesheet = File.read(filename, encoding: "UTF-8")
|
97
96
|
stylesheet = populate_template(stylesheet, :word)
|
98
97
|
stylesheet.gsub!(/(\s|\{)mso-[^:]+:[^;]+;/m, "\\1") if stripwordcss
|
99
98
|
stylesheet.gsub!(/--/, "-DOUBLE_HYPHEN_ESCAPE-") unless stripwordcss
|
100
|
-
|
99
|
+
File.extname(filename) == ".scss" and
|
101
100
|
stylesheet = convert_scss(filename, stylesheet, stripwordcss)
|
102
|
-
end
|
103
101
|
Tempfile.open([File.basename(filename, ".*"), "css"],
|
104
102
|
mode: File::BINARY | File::SHARE_DELETE,
|
105
103
|
encoding: "utf-8") do |f|
|
@@ -161,8 +161,7 @@ module IsoDoc
|
|
161
161
|
def quote_attribution(node, out)
|
162
162
|
author = node.at(ns("./author"))
|
163
163
|
source = node.at(ns("./source"))
|
164
|
-
|
165
|
-
|
164
|
+
author.nil? && source.nil? and return
|
166
165
|
out.p class: "QuoteAttribution" do |p|
|
167
166
|
p << "— #{author.text}" if author
|
168
167
|
p << ", " if author && source
|
@@ -206,6 +205,18 @@ module IsoDoc
|
|
206
205
|
end
|
207
206
|
end
|
208
207
|
|
208
|
+
def cross_align_parse(node, out)
|
209
|
+
out.table do |t|
|
210
|
+
t.tbody do |b|
|
211
|
+
node.xpath(ns("./align-cell")).each do |c|
|
212
|
+
b.td do |td|
|
213
|
+
c.children.each { |n| parse(n, td) }
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
209
220
|
def columnbreak_parse(node, out); end
|
210
221
|
end
|
211
222
|
end
|
@@ -51,24 +51,31 @@ module IsoDoc
|
|
51
51
|
|
52
52
|
# returns [metanorma, non-metanorma, DOI/ISSN/ISBN] identifiers
|
53
53
|
def bibitem_ref_code(bib)
|
54
|
+
id, id1, id2, id3 = bibitem_ref_code_prep(bib)
|
55
|
+
id || id1 || id2 || id3 and return [id, id1, id2, id3]
|
56
|
+
bib["suppress_identifier"] == "true" and return [nil, nil, nil, nil]
|
57
|
+
[nil, no_identifier(bib), nil, nil]
|
58
|
+
end
|
59
|
+
|
60
|
+
def bibitem_ref_code_prep(bib)
|
54
61
|
id = bib.at(ns("./docidentifier[@type = 'metanorma']"))
|
55
62
|
id1 = pref_ref_code(bib)
|
56
63
|
id2 = bib.at(ns("./docidentifier[#{SKIP_DOCID}]"))
|
57
64
|
id3 = bib.at(ns("./docidentifier[@type = 'metanorma-ordinal']"))
|
58
|
-
|
59
|
-
|
65
|
+
[id, id1, id2, id3]
|
66
|
+
end
|
60
67
|
|
68
|
+
def no_identifier(bib)
|
69
|
+
@i18n.no_identifier or return nil
|
61
70
|
id = Nokogiri::XML::Node.new("docidentifier", bib.document)
|
62
|
-
id <<
|
63
|
-
|
71
|
+
id << @i18n.no_identifier
|
72
|
+
id
|
64
73
|
end
|
65
74
|
|
66
75
|
def bracket_if_num(num)
|
67
|
-
|
68
|
-
|
76
|
+
num.nil? and return nil
|
69
77
|
num = num.text.sub(/^\[/, "").sub(/\]$/, "")
|
70
|
-
return "[#{num}]"
|
71
|
-
|
78
|
+
/^\d+$/.match?(num) and return "[#{num}]"
|
72
79
|
num
|
73
80
|
end
|
74
81
|
|
@@ -18,6 +18,14 @@ module IsoDoc
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
def freestanding_title(node, out)
|
22
|
+
parents = node.ancestors("clause, annex, terms, references, " \
|
23
|
+
"definitions, acknowledgements, introduction, " \
|
24
|
+
"foreword")
|
25
|
+
clause_parse_title(parents.empty? ? node : parents.first,
|
26
|
+
out, node, out)
|
27
|
+
end
|
28
|
+
|
21
29
|
# used for subclauses
|
22
30
|
def clause_parse_title(node, div, title, out, header_class = {})
|
23
31
|
return if title.nil?
|
@@ -153,6 +153,12 @@ module IsoDoc
|
|
153
153
|
@meta.get
|
154
154
|
end
|
155
155
|
|
156
|
+
def cross_align(isoxml, out)
|
157
|
+
isoxml.xpath(ns("//cross-align")).each do |c|
|
158
|
+
parse(c, out)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
156
162
|
def boilerplate(node, out)
|
157
163
|
@bare and return
|
158
164
|
boilerplate = node.at(ns("//boilerplate")) or return
|
@@ -249,9 +255,11 @@ module IsoDoc
|
|
249
255
|
when "option" then option_parse(node, out)
|
250
256
|
when "textarea" then textarea_parse(node, out)
|
251
257
|
when "toc" then toc_parse(node, out)
|
258
|
+
when "title" then freestanding_title(node, out) # not inside clause
|
252
259
|
when "variant-title" then variant_title(node, out)
|
253
260
|
when "span" then span_parse(node, out)
|
254
261
|
when "location" then location_parse(node, out)
|
262
|
+
when "cross-align" then cross_align_parse(node, out)
|
255
263
|
when "columnbreak" then columnbreak_parse(node, out)
|
256
264
|
when "ruby" then ruby_parse(node, out)
|
257
265
|
when "rt" then rt_parse(node, out)
|
@@ -28,8 +28,8 @@ module IsoDoc
|
|
28
28
|
else implicit_number_formatter(x, locale)
|
29
29
|
end
|
30
30
|
rescue ArgumentError
|
31
|
-
rescue
|
32
|
-
warn "Failure to
|
31
|
+
rescue StandardError, RuntimeError => e
|
32
|
+
warn "Failure to localise MathML/mn\n#{node.parent.to_xml}\n#{e}"
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -40,10 +40,8 @@ module IsoDoc
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def implicit_number_formatter(num, locale)
|
43
|
-
fmt = {
|
43
|
+
fmt = { significant: num_totaldigits(num.text) }.compact
|
44
44
|
n = normalise_number(num.text)
|
45
|
-
# Plurimath confused by exponent notation
|
46
|
-
#warn "IMPLICIT: precision: #{num_precision(num.text)} ; symbols: #{fmt}, n: #{n}; output: #{@numfmt.localized_number(n, locale:, format: fmt, precision: num_precision(num.text))}"
|
47
45
|
@numfmt.localized_number(n, locale:, format: fmt,
|
48
46
|
precision: num_precision(num.text))
|
49
47
|
end
|
@@ -57,7 +55,8 @@ module IsoDoc
|
|
57
55
|
end
|
58
56
|
|
59
57
|
def numberformat_type(ret)
|
60
|
-
%i(precision digit_count group_digits fraction_group_digits)
|
58
|
+
%i(precision significant digit_count group_digits fraction_group_digits)
|
59
|
+
.each do |i|
|
61
60
|
ret[i] &&= ret[i].to_i
|
62
61
|
end
|
63
62
|
%i(notation exponent_sign locale).each do |i|
|
@@ -69,20 +68,20 @@ module IsoDoc
|
|
69
68
|
def explicit_number_formatter(num, locale, options)
|
70
69
|
ret = numberformat_type(numberformat_extract(options))
|
71
70
|
l = ret[:locale] || locale
|
72
|
-
precision, symbols,
|
71
|
+
precision, symbols, significant = explicit_number_formatter_cfg(num, ret)
|
73
72
|
n = normalise_number(num.text)
|
74
|
-
|
75
|
-
#warn "EXPLICIT: precision: #{precision} ; symbols: #{symbols}, n: #{n}; output: #{Plurimath::NumberFormatter.new(l, localizer_symbols: symbols).localized_number(n, precision:, format: symbols.merge(digit_count:))}"
|
76
|
-
Plurimath::NumberFormatter.new(l, localizer_symbols: symbols)
|
73
|
+
Plurimath::NumberFormatter.new(l)
|
77
74
|
.localized_number(n, precision:,
|
78
|
-
format: symbols.merge(
|
75
|
+
format: symbols.merge(significant:))
|
79
76
|
end
|
80
77
|
|
81
78
|
def explicit_number_formatter_cfg(num, fmt)
|
82
79
|
symbols = twitter_cldr_localiser_symbols.dup.merge(fmt)
|
83
|
-
precision = symbols[:precision]
|
84
|
-
symbols[:
|
85
|
-
|
80
|
+
precision = symbols[:precision] || num_precision(num.text)
|
81
|
+
signif = symbols[:significant]
|
82
|
+
(symbols.keys & %i(precision digit_count)).empty? and
|
83
|
+
signif ||= num_totaldigits(num.text)
|
84
|
+
[precision, symbols, signif]
|
86
85
|
end
|
87
86
|
|
88
87
|
def num_precision(num)
|
@@ -96,8 +95,8 @@ module IsoDoc
|
|
96
95
|
def num_totaldigits(num)
|
97
96
|
totaldigits = nil
|
98
97
|
/\.(?=\d+e)/.match?(num) and
|
99
|
-
totaldigits = twitter_cldr_localiser_symbols[:
|
100
|
-
num.sub(/^.*\./, "").sub(/e.*$/, "").size
|
98
|
+
totaldigits = twitter_cldr_localiser_symbols[:significant] ||
|
99
|
+
num.sub(/^0\./, ".").sub(/^.*\./, "").sub(/e.*$/, "").size
|
101
100
|
totaldigits
|
102
101
|
end
|
103
102
|
|
@@ -109,6 +108,7 @@ module IsoDoc
|
|
109
108
|
@suppressasciimathdup || node.parent.at(ns("./asciimath")) and return
|
110
109
|
math = node.to_xml.gsub(/ xmlns=["'][^"']+["']/, "")
|
111
110
|
.gsub(%r{<[^:/>]+:}, "<").gsub(%r{</[^:/>]+:}, "</")
|
111
|
+
.gsub(%r{ data-metanorma-numberformat="[^"]+"}, "")
|
112
112
|
ret = Plurimath::Math.parse(math, "mathml").to_asciimath
|
113
113
|
node.next = "<asciimath>#{@c.encode(ret, :basic)}</asciimath>"
|
114
114
|
rescue StandardError => e
|
@@ -116,7 +116,8 @@ module IsoDoc
|
|
116
116
|
end
|
117
117
|
|
118
118
|
def maths_just_numeral(node)
|
119
|
-
mn = node.at(".//m:mn", MATHML).children
|
119
|
+
mn = node.at(".//m:mn", MATHML).children.text
|
120
|
+
.sub(/\^([0-9+-]+)$/, "<sup>\\1</sup>")
|
120
121
|
if node.parent.name == "stem"
|
121
122
|
node.parent.replace(mn)
|
122
123
|
else
|
@@ -142,11 +143,24 @@ module IsoDoc
|
|
142
143
|
OUTPUT
|
143
144
|
end
|
144
145
|
|
146
|
+
# convert any Ascii superscripts to correct(ish) MathML
|
147
|
+
# Not bothering to match times, base of 1.0 x 10^-20, just ^-20
|
148
|
+
def mn_to_msup(node)
|
149
|
+
node.xpath(".//m:mn", MATHML).each do |n|
|
150
|
+
m = %r{^(.+)\^([0-9+-]+)$}.match(n.text) or next
|
151
|
+
n.replace("<msup><mn>#{m[1]}</mn><mn>#{m[2]}</mn></msup>")
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
145
155
|
def mathml_number(node, locale)
|
146
156
|
justnumeral = numeric_mathml?(node)
|
147
157
|
justnumeral or asciimath_dup(node)
|
148
158
|
localize_maths(node, locale)
|
149
|
-
justnumeral
|
159
|
+
if justnumeral
|
160
|
+
maths_just_numeral(node)
|
161
|
+
else
|
162
|
+
mn_to_msup(node)
|
163
|
+
end
|
150
164
|
end
|
151
165
|
|
152
166
|
def numeric_mathml?(node)
|
@@ -13,15 +13,21 @@ module IsoDoc
|
|
13
13
|
|
14
14
|
def move_norm_ref_to_sections(docxml)
|
15
15
|
docxml.at(ns(@xrefs.klass.norm_ref_xpath)) or return
|
16
|
-
s = docxml
|
17
|
-
docxml.at(ns("//preface"))&.after("<sections/>")&.next_element ||
|
18
|
-
docxml.at(ns("//annex | //bibliography"))&.before("<sections/>")
|
19
|
-
&.previous_element or return
|
16
|
+
s = move_norm_ref_to_sections_insert_pt(docxml) or return
|
20
17
|
docxml.xpath(ns(@xrefs.klass.norm_ref_xpath)).each do |r|
|
18
|
+
r.at("./ancestor::xmlns:bibliography") or next
|
21
19
|
s << r.remove
|
22
20
|
end
|
23
21
|
end
|
24
22
|
|
23
|
+
def move_norm_ref_to_sections_insert_pt(docxml)
|
24
|
+
s = docxml.at(ns("//sections")) and return s
|
25
|
+
s = docxml.at(ns("//preface")) and
|
26
|
+
return s.after("<sections/>").next_element
|
27
|
+
docxml.at(ns("//annex | //bibliography"))&.before("<sections/>")
|
28
|
+
&.previous_element
|
29
|
+
end
|
30
|
+
|
25
31
|
def hidden_items(docxml)
|
26
32
|
docxml.xpath(ns("//references[bibitem/@hidden = 'true']")).each do |x|
|
27
33
|
x.at(ns("./bibitem[not(@hidden = 'true')]")) and next
|
data/lib/isodoc/version.rb
CHANGED
@@ -29,9 +29,9 @@ module IsoDoc
|
|
29
29
|
j = 0
|
30
30
|
clause.xpath(ns(self.class::FIGURE_NO_CLASS)).noblank.each do |t|
|
31
31
|
j = subfigure_increment(j, c, t)
|
32
|
-
sequential_figure_body(j, c, t, "figure", container:
|
32
|
+
sequential_figure_body(j, c, t, "figure", container:)
|
33
33
|
end
|
34
|
-
sequential_figure_class_names(clause, container:
|
34
|
+
sequential_figure_class_names(clause, container:)
|
35
35
|
end
|
36
36
|
|
37
37
|
def sequential_figure_class_names(clause, container: false)
|
@@ -42,13 +42,13 @@ module IsoDoc
|
|
42
42
|
c[t["class"]] ||= Counter.new
|
43
43
|
j = subfigure_increment(j, c[t["class"]], t)
|
44
44
|
sequential_figure_body(j, c[t["class"]], t, t["class"],
|
45
|
-
container:
|
45
|
+
container:)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
def subfigure_label(subfignum)
|
50
50
|
subfignum.zero? and return ""
|
51
|
-
"
|
51
|
+
"#{hierfigsep}#{subfignum}"
|
52
52
|
end
|
53
53
|
|
54
54
|
def sequential_figure_body(subfig, counter, elem, klass, container: false)
|
@@ -100,8 +100,8 @@ module IsoDoc
|
|
100
100
|
klass, label = reqt2class_label(t, m)
|
101
101
|
id = c.increment(label, t).print
|
102
102
|
sequential_permission_body(id, t, label, klass, m,
|
103
|
-
container:
|
104
|
-
sequential_permission_children(t, id, container:
|
103
|
+
container:)
|
104
|
+
sequential_permission_children(t, id, container:)
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
@@ -112,12 +112,13 @@ module IsoDoc
|
|
112
112
|
klass, label = reqt2class_nested_label(t, m)
|
113
113
|
id = "#{lbl}#{hierfigsep}#{c.increment(label, t).print}"
|
114
114
|
sequential_permission_body(id, t, label, klass, m,
|
115
|
-
container:
|
116
|
-
sequential_permission_children(t, id, container:
|
115
|
+
container:)
|
116
|
+
sequential_permission_children(t, id, container:)
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
|
-
def sequential_permission_body(id, elem, label, klass, model,
|
120
|
+
def sequential_permission_body(id, elem, label, klass, model,
|
121
|
+
container: false)
|
121
122
|
@anchors[elem["id"]] = model.postprocess_anchor_struct(
|
122
123
|
elem, anchor_struct(id, elem,
|
123
124
|
label, klass, elem["unnumbered"])
|
@@ -146,10 +147,10 @@ module IsoDoc
|
|
146
147
|
|
147
148
|
# container makes numbering be prefixed with the parent clause reference
|
148
149
|
def sequential_asset_names(clause, container: false)
|
149
|
-
sequential_table_names(clause, container:
|
150
|
-
sequential_figure_names(clause, container:
|
151
|
-
sequential_formula_names(clause, container:
|
152
|
-
sequential_permission_names(clause, container:
|
150
|
+
sequential_table_names(clause, container:)
|
151
|
+
sequential_figure_names(clause, container:)
|
152
|
+
sequential_formula_names(clause, container:)
|
153
|
+
sequential_permission_names(clause, container:)
|
153
154
|
end
|
154
155
|
|
155
156
|
def hierarchical_figure_names(clause, num)
|
@@ -19,7 +19,8 @@ module IsoDoc
|
|
19
19
|
|
20
20
|
SECTIONS_XPATH =
|
21
21
|
"//foreword | //introduction | //acknowledgements | " \
|
22
|
-
"//preface/
|
22
|
+
"//preface/abstract | " \
|
23
|
+
"//preface/terms | //preface/definitions | //preface/references | " \
|
23
24
|
"//preface/clause | //sections/terms | //annex | " \
|
24
25
|
"//sections/clause | //sections/definitions | " \
|
25
26
|
"//bibliography/references | //bibliography/clause".freeze
|
@@ -34,8 +35,8 @@ module IsoDoc
|
|
34
35
|
"./xmlns:X".gsub("X", asset)
|
35
36
|
end
|
36
37
|
|
37
|
-
|
38
|
-
|
38
|
+
CHILD_SECTIONS = "./clause | ./appendix | ./terms | ./definitions | " \
|
39
|
+
"./references".freeze
|
39
40
|
end
|
40
41
|
end
|
41
42
|
end
|
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.
|
4
|
+
version: 2.10.6
|
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-
|
11
|
+
date: 2024-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: bigdecimal
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: debug
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|