isodoc 3.1.6 → 3.1.9
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/css_border_parser.rb +229 -0
- data/lib/isodoc/css_border_parser_vars.rb +211 -0
- data/lib/isodoc/function/blocks.rb +1 -1
- data/lib/isodoc/function/blocks_example_note.rb +0 -2
- data/lib/isodoc/function/footnotes.rb +4 -3
- data/lib/isodoc/function/inline.rb +1 -0
- data/lib/isodoc/function/lists.rb +0 -15
- data/lib/isodoc/function/section.rb +6 -2
- data/lib/isodoc/function/section_titles.rb +2 -2
- data/lib/isodoc/function/table.rb +1 -1
- data/lib/isodoc/function/terms.rb +1 -1
- data/lib/isodoc/function/to_word_html.rb +4 -1
- data/lib/isodoc/function/utils.rb +6 -15
- data/lib/isodoc/html_function/postprocess.rb +1 -2
- data/lib/isodoc/html_function/postprocess_cover.rb +14 -5
- data/lib/isodoc/init.rb +12 -3
- data/lib/isodoc/presentation_function/autonum.rb +4 -3
- data/lib/isodoc/presentation_function/block.rb +50 -10
- data/lib/isodoc/presentation_function/concepts.rb +19 -13
- data/lib/isodoc/presentation_function/docid.rb +2 -1
- data/lib/isodoc/presentation_function/erefs.rb +1 -2
- data/lib/isodoc/presentation_function/footnotes.rb +4 -4
- data/lib/isodoc/presentation_function/ids.rb +79 -0
- data/lib/isodoc/presentation_function/image.rb +1 -2
- data/lib/isodoc/presentation_function/inline.rb +13 -7
- data/lib/isodoc/presentation_function/math.rb +19 -23
- data/lib/isodoc/presentation_function/refs.rb +1 -1
- data/lib/isodoc/presentation_function/section.rb +11 -10
- data/lib/isodoc/presentation_function/terms.rb +50 -21
- data/lib/isodoc/presentation_function/title.rb +1 -3
- data/lib/isodoc/presentation_function/xrefs.rb +2 -2
- data/lib/isodoc/presentation_xml_convert.rb +3 -75
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/comments.rb +1 -2
- data/lib/isodoc/word_function/footnotes.rb +0 -29
- data/lib/isodoc/word_function/inline.rb +1 -1
- data/lib/isodoc/word_function/postprocess.rb +0 -1
- data/lib/isodoc/xref/xref_gen_seq.rb +5 -30
- data/lib/isodoc/xref/xref_sect_asset.rb +44 -0
- data/lib/isodoc/xref/xref_sect_gen.rb +39 -37
- data/lib/isodoc/xref/xref_util.rb +28 -1
- 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
- data/lib/isodoc.rb +1 -1
- metadata +6 -2
@@ -1,23 +1,29 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
3
|
+
DESIGNATION_ELEMS =
|
4
|
+
%w(preferred admitted deprecates related definition source).freeze
|
5
|
+
|
6
|
+
def target_desgn_elem(name)
|
7
|
+
target = "fmt-#{name}"
|
8
|
+
name == "source" and target = "fmt-termsource"
|
9
|
+
target
|
10
|
+
end
|
11
|
+
|
3
12
|
def termcontainers(docxml)
|
4
13
|
docxml.xpath(ns("//term")).each do |t|
|
5
|
-
|
6
|
-
|
7
|
-
d = t.at(ns("./#{w}[last()]")) and d.after("
|
14
|
+
DESIGNATION_ELEMS.each do |w|
|
15
|
+
target = target_desgn_elem(w)
|
16
|
+
d = t.at(ns("./#{w}[last()]")) and d.after("<#{target}/>")
|
8
17
|
end
|
9
18
|
end
|
10
|
-
docxml.xpath(ns("//termsource")).each do |s|
|
11
|
-
s["id"] ||= "_#{UUIDTools::UUID.random_create}"
|
12
|
-
end
|
13
19
|
end
|
14
20
|
|
15
21
|
def termcleanup(docxml)
|
16
22
|
docxml.xpath(ns("//term")).each do |t|
|
17
|
-
|
18
|
-
|
23
|
+
DESIGNATION_ELEMS.each do |w|
|
24
|
+
target = target_desgn_elem(w)
|
19
25
|
t.xpath(ns("./#{w}//fmt-name | ./#{w}//fmt-xref-label")).each(&:remove)
|
20
|
-
f = t.at(ns("
|
26
|
+
f = t.at(ns(".//#{target}"))
|
21
27
|
f&.children&.empty? and f.remove
|
22
28
|
end
|
23
29
|
end
|
@@ -55,6 +61,11 @@ module IsoDoc
|
|
55
61
|
else singledef(elem, d, d1)
|
56
62
|
end
|
57
63
|
unwrap_definition(elem, d1)
|
64
|
+
s1 = d.xpath(ns(".//source"))
|
65
|
+
s2 = d1.xpath(ns(".//source"))
|
66
|
+
s1.each_with_index do |s, i|
|
67
|
+
modification_dup_align(s, s2[i])
|
68
|
+
end
|
58
69
|
termdomain(elem, d1)
|
59
70
|
end
|
60
71
|
|
@@ -88,7 +99,8 @@ module IsoDoc
|
|
88
99
|
def termsource(docxml)
|
89
100
|
copy_baselevel_termsource(docxml)
|
90
101
|
# TODO should I wrap fmt-definition//termsource in fmt-termsource, in order to preserve termsource attributes?
|
91
|
-
|
102
|
+
# differentiating term and nonterm source under designations is not worth it
|
103
|
+
docxml.xpath(ns("//fmt-termsource/source | //fmt-definition//source | //fmt-preferred//source | //fmt-admitted//source | //fmt-deprecates//source"))
|
92
104
|
.each do |f|
|
93
105
|
termsource_modification(f)
|
94
106
|
end
|
@@ -96,7 +108,7 @@ module IsoDoc
|
|
96
108
|
.each do |f|
|
97
109
|
termsource_designation(f)
|
98
110
|
end
|
99
|
-
docxml.xpath(ns("//fmt-termsource/
|
111
|
+
docxml.xpath(ns("//fmt-termsource/source | //fmt-definition//source | //fmt-preferred//source | //fmt-admitted//source | //fmt-deprecates//source"))
|
100
112
|
.each do |f|
|
101
113
|
f.parent and termsource1(f)
|
102
114
|
end
|
@@ -104,24 +116,39 @@ module IsoDoc
|
|
104
116
|
|
105
117
|
def termsource_designation(fmtsource)
|
106
118
|
p = fmtsource.previous_element
|
107
|
-
|
108
|
-
|
109
|
-
|
119
|
+
p&.name == "p" or return
|
120
|
+
p << " "
|
121
|
+
p << fmtsource.children
|
110
122
|
end
|
111
123
|
|
112
124
|
def copy_baselevel_termsource(docxml)
|
113
|
-
docxml.xpath(ns("//term[
|
114
|
-
s = x.xpath(ns("./
|
125
|
+
docxml.xpath(ns("//term[source]")).each do |x|
|
126
|
+
s = x.xpath(ns("./source"))
|
115
127
|
s1 = x.at(ns("./fmt-termsource"))
|
116
|
-
s.each
|
128
|
+
s.each do |ss|
|
129
|
+
dup = ss.clone
|
130
|
+
modification_dup_align(ss, dup)
|
131
|
+
s1 << dup
|
132
|
+
end
|
117
133
|
strip_duplicate_ids(nil, s, s1)
|
118
134
|
%w(status type).each { |a| s[0][a] and s1[a] = s[0][a] }
|
119
135
|
end
|
120
136
|
end
|
121
137
|
|
138
|
+
def modification_dup_align(sem, pres)
|
139
|
+
m = sem&.at(ns("./modification")) or return
|
140
|
+
m1 = pres.at(ns("./modification"))
|
141
|
+
if m["original-id"]
|
142
|
+
m["id"] = m["original-id"]
|
143
|
+
m.delete("original-id")
|
144
|
+
end
|
145
|
+
new_m1 = semx_fmt_dup(m)
|
146
|
+
m1.replace("<modification>#{to_xml(new_m1)}</modification>")
|
147
|
+
end
|
148
|
+
|
122
149
|
def termsource1(elem)
|
123
150
|
ret = [semx_fmt_dup(elem)]
|
124
|
-
while elem&.next_element&.name == "
|
151
|
+
while elem&.next_element&.name == "source"
|
125
152
|
ret << semx_fmt_dup(elem.next_element.remove)
|
126
153
|
end
|
127
154
|
s = ret.map { |x| to_xml(x) }.map(&:strip).join("; ")
|
@@ -136,7 +163,8 @@ module IsoDoc
|
|
136
163
|
elem.xpath(".//text()[normalize-space() = '']").each(&:remove)
|
137
164
|
origin = elem.at(ns("./origin"))
|
138
165
|
s = termsource_status(elem["status"]) and origin.next = l10n(", #{s}")
|
139
|
-
|
166
|
+
mod = elem.at(ns("./modification")) or return
|
167
|
+
termsource_add_modification_text(mod)
|
140
168
|
end
|
141
169
|
|
142
170
|
def termsource_add_modification_text(mod)
|
@@ -146,8 +174,9 @@ module IsoDoc
|
|
146
174
|
return
|
147
175
|
end
|
148
176
|
mod.previous = " — "
|
149
|
-
|
150
|
-
|
177
|
+
c = mod.at(ns("./semx")) || mod
|
178
|
+
c.elements.size == 1 and c.children = to_xml(c.elements[0].children)
|
179
|
+
mod.replace(mod.children)
|
151
180
|
end
|
152
181
|
|
153
182
|
def termsource_status(status)
|
@@ -25,7 +25,6 @@ module IsoDoc
|
|
25
25
|
|
26
26
|
# TODO not currently doing anything with the @depth attribute of floating-title
|
27
27
|
def floattitle1(elem)
|
28
|
-
elem["id"] ||= "_#{UUIDTools::UUID.random_create}"
|
29
28
|
p = elem.dup
|
30
29
|
p.children = "<semx element='floating-title' source='#{elem['id']}'>" \
|
31
30
|
"#{to_xml(p.children)}</semx>"
|
@@ -41,9 +40,8 @@ module IsoDoc
|
|
41
40
|
%w(note admonition p floating-title).include?(p.name) or break m
|
42
41
|
m << p
|
43
42
|
end
|
44
|
-
#require 'debug'; out.empty? or binding.b
|
45
43
|
out.reject { |c| c["displayorder"] }.reverse_each do |c|
|
46
|
-
|
44
|
+
skip_display_order?(c) and next
|
47
45
|
c["displayorder"] = idx
|
48
46
|
idx += 1
|
49
47
|
end
|
@@ -26,8 +26,8 @@ module IsoDoc
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def anchor_value(id)
|
29
|
-
@xrefs.anchor(id, :bare_xref) || @xrefs.anchor(id, :
|
30
|
-
@xrefs.anchor(id, :
|
29
|
+
@xrefs.anchor(id, :bare_xref) || @xrefs.anchor(id, :value) ||
|
30
|
+
@xrefs.anchor(id, :label) || @xrefs.anchor(id, :xref)
|
31
31
|
end
|
32
32
|
|
33
33
|
def anchor_linkend(node, linkend)
|
@@ -12,6 +12,7 @@ require_relative "presentation_function/index"
|
|
12
12
|
require_relative "presentation_function/bibdata"
|
13
13
|
require_relative "presentation_function/metadata"
|
14
14
|
require_relative "presentation_function/footnotes"
|
15
|
+
require_relative "presentation_function/ids"
|
15
16
|
|
16
17
|
module IsoDoc
|
17
18
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
@@ -25,8 +26,7 @@ module IsoDoc
|
|
25
26
|
presxml_convert_init(docxml, filename, dir)
|
26
27
|
conversions(docxml)
|
27
28
|
docxml.root["type"] = "presentation"
|
28
|
-
|
29
|
-
idref_validate(docxml.root)
|
29
|
+
id_validate(docxml.root)
|
30
30
|
docxml.to_xml.gsub("<", "<").gsub(">", ">")
|
31
31
|
end
|
32
32
|
|
@@ -38,56 +38,13 @@ module IsoDoc
|
|
38
38
|
@outputdir = dir
|
39
39
|
@outputfile = Pathname.new(filename).basename.to_s
|
40
40
|
docid_prefixes(docxml) # feeds @xrefs.parse citation processing
|
41
|
+
provide_ids docxml # feeds @xrefs.parse
|
41
42
|
@xrefs.parse docxml
|
42
43
|
@xrefs.klass.meta = @meta
|
43
44
|
@xrefs.klass.info docxml, nil
|
44
45
|
counter_init
|
45
46
|
end
|
46
47
|
|
47
|
-
def repeat_id_validate1(elem)
|
48
|
-
if @doc_ids[elem["id"]]
|
49
|
-
@log.add("Anchors", elem,
|
50
|
-
"Anchor #{elem['id']} has already been " \
|
51
|
-
"used at line #{@doc_ids[elem['id']]}", severity: 0)
|
52
|
-
end
|
53
|
-
@doc_ids[elem["id"]] = elem.line
|
54
|
-
end
|
55
|
-
|
56
|
-
def repeat_id_validate(doc)
|
57
|
-
@log or return
|
58
|
-
@doc_ids = {}
|
59
|
-
doc.xpath("//*[@id]").each do |x|
|
60
|
-
repeat_id_validate1(x)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
IDREF =
|
65
|
-
[%w(review from), %w(review to), %w(index to), %w(xref target),
|
66
|
-
%w(callout target), %w(eref bibitemid), %w(citation bibitemid),
|
67
|
-
%w(admonition target), %w(label for), %w(semx source),
|
68
|
-
%w(fmt-title source), %w(fmt-xref-label container), %w(fn target),
|
69
|
-
%w(fmt-fn-body target), %w(fmt-review-start source),
|
70
|
-
%w(fmt-review-start end), %w(fmt-review-start target),
|
71
|
-
%w(fmt-review-end source), %w(fmt-review-end start),
|
72
|
-
%w(fmt-review-end target)].freeze
|
73
|
-
|
74
|
-
def idref_validate(doc)
|
75
|
-
@log or return
|
76
|
-
IDREF.each do |e|
|
77
|
-
doc.xpath("//xmlns:#{e[0]}[@#{e[1]}]").each do |x|
|
78
|
-
idref_validate1(x, e[1])
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def idref_validate1(node, attr)
|
84
|
-
node[attr].strip.empty? and return
|
85
|
-
@doc_ids[node[attr]] and return
|
86
|
-
@log.add("Anchors", node,
|
87
|
-
"Anchor #{node[attr]} pointed to by #{node.name} " \
|
88
|
-
"is not defined in the document", severity: 1)
|
89
|
-
end
|
90
|
-
|
91
48
|
def bibitem_lookup(docxml)
|
92
49
|
@bibitem_lookup ||= docxml.xpath(ns("//references/bibitem"))
|
93
50
|
.each_with_object({}) do |b, m|
|
@@ -185,35 +142,6 @@ module IsoDoc
|
|
185
142
|
.previous_element
|
186
143
|
end
|
187
144
|
|
188
|
-
def embedable_semantic_xml(xml)
|
189
|
-
xml = embedable_semantic_xml_tags(xml)
|
190
|
-
embedable_semantic_xml_attributes(xml)
|
191
|
-
end
|
192
|
-
|
193
|
-
def embedable_semantic_xml_tags(xml)
|
194
|
-
ret = to_xml(xml)
|
195
|
-
.sub(/ xmlns=['"][^"']+['"]/, "") # root XMLNS
|
196
|
-
.split(/(?=[<> \t\r\n\f\v])/).map do |x|
|
197
|
-
case x
|
198
|
-
when /^<[^:]+:/ then x.sub(":", ":semantic__")
|
199
|
-
when /^<[^:]+$/ then x.sub(%r{(</?)([[:alpha:]])},
|
200
|
-
"\\1semantic__\\2")
|
201
|
-
else x end
|
202
|
-
end
|
203
|
-
Nokogiri::XML(ret.join).root
|
204
|
-
end
|
205
|
-
|
206
|
-
def embedable_semantic_xml_attributes(xml)
|
207
|
-
Metanorma::Utils::anchor_attributes.each do |(tag_name, attr_name)|
|
208
|
-
tag_name == "*" or tag_name = "semantic__#{tag_name}"
|
209
|
-
xml.xpath("//#{tag_name}[@#{attr_name}]").each do |elem|
|
210
|
-
elem.attributes[attr_name].value =
|
211
|
-
"semantic__#{elem.attributes[attr_name].value}"
|
212
|
-
end
|
213
|
-
end
|
214
|
-
xml
|
215
|
-
end
|
216
|
-
|
217
145
|
def postprocess(result, filename, _dir)
|
218
146
|
to_xml_file(result, filename)
|
219
147
|
@files_to_delete.each { |f| FileUtils.rm_rf f }
|
data/lib/isodoc/version.rb
CHANGED
@@ -29,7 +29,7 @@ module IsoDoc
|
|
29
29
|
s2.a style: "mso-comment-reference:SMC_#{fnote};" \
|
30
30
|
"mso-comment-date:#{node['date'].gsub(/[:-]+/,
|
31
31
|
'')}"
|
32
|
-
s2.span style: "mso-special-character:comment", target: fnote
|
32
|
+
s2.span style: "mso-special-character:comment", target: fnote
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -126,7 +126,6 @@ module IsoDoc
|
|
126
126
|
end
|
127
127
|
|
128
128
|
def insert_comment_cont(from, upto, target)
|
129
|
-
# includes_to = from.at(".//*[@id='#{upto}']")
|
130
129
|
while !from.nil? && from["id"] != upto
|
131
130
|
following = from.xpath("./following::*")
|
132
131
|
(from = following.shift) && incl_to = from.at(".//*[@id='#{upto}']")
|
@@ -10,14 +10,6 @@ module IsoDoc
|
|
10
10
|
sprintf "%09d", ret
|
11
11
|
end
|
12
12
|
|
13
|
-
def make_table_footnote_link(out, fnid, node)
|
14
|
-
attrs = { href: "##{fnid}", class: "TableFootnoteRef" }
|
15
|
-
sup = node.at(ns("./sup")) and sup.replace(sup.children)
|
16
|
-
out.a **attrs do |a|
|
17
|
-
children_parse(node, a)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
13
|
def fmt_fn_body_parse(node, out)
|
22
14
|
node.at(ns(".//fmt-fn-label"))&.remove
|
23
15
|
aside = node.parent.name == "fmt-footnote-container"
|
@@ -28,27 +20,6 @@ module IsoDoc
|
|
28
20
|
end
|
29
21
|
end
|
30
22
|
|
31
|
-
# dupe to HTML
|
32
|
-
def get_table_ancestor_id(node)
|
33
|
-
table = node.ancestors("table")
|
34
|
-
table.empty? and table = node.ancestors("figure")
|
35
|
-
table.empty? and return [nil,
|
36
|
-
UUIDTools::UUID.random_create.to_s]
|
37
|
-
[table.last, table.last["id"]]
|
38
|
-
end
|
39
|
-
|
40
|
-
# dupe to HTML
|
41
|
-
def table_footnote_parse(node, out)
|
42
|
-
fn = node["reference"] || UUIDTools::UUID.random_create.to_s
|
43
|
-
table, tid = get_table_ancestor_id(node)
|
44
|
-
make_table_footnote_link(out, tid + fn, node.at(ns("./fmt-fn-label")))
|
45
|
-
# do not output footnote text if we have already seen it for this table
|
46
|
-
return if @seen_footnote.include?(tid + fn)
|
47
|
-
|
48
|
-
update_table_fn_body_ref(node, table, tid + fn)
|
49
|
-
@seen_footnote << (tid + fn)
|
50
|
-
end
|
51
|
-
|
52
23
|
def seen_footnote_parse(node, out, footnote)
|
53
24
|
f = node.at(ns("./fmt-fn-label"))
|
54
25
|
sup = f.at(ns(".//sup")) and sup.replace(sup.children)
|
@@ -100,22 +100,13 @@ module IsoDoc
|
|
100
100
|
t["inequality"] ? @labels["inequality"] : @labels["formula"],
|
101
101
|
"formula", { unnumb: t["unnumbered"], container: true }
|
102
102
|
)
|
103
|
+
@anchors[t["id"]][:bare_xref] = @anchors[t["id"]][:label]
|
103
104
|
end
|
104
105
|
end
|
105
106
|
|
106
|
-
FIRST_LVL_REQ_RULE = <<~XPATH.freeze
|
107
|
-
[not(ancestor::permission or ancestor::requirement or ancestor::recommendation)]
|
108
|
-
XPATH
|
109
|
-
FIRST_LVL_REQ = <<~XPATH.freeze
|
110
|
-
.//permission#{FIRST_LVL_REQ_RULE} | .//requirement#{FIRST_LVL_REQ_RULE} | .//recommendation#{FIRST_LVL_REQ_RULE}
|
111
|
-
XPATH
|
112
|
-
REQ_CHILDREN = <<~XPATH.freeze
|
113
|
-
./permission | ./requirement | ./recommendation
|
114
|
-
XPATH
|
115
|
-
|
116
107
|
def sequential_permission_names(clause, container: true)
|
117
108
|
c = ReqCounter.new
|
118
|
-
clause.xpath(ns(
|
109
|
+
clause.xpath(ns(first_lvl_req)).noblank.each do |t|
|
119
110
|
m = @reqt_models.model(t["model"])
|
120
111
|
klass, label = reqt2class_label(t, m)
|
121
112
|
id = c.increment(label, t).print
|
@@ -127,7 +118,7 @@ module IsoDoc
|
|
127
118
|
|
128
119
|
def sequential_permission_children(elem, lbl, klass, container: false)
|
129
120
|
c = ReqCounter.new
|
130
|
-
elem.xpath(ns(
|
121
|
+
elem.xpath(ns(req_children)).noblank.each do |t|
|
131
122
|
m = @reqt_models.model(t["model"])
|
132
123
|
klass, label = reqt2class_nested_label(t, m)
|
133
124
|
ctr = c.increment(label, t).print
|
@@ -177,14 +168,6 @@ container: false)
|
|
177
168
|
[nil, nil]
|
178
169
|
end
|
179
170
|
|
180
|
-
# container makes numbering be prefixed with the parent clause reference
|
181
|
-
def sequential_asset_names(clause, container: false)
|
182
|
-
sequential_table_names(clause, container:)
|
183
|
-
sequential_figure_names(clause, container:)
|
184
|
-
sequential_formula_names(clause, container:)
|
185
|
-
sequential_permission_names(clause, container:)
|
186
|
-
end
|
187
|
-
|
188
171
|
# these can take a NodeSet as argument; semx will point to members of the NodeSet,
|
189
172
|
# but numbering will be consecutive
|
190
173
|
def hierarchical_figure_names(clauses, num)
|
@@ -229,23 +212,16 @@ container: false)
|
|
229
212
|
end
|
230
213
|
end
|
231
214
|
|
232
|
-
def hierarchical_asset_names(clause, num)
|
233
|
-
hierarchical_table_names(clause, num)
|
234
|
-
hierarchical_figure_names(clause, num)
|
235
|
-
hierarchical_formula_names(clause, num)
|
236
|
-
hierarchical_permission_names(clause, num)
|
237
|
-
end
|
238
|
-
|
239
215
|
def hierarchical_formula_names(clauses, num)
|
240
216
|
c = Counter.new
|
241
217
|
nodeSet(clauses).each do |clause|
|
242
218
|
clause.xpath(ns(".//formula")).noblank.each do |t|
|
243
219
|
@anchors[t["id"]] = anchor_struct(
|
244
|
-
# "#{num}#{hier_separator}#{c.increment(t).print}", t,
|
245
220
|
hiersemx(clause, num, c.increment(t), t), t,
|
246
221
|
t["inequality"] ? @labels["inequality"] : @labels["formula"],
|
247
222
|
"formula", { unnumb: t["unnumbered"], container: false }
|
248
223
|
)
|
224
|
+
@anchors[t["id"]][:bare_xref] = @anchors[t["id"]][:label]
|
249
225
|
end
|
250
226
|
end
|
251
227
|
end
|
@@ -253,10 +229,9 @@ container: false)
|
|
253
229
|
def hierarchical_permission_names(clauses, num)
|
254
230
|
c = ReqCounter.new
|
255
231
|
nodeSet(clauses).each do |clause|
|
256
|
-
clause.xpath(ns(
|
232
|
+
clause.xpath(ns(first_lvl_req)).noblank.each do |t|
|
257
233
|
m = @reqt_models.model(t["model"])
|
258
234
|
klass, label = reqt2class_label(t, m)
|
259
|
-
# id = "#{num}#{hier_separator}#{c.increment(label, t).print}"
|
260
235
|
id = hiersemx(clause, num, c.increment(label, t), t)
|
261
236
|
sequential_permission_body(id, nil, t, label, klass, m,
|
262
237
|
container: false)
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
module XrefGen
|
3
|
+
module Sections
|
4
|
+
# preempt clause notes with all other types of note (ISO default)
|
5
|
+
def asset_anchor_names(doc)
|
6
|
+
(@parse_settings.empty? || @parse_settings[:assets]) or return
|
7
|
+
middle_section_asset_names(doc)
|
8
|
+
termnote_anchor_names(doc)
|
9
|
+
termexample_anchor_names(doc)
|
10
|
+
note_anchor_names(doc.xpath(ns("//table | //figure")))
|
11
|
+
sections = doc.xpath(ns(sections_xpath))
|
12
|
+
note_anchor_names(sections)
|
13
|
+
admonition_anchor_names(sections)
|
14
|
+
example_anchor_names(sections)
|
15
|
+
list_anchor_names(sections)
|
16
|
+
deflist_anchor_names(sections)
|
17
|
+
bookmark_anchor_names(doc)
|
18
|
+
end
|
19
|
+
|
20
|
+
def middle_section_asset_names(doc)
|
21
|
+
middle_sections =
|
22
|
+
"//clause[@type = 'scope'] | #{@klass.norm_ref_xpath} | " \
|
23
|
+
"//sections/terms | //preface/* | " \
|
24
|
+
"//sections/definitions | //clause[parent::sections]"
|
25
|
+
sequential_asset_names(doc.xpath(ns(middle_sections)))
|
26
|
+
end
|
27
|
+
|
28
|
+
# container makes numbering be prefixed with the parent clause reference
|
29
|
+
def sequential_asset_names(clause, container: false)
|
30
|
+
sequential_table_names(clause, container:)
|
31
|
+
sequential_figure_names(clause, container:)
|
32
|
+
sequential_formula_names(clause, container:)
|
33
|
+
sequential_permission_names(clause, container:)
|
34
|
+
end
|
35
|
+
|
36
|
+
def hierarchical_asset_names(clause, num)
|
37
|
+
hierarchical_table_names(clause, num)
|
38
|
+
hierarchical_figure_names(clause, num)
|
39
|
+
hierarchical_formula_names(clause, num)
|
40
|
+
hierarchical_permission_names(clause, num)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative "clause_order"
|
2
|
+
require_relative "xref_sect_asset"
|
2
3
|
|
3
4
|
module IsoDoc
|
4
5
|
module XrefGen
|
@@ -58,22 +59,6 @@ module IsoDoc
|
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
61
|
-
# preempt clause notes with all other types of note (ISO default)
|
62
|
-
def asset_anchor_names(doc)
|
63
|
-
(@parse_settings.empty? || @parse_settings[:assets]) or return
|
64
|
-
middle_section_asset_names(doc)
|
65
|
-
termnote_anchor_names(doc)
|
66
|
-
termexample_anchor_names(doc)
|
67
|
-
note_anchor_names(doc.xpath(ns("//table | //figure")))
|
68
|
-
sections = doc.xpath(ns(sections_xpath))
|
69
|
-
note_anchor_names(sections)
|
70
|
-
admonition_anchor_names(sections)
|
71
|
-
example_anchor_names(sections)
|
72
|
-
list_anchor_names(sections)
|
73
|
-
deflist_anchor_names(sections)
|
74
|
-
bookmark_anchor_names(doc)
|
75
|
-
end
|
76
|
-
|
77
62
|
def clause_title(clause, use_elem_name: false)
|
78
63
|
ret = clause.at(ns("./title"))&.text
|
79
64
|
if use_elem_name && ret.blank?
|
@@ -83,9 +68,6 @@ module IsoDoc
|
|
83
68
|
end
|
84
69
|
end
|
85
70
|
|
86
|
-
SUBCLAUSES =
|
87
|
-
"./clause | ./references | ./term | ./terms | ./definitions".freeze
|
88
|
-
|
89
71
|
# in StanDoc, prefaces have no numbering; they are referenced only by title
|
90
72
|
def preface_names(clause)
|
91
73
|
unnumbered_names(clause)
|
@@ -103,7 +85,7 @@ module IsoDoc
|
|
103
85
|
clause.nil? and return
|
104
86
|
title = clause_title(clause, use_elem_name: true)
|
105
87
|
preface_name_anchors(clause, 1, title)
|
106
|
-
clause.xpath(ns(
|
88
|
+
clause.xpath(ns(subclauses)).each_with_index do |c, i|
|
107
89
|
t = c.at(ns("./title"))
|
108
90
|
tt = "#{semx(clause, title, clause.name)}" \
|
109
91
|
"<span class='fmt-comma'>,</span> #{semx(c, i + 1)}"
|
@@ -114,7 +96,7 @@ module IsoDoc
|
|
114
96
|
def preface_names1(clause, title, parent_title, level)
|
115
97
|
label = title || parent_title
|
116
98
|
preface_name_anchors(clause, level, title || parent_title)
|
117
|
-
clause.xpath(ns(
|
99
|
+
clause.xpath(ns(subclauses)).each_with_index do |c, i|
|
118
100
|
t = c.at(ns("./title"))
|
119
101
|
preface_names1(c, t ? semx(c, t.text, c.name) : nil,
|
120
102
|
"#{label} #{semx(c, i + 1)}",
|
@@ -131,20 +113,12 @@ module IsoDoc
|
|
131
113
|
type: "clause", elem: @labels["clause"] }
|
132
114
|
end
|
133
115
|
|
134
|
-
def middle_section_asset_names(doc)
|
135
|
-
middle_sections =
|
136
|
-
"//clause[@type = 'scope'] | #{@klass.norm_ref_xpath} | " \
|
137
|
-
"//sections/terms | //preface/* | " \
|
138
|
-
"//sections/definitions | //clause[parent::sections]"
|
139
|
-
sequential_asset_names(doc.xpath(ns(middle_sections)))
|
140
|
-
end
|
141
|
-
|
142
116
|
def section_names(clause, num, lvl)
|
143
117
|
unnumbered_section_name?(clause) and return num
|
144
118
|
num.increment(clause)
|
145
119
|
lbl = semx(clause, num.print)
|
146
120
|
section_name_anchors(clause, lbl, lvl)
|
147
|
-
clause.xpath(ns(
|
121
|
+
clause.xpath(ns(subclauses))
|
148
122
|
.each_with_object(clause_counter(0)) do |c, i|
|
149
123
|
section_names1(c, lbl, i.increment(c).print, lvl + 1)
|
150
124
|
end
|
@@ -153,12 +127,12 @@ module IsoDoc
|
|
153
127
|
|
154
128
|
def clause_number_semx(parentnum, clause, num)
|
155
129
|
if clause["branch-number"]
|
156
|
-
|
130
|
+
semx(clause, clause["branch-number"])
|
157
131
|
elsif parentnum.nil?
|
158
132
|
semx(clause, num)
|
159
|
-
|
160
|
-
|
161
|
-
|
133
|
+
else
|
134
|
+
"#{parentnum}#{delim_wrap(clausesep)}#{semx(clause, num)}"
|
135
|
+
end
|
162
136
|
end
|
163
137
|
|
164
138
|
def section_names1(clause, parentnum, num, level)
|
@@ -166,7 +140,7 @@ module IsoDoc
|
|
166
140
|
lbl = clause_number_semx(parentnum, clause, num)
|
167
141
|
section_name_anchors(clause, lbl, level)
|
168
142
|
i = clause_counter(0)
|
169
|
-
clause.xpath(ns(
|
143
|
+
clause.xpath(ns(subclauses)).each do |c|
|
170
144
|
section_names1(c, lbl, i.increment(c).print, level + 1)
|
171
145
|
end
|
172
146
|
end
|
@@ -218,13 +192,14 @@ module IsoDoc
|
|
218
192
|
end
|
219
193
|
|
220
194
|
def annex_names(clause, num)
|
195
|
+
appendix_names(clause, num)
|
221
196
|
label = semx(clause, num)
|
222
197
|
annex_name_anchors(clause, label, 1)
|
223
198
|
if @klass.single_term_clause?(clause)
|
224
199
|
annex_names1(clause.at(ns("./references | ./terms | ./definitions")),
|
225
200
|
nil, num.to_s, 1)
|
226
201
|
else
|
227
|
-
clause.xpath(ns(
|
202
|
+
clause.xpath(ns(subclauses))
|
228
203
|
.each_with_object(clause_counter(0)) do |c, i|
|
229
204
|
annex_names1(c, label, i.increment(c).print, 2)
|
230
205
|
end
|
@@ -236,7 +211,7 @@ module IsoDoc
|
|
236
211
|
lbl = clause_number_semx(parentnum, clause, num)
|
237
212
|
annex_name_anchors1(clause, lbl, level)
|
238
213
|
i = clause_counter(0)
|
239
|
-
clause.xpath(ns(
|
214
|
+
clause.xpath(ns(subclauses)).each do |c|
|
240
215
|
annex_names1(c, lbl, i.increment(c).print, level + 1)
|
241
216
|
end
|
242
217
|
end
|
@@ -245,6 +220,33 @@ module IsoDoc
|
|
245
220
|
def annex_name_anchors1(clause, num, level)
|
246
221
|
annex_name_anchors(clause, num, level)
|
247
222
|
end
|
223
|
+
|
224
|
+
def appendix_names(clause, _num)
|
225
|
+
i = clause_counter(0)
|
226
|
+
clause.xpath(ns("./appendix")).each do |c|
|
227
|
+
i.increment(c)
|
228
|
+
num = semx(c, i.print)
|
229
|
+
lbl = labelled_autonum(@labels["appendix"], num)
|
230
|
+
@anchors[c["id"]] =
|
231
|
+
anchor_struct(i.print, c, @labels["appendix"],
|
232
|
+
"clause").merge(level: 2, subtype: "annex",
|
233
|
+
container: clause["id"])
|
234
|
+
j = clause_counter(0)
|
235
|
+
c.xpath(ns("./clause | ./references")).each do |c1|
|
236
|
+
appendix_names1(c1, lbl, j.increment(c1).print, 3, clause["id"])
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
def appendix_names1(clause, parentnum, num, level, container)
|
242
|
+
num = clause_number_semx(parentnum, clause, num)
|
243
|
+
@anchors[clause["id"]] = { label: num, xref: num, level: level,
|
244
|
+
container: container }
|
245
|
+
i = clause_counter(0)
|
246
|
+
clause.xpath(ns("./clause | ./references")).each do |c|
|
247
|
+
appendix_names1(c, num, i.increment(c).print, level + 1, container)
|
248
|
+
end
|
249
|
+
end
|
248
250
|
end
|
249
251
|
end
|
250
252
|
end
|