isodoc 3.1.6 → 3.1.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/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 +2 -1
- data/lib/isodoc/function/section.rb +6 -2
- data/lib/isodoc/function/section_titles.rb +2 -2
- data/lib/isodoc/function/terms.rb +1 -1
- data/lib/isodoc/function/to_word_html.rb +2 -0
- 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 +14 -1
- data/lib/isodoc/presentation_function/concepts.rb +17 -11
- data/lib/isodoc/presentation_function/docid.rb +2 -1
- data/lib/isodoc/presentation_function/erefs.rb +1 -1
- 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/section.rb +11 -10
- data/lib/isodoc/presentation_function/terms.rb +34 -12
- data/lib/isodoc/presentation_function/title.rb +1 -2
- data/lib/isodoc/presentation_function/xrefs.rb +2 -2
- data/lib/isodoc/presentation_xml_convert.rb +3 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/comments.rb +1 -2
- 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 +5 -2
data/lib/isodoc/init.rb
CHANGED
@@ -143,9 +143,9 @@ module IsoDoc
|
|
143
143
|
self.class::AGENCIES.include?(text)
|
144
144
|
end
|
145
145
|
|
146
|
-
def docid_l10n(text)
|
146
|
+
def docid_l10n(text, citation: true)
|
147
147
|
text.nil? and return text
|
148
|
-
|
148
|
+
docid_all_parts(text, citation)
|
149
149
|
x = Nokogiri::XML::DocumentFragment.parse(text)
|
150
150
|
(x.xpath(".//text()") - x.xpath(".//fn//text()")).each do |n|
|
151
151
|
n.replace(n.text.gsub(/ /, " "))
|
@@ -153,10 +153,19 @@ module IsoDoc
|
|
153
153
|
to_xml(x)
|
154
154
|
end
|
155
155
|
|
156
|
+
def docid_all_parts(text, citation)
|
157
|
+
if citation
|
158
|
+
text.sub!(%r{\p{Zs}\(all\p{Zs}parts\)}, "")
|
159
|
+
else
|
160
|
+
@i18n.all_parts && !citation and
|
161
|
+
text.gsub!(/all\p{Zs}parts/, @i18n.all_parts.downcase)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
156
165
|
def docid_prefix(prefix, docid)
|
157
166
|
docid = "#{prefix} #{docid}" if prefix && !omit_docid_prefix(prefix) &&
|
158
167
|
!/^#{prefix}\b/.match(docid)
|
159
|
-
docid_l10n(docid)
|
168
|
+
docid_l10n(docid, citation: false)
|
160
169
|
end
|
161
170
|
|
162
171
|
def omit_docid_prefix(prefix)
|
@@ -11,7 +11,7 @@ module IsoDoc
|
|
11
11
|
prefix_name_postprocess(node, elem)
|
12
12
|
end
|
13
13
|
|
14
|
-
def prefix_name_defaults(
|
14
|
+
def prefix_name_defaults(_node, delims, label)
|
15
15
|
label&.empty? and label = nil
|
16
16
|
delims.nil? and delims = {}
|
17
17
|
[label, delims]
|
@@ -80,7 +80,7 @@ module IsoDoc
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def autonum(id, num)
|
83
|
-
|
83
|
+
num.include?("<semx") and return num # already contains markup
|
84
84
|
"<semx element='autonum' source='#{id}'>#{num}</semx>"
|
85
85
|
end
|
86
86
|
|
@@ -135,7 +135,8 @@ module IsoDoc
|
|
135
135
|
end
|
136
136
|
|
137
137
|
def fmt_caption_label_wrap(label)
|
138
|
-
empty_xml?(label) ||
|
138
|
+
empty_xml?(label) ||
|
139
|
+
%r{<span class=['"]fmt-caption-label['"]}.match?(label) or
|
139
140
|
label = "<span class='fmt-caption-label'>#{label}</span>"
|
140
141
|
label
|
141
142
|
end
|
@@ -102,6 +102,7 @@ module IsoDoc
|
|
102
102
|
|
103
103
|
def table1(elem)
|
104
104
|
table_fn(elem)
|
105
|
+
table_css(elem)
|
105
106
|
labelled_ancestor(elem) and return
|
106
107
|
elem["unnumbered"] && !elem.at(ns("./name")) and return
|
107
108
|
n = @xrefs.anchor(elem["id"], :label, false)
|
@@ -109,6 +110,16 @@ module IsoDoc
|
|
109
110
|
prefix_name(elem, { caption: table_delim }, l10n(lbl), "name")
|
110
111
|
end
|
111
112
|
|
113
|
+
def table_css(elem)
|
114
|
+
parser = IsoDoc::CssBorderParser::BorderParser.new
|
115
|
+
elem.xpath(ns(".//tr | .//th | .//td")).each do |n|
|
116
|
+
n["style"] or next
|
117
|
+
parsed_properties = parser.parse_declaration(n["style"])
|
118
|
+
new_style = parser.to_css_string(parsed_properties)
|
119
|
+
n["style"] = new_style
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
112
123
|
def table_delim
|
113
124
|
block_delim
|
114
125
|
end
|
@@ -139,7 +150,7 @@ module IsoDoc
|
|
139
150
|
end
|
140
151
|
|
141
152
|
def source(docxml)
|
142
|
-
|
153
|
+
docxml.xpath(ns("//source/modification")).each do |f|
|
143
154
|
source_modification(f)
|
144
155
|
end
|
145
156
|
docxml.xpath(ns("//table/source")).each { |f| tablesource(f) }
|
@@ -161,6 +172,8 @@ module IsoDoc
|
|
161
172
|
elem.children = l10n("[#{@i18n.source}: #{to_xml(elem.children).strip}]")
|
162
173
|
end
|
163
174
|
|
175
|
+
# TODO just as termsource is duplicated in fmt-termsource to allow for changes,
|
176
|
+
# should double up source with fmt-source
|
164
177
|
def source_modification(mod)
|
165
178
|
termsource_modification(mod.parent)
|
166
179
|
end
|
@@ -30,8 +30,7 @@ module IsoDoc
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def concept_dup(node, ret)
|
33
|
-
node
|
34
|
-
"xmlns:fmt-origin | xmlns:fmt-link]").each(&:remove)
|
33
|
+
concept_dup_cleanup_orig(node)
|
35
34
|
ret.xpath(ns(".//xref | .//eref | .//origin | .//link")).each(&:remove)
|
36
35
|
ret.xpath(ns(".//semx")).each do |s|
|
37
36
|
s.children.empty? and s.remove
|
@@ -41,6 +40,16 @@ module IsoDoc
|
|
41
40
|
node.next = f
|
42
41
|
end
|
43
42
|
|
43
|
+
def concept_dup_cleanup_orig(node)
|
44
|
+
node.xpath(".//xmlns:semx[xmlns:fmt-xref | xmlns:fmt-eref | " \
|
45
|
+
"xmlns:fmt-origin | xmlns:fmt-link]").each(&:remove)
|
46
|
+
node.xpath(ns(".//xref | .//eref | .//origin | .//link")).each do |x|
|
47
|
+
x["original-id"] or next
|
48
|
+
x["id"] = x["original-id"]
|
49
|
+
x.delete("original-id")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
44
53
|
def concept1_style(node, opts)
|
45
54
|
r = node.at(ns(".//renderterm")) or return
|
46
55
|
opts[:ital] == "true" and r.children = "<em>#{to_xml(r.children)}</em>"
|
@@ -103,13 +112,9 @@ module IsoDoc
|
|
103
112
|
def related1(node)
|
104
113
|
p, ref, orig = related1_prep(node)
|
105
114
|
label = @i18n.relatedterms[orig["type"]].upcase
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
else
|
110
|
-
node.children = (l10n("<p><strong>#{label}:</strong> " \
|
111
|
-
"<strong>**RELATED TERM NOT FOUND**</strong></p>"))
|
112
|
-
end
|
115
|
+
ret = "<strong>**RELATED TERM NOT FOUND**</strong>"
|
116
|
+
p && ref and ret = "<em>#{to_xml(p)}</em> (#{Common::to_xml(ref)})"
|
117
|
+
node.children = (l10n("<p><strong>#{label}:</strong> #{ret}</p>"))
|
113
118
|
end
|
114
119
|
|
115
120
|
def related1_prep(node)
|
@@ -152,8 +157,7 @@ module IsoDoc
|
|
152
157
|
.with_object([]) do |(p, i), m|
|
153
158
|
if (i.zero? && (pref = p)) || merge_preferred_eligible?(pref, p)
|
154
159
|
m << p
|
155
|
-
else
|
156
|
-
p.wrap("<p></p>")
|
160
|
+
else p.wrap("<p></p>")
|
157
161
|
end
|
158
162
|
end
|
159
163
|
pref&.replace(merge_second_preferred1(out, term))
|
@@ -189,6 +193,8 @@ module IsoDoc
|
|
189
193
|
out = desgn.parent.at(ns("./fmt-#{desgn.name}"))
|
190
194
|
d1 = semx_fmt_dup(desgn)
|
191
195
|
s = d1.at(ns("./termsource"))
|
196
|
+
s0 = desgn.at(ns("./termsource"))
|
197
|
+
modification_dup_align(s0, s)
|
192
198
|
name = d1.at(ns("./expression/name | ./letter-symbol/name | " \
|
193
199
|
"./graphical-symbol")) or return
|
194
200
|
designation_annotate(d1, name, desgn)
|
@@ -13,7 +13,8 @@ module IsoDoc
|
|
13
13
|
ret = pref_ref_code_parse(bib) or return nil
|
14
14
|
ins = bib.at(ns("./docidentifier[last()]"))
|
15
15
|
ret.reverse_each do |r|
|
16
|
-
|
16
|
+
id = docid_l10n(r, citation: false)
|
17
|
+
ins.next = "<docidentifier scope='biblio-tag'>#{id}</docidentifier>"
|
17
18
|
end
|
18
19
|
ret
|
19
20
|
end
|
@@ -24,11 +24,10 @@ module IsoDoc
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def svgmap_extract(elem)
|
27
|
-
if elem.at(ns("./figure"))
|
27
|
+
if elem.at(ns("./figure"))
|
28
28
|
n = semx_fmt_dup(elem)
|
29
29
|
n.xpath(ns("./target")).each(&:remove)
|
30
30
|
elem.next = n
|
31
|
-
#else elem.remove
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|
@@ -71,13 +71,19 @@ module IsoDoc
|
|
71
71
|
# do not change to Presentation XML rendering
|
72
72
|
def sem_xml_descendant?(node)
|
73
73
|
ancestor_names = node.ancestors.map(&:name)
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
return true
|
78
|
-
|
79
|
-
|
80
|
-
|
74
|
+
%w[preferred admitted deprecated related definition termsource]
|
75
|
+
.any? do |name|
|
76
|
+
ancestor_names.include?(name)
|
77
|
+
end and return true
|
78
|
+
%w[xref eref origin link name title].any? do |name|
|
79
|
+
ancestor_names.include?(name)
|
80
|
+
end and return true
|
81
|
+
ancestor_names.include?("bibitem") &&
|
82
|
+
%w[formattedref biblio-tag].none? do |name|
|
83
|
+
ancestor_names.include?(name)
|
84
|
+
end and return true
|
85
|
+
(ancestor_names & %w[requirement recommendation permission]).any? &&
|
86
|
+
!ancestor_names.include?("fmt-provision") and return true
|
81
87
|
|
82
88
|
false
|
83
89
|
end
|
@@ -50,41 +50,37 @@ module IsoDoc
|
|
50
50
|
precision: num_precision(num.text))
|
51
51
|
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
COMMA_PLACEHOLDER = "##COMMA##".freeze
|
54
|
+
|
55
|
+
# Temporarily replace commas inside quotes with a placeholder
|
56
|
+
def comma_placeholder(options)
|
57
57
|
processed = ""
|
58
58
|
in_quotes = false
|
59
|
-
placeholder = "##COMMA##"
|
60
|
-
|
61
59
|
options.each_char do |c|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
if c == ',' && in_quotes
|
67
|
-
processed << placeholder
|
68
|
-
else
|
69
|
-
processed << c
|
70
|
-
end
|
60
|
+
c == "'" and in_quotes = !in_quotes
|
61
|
+
processed << if c == "," && in_quotes
|
62
|
+
COMMA_PLACEHOLDER
|
63
|
+
else c end
|
71
64
|
end
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
65
|
+
processed
|
66
|
+
end
|
67
|
+
|
68
|
+
def numberformat_extract(options)
|
69
|
+
options.gsub!(/([a-z_]+)='/, %('\\1=))
|
70
|
+
processed = comma_placeholder(options)
|
71
|
+
CSV.parse_line(processed,
|
72
|
+
quote_char: "'").each_with_object({}) do |x, acc|
|
73
|
+
x.gsub!(COMMA_PLACEHOLDER, ",")
|
76
74
|
m = /^(.+?)=(.+)?$/.match(x) or next
|
77
75
|
acc[m[1].to_sym] = m[2].sub(/^(["'])(.+)\1$/, "\\2")
|
78
76
|
end
|
79
|
-
|
80
|
-
result
|
81
77
|
end
|
82
78
|
|
83
79
|
def numberformat_type(ret)
|
84
80
|
%i(precision significant digit_count group_digits fraction_group_digits)
|
85
81
|
.each do |i|
|
86
|
-
|
87
|
-
|
82
|
+
ret[i] &&= ret[i].to_i
|
83
|
+
end
|
88
84
|
%i(notation exponent_sign number_sign locale).each do |i|
|
89
85
|
ret[i] &&= ret[i].to_sym
|
90
86
|
end
|
@@ -6,8 +6,8 @@ module IsoDoc
|
|
6
6
|
def clause(docxml)
|
7
7
|
docxml.xpath(ns("//clause | //terms | //definitions | //references | " \
|
8
8
|
"//introduction | //foreword | //preface/abstract | " \
|
9
|
-
"//acknowledgements | //colophon | //indexsect "
|
10
|
-
|
9
|
+
"//acknowledgements | //colophon | //indexsect | " \
|
10
|
+
"//executivesummary | //appendix")).each do |f|
|
11
11
|
f.parent.name == "annex" &&
|
12
12
|
@xrefs.klass.single_term_clause?(f.parent) and next
|
13
13
|
clause1(f)
|
@@ -133,14 +133,15 @@ module IsoDoc
|
|
133
133
|
end
|
134
134
|
|
135
135
|
def preface_rearrange(doc)
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
136
|
+
[["//preface/abstract",
|
137
|
+
%w(foreword introduction clause acknowledgements executivesummary)],
|
138
|
+
["//preface/foreword",
|
139
|
+
%w(introduction clause acknowledgements executivesummary)],
|
140
|
+
["//preface/introduction", %w(clause acknowledgements executivesummary)],
|
141
|
+
["//preface/acknowledgements", %w(executivesummary)],
|
142
|
+
["//preface/executivesummary", %w()]].each do |x|
|
143
|
+
preface_move(doc.xpath(ns(x[0])), x[1], doc)
|
144
|
+
end
|
144
145
|
end
|
145
146
|
|
146
147
|
def preface_move(clauses, after, _doc)
|
@@ -1,9 +1,11 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
3
|
+
DESIGNATION_ELEMS =
|
4
|
+
%w(preferred admitted deprecates related definition termsource).freeze
|
5
|
+
|
3
6
|
def termcontainers(docxml)
|
4
7
|
docxml.xpath(ns("//term")).each do |t|
|
5
|
-
|
6
|
-
.each do |w|
|
8
|
+
DESIGNATION_ELEMS.each do |w|
|
7
9
|
d = t.at(ns("./#{w}[last()]")) and d.after("<fmt-#{w}/>")
|
8
10
|
end
|
9
11
|
end
|
@@ -14,8 +16,7 @@ module IsoDoc
|
|
14
16
|
|
15
17
|
def termcleanup(docxml)
|
16
18
|
docxml.xpath(ns("//term")).each do |t|
|
17
|
-
|
18
|
-
.each do |w|
|
19
|
+
DESIGNATION_ELEMS.each do |w|
|
19
20
|
t.xpath(ns("./#{w}//fmt-name | ./#{w}//fmt-xref-label")).each(&:remove)
|
20
21
|
f = t.at(ns(".//fmt-#{w}"))
|
21
22
|
f&.children&.empty? and f.remove
|
@@ -55,7 +56,12 @@ module IsoDoc
|
|
55
56
|
else singledef(elem, d, d1)
|
56
57
|
end
|
57
58
|
unwrap_definition(elem, d1)
|
58
|
-
|
59
|
+
s1 = d.xpath(ns(".//termsource"))
|
60
|
+
s2 = d1.xpath(ns(".//termsource"))
|
61
|
+
s1.each_with_index do |s, i|
|
62
|
+
modification_dup_align(s, s2[i])
|
63
|
+
end
|
64
|
+
termdomain(elem, d1)
|
59
65
|
end
|
60
66
|
|
61
67
|
def multidef(_elem, defn, fmt_defn)
|
@@ -104,21 +110,35 @@ module IsoDoc
|
|
104
110
|
|
105
111
|
def termsource_designation(fmtsource)
|
106
112
|
p = fmtsource.previous_element
|
107
|
-
|
108
|
-
|
109
|
-
|
113
|
+
p&.name == "p" or return
|
114
|
+
p << " "
|
115
|
+
p << fmtsource.children
|
110
116
|
end
|
111
117
|
|
112
118
|
def copy_baselevel_termsource(docxml)
|
119
|
+
docxml.xpath(ns("//term//modification")).each do |f|
|
120
|
+
f["id"] ||= "_#{UUIDTools::UUID.random_create}"
|
121
|
+
end
|
113
122
|
docxml.xpath(ns("//term[termsource]")).each do |x|
|
114
123
|
s = x.xpath(ns("./termsource"))
|
115
124
|
s1 = x.at(ns("./fmt-termsource"))
|
116
|
-
s.each
|
125
|
+
s.each do |ss|
|
126
|
+
dup = ss.clone
|
127
|
+
modification_dup_align(ss, dup)
|
128
|
+
s1 << dup
|
129
|
+
end
|
117
130
|
strip_duplicate_ids(nil, s, s1)
|
118
131
|
%w(status type).each { |a| s[0][a] and s1[a] = s[0][a] }
|
119
132
|
end
|
120
133
|
end
|
121
134
|
|
135
|
+
def modification_dup_align(sem, pres)
|
136
|
+
m = sem&.at(ns("./modification")) or return
|
137
|
+
m1 = pres.at(ns("./modification"))
|
138
|
+
new_m1 = semx_fmt_dup(m)
|
139
|
+
m1.replace("<modification>#{to_xml(new_m1)}</modification>")
|
140
|
+
end
|
141
|
+
|
122
142
|
def termsource1(elem)
|
123
143
|
ret = [semx_fmt_dup(elem)]
|
124
144
|
while elem&.next_element&.name == "termsource"
|
@@ -136,7 +156,8 @@ module IsoDoc
|
|
136
156
|
elem.xpath(".//text()[normalize-space() = '']").each(&:remove)
|
137
157
|
origin = elem.at(ns("./origin"))
|
138
158
|
s = termsource_status(elem["status"]) and origin.next = l10n(", #{s}")
|
139
|
-
|
159
|
+
mod = elem.at(ns("./modification")) or return
|
160
|
+
termsource_add_modification_text(mod)
|
140
161
|
end
|
141
162
|
|
142
163
|
def termsource_add_modification_text(mod)
|
@@ -146,8 +167,9 @@ module IsoDoc
|
|
146
167
|
return
|
147
168
|
end
|
148
169
|
mod.previous = " — "
|
149
|
-
|
150
|
-
|
170
|
+
c = mod.at(ns("./semx" )) || mod
|
171
|
+
c.elements.size == 1 and c.children = to_xml(c.elements[0].children)
|
172
|
+
mod.replace(mod.children)
|
151
173
|
end
|
152
174
|
|
153
175
|
def termsource_status(status)
|
@@ -41,9 +41,8 @@ module IsoDoc
|
|
41
41
|
%w(note admonition p floating-title).include?(p.name) or break m
|
42
42
|
m << p
|
43
43
|
end
|
44
|
-
#require 'debug'; out.empty? or binding.b
|
45
44
|
out.reject { |c| c["displayorder"] }.reverse_each do |c|
|
46
|
-
|
45
|
+
skip_display_order?(c) and next
|
47
46
|
c["displayorder"] = idx
|
48
47
|
idx += 1
|
49
48
|
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)
|
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}']")
|
@@ -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
|