isodoc 2.10.5 → 2.10.7
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 +2 -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/function/utils.rb +2 -3
- data/lib/isodoc/metadata.rb +10 -14
- data/lib/isodoc/metadata_contributor.rb +4 -9
- data/lib/isodoc/presentation_function/erefs.rb +4 -4
- data/lib/isodoc/presentation_function/image.rb +10 -7
- data/lib/isodoc/presentation_function/inline.rb +1 -0
- data/lib/isodoc/presentation_function/math.rb +32 -18
- data/lib/isodoc/presentation_function/metadata.rb +1 -1
- data/lib/isodoc/presentation_function/refs.rb +10 -4
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/xref/xref_gen.rb +5 -4
- data/lib/isodoc/xref/xref_gen_seq.rb +18 -14
- 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 +19 -18
- data/lib/isodoc-yaml/i18n-ru.yaml +1 -0
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dfe3b646b2b65d551ff524de95c5960c5dc0d9e607a40b59948deb10832f659
|
4
|
+
data.tar.gz: 5230ba55bdba86b34080a412366c26e347f5284151d6099cee23446da6eddfd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02e6090e1a7c726ff5024b62f42606aad5ec942e1d8ecd63d576b975d4103b6adfa0cb211d226902f4003e1ad4bec6a00a81ea92edb99c8f1626e6941db8b0fd
|
7
|
+
data.tar.gz: ffa9b8ee9be5501fd29cd638b1cde09287f2111a3d6d3a302484e92f2f0d5a035d3765f97d80207edd4119825ebd796f98bde1010eb072ecc16bada797bff310
|
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"
|
@@ -54,5 +55,6 @@ Gem::Specification.new do |spec|
|
|
54
55
|
spec.add_development_dependency "sassc", "~> 2.4.0"
|
55
56
|
spec.add_development_dependency "simplecov", "~> 0.15"
|
56
57
|
spec.add_development_dependency "timecop", "~> 0.9"
|
58
|
+
spec.add_development_dependency "xml-c14n"
|
57
59
|
# spec.metadata["rubygems_mfa_required"] = "true"
|
58
60
|
end
|
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)
|
@@ -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)
|
data/lib/isodoc/metadata.rb
CHANGED
@@ -14,7 +14,7 @@ module IsoDoc
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def initialize(lang, script, locale, i18n, fonts_options = {})
|
17
|
-
@metadata = { lang
|
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
|
48
|
-
set(:doctype, status_print(b))
|
49
|
-
b1 = isoxml
|
50
|
-
set(:doctype_display, status_print(b1))
|
51
|
-
b = isoxml
|
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
|
58
|
+
(i = xml.at(ns("//bibdata/status/substage#{NOLANG}"))&.text) and
|
63
59
|
set(:substage, i)
|
64
|
-
(i1 = xml
|
60
|
+
(i1 = xml.at(ns("//bibdata/status/substage#{currlang}"))&.text || i) and
|
65
61
|
set(:substage_display, i1)
|
66
|
-
(i2 = xml
|
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 =
|
71
|
-
|
72
|
-
|
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
|
41
|
+
eref_localities1({ target:, number: "pl",
|
42
42
|
type: refs.first.at(ns("./locality/@type")).text,
|
43
|
-
from: l10n(ret[1..-1].join), node
|
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
|
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
|
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[^>]*>/, ""))
|
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
|
-
|
50
|
-
elem
|
51
|
-
|
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
|
@@ -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)
|
@@ -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
|
@@ -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
data/lib/isodoc/xref/xref_gen.rb
CHANGED
@@ -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
|
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
|
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,
|
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,10 +28,11 @@ 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
|
-
sequential_figure_body(j, c, t, "figure", container:
|
33
|
+
sequential_figure_body(j, c, t, "figure", container:)
|
33
34
|
end
|
34
|
-
sequential_figure_class_names(clause, container:
|
35
|
+
sequential_figure_class_names(clause, container:)
|
35
36
|
end
|
36
37
|
|
37
38
|
def sequential_figure_class_names(clause, container: false)
|
@@ -40,15 +41,16 @@ 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
|
-
container:
|
47
|
+
container:)
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
49
51
|
def subfigure_label(subfignum)
|
50
52
|
subfignum.zero? and return ""
|
51
|
-
"
|
53
|
+
"#{hierfigsep}#{subfignum}"
|
52
54
|
end
|
53
55
|
|
54
56
|
def sequential_figure_body(subfig, counter, elem, klass, container: false)
|
@@ -100,8 +102,8 @@ module IsoDoc
|
|
100
102
|
klass, label = reqt2class_label(t, m)
|
101
103
|
id = c.increment(label, t).print
|
102
104
|
sequential_permission_body(id, t, label, klass, m,
|
103
|
-
container:
|
104
|
-
sequential_permission_children(t, id, container:
|
105
|
+
container:)
|
106
|
+
sequential_permission_children(t, id, container:)
|
105
107
|
end
|
106
108
|
end
|
107
109
|
|
@@ -112,12 +114,13 @@ module IsoDoc
|
|
112
114
|
klass, label = reqt2class_nested_label(t, m)
|
113
115
|
id = "#{lbl}#{hierfigsep}#{c.increment(label, t).print}"
|
114
116
|
sequential_permission_body(id, t, label, klass, m,
|
115
|
-
container:
|
116
|
-
sequential_permission_children(t, id, container:
|
117
|
+
container:)
|
118
|
+
sequential_permission_children(t, id, container:)
|
117
119
|
end
|
118
120
|
end
|
119
121
|
|
120
|
-
def sequential_permission_body(id, elem, label, klass, model,
|
122
|
+
def sequential_permission_body(id, elem, label, klass, model,
|
123
|
+
container: false)
|
121
124
|
@anchors[elem["id"]] = model.postprocess_anchor_struct(
|
122
125
|
elem, anchor_struct(id, elem,
|
123
126
|
label, klass, elem["unnumbered"])
|
@@ -146,17 +149,17 @@ module IsoDoc
|
|
146
149
|
|
147
150
|
# container makes numbering be prefixed with the parent clause reference
|
148
151
|
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:
|
152
|
+
sequential_table_names(clause, container:)
|
153
|
+
sequential_figure_names(clause, container:)
|
154
|
+
sequential_formula_names(clause, container:)
|
155
|
+
sequential_permission_names(clause, container:)
|
153
156
|
end
|
154
157
|
|
155
158
|
def hierarchical_figure_names(clause, num)
|
156
159
|
c = Counter.new
|
157
160
|
j = 0
|
158
161
|
clause.xpath(ns(self.class::FIGURE_NO_CLASS)).noblank.each do |t|
|
159
|
-
#
|
162
|
+
# labelled_ancestor(t, %w(figure)) and next
|
160
163
|
j = subfigure_increment(j, c, t)
|
161
164
|
hierarchical_figure_body(num, j, c, t, "figure")
|
162
165
|
end
|
@@ -168,6 +171,7 @@ module IsoDoc
|
|
168
171
|
j = 0
|
169
172
|
clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]"))
|
170
173
|
.noblank.each do |t|
|
174
|
+
# labelled_ancestor(t, %w(figure)) and next
|
171
175
|
c[t["class"]] ||= Counter.new
|
172
176
|
j = subfigure_increment(j, c[t["class"]], t)
|
173
177
|
hierarchical_figure_body(num, j, c[t["class"]], t, t["class"])
|
@@ -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
|
@@ -52,28 +52,28 @@ note: 注記
|
|
52
52
|
note_xref: 注記
|
53
53
|
termnote: 注釈%
|
54
54
|
list: リスト
|
55
|
-
deflist:
|
55
|
+
deflist: 定義リスト
|
56
56
|
figure: 図
|
57
57
|
diagram: Diagram
|
58
58
|
formula: 式
|
59
|
-
inequality:
|
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:
|
70
|
-
requirementtest:
|
71
|
-
permissiontest:
|
72
|
-
recommendationclass:
|
73
|
-
requirementclass:
|
74
|
-
permissionclass:
|
75
|
-
abstracttest:
|
76
|
-
conformanceclass:
|
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: 例
|
@@ -88,6 +88,7 @@ adapted: 適合しました
|
|
88
88
|
deprecated: 推奨しない用語
|
89
89
|
source: 出典
|
90
90
|
and: and
|
91
|
+
no_identifier: (識別子なし)
|
91
92
|
all_parts: 規格群
|
92
93
|
edition_ordinal: "第{{ var1 }}版"
|
93
94
|
edition: 版
|
@@ -109,12 +110,12 @@ month_november: November
|
|
109
110
|
month_december: December
|
110
111
|
obligation: Obligation
|
111
112
|
admonition: {
|
112
|
-
danger:
|
113
|
+
danger: 危険です,
|
113
114
|
warning: 警告,
|
114
|
-
caution:
|
115
|
-
important:
|
116
|
-
safety precautions:
|
117
|
-
editorial:
|
115
|
+
caution: 注意,
|
116
|
+
important: 重要,
|
117
|
+
safety precautions: 安全上の注意,
|
118
|
+
editorial: 編集者注
|
118
119
|
}
|
119
120
|
locality: {
|
120
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.
|
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-
|
11
|
+
date: 2024-08-05 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
|
@@ -304,6 +318,20 @@ dependencies:
|
|
304
318
|
- - "~>"
|
305
319
|
- !ruby/object:Gem::Version
|
306
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'
|
307
335
|
description: |
|
308
336
|
isodoc converts documents in the IsoDoc document model into
|
309
337
|
Microsoft Word and HTML.
|