isodoc 3.3.0 → 3.3.1
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/lib/isodoc/presentation_function/autonum.rb +2 -2
- data/lib/isodoc/presentation_function/bibdata.rb +1 -0
- data/lib/isodoc/presentation_function/block.rb +1 -1
- data/lib/isodoc/presentation_function/docid.rb +1 -1
- data/lib/isodoc/presentation_function/erefs.rb +15 -111
- data/lib/isodoc/presentation_function/erefs_locality.rb +113 -0
- data/lib/isodoc/presentation_function/image.rb +1 -1
- data/lib/isodoc/presentation_function/list.rb +14 -1
- data/lib/isodoc/presentation_function/reqt.rb +1 -1
- data/lib/isodoc/presentation_function/terms.rb +8 -4
- data/lib/isodoc/presentation_function/xrefs.rb +10 -6
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/xref/xref_anchor.rb +1 -2
- data/lib/isodoc/xref/xref_gen_seq.rb +27 -30
- data/lib/isodoc/xref/xref_util.rb +6 -4
- data/lib/isodoc/xref.rb +6 -4
- data/lib/isodoc-yaml/i18n-ja.yaml +25 -2
- data/lib/isodoc-yaml/i18n-ko.yaml +22 -0
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +24 -2
- data/lib/isodoc-yaml/i18n-zh-Hant.yaml +22 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb4af3689c8908e75e4b6919cb448f2f909b35de01d4fdf44e30d2f080b7a7ce
|
4
|
+
data.tar.gz: 18ac32a56d90f11d83ebfc57d6ab17044228b7ab7a7aba65a90e2f6436505793
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36124955f274bdc52944895c0b7742e89da9ec7646ad0801e1711393a266e405ab22087aeb475a513a46c4b8e4421b83e6b09c4092add9782cd5320ecb28c471
|
7
|
+
data.tar.gz: 462d5b598a87eaa3016b2cb5cc81ec94bf5da6a02608f9e5e008bc142c7dc5d67dfc043255ec773929132035f882b8d7555a886bc6ea0288c32487a6ba9614ec
|
@@ -78,7 +78,7 @@ module IsoDoc
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def semx(node, label, element = "autonum")
|
81
|
-
id = node["id"] || node[:id]
|
81
|
+
id = node["id"] || node[:id] || elem['original-id']
|
82
82
|
/<semx element='[^']+' source='#{id}'/.match?(label) and return label
|
83
83
|
l = stripsemx(label)
|
84
84
|
%(<semx element='#{element}' source='#{id}'>#{l}</semx>)
|
@@ -118,7 +118,7 @@ module IsoDoc
|
|
118
118
|
prefix_container_fmt_xref_label(container_container,
|
119
119
|
@xrefs.anchor(container, :xref, false))
|
120
120
|
l10n(connectives_spans(@i18n.nested_xref
|
121
|
-
.sub("%1", "<span class='fmt-xref-container'>#{container_label}</span>")
|
121
|
+
.sub("%1", "<span class='fmt-xref-container'><esc>#{container_label}</esc></span>")
|
122
122
|
.sub("%2", xref)))
|
123
123
|
end
|
124
124
|
|
@@ -108,7 +108,7 @@ module IsoDoc
|
|
108
108
|
elem["unnumbered"] && !elem.at(ns("./name")) and return
|
109
109
|
n = @xrefs.anchor(elem["id"], :label, false)
|
110
110
|
lbl = labelled_autonum(lower2cap(@i18n.table), elem["id"], n)
|
111
|
-
prefix_name(elem, { caption: table_delim },
|
111
|
+
prefix_name(elem, { caption: table_delim }, lbl, "name")
|
112
112
|
end
|
113
113
|
|
114
114
|
def table_css(elem)
|
@@ -23,7 +23,7 @@ module IsoDoc
|
|
23
23
|
data, = @bibrender.parse(bib)
|
24
24
|
ret = data[:authoritative_identifier] or return nil
|
25
25
|
ret.empty? and return nil
|
26
|
-
ret
|
26
|
+
ret.map { |x| @i18n.l10n(x) } # get rid of `<esc>` wrappers
|
27
27
|
end
|
28
28
|
|
29
29
|
# returns [metanorma, non-metanorma, DOI/ISSN/ISBN] identifiers
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "metanorma-utils"
|
2
|
+
require_relative "erefs_locality"
|
2
3
|
|
3
4
|
module IsoDoc
|
4
5
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
@@ -34,38 +35,11 @@ module IsoDoc
|
|
34
35
|
[e["connective"], to_xml(e.parent.remove)]
|
35
36
|
end.flatten
|
36
37
|
ret = resolve_eref_connectives(locs)
|
37
|
-
elem.next = "<semx element='erefstack' source='#{elem['id']}'>#{ret[1]}</semx>"
|
38
|
-
end
|
39
|
-
|
40
|
-
def eref_localities(refs, target, node)
|
41
|
-
if can_conflate_eref_rendering?(refs)
|
42
|
-
l10n(", #{eref_localities_conflated(refs, target, node)}"
|
43
|
-
.gsub(/\s+/, " "), @lang, @script, { prev: target })
|
44
|
-
else
|
45
|
-
ret = resolve_eref_connectives(eref_locality_stacks(refs, target, node))
|
46
|
-
l10n(ret.join.gsub(/\s+/, " "), @lang, @script, { prev: target })
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def eref_localities_conflated(refs, target, node)
|
51
|
-
droploc = node["droploc"]
|
52
|
-
node["droploc"] = true
|
53
|
-
ret = resolve_eref_connectives(eref_locality_stacks(refs, target, node))
|
54
|
-
node.delete("droploc") unless droploc
|
55
|
-
eref_localities1({ target:, number: "pl",
|
56
|
-
type: refs.first.at(ns("./locality/@type")).text,
|
57
|
-
from: l10n(ret[1..].join), node:, lang: @lang })
|
58
|
-
end
|
59
|
-
|
60
|
-
def can_conflate_eref_rendering?(refs)
|
61
|
-
(refs.size > 1 &&
|
62
|
-
refs.all? { |r| r.name == "localityStack" } &&
|
63
|
-
refs.all? { |r| r.xpath(ns("./locality")).size == 1 }) or return false
|
64
|
-
first = refs.first.at(ns("./locality/@type")).text
|
65
|
-
refs.all? { |r| r.at(ns("./locality/@type")).text == first }
|
38
|
+
elem.next = "<semx element='erefstack' source='#{elem['id']}'>#{l10n ret[1]}</semx>"
|
66
39
|
end
|
67
40
|
|
68
41
|
def resolve_eref_connectives(locs)
|
42
|
+
locs = escape_l10n(locs)
|
69
43
|
locs = resolve_comma_connectives(locs)
|
70
44
|
locs = resolve_to_connectives(locs)
|
71
45
|
locs.size < 3 and return locs
|
@@ -75,6 +49,18 @@ module IsoDoc
|
|
75
49
|
[", ", combine_conn(locs)]
|
76
50
|
end
|
77
51
|
|
52
|
+
XREF_CONNECTIVES = %w(from to or and).freeze
|
53
|
+
|
54
|
+
def escape_l10n(locs)
|
55
|
+
locs.map do |x|
|
56
|
+
if XREF_CONNECTIVES.include?(x) || [", ", " ", ""].include?(x)
|
57
|
+
x
|
58
|
+
else
|
59
|
+
"<esc>#{x}</esc>"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
78
64
|
def resolve_comma_connectives(locs)
|
79
65
|
locs1 = []
|
80
66
|
add = ""
|
@@ -110,88 +96,6 @@ module IsoDoc
|
|
110
96
|
locs1
|
111
97
|
end
|
112
98
|
|
113
|
-
def eref_locality_stacks(refs, target, node)
|
114
|
-
ret = refs.each_with_index.with_object([]) do |(r, i), m|
|
115
|
-
added = eref_locality_stack(r, i, target, node)
|
116
|
-
added.empty? and next
|
117
|
-
added.each { |a| m << a }
|
118
|
-
i == refs.size - 1 and next
|
119
|
-
m << eref_locality_delimiter(r)
|
120
|
-
end
|
121
|
-
ret.empty? ? ret : [", "] + ret
|
122
|
-
end
|
123
|
-
|
124
|
-
def eref_locality_delimiter(ref)
|
125
|
-
if ref&.next_element&.name == "localityStack"
|
126
|
-
ref.next_element["connective"]
|
127
|
-
else locality_delimiter(ref)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def eref_locality_stack(ref, idx, target, node)
|
132
|
-
ret = []
|
133
|
-
if ref.name == "localityStack"
|
134
|
-
ret = eref_locality_stack1(ref, target, node, ret)
|
135
|
-
else
|
136
|
-
l = eref_localities0(ref, idx, target, node) and ret << l
|
137
|
-
end
|
138
|
-
ret[-1] == ", " and ret.pop
|
139
|
-
ret
|
140
|
-
end
|
141
|
-
|
142
|
-
def eref_locality_stack1(ref, target, node, ret)
|
143
|
-
ref.elements.each_with_index do |rr, j|
|
144
|
-
l = eref_localities0(rr, j, target, node) or next
|
145
|
-
ret << l
|
146
|
-
ret << locality_delimiter(rr) unless j == ref.elements.size - 1
|
147
|
-
end
|
148
|
-
ret
|
149
|
-
end
|
150
|
-
|
151
|
-
def locality_delimiter(_loc)
|
152
|
-
", "
|
153
|
-
end
|
154
|
-
|
155
|
-
def eref_localities0(ref, _idx, target, node)
|
156
|
-
if ref["type"] == "whole" then @i18n.wholeoftext
|
157
|
-
else
|
158
|
-
eref_localities1({ target:, type: ref["type"], number: "sg",
|
159
|
-
from: ref.at(ns("./referenceFrom"))&.text,
|
160
|
-
upto: ref.at(ns("./referenceTo"))&.text, node:,
|
161
|
-
lang: @lang })
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
def eref_localities1_zh(opt)
|
166
|
-
ret = "第#{opt[:from]}" if opt[:from]
|
167
|
-
ret += "–#{opt[:upto]}" if opt[:upto]
|
168
|
-
loc = eref_locality_populate(opt[:type], opt[:node], "sg")
|
169
|
-
ret += " #{loc}" unless opt[:node]["droploc"] == "true"
|
170
|
-
ret
|
171
|
-
end
|
172
|
-
|
173
|
-
def eref_localities1(opt)
|
174
|
-
opt[:type] == "anchor" and return nil
|
175
|
-
opt[:lang] == "zh" and
|
176
|
-
return l10n(eref_localities1_zh(opt))
|
177
|
-
ret = eref_locality_populate(opt[:type], opt[:node], opt[:number])
|
178
|
-
ret += " #{opt[:from]}" if opt[:from]
|
179
|
-
ret += "–#{opt[:upto]}" if opt[:upto]
|
180
|
-
l10n(ret)
|
181
|
-
end
|
182
|
-
|
183
|
-
def eref_locality_populate(type, node, number)
|
184
|
-
node["droploc"] == "true" and return ""
|
185
|
-
loc = type.sub(/^locality:/, "")
|
186
|
-
ret = @i18n.locality[loc] || loc
|
187
|
-
number == "pl" and ret = @i18n.inflect(ret, number: "pl")
|
188
|
-
ret = case node["case"]
|
189
|
-
when "lowercase" then ret.downcase
|
190
|
-
else Metanorma::Utils.strict_capitalize_first(ret)
|
191
|
-
end
|
192
|
-
" #{ret}"
|
193
|
-
end
|
194
|
-
|
195
99
|
def eref2link(docxml)
|
196
100
|
docxml.xpath(ns("//display-text")).each { |f| f.replace(f.children) }
|
197
101
|
docxml.xpath(ns("//fmt-eref | //fmt-origin[not(.//termref)]"))
|
@@ -0,0 +1,113 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
class PresentationXMLConvert < ::IsoDoc::Convert
|
3
|
+
def eref_localities(refs, target, node)
|
4
|
+
if can_conflate_eref_rendering?(refs)
|
5
|
+
l10n(", <esc>#{eref_localities_conflated(refs, target, node)}</esc>"
|
6
|
+
.gsub(/\s+/, " "), @lang, @script, { prev: target })
|
7
|
+
else
|
8
|
+
ret = resolve_eref_connectives(eref_locality_stacks(refs, target, node))
|
9
|
+
l10n(ret.join.gsub(/\s+/, " "), @lang, @script, { prev: target })
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def eref_localities_conflated(refs, target, node)
|
14
|
+
droploc = node["droploc"]
|
15
|
+
node["droploc"] = true
|
16
|
+
ret = resolve_eref_connectives(eref_locality_stacks(refs, target, node))
|
17
|
+
node.delete("droploc") unless droploc
|
18
|
+
eref_localities1({ target:, number: "pl",
|
19
|
+
type: refs.first.at(ns("./locality/@type")).text,
|
20
|
+
from: l10n(ret[1..].join), node:, lang: @lang })
|
21
|
+
end
|
22
|
+
|
23
|
+
def can_conflate_eref_rendering?(refs)
|
24
|
+
(refs.size > 1 &&
|
25
|
+
refs.all? { |r| r.name == "localityStack" } &&
|
26
|
+
refs.all? { |r| r.xpath(ns("./locality")).size == 1 }) or return false
|
27
|
+
first = refs.first.at(ns("./locality/@type")).text
|
28
|
+
refs.all? { |r| r.at(ns("./locality/@type")).text == first }
|
29
|
+
end
|
30
|
+
|
31
|
+
def eref_locality_stacks(refs, target, node)
|
32
|
+
ret = refs.each_with_index.with_object([]) do |(r, i), m|
|
33
|
+
added = eref_locality_stack(r, i, target, node)
|
34
|
+
added.empty? and next
|
35
|
+
added.each { |a| m << a }
|
36
|
+
i == refs.size - 1 and next
|
37
|
+
m << eref_locality_delimiter(r)
|
38
|
+
end
|
39
|
+
ret.empty? ? ret : [", "] + ret
|
40
|
+
end
|
41
|
+
|
42
|
+
def eref_locality_delimiter(ref)
|
43
|
+
if ref&.next_element&.name == "localityStack"
|
44
|
+
ref.next_element["connective"]
|
45
|
+
else locality_delimiter(ref)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def eref_locality_stack(ref, idx, target, node)
|
50
|
+
ret = []
|
51
|
+
if ref.name == "localityStack"
|
52
|
+
ret = eref_locality_stack1(ref, target, node, ret)
|
53
|
+
else
|
54
|
+
l = eref_localities0(ref, idx, target, node) and ret << l
|
55
|
+
end
|
56
|
+
ret[-1] == ", " and ret.pop
|
57
|
+
ret
|
58
|
+
end
|
59
|
+
|
60
|
+
def eref_locality_stack1(ref, target, node, ret)
|
61
|
+
ref.elements.each_with_index do |rr, j|
|
62
|
+
l = eref_localities0(rr, j, target, node) or next
|
63
|
+
ret << l
|
64
|
+
ret << locality_delimiter(rr) unless j == ref.elements.size - 1
|
65
|
+
end
|
66
|
+
ret
|
67
|
+
end
|
68
|
+
|
69
|
+
def locality_delimiter(_loc)
|
70
|
+
", "
|
71
|
+
end
|
72
|
+
|
73
|
+
def eref_localities0(ref, _idx, target, node)
|
74
|
+
if ref["type"] == "whole" then @i18n.wholeoftext
|
75
|
+
else
|
76
|
+
eref_localities1({ target:, type: ref["type"], number: "sg",
|
77
|
+
from: ref.at(ns("./referenceFrom"))&.text,
|
78
|
+
upto: ref.at(ns("./referenceTo"))&.text, node:,
|
79
|
+
lang: @lang })
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def eref_localities1_zh(opt)
|
84
|
+
ret = "第<esc>#{opt[:from]}</esc>" if opt[:from]
|
85
|
+
ret += "–<esc>#{opt[:upto]}</esc>" if opt[:upto]
|
86
|
+
loc = eref_locality_populate(opt[:type], opt[:node], "sg")
|
87
|
+
ret += " #{loc}" unless opt[:node]["droploc"] == "true"
|
88
|
+
ret
|
89
|
+
end
|
90
|
+
|
91
|
+
def eref_localities1(opt)
|
92
|
+
opt[:type] == "anchor" and return nil
|
93
|
+
%(zh ja ko).include?(opt[:lang]) and
|
94
|
+
return l10n(eref_localities1_zh(opt))
|
95
|
+
ret = eref_locality_populate(opt[:type], opt[:node], opt[:number])
|
96
|
+
ret += " #{opt[:from]}" if opt[:from]
|
97
|
+
ret += "–#{opt[:upto]}" if opt[:upto]
|
98
|
+
l10n(ret)
|
99
|
+
end
|
100
|
+
|
101
|
+
def eref_locality_populate(type, node, number)
|
102
|
+
node["droploc"] == "true" and return ""
|
103
|
+
loc = type.sub(/^locality:/, "")
|
104
|
+
ret = @i18n.locality[loc] || loc
|
105
|
+
number == "pl" and ret = @i18n.inflect(ret, number: "pl")
|
106
|
+
ret = case node["case"]
|
107
|
+
when "lowercase" then ret.downcase
|
108
|
+
else Metanorma::Utils.strict_capitalize_first(ret)
|
109
|
+
end
|
110
|
+
" #{ret}"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -70,7 +70,7 @@ module IsoDoc
|
|
70
70
|
lbl = @xrefs.anchor(elem["id"], :label, false)
|
71
71
|
lbl and a = autonum(elem["id"], lbl)
|
72
72
|
figname = figure_name(elem)
|
73
|
-
|
73
|
+
elem.at("./ancestor::xmlns:figure") && a and
|
74
74
|
a += subfigure_delim
|
75
75
|
lbl && figure_label?(elem) and s = "#{figname}#{a}"
|
76
76
|
prefix_name(elem, { caption: figure_delim(elem) }, l10n(s&.strip), "name")
|
@@ -20,11 +20,24 @@ module IsoDoc
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def ol(docxml)
|
23
|
+
ol_prep(docxml)
|
23
24
|
docxml.xpath(ns("//ol")).each { |f| ol1(f) }
|
24
|
-
@xrefs.list_anchor_names(docxml.xpath(ns(@xrefs.sections_xpath)))
|
25
25
|
docxml.xpath(ns("//ol/li")).each { |f| ol_label(f) }
|
26
26
|
end
|
27
27
|
|
28
|
+
def ol_numbering(docxml)
|
29
|
+
docxml.xpath(ns("//ol")).each do |elem|
|
30
|
+
elem["type"] ||= ol_depth(elem).to_s # feeds ol_label_format
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def ol_prep(docxml)
|
35
|
+
ol_numbering(docxml)
|
36
|
+
@xrefs.list_anchor_names(docxml.xpath(ns(@xrefs.sections_xpath)))
|
37
|
+
@xrefs.localise_anchors("list")
|
38
|
+
@xrefs.localise_anchors("listitem")
|
39
|
+
end
|
40
|
+
|
28
41
|
def ol_depth(node)
|
29
42
|
depth = node.ancestors("ul, ol").size + 1
|
30
43
|
@counter.ol_type(node, depth) # defined in Xref::Counter
|
@@ -24,7 +24,7 @@ module IsoDoc
|
|
24
24
|
def recommendation1(elem, type)
|
25
25
|
lbl = @reqt_models.model(elem["model"])
|
26
26
|
.recommendation_label(elem, type, xrefs)
|
27
|
-
prefix_name(elem, {},
|
27
|
+
prefix_name(elem, {}, lbl, "name")
|
28
28
|
end
|
29
29
|
|
30
30
|
def requirement_render_preprocessing(docxml); end
|
@@ -148,14 +148,18 @@ module IsoDoc
|
|
148
148
|
m1.replace("<modification>#{to_xml(new_m1)}</modification>")
|
149
149
|
end
|
150
150
|
|
151
|
+
# concatenate sources. localise the concatenation, escaping the concatenands
|
152
|
+
# from punctuation localisation: l10n(<esc>A</esc>, <esc>B</esc>)
|
153
|
+
# pass the result to termsource_label, where it will be appended after
|
154
|
+
# "SOURCE: ", and therefore again needs to be escaped
|
151
155
|
def termsource1(elem)
|
152
156
|
ret = [semx_fmt_dup(elem)]
|
153
|
-
while elem
|
157
|
+
while elem.next_element&.name == "source"
|
154
158
|
ret << semx_fmt_dup(elem.next_element.remove)
|
155
159
|
end
|
156
|
-
s = ret.map { |x| to_xml(x) }.map(&:strip)
|
160
|
+
s = ret.map { |x| to_xml(x) }.map(&:strip).map { |x| "<esc>#{x}</esc>" }
|
157
161
|
.join(termsource_join_delim(elem))
|
158
|
-
termsource_label(elem, s)
|
162
|
+
termsource_label(elem, "<esc>#{@i18n.l10n s}</esc>")
|
159
163
|
end
|
160
164
|
|
161
165
|
def termsource_join_delim(_elem)
|
@@ -163,7 +167,7 @@ module IsoDoc
|
|
163
167
|
end
|
164
168
|
|
165
169
|
def termsource_label(elem, sources)
|
166
|
-
elem.replace(l10n("[#{@i18n.source}:
|
170
|
+
elem.replace(l10n("[#{@i18n.source}: <esc>#{sources}</esc>]"))
|
167
171
|
end
|
168
172
|
|
169
173
|
def termsource_modification(elem)
|
@@ -21,8 +21,8 @@ module IsoDoc
|
|
21
21
|
anchor_xref(node, container, container: true),
|
22
22
|
node, target)
|
23
23
|
l10n(connectives_spans(@i18n.nested_xref
|
24
|
-
.sub("%1", "<span class='fmt-xref-container'>#{container_label}</span>")
|
25
|
-
.sub("%2", linkend)))
|
24
|
+
.sub("%1", "<span class='fmt-xref-container'><esc>#{container_label}</esc></span>")
|
25
|
+
.sub("%2", "<esc>#{linkend}</esc>")))
|
26
26
|
end
|
27
27
|
|
28
28
|
def anchor_value(id)
|
@@ -70,7 +70,7 @@ module IsoDoc
|
|
70
70
|
def anchor_xref_short(node, target, container)
|
71
71
|
if (l = node["label"]) && !container
|
72
72
|
v = anchor_value(target)
|
73
|
-
@i18n.l10n(%[<span class="fmt-element-name">#{l}</span>
|
73
|
+
@i18n.l10n(%[<span class="fmt-element-name">#{l}</span> <esc>#{v}</esc>])
|
74
74
|
else @xrefs.anchor(target, :xref)
|
75
75
|
end
|
76
76
|
end
|
@@ -93,7 +93,9 @@ module IsoDoc
|
|
93
93
|
linkend = if can_conflate_xref_rendering?(locs)
|
94
94
|
combine_conflated_xref_locations(locs)
|
95
95
|
else
|
96
|
-
out = locs.each
|
96
|
+
out = locs.each do |l|
|
97
|
+
l[:label] = "<esc>#{anchor_linkend1(l[:node])}</esc>"
|
98
|
+
end
|
97
99
|
l10n(combine_conn(out))
|
98
100
|
end
|
99
101
|
capitalise_xref(node, linkend, anchor_value(node["target"]))
|
@@ -114,7 +116,7 @@ module IsoDoc
|
|
114
116
|
def conflate_xref_locations(locs)
|
115
117
|
out = locs.each { |l| l[:label] = anchor_value(l[:target]) }
|
116
118
|
label = @i18n.inflect(locs.first[:elem], number: "pl")
|
117
|
-
out[0][:label] = l10n("#{label}
|
119
|
+
out[0][:label] = l10n("#{label} <esc>#{out[0][:label]}</esc>").strip
|
118
120
|
out
|
119
121
|
end
|
120
122
|
|
@@ -139,7 +141,9 @@ module IsoDoc
|
|
139
141
|
|
140
142
|
def loc2xref(entry)
|
141
143
|
if entry[:target]
|
142
|
-
|
144
|
+
<<~XML
|
145
|
+
<fmt-xref nested='true' target='#{entry[:target]}'>#{entry[:label]}</fmt-xref>
|
146
|
+
XML
|
143
147
|
else
|
144
148
|
entry[:label]
|
145
149
|
end
|
data/lib/isodoc/version.rb
CHANGED
@@ -46,8 +46,7 @@ module IsoDoc
|
|
46
46
|
lbl = semx(node, lbl)
|
47
47
|
s = " #{anchor_struct_value(lbl, elem)}"
|
48
48
|
end
|
49
|
-
|
50
|
-
.gsub(/ $/, "")
|
49
|
+
"<span class='fmt-element-name'>#{elem}</span>#{s}".gsub(/ $/, "")
|
51
50
|
end
|
52
51
|
|
53
52
|
def anchor_struct_value(lbl, elem)
|
@@ -5,7 +5,7 @@ module IsoDoc
|
|
5
5
|
module XrefGen
|
6
6
|
module Blocks
|
7
7
|
def subfigure_increment(idx, counter, elem)
|
8
|
-
if elem.
|
8
|
+
if elem.ancestors.map(&:name).include?("figure") then idx += 1
|
9
9
|
else
|
10
10
|
idx = 0
|
11
11
|
counter.increment(elem)
|
@@ -18,9 +18,9 @@ module IsoDoc
|
|
18
18
|
XPATH
|
19
19
|
|
20
20
|
def sequential_figure_names(clause, container: false)
|
21
|
-
c = Counter.new
|
22
21
|
j = 0
|
23
|
-
clause.xpath(ns(self.class::FIGURE_NO_CLASS)).noblank
|
22
|
+
clause.xpath(ns(self.class::FIGURE_NO_CLASS)).noblank
|
23
|
+
.each_with_object(Counter.new) do |t, c|
|
24
24
|
# labelled_ancestor(t, %w(figure)) and next # disable nested figure labelling
|
25
25
|
j = subfigure_increment(j, c, t)
|
26
26
|
sublabel = subfigure_label(j)
|
@@ -34,7 +34,6 @@ module IsoDoc
|
|
34
34
|
clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]"))
|
35
35
|
.each_with_object({}) do |t, c|
|
36
36
|
c[t["class"]] ||= Counter.new
|
37
|
-
# labelled_ancestor(t, %w(figure)) and next
|
38
37
|
j = subfigure_increment(j, c[t["class"]], t)
|
39
38
|
sublabel = subfigure_label(j)
|
40
39
|
figure_anchor(t, sublabel, c[t["class"]].print, t["class"],
|
@@ -71,19 +70,19 @@ module IsoDoc
|
|
71
70
|
{ unnumb: elem["unnumbered"] }
|
72
71
|
)
|
73
72
|
if elem["unnumbered"] != "true"
|
73
|
+
p = elem.at("./ancestor::xmlns:figure")
|
74
74
|
x = "#{subfigure_separator(markup: true)}#{semx(elem, sublabel)}"
|
75
75
|
@anchors[elem["id"]][:label] = "#{label}#{x}"
|
76
|
-
@anchors[elem["id"]][:xref] = @anchors[
|
76
|
+
@anchors[elem["id"]][:xref] = @anchors[p["id"]][:xref] + x +
|
77
77
|
delim_wrap(subfigure_delim)
|
78
|
-
x = @anchors[
|
78
|
+
x = @anchors[p["id"]][:container] and
|
79
79
|
@anchors[elem["id"]][:container] = x
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
83
|
def sequential_table_names(clause, container: false)
|
84
|
-
|
85
|
-
|
86
|
-
# labelled_ancestor(t) and next
|
84
|
+
clause.xpath(ns(".//table")).noblank
|
85
|
+
.each_with_object(Counter.new) do |t, c|
|
87
86
|
@anchors[t["id"]] = anchor_struct(
|
88
87
|
c.increment(t).print, t, @labels["table"], "table",
|
89
88
|
{ unnumb: t["unnumbered"], container: container }
|
@@ -92,8 +91,8 @@ module IsoDoc
|
|
92
91
|
end
|
93
92
|
|
94
93
|
def sequential_formula_names(clause, container: false)
|
95
|
-
|
96
|
-
|
94
|
+
clause.xpath(ns(".//formula")).noblank
|
95
|
+
.each_with_object(Counter.new) do |t, c|
|
97
96
|
@anchors[t["id"]] = anchor_struct(
|
98
97
|
c.increment(t).print, t,
|
99
98
|
t["inequality"] ? @labels["inequality"] : @labels["formula"],
|
@@ -104,8 +103,8 @@ module IsoDoc
|
|
104
103
|
end
|
105
104
|
|
106
105
|
def sequential_permission_names(clause, container: true)
|
107
|
-
|
108
|
-
|
106
|
+
clause.xpath(ns(first_lvl_req)).noblank
|
107
|
+
.each_with_object(ReqCounter.new) do |t, c|
|
109
108
|
m = @reqt_models.model(t["model"])
|
110
109
|
klass, label = reqt2class_label(t, m)
|
111
110
|
id = c.increment(label, t).print
|
@@ -115,9 +114,14 @@ module IsoDoc
|
|
115
114
|
end
|
116
115
|
end
|
117
116
|
|
117
|
+
def delim_wrap(delim, klass = "fmt-autonum-delim")
|
118
|
+
delim.blank? and return ""
|
119
|
+
"<span class='#{klass}'><esc>#{delim}</esc></span>"
|
120
|
+
end
|
121
|
+
|
118
122
|
def sequential_permission_children(elem, lbl, klass, container: false)
|
119
|
-
|
120
|
-
|
123
|
+
elem.xpath(ns(req_children)).noblank
|
124
|
+
.each_with_object(ReqCounter.new) do |t, c|
|
121
125
|
m = @reqt_models.model(t["model"])
|
122
126
|
klass, label = reqt2class_nested_label(t, m)
|
123
127
|
ctr = c.increment(label, t).print
|
@@ -131,7 +135,7 @@ module IsoDoc
|
|
131
135
|
def sequential_permission_body(id, parent_id, elem, label, klass, model,
|
132
136
|
container: false)
|
133
137
|
lbl = parent_id ? "#{parent_id}#{subreqt_separator}#{id}" : id
|
134
|
-
e = elem["id"]
|
138
|
+
e = elem["id"] || elem["original-id"]
|
135
139
|
@anchors[e] = model.postprocess_anchor_struct(
|
136
140
|
elem, anchor_struct(lbl, elem,
|
137
141
|
label, klass, { unnumb: elem["unnumbered"], container: })
|
@@ -142,8 +146,7 @@ container: false)
|
|
142
146
|
@anchors[e][:semx] = @anchors[elem.parent["id"]][:semx] + x
|
143
147
|
@anchors[e][:label] =
|
144
148
|
"<span class='fmt-element-name'>#{label}</span> #{@anchors[e][:semx]}"
|
145
|
-
@anchors[e][:xref] =
|
146
|
-
"<span class='fmt-element-name'>#{label}</span> #{@anchors[e][:semx]}"
|
149
|
+
@anchors[e][:xref] = @anchors[e][:label]
|
147
150
|
end
|
148
151
|
model.permission_parts(elem, id, label, klass).each do |n|
|
149
152
|
@anchors[n[:id]] = anchor_struct(n[:number], n[:elem], n[:label],
|
@@ -168,12 +171,11 @@ container: false)
|
|
168
171
|
[nil, nil]
|
169
172
|
end
|
170
173
|
|
171
|
-
# these can take a NodeSet as argument; semx will point to members
|
172
|
-
# but numbering will be consecutive
|
174
|
+
# these can take a NodeSet as argument; semx will point to members
|
175
|
+
# of the NodeSet, but numbering will be consecutive
|
173
176
|
def hierarchical_figure_names(clauses, num)
|
174
|
-
c = Counter.new
|
175
177
|
j = 0
|
176
|
-
nodeSet(clauses).
|
178
|
+
nodeSet(clauses).each_with_object(Counter.new) do |clause, c|
|
177
179
|
clause.xpath(ns(self.class::FIGURE_NO_CLASS)).noblank.each do |t|
|
178
180
|
# labelled_ancestor(t, %w(figure)) and next
|
179
181
|
j = subfigure_increment(j, c, t)
|
@@ -189,7 +191,6 @@ container: false)
|
|
189
191
|
nodeSet(clauses).each_with_object({}) do |clause, c|
|
190
192
|
clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]"))
|
191
193
|
.noblank.each do |t|
|
192
|
-
# labelled_ancestor(t, %w(figure)) and next
|
193
194
|
c[t["class"]] ||= Counter.new
|
194
195
|
j = subfigure_increment(j, c[t["class"]], t)
|
195
196
|
sublabel = subfigure_label(j)
|
@@ -200,10 +201,8 @@ container: false)
|
|
200
201
|
end
|
201
202
|
|
202
203
|
def hierarchical_table_names(clauses, num)
|
203
|
-
|
204
|
-
nodeSet(clauses).each do |clause|
|
204
|
+
nodeSet(clauses).each_with_object(Counter.new) do |clause, c|
|
205
205
|
clause.xpath(ns(".//table")).noblank.each do |t|
|
206
|
-
# labelled_ancestor(t) and next
|
207
206
|
@anchors[t["id"]] =
|
208
207
|
anchor_struct(hiersemx(clause, num, c.increment(t), t),
|
209
208
|
t, @labels["table"], "table",
|
@@ -213,8 +212,7 @@ container: false)
|
|
213
212
|
end
|
214
213
|
|
215
214
|
def hierarchical_formula_names(clauses, num)
|
216
|
-
|
217
|
-
nodeSet(clauses).each do |clause|
|
215
|
+
nodeSet(clauses).each_with_object(Counter.new) do |clause, c|
|
218
216
|
clause.xpath(ns(".//formula")).noblank.each do |t|
|
219
217
|
@anchors[t["id"]] = anchor_struct(
|
220
218
|
hiersemx(clause, num, c.increment(t), t), t,
|
@@ -227,8 +225,7 @@ container: false)
|
|
227
225
|
end
|
228
226
|
|
229
227
|
def hierarchical_permission_names(clauses, num)
|
230
|
-
|
231
|
-
nodeSet(clauses).each do |clause|
|
228
|
+
nodeSet(clauses).each_with_object(ReqCounter.new) do |clause, c|
|
232
229
|
clause.xpath(ns(first_lvl_req)).noblank.each do |t|
|
233
230
|
m = @reqt_models.model(t["model"])
|
234
231
|
klass, label = reqt2class_label(t, m)
|
@@ -1,7 +1,9 @@
|
|
1
1
|
module Enumerable
|
2
2
|
def noblank
|
3
3
|
reject do |n|
|
4
|
-
n["id"].nil? || n["id"].empty?
|
4
|
+
(n["id"].nil? || n["id"].empty?) &&
|
5
|
+
# deal with possible temporary swap of id to original-id
|
6
|
+
(n["original-id"].nil? || n["original-id"].empty?)
|
5
7
|
end
|
6
8
|
end
|
7
9
|
end
|
@@ -122,7 +124,7 @@ module IsoDoc
|
|
122
124
|
# leave alone, else wrap in semx
|
123
125
|
def semx(node, label, element = "autonum")
|
124
126
|
label = label.to_s
|
125
|
-
id = node["id"] || node[:id]
|
127
|
+
id = node["id"] || node[:id] || node["original-id"]
|
126
128
|
/<semx element='[^']+' source='#{id}'/.match?(label) and return label
|
127
129
|
l = stripsemx(label)
|
128
130
|
%(<semx element='#{element}' source='#{id}'>#{l}</semx>)
|
@@ -136,7 +138,7 @@ module IsoDoc
|
|
136
138
|
|
137
139
|
def delim_wrap(delim, klass = "fmt-autonum-delim")
|
138
140
|
delim.blank? and return ""
|
139
|
-
"<span class='#{klass}'>#{delim}</span>"
|
141
|
+
"<span class='#{klass}'><esc>#{delim}</esc></span>"
|
140
142
|
end
|
141
143
|
|
142
144
|
def stripsemx(elem)
|
@@ -153,7 +155,7 @@ module IsoDoc
|
|
153
155
|
|
154
156
|
def labelled_autonum(label, autonum)
|
155
157
|
label.blank? and return autonum
|
156
|
-
|
158
|
+
"<span class='fmt-element-name'>#{label}</span> #{autonum}"
|
157
159
|
end
|
158
160
|
|
159
161
|
def increment_label(elems, node, counter, increment: true)
|
data/lib/isodoc/xref.rb
CHANGED
@@ -78,11 +78,13 @@ module IsoDoc
|
|
78
78
|
@parse_settings = {}
|
79
79
|
end
|
80
80
|
|
81
|
-
def localise_anchors
|
81
|
+
def localise_anchors(type = nil)
|
82
82
|
@anchors.each_value do |v|
|
83
|
-
v[:
|
84
|
-
|
85
|
-
|
83
|
+
type && v[:type] != type and next
|
84
|
+
%i(label value xref xref_bare modspec).each do |t|
|
85
|
+
v[t] && !v[t].empty? or next
|
86
|
+
v[t] = @i18n.l10n(v[t])
|
87
|
+
end
|
86
88
|
end
|
87
89
|
end
|
88
90
|
|
@@ -39,9 +39,9 @@ internal_external_terms_boilerplate: |
|
|
39
39
|
no_information_available: "[情報はありません]"
|
40
40
|
term_defined_in: "(%)"
|
41
41
|
binary_and: "%1 <conn>及び</conn> %2"
|
42
|
-
multiple_and: "%1<enum-comma
|
42
|
+
multiple_and: "%1<enum-comma>#{ self.punct['enum-comma'] }</enum-comma>%2"
|
43
43
|
binary_or: "%1 <conn>または</conn> %2"
|
44
|
-
multiple_or: "%1<enum-comma
|
44
|
+
multiple_or: "%1<enum-comma>#{ self.punct['enum-comma'] }</enum-comma> <conn>または</conn> %2"
|
45
45
|
chain_and: "%1 <conn>及び</conn> %2"
|
46
46
|
chain_or: "%1 <conn>または</conn> %2"
|
47
47
|
chain_from: "%1 <conn>から</conn> %2"
|
@@ -224,3 +224,26 @@ doctype_dict:
|
|
224
224
|
amendment: 追補
|
225
225
|
technical-corrigendum: Technical Corrigendum
|
226
226
|
directive: Directive
|
227
|
+
punct:
|
228
|
+
colon: ":"
|
229
|
+
comma: "、"
|
230
|
+
enum-comma: "、"
|
231
|
+
semicolon: ";"
|
232
|
+
period: "。"
|
233
|
+
close-paren: ")"
|
234
|
+
open-paren: "("
|
235
|
+
close-bracket: "]"
|
236
|
+
open-bracket: "["
|
237
|
+
question-mark: "?"
|
238
|
+
exclamation-mark: "!"
|
239
|
+
emphasis-mark: •
|
240
|
+
em-dash: ⸺
|
241
|
+
en-dash: "〜"
|
242
|
+
number-en-dash: "〜"
|
243
|
+
open-quote: "「"
|
244
|
+
close-quote: "」"
|
245
|
+
open-nested-quote: "『"
|
246
|
+
close-nested-quote: "』"
|
247
|
+
ellipse: ⋯⋯
|
248
|
+
cjk-latin-separator: " "
|
249
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
punct:
|
2
|
+
colon: ":"
|
3
|
+
comma: ","
|
4
|
+
enum-comma: ","
|
5
|
+
semicolon: ";"
|
6
|
+
period: "."
|
7
|
+
close-paren: ")"
|
8
|
+
open-paren: "("
|
9
|
+
close-bracket: "]"
|
10
|
+
open-bracket: "["
|
11
|
+
question-mark: "?"
|
12
|
+
exclamation-mark: "!"
|
13
|
+
emphasis-mark: •
|
14
|
+
em-dash: ⸺
|
15
|
+
en-dash: "–"
|
16
|
+
number-en-dash: "〜"
|
17
|
+
open-quote: "“"
|
18
|
+
close-quote: "”"
|
19
|
+
open-nested-quote: "’"
|
20
|
+
close-nested-quote: "’"
|
21
|
+
ellipse: ⋯⋯
|
22
|
+
|
@@ -41,9 +41,9 @@ internal_external_terms_boilerplate: |
|
|
41
41
|
no_information_available: "[无资料]"
|
42
42
|
term_defined_in: "(%)"
|
43
43
|
binary_and: "%1<conn>和</conn>%2"
|
44
|
-
multiple_and: "%1<enum-comma
|
44
|
+
multiple_and: "%1<enum-comma>#{ self.punct['enum-comma'] }</enum-comma><conn>和</conn>%2"
|
45
45
|
binary_or: "%1<conn>或</conn>%2"
|
46
|
-
multiple_or: "%1<enum-comma
|
46
|
+
multiple_or: "%1<enum-comma>#{ self.punct['enum-comma'] }</enum-comma><conn>或</conn>%2"
|
47
47
|
chain_and: "%1<conn>和</conn>%2"
|
48
48
|
chain_or: "%1<conn>或</conn>%2"
|
49
49
|
chain_from: "%1<conn>从</conn>%2"
|
@@ -147,4 +147,26 @@ relatedterms:
|
|
147
147
|
contrast: 对比
|
148
148
|
see: 见
|
149
149
|
seealso: 参见
|
150
|
+
punct:
|
151
|
+
colon: ":"
|
152
|
+
comma: ","
|
153
|
+
enum-comma: "、"
|
154
|
+
semicolon: ";"
|
155
|
+
period: "。"
|
156
|
+
close-paren: ")"
|
157
|
+
open-paren: "("
|
158
|
+
close-bracket: "]"
|
159
|
+
open-bracket: "["
|
160
|
+
question-mark: "?"
|
161
|
+
exclamation-mark: "!"
|
162
|
+
emphasis-mark: •
|
163
|
+
em-dash: ⸺
|
164
|
+
en-dash: "–"
|
165
|
+
number-en-dash: "〜"
|
166
|
+
open-quote: "“"
|
167
|
+
close-quote: "”"
|
168
|
+
open-nested-quote: "’"
|
169
|
+
close-nested-quote: "’"
|
170
|
+
ellipse: ⋯⋯
|
171
|
+
cjk-latin-separator: ""
|
150
172
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
punct:
|
2
|
+
colon: ":"
|
3
|
+
comma: ","
|
4
|
+
enum-comma: "、"
|
5
|
+
semicolon: ";"
|
6
|
+
period: "。"
|
7
|
+
close-paren: ")"
|
8
|
+
open-paren: "("
|
9
|
+
close-bracket: "]"
|
10
|
+
open-bracket: "["
|
11
|
+
question-mark: "?"
|
12
|
+
exclamation-mark: "!"
|
13
|
+
emphasis-mark: •
|
14
|
+
em-dash: ⸺
|
15
|
+
en-dash: "–"
|
16
|
+
number-en-dash: "〜"
|
17
|
+
open-quote: "「"
|
18
|
+
close-quote: "」"
|
19
|
+
open-nested-quote: "『"
|
20
|
+
close-nested-quote: "』"
|
21
|
+
ellipse: ⋯⋯
|
22
|
+
|
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: 3.3.
|
4
|
+
version: 3.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|
@@ -372,8 +372,10 @@ files:
|
|
372
372
|
- lib/isodoc-yaml/i18n-es.yaml
|
373
373
|
- lib/isodoc-yaml/i18n-fr.yaml
|
374
374
|
- lib/isodoc-yaml/i18n-ja.yaml
|
375
|
+
- lib/isodoc-yaml/i18n-ko.yaml
|
375
376
|
- lib/isodoc-yaml/i18n-ru.yaml
|
376
377
|
- lib/isodoc-yaml/i18n-zh-Hans.yaml
|
378
|
+
- lib/isodoc-yaml/i18n-zh-Hant.yaml
|
377
379
|
- lib/isodoc.rb
|
378
380
|
- lib/isodoc/base_style/all.css
|
379
381
|
- lib/isodoc/base_style/all.scss
|
@@ -443,6 +445,7 @@ files:
|
|
443
445
|
- lib/isodoc/presentation_function/designations.rb
|
444
446
|
- lib/isodoc/presentation_function/docid.rb
|
445
447
|
- lib/isodoc/presentation_function/erefs.rb
|
448
|
+
- lib/isodoc/presentation_function/erefs_locality.rb
|
446
449
|
- lib/isodoc/presentation_function/footnotes.rb
|
447
450
|
- lib/isodoc/presentation_function/ids.rb
|
448
451
|
- lib/isodoc/presentation_function/image.rb
|