metanorma-iso 1.10.4 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +3 -33
- data/.github/workflows/ubuntu.yml +1 -1
- data/.gitignore +26 -0
- data/Makefile +1 -1
- data/lib/asciidoctor/iso/base.rb +2 -69
- data/lib/asciidoctor/iso/cleanup.rb +2 -175
- data/lib/asciidoctor/iso/converter.rb +2 -17
- data/lib/asciidoctor/iso/deprecated.rb +5 -0
- data/lib/asciidoctor/iso/front.rb +2 -156
- data/lib/asciidoctor/iso/front_id.rb +2 -221
- data/lib/asciidoctor/iso/section.rb +2 -48
- data/lib/asciidoctor/iso/validate.rb +2 -171
- data/lib/asciidoctor/iso/validate_image.rb +2 -96
- data/lib/asciidoctor/iso/validate_requirements.rb +2 -110
- data/lib/asciidoctor/iso/validate_section.rb +2 -246
- data/lib/asciidoctor/iso/validate_style.rb +2 -169
- data/lib/asciidoctor/iso/validate_title.rb +2 -104
- data/lib/isodoc/iso/base_convert.rb +14 -31
- data/lib/isodoc/iso/html/style-human.css +37 -22
- data/lib/isodoc/iso/html/style-human.scss +17 -10
- data/lib/isodoc/iso/html/style-iso.css +34 -20
- data/lib/isodoc/iso/html/style-iso.scss +13 -7
- 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 +6 -4
- data/lib/isodoc/iso/index.rb +53 -45
- data/lib/isodoc/iso/iso.amendment.xsl +1328 -1225
- data/lib/isodoc/iso/iso.international-standard.xsl +1328 -1225
- data/lib/isodoc/iso/metadata.rb +27 -22
- data/lib/isodoc/iso/presentation_xml_convert.rb +41 -16
- data/lib/isodoc/iso/sts_convert.rb +2 -4
- data/lib/isodoc/iso/word_convert.rb +2 -0
- data/lib/metanorma/iso/base.rb +70 -0
- data/lib/{asciidoctor → metanorma}/iso/basicdoc.rng +0 -0
- data/lib/{asciidoctor → metanorma}/iso/biblio.rng +0 -0
- data/lib/{asciidoctor → metanorma}/iso/boilerplate-fr.xml +0 -0
- data/lib/{asciidoctor → metanorma}/iso/boilerplate.xml +0 -0
- data/lib/metanorma/iso/cleanup.rb +176 -0
- data/lib/metanorma/iso/converter.rb +18 -0
- data/lib/metanorma/iso/front.rb +170 -0
- data/lib/metanorma/iso/front_id.rb +225 -0
- data/lib/{asciidoctor → metanorma}/iso/isodoc.rng +35 -2
- data/lib/{asciidoctor → metanorma}/iso/isostandard-amd.rng +0 -0
- data/lib/{asciidoctor → metanorma}/iso/isostandard.rnc +0 -0
- data/lib/{asciidoctor → metanorma}/iso/isostandard.rng +0 -0
- data/lib/{asciidoctor → metanorma}/iso/reqt.rng +0 -0
- data/lib/metanorma/iso/section.rb +49 -0
- data/lib/metanorma/iso/validate.rb +172 -0
- data/lib/metanorma/iso/validate_image.rb +97 -0
- data/lib/metanorma/iso/validate_requirements.rb +111 -0
- data/lib/metanorma/iso/validate_section.rb +247 -0
- data/lib/metanorma/iso/validate_style.rb +170 -0
- data/lib/metanorma/iso/validate_title.rb +105 -0
- data/lib/metanorma/iso/version.rb +1 -1
- data/lib/metanorma-iso.rb +1 -1
- data/metanorma-iso.gemspec +2 -2
- data/spec/isodoc/amd_spec.rb +261 -250
- data/spec/isodoc/inline_spec.rb +238 -212
- data/spec/isodoc/iso_spec.rb +3 -1
- data/spec/isodoc/ref_spec.rb +4 -2
- data/spec/isodoc/section_spec.rb +1 -1
- data/spec/isodoc/terms_spec.rb +4 -4
- data/spec/{asciidoctor → metanorma}/amd_spec.rb +1 -1
- data/spec/metanorma/base_spec.rb +1185 -0
- data/spec/{asciidoctor → metanorma}/blank_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/blocks_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/cleanup_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/inline_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/lists_spec.rb +1 -1
- data/spec/metanorma/processor_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/refs_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/section_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/table_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/validate_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/vcr_cassettes/docrels.yml +34 -424
- metadata +39 -26
- data/spec/asciidoctor/base_spec.rb +0 -1333
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)
|