metanorma-iso 1.10.1 → 1.10.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ubuntu.yml +1 -1
- data/Gemfile +1 -1
- data/lib/asciidoctor/iso/base.rb +1 -1
- data/lib/asciidoctor/iso/basicdoc.rng +1 -11
- data/lib/asciidoctor/iso/biblio.rng +0 -2
- data/lib/asciidoctor/iso/front.rb +17 -4
- data/lib/asciidoctor/iso/front_id.rb +20 -17
- data/lib/asciidoctor/iso/isodoc.rng +61 -19
- data/lib/asciidoctor/iso/isostandard-amd.rng +1 -1
- data/lib/asciidoctor/iso/isostandard.rng +15 -3
- data/lib/asciidoctor/iso/reqt.rng +1 -1
- data/lib/asciidoctor/iso/section.rb +1 -1
- data/lib/asciidoctor/iso/validate.rb +1 -1
- data/lib/asciidoctor/iso/validate_image.rb +1 -1
- data/lib/asciidoctor/iso/validate_section.rb +1 -1
- data/lib/isodoc/iso/base_convert.rb +14 -31
- data/lib/isodoc/iso/html/isodoc.css +0 -1
- data/lib/isodoc/iso/html/isodoc.scss +0 -1
- data/lib/isodoc/iso/html/style-human.css +40 -9
- data/lib/isodoc/iso/html/style-human.scss +36 -9
- data/lib/isodoc/iso/html/style-iso.css +35 -6
- data/lib/isodoc/iso/html/style-iso.scss +31 -6
- data/lib/isodoc/iso/html/wordstyle.css +10 -8
- data/lib/isodoc/iso/html/wordstyle.scss +10 -8
- data/lib/isodoc/iso/html_convert.rb +81 -22
- data/lib/isodoc/iso/index.rb +53 -45
- data/lib/isodoc/iso/iso.amendment.xsl +333 -113
- data/lib/isodoc/iso/iso.international-standard.xsl +333 -113
- data/lib/isodoc/iso/isosts_convert.rb +6 -2
- data/lib/isodoc/iso/metadata.rb +27 -22
- data/lib/isodoc/iso/presentation_xml_convert.rb +60 -25
- data/lib/isodoc/iso/sts_convert.rb +3 -2
- data/lib/isodoc/iso/word_convert.rb +0 -2
- data/lib/metanorma/iso/processor.rb +2 -2
- data/lib/metanorma/iso/version.rb +1 -1
- data/metanorma-iso.gemspec +3 -3
- data/spec/asciidoctor/base_spec.rb +397 -545
- data/spec/asciidoctor/blocks_spec.rb +4 -4
- data/spec/asciidoctor/cleanup_spec.rb +15 -12
- data/spec/asciidoctor/refs_spec.rb +87 -84
- data/spec/isodoc/amd_spec.rb +261 -250
- data/spec/isodoc/i18n_spec.rb +7 -7
- data/spec/isodoc/inline_spec.rb +242 -216
- data/spec/isodoc/iso_spec.rb +3 -1
- data/spec/isodoc/postproc_spec.rb +111 -28
- data/spec/isodoc/section_spec.rb +3 -3
- data/spec/isodoc/terms_spec.rb +34 -41
- data/spec/isodoc/xref_spec.rb +3 -3
- data/spec/metanorma/processor_spec.rb +110 -14
- data/spec/vcr_cassettes/docrels.yml +37 -427
- metadata +8 -8
data/lib/isodoc/iso/index.rb
CHANGED
@@ -5,32 +5,36 @@ module IsoDoc
|
|
5
5
|
%(id="_#{UUIDTools::UUID.random_create}")
|
6
6
|
end
|
7
7
|
|
8
|
-
def index(
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
def index(xml)
|
9
|
+
if xml.at(ns("//index"))
|
10
|
+
i = xml.at(ns("//indexsect")) ||
|
11
|
+
xml.root.add_child("<indexsect #{add_id}><title>#{@i18n.index}"\
|
12
|
+
"</title></indexsect>").first
|
13
|
+
index = sort_indexterms(xml.xpath(ns("//index")),
|
14
|
+
xml.xpath(ns("//index-xref[@also = 'false']")),
|
15
|
+
xml.xpath(ns("//index-xref[@also = 'true']")))
|
16
|
+
index1(xml, i, index)
|
17
|
+
else xml.xpath(ns("//indexsect")).each(&:remove)
|
12
18
|
end
|
13
|
-
i = docxml.at(ns("//indexsect")) ||
|
14
|
-
docxml.root.add_child("<indexsect #{add_id}><title>#{@i18n.index}</title></indexsect>").first
|
15
|
-
index = sort_indexterms(docxml.xpath(ns("//index")),
|
16
|
-
docxml.xpath(ns("//index-xref[@also = 'false']")),
|
17
|
-
docxml.xpath(ns("//index-xref[@also = 'true']")))
|
18
|
-
index1(docxml, i, index)
|
19
19
|
end
|
20
20
|
|
21
|
-
def index1(docxml,
|
22
|
-
c =
|
21
|
+
def index1(docxml, indexsect, index)
|
22
|
+
c = indexsect.add_child("<ul></ul>").first
|
23
23
|
index.keys.sort.each do |k|
|
24
|
-
# c = i.add_child "<clause #{add_id}><title>#{k}</title><ul></ul></clause>"
|
25
24
|
words = index[k].keys.each_with_object({}) do |w, v|
|
26
25
|
v[sortable(w).downcase] = w
|
27
26
|
end
|
28
27
|
words.keys.localize(@lang.to_sym).sort.to_a.each do |w|
|
29
|
-
# c.first.at(ns("./ul")).add_child index_entries(words, index[k], w)
|
30
28
|
c.add_child index_entries(words, index[k], w)
|
31
29
|
end
|
32
30
|
end
|
33
|
-
docxml
|
31
|
+
index1_cleanup(docxml)
|
32
|
+
end
|
33
|
+
|
34
|
+
def index1_cleanup(docxml)
|
35
|
+
docxml.xpath(ns("//indexsect//xref")).each do |x|
|
36
|
+
x.children.remove
|
37
|
+
end
|
34
38
|
@xrefs.bookmark_anchor_names(docxml)
|
35
39
|
end
|
36
40
|
|
@@ -56,7 +60,7 @@ module IsoDoc
|
|
56
60
|
end
|
57
61
|
ret += "</ul>"
|
58
62
|
end
|
59
|
-
ret
|
63
|
+
"#{ret}</li>"
|
60
64
|
end
|
61
65
|
|
62
66
|
def index_entries2(words, index, secondary)
|
@@ -75,30 +79,29 @@ module IsoDoc
|
|
75
79
|
end
|
76
80
|
ret += "</ul>"
|
77
81
|
end
|
78
|
-
ret
|
82
|
+
"#{ret}</li>"
|
79
83
|
end
|
80
84
|
|
81
85
|
def index_entries_head(head, entries, opt)
|
82
86
|
ret = "<li>#{head}"
|
83
87
|
xref = entries&.dig(:xref)&.join(", ")
|
84
|
-
|
85
|
-
|
86
|
-
end
|
87
|
-
see = see_sort&.keys&.localize(@lang.to_sym)&.sort&.to_a&.map do |k|
|
88
|
-
see_sort[k]
|
89
|
-
end&.join(", ")
|
90
|
-
also_sort = entries&.dig(:also)&.each_with_object({}) do |w, v|
|
91
|
-
v[sortable(w).downcase] = w
|
92
|
-
end
|
93
|
-
also = also_sort&.keys&.localize(@lang.to_sym)&.sort&.to_a&.map do |k|
|
94
|
-
also_sort[k]
|
95
|
-
end&.join(", ")
|
88
|
+
see = index_entries_see(entries, :see)
|
89
|
+
also = index_entries_see(entries, :also)
|
96
90
|
ret += "#{opt[:xref_lbl]} #{xref}" if xref
|
97
91
|
ret += "#{opt[:see_lbl]} #{see}" if see
|
98
92
|
ret += "#{opt[:also_lbl]} #{also}" if also
|
99
93
|
ret
|
100
94
|
end
|
101
95
|
|
96
|
+
def index_entries_see(entries, label)
|
97
|
+
see_sort = entries&.dig(label)&.each_with_object({}) do |w, v|
|
98
|
+
v[sortable(w).downcase] = w
|
99
|
+
end
|
100
|
+
see_sort&.keys&.localize(@lang.to_sym)&.sort&.to_a&.map do |k|
|
101
|
+
see_sort[k]
|
102
|
+
end&.join(", ")
|
103
|
+
end
|
104
|
+
|
102
105
|
def see_lbl
|
103
106
|
@lang == "en" ? @i18n.see : "<em>#{@i18n.see}</em>"
|
104
107
|
end
|
@@ -119,13 +122,8 @@ module IsoDoc
|
|
119
122
|
|
120
123
|
def extract_indexsee(val, terms, label)
|
121
124
|
terms.each_with_object(val) do |t, v|
|
122
|
-
term = t
|
123
|
-
term2
|
124
|
-
term3 = t&.at(ns("./tertiary"))&.children&.to_xml
|
125
|
-
v[term] ||= {}
|
126
|
-
v[term][term2] ||= {}
|
127
|
-
v[term][term2][term3] ||= {}
|
128
|
-
v[term][term2][term3][label] ||= []
|
125
|
+
term, term2, term3 = extract_indexterms_init(t)
|
126
|
+
term_hash_init(v, term, term2, term3, label)
|
129
127
|
v[term][term2][term3][label] << t&.at(ns("./target"))&.children&.to_xml
|
130
128
|
t.remove
|
131
129
|
end
|
@@ -138,22 +136,32 @@ module IsoDoc
|
|
138
136
|
end
|
139
137
|
end
|
140
138
|
|
141
|
-
# attributes are decoded into UTF-8,
|
139
|
+
# attributes are decoded into UTF-8,
|
140
|
+
# elements in extract_indexsee are still in entities
|
142
141
|
def extract_indexterms(terms)
|
143
142
|
terms.each_with_object({}) do |t, v|
|
144
|
-
term = t
|
145
|
-
term2 = t&.at(ns("./secondary"))&.children&.to_xml
|
146
|
-
term3 = t&.at(ns("./tertiary"))&.children&.to_xml
|
143
|
+
term, term2, term3 = extract_indexterms_init(t)
|
147
144
|
index2bookmark(t)
|
148
|
-
v
|
149
|
-
v[term][term2] ||= {}
|
150
|
-
v[term][term2][term3] ||= {}
|
151
|
-
v[term][term2][term3][:xref] ||= []
|
145
|
+
term_hash_init(v, term, term2, term3, :xref)
|
152
146
|
to = t["to"] ? "to='#{t['to']}' " : ""
|
153
|
-
v[term][term2][term3][:xref] << "<xref target='#{t['id']}'
|
147
|
+
v[term][term2][term3][:xref] << "<xref target='#{t['id']}' "\
|
148
|
+
"#{to}pagenumber='true'/>"
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def extract_indexterms_init(term)
|
153
|
+
%w(primary secondary tertiary).each_with_object([]) do |x, m|
|
154
|
+
m << term&.at(ns("./#{x}"))&.children&.to_xml
|
154
155
|
end
|
155
156
|
end
|
156
157
|
|
158
|
+
def term_hash_init(hash, term, term2, term3, label)
|
159
|
+
hash[term] ||= {}
|
160
|
+
hash[term][term2] ||= {}
|
161
|
+
hash[term][term2][term3] ||= {}
|
162
|
+
hash[term][term2][term3][label] ||= []
|
163
|
+
end
|
164
|
+
|
157
165
|
def index2bookmark(node)
|
158
166
|
node.name = "bookmark"
|
159
167
|
node.children.each(&:remove)
|