isodoc 3.2.7 → 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/isodoc.gemspec +1 -1
- data/lib/isodoc/convert.rb +3 -2
- data/lib/isodoc/function/terms.rb +6 -0
- data/lib/isodoc/function/to_word_html.rb +1 -0
- data/lib/isodoc/init.rb +5 -4
- data/lib/isodoc/metadata.rb +4 -3
- 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 +20 -7
- data/lib/isodoc/presentation_function/concepts.rb +0 -148
- data/lib/isodoc/presentation_function/designations.rb +158 -0
- data/lib/isodoc/presentation_function/docid.rb +5 -3
- data/lib/isodoc/presentation_function/erefs.rb +17 -113
- 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/refs.rb +2 -1
- data/lib/isodoc/presentation_function/reqt.rb +1 -1
- data/lib/isodoc/presentation_function/terms.rb +19 -8
- data/lib/isodoc/presentation_function/xrefs.rb +10 -6
- data/lib/isodoc/presentation_xml_convert.rb +1 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/xref/xref_anchor.rb +1 -2
- data/lib/isodoc/xref/xref_gen.rb +0 -1
- data/lib/isodoc/xref/xref_gen_seq.rb +27 -30
- data/lib/isodoc/xref/xref_util.rb +6 -4
- data/lib/isodoc/xref.rb +9 -6
- data/lib/isodoc-yaml/i18n-ja.yaml +25 -3
- 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 +8 -4
|
@@ -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
|
|
@@ -15,6 +16,7 @@ module IsoDoc
|
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
def citeas_cleanup(ref)
|
|
19
|
+
ref.nil? and return nil
|
|
18
20
|
if ref.include?("<")
|
|
19
21
|
xml = Nokogiri::XML("<root>#{ref}</root>")
|
|
20
22
|
xml.xpath("//semx").each { |x| x.replace(x.children) }
|
|
@@ -33,39 +35,11 @@ module IsoDoc
|
|
|
33
35
|
[e["connective"], to_xml(e.parent.remove)]
|
|
34
36
|
end.flatten
|
|
35
37
|
ret = resolve_eref_connectives(locs)
|
|
36
|
-
elem.next = "<semx element='erefstack' source='#{elem['id']}'>#{ret[1]}</semx>"
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def eref_localities(refs, target, node)
|
|
40
|
-
if can_conflate_eref_rendering?(refs)
|
|
41
|
-
l10n(", #{eref_localities_conflated(refs, target, node)}"
|
|
42
|
-
.gsub(/\s+/, " "))
|
|
43
|
-
else
|
|
44
|
-
ret = resolve_eref_connectives(eref_locality_stacks(refs, target, node))
|
|
45
|
-
l10n(ret.join.gsub(/\s+/, " "))
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def eref_localities_conflated(refs, target, node)
|
|
50
|
-
droploc = node["droploc"]
|
|
51
|
-
node["droploc"] = true
|
|
52
|
-
ret = resolve_eref_connectives(eref_locality_stacks(refs, target,
|
|
53
|
-
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)]"))
|
|
@@ -216,7 +120,7 @@ module IsoDoc
|
|
|
216
120
|
def eref2link1(node, href)
|
|
217
121
|
url = href[:link]
|
|
218
122
|
att = href[:type] == :attachment ? "attachment='true'" : ""
|
|
219
|
-
repl = "<fmt-link #{att} target='#{url}'>#{node.children}</link>"
|
|
123
|
+
repl = "<fmt-link #{att} target='#{url}'>#{to_xml(node.children)}</link>"
|
|
220
124
|
node["type"] == "footnote" and repl = "<sup>#{repl}</sup>"
|
|
221
125
|
node.replace(repl)
|
|
222
126
|
end
|
|
@@ -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
|
|
@@ -184,6 +184,7 @@ module IsoDoc
|
|
|
184
184
|
ret += datefn
|
|
185
185
|
ret.empty? and return ret
|
|
186
186
|
idents[:sdo] and ret += ","
|
|
187
|
+
ret.sub(",", "").strip.empty? and return ""
|
|
187
188
|
"#{ret} "
|
|
188
189
|
end
|
|
189
190
|
|
|
@@ -192,7 +193,7 @@ module IsoDoc
|
|
|
192
193
|
def biblio_ref_entry_code(ordinal, ids, _id, _standard, datefn, _bib)
|
|
193
194
|
# standard and id = nil
|
|
194
195
|
ret = ids[:ordinal] || ids[:metanorma] || "[#{ordinal}]"
|
|
195
|
-
if ids[:sdo]
|
|
196
|
+
if ids[:sdo] && !ids[:sdo].empty?
|
|
196
197
|
ret = prefix_bracketed_ref(ret)
|
|
197
198
|
ret += "#{ids[:sdo]}#{datefn}, "
|
|
198
199
|
else
|
|
@@ -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
|
|
@@ -37,13 +37,14 @@ module IsoDoc
|
|
|
37
37
|
docxml.xpath(ns("//termnote")).each { |f| termnote1(f) }
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
def termnote_delim(_elem)
|
|
41
|
-
l10n(": ")
|
|
40
|
+
def termnote_delim(_elem, lbl)
|
|
41
|
+
l10n(": ", { prev: lbl })
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def termnote1(elem)
|
|
45
45
|
lbl = termnote_label(elem)
|
|
46
|
-
prefix_name(elem, { label: termnote_delim(elem
|
|
46
|
+
prefix_name(elem, { label: termnote_delim(elem, lbl) },
|
|
47
|
+
lower2cap(lbl), "name")
|
|
47
48
|
end
|
|
48
49
|
|
|
49
50
|
def termnote_label(elem)
|
|
@@ -147,23 +148,33 @@ module IsoDoc
|
|
|
147
148
|
m1.replace("<modification>#{to_xml(new_m1)}</modification>")
|
|
148
149
|
end
|
|
149
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
|
|
150
155
|
def termsource1(elem)
|
|
151
156
|
ret = [semx_fmt_dup(elem)]
|
|
152
|
-
while elem
|
|
157
|
+
while elem.next_element&.name == "source"
|
|
153
158
|
ret << semx_fmt_dup(elem.next_element.remove)
|
|
154
159
|
end
|
|
155
|
-
s = ret.map { |x| to_xml(x) }.map(&:strip).
|
|
156
|
-
|
|
160
|
+
s = ret.map { |x| to_xml(x) }.map(&:strip).map { |x| "<esc>#{x}</esc>" }
|
|
161
|
+
.join(termsource_join_delim(elem))
|
|
162
|
+
termsource_label(elem, "<esc>#{@i18n.l10n s}</esc>")
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def termsource_join_delim(_elem)
|
|
166
|
+
"; "
|
|
157
167
|
end
|
|
158
168
|
|
|
159
169
|
def termsource_label(elem, sources)
|
|
160
|
-
elem.replace(l10n("[#{@i18n.source}:
|
|
170
|
+
elem.replace(l10n("[#{@i18n.source}: <esc>#{sources}</esc>]"))
|
|
161
171
|
end
|
|
162
172
|
|
|
163
173
|
def termsource_modification(elem)
|
|
164
174
|
elem.xpath(".//text()[normalize-space() = '']").each(&:remove)
|
|
165
175
|
origin = elem.at(ns("./origin"))
|
|
166
|
-
s = termsource_status(elem["status"]) and
|
|
176
|
+
s = termsource_status(elem["status"]) and
|
|
177
|
+
origin.next = l10n(", #{s}", @lang, @script, { prev: origin.text })
|
|
167
178
|
mod = elem.at(ns("./modification")) or return
|
|
168
179
|
termsource_add_modification_text(mod)
|
|
169
180
|
end
|
|
@@ -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
|
|
@@ -2,6 +2,7 @@ require_relative "presentation_function/block"
|
|
|
2
2
|
require_relative "presentation_function/list"
|
|
3
3
|
require_relative "presentation_function/reqt"
|
|
4
4
|
require_relative "presentation_function/concepts"
|
|
5
|
+
require_relative "presentation_function/designations"
|
|
5
6
|
require_relative "presentation_function/terms"
|
|
6
7
|
require_relative "presentation_function/xrefs"
|
|
7
8
|
require_relative "presentation_function/erefs"
|
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)
|
data/lib/isodoc/xref/xref_gen.rb
CHANGED
|
@@ -147,7 +147,6 @@ refer_list)
|
|
|
147
147
|
list_item_value(li, c, depth,
|
|
148
148
|
{ list_anchor:, prev_label:,
|
|
149
149
|
refer_list: depth == 1 ? refer_list : nil })
|
|
150
|
-
#li["id"] ||= "_#{UUIDTools::UUID.random_create}"
|
|
151
150
|
@anchors[li["id"]] =
|
|
152
151
|
{ label: bare_label, bare_xref: "#{label})", type: "listitem",
|
|
153
152
|
xref: %[#{label}#{delim_wrap(list_item_delim)}], refer_list:,
|
|
@@ -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)
|