isodoc 1.7.1 → 1.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/isodoc.gemspec +2 -1
- data/lib/isodoc/convert.rb +1 -0
- data/lib/isodoc/css.rb +3 -3
- data/lib/isodoc/function/blocks.rb +180 -168
- data/lib/isodoc/function/blocks_example_note.rb +85 -79
- data/lib/isodoc/function/cleanup.rb +181 -175
- data/lib/isodoc/function/inline.rb +110 -108
- data/lib/isodoc/function/inline_simple.rb +55 -55
- data/lib/isodoc/function/lists.rb +75 -71
- data/lib/isodoc/function/references.rb +165 -160
- data/lib/isodoc/function/reqt.rb +91 -85
- data/lib/isodoc/function/section.rb +140 -190
- data/lib/isodoc/function/section_titles.rb +82 -0
- data/lib/isodoc/function/table.rb +90 -87
- data/lib/isodoc/function/terms.rb +58 -56
- data/lib/isodoc/function/to_word_html.rb +208 -204
- data/lib/isodoc/html_convert.rb +0 -4
- data/lib/isodoc/html_function/mathvariant_to_plain.rb +5 -3
- data/lib/isodoc/presentation_function/inline.rb +1 -1
- data/lib/isodoc/presentation_function/math.rb +9 -0
- data/lib/isodoc/presentation_function/section.rb +12 -1
- data/lib/isodoc/presentation_xml_convert.rb +2 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +5 -5
- data/lib/isodoc/xslfo_convert.rb +2 -2
- data/lib/isodoc.rb +2 -1
- data/lib/metanorma/output/base.rb +13 -0
- data/lib/metanorma/output/utils.rb +17 -0
- data/lib/metanorma/output/xslfo.rb +21 -0
- data/lib/metanorma/output.rb +7 -0
- data/spec/assets/outputtest/a.xml +66 -0
- data/spec/assets/outputtest/iso.international-standard.xsl +3011 -0
- data/spec/isodoc/blocks_spec.rb +441 -243
- data/spec/isodoc/inline_spec.rb +197 -114
- data/spec/isodoc/postproc_spec.rb +2 -2
- data/spec/isodoc/presentation_xml_spec.rb +84 -0
- data/spec/isodoc/section_spec.rb +639 -0
- metadata +23 -18
- data/lib/isodoc/html_function/sectionsplit.rb +0 -244
- data/spec/isodoc/sectionsplit_spec.rb +0 -190
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isodoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciimath
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '4'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: metanorma
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 1.2.0
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 1.2.0
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: nokogiri
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,6 +150,20 @@ dependencies:
|
|
164
150
|
- - ">="
|
165
151
|
- !ruby/object:Gem::Version
|
166
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: mathml2asciimath
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: byebug
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -395,6 +395,7 @@ files:
|
|
395
395
|
- lib/isodoc/function/references.rb
|
396
396
|
- lib/isodoc/function/reqt.rb
|
397
397
|
- lib/isodoc/function/section.rb
|
398
|
+
- lib/isodoc/function/section_titles.rb
|
398
399
|
- lib/isodoc/function/table.rb
|
399
400
|
- lib/isodoc/function/terms.rb
|
400
401
|
- lib/isodoc/function/to_word_html.rb
|
@@ -410,7 +411,6 @@ files:
|
|
410
411
|
- lib/isodoc/html_function/mathvariant_to_plain.rb
|
411
412
|
- lib/isodoc/html_function/postprocess.rb
|
412
413
|
- lib/isodoc/html_function/postprocess_footnotes.rb
|
413
|
-
- lib/isodoc/html_function/sectionsplit.rb
|
414
414
|
- lib/isodoc/i18n.rb
|
415
415
|
- lib/isodoc/metadata.rb
|
416
416
|
- lib/isodoc/metadata_contributor.rb
|
@@ -440,6 +440,10 @@ files:
|
|
440
440
|
- lib/isodoc/xref/xref_gen_seq.rb
|
441
441
|
- lib/isodoc/xref/xref_sect_gen.rb
|
442
442
|
- lib/isodoc/xslfo_convert.rb
|
443
|
+
- lib/metanorma/output.rb
|
444
|
+
- lib/metanorma/output/base.rb
|
445
|
+
- lib/metanorma/output/utils.rb
|
446
|
+
- lib/metanorma/output/xslfo.rb
|
443
447
|
- spec/assets/header.html
|
444
448
|
- spec/assets/html.scss
|
445
449
|
- spec/assets/html_override.css
|
@@ -450,6 +454,8 @@ files:
|
|
450
454
|
- spec/assets/odf.emf
|
451
455
|
- spec/assets/odf.svg
|
452
456
|
- spec/assets/odf1.svg
|
457
|
+
- spec/assets/outputtest/a.xml
|
458
|
+
- spec/assets/outputtest/iso.international-standard.xsl
|
453
459
|
- spec/assets/rice_image1
|
454
460
|
- spec/assets/rice_image1.png
|
455
461
|
- spec/assets/scripts.html
|
@@ -471,7 +477,6 @@ files:
|
|
471
477
|
- spec/isodoc/presentation_xml_spec.rb
|
472
478
|
- spec/isodoc/ref_spec.rb
|
473
479
|
- spec/isodoc/section_spec.rb
|
474
|
-
- spec/isodoc/sectionsplit_spec.rb
|
475
480
|
- spec/isodoc/table_spec.rb
|
476
481
|
- spec/isodoc/terms_spec.rb
|
477
482
|
- spec/isodoc/xref_spec.rb
|
@@ -1,244 +0,0 @@
|
|
1
|
-
require "metanorma"
|
2
|
-
require "yaml"
|
3
|
-
|
4
|
-
module IsoDoc::HtmlFunction
|
5
|
-
module Html
|
6
|
-
# assume we pass in Presentation XML, but we want to recover Semantic XML
|
7
|
-
def sectionsplit_convert(input_filename, file, debug, output_filename = nil)
|
8
|
-
input_filename += ".xml" unless input_filename.match?(/\.xml$/)
|
9
|
-
File.exist?(input_filename) or
|
10
|
-
File.open(input_filename, "w:UTF-8") { |f| f.write(file) }
|
11
|
-
presxml = File.read(input_filename, encoding: "utf-8")
|
12
|
-
@openmathdelim, @closemathdelim = extract_delims(presxml)
|
13
|
-
xml, filename, dir = convert_init(presxml, input_filename, debug)
|
14
|
-
build_collection(xml, presxml, output_filename || filename, dir)
|
15
|
-
end
|
16
|
-
|
17
|
-
def build_collection(xml, presxml, filename, dir)
|
18
|
-
base = File.basename(filename)
|
19
|
-
collection_setup(base, dir)
|
20
|
-
files = sectionsplit(xml, base, dir)
|
21
|
-
collection_manifest(base, files, xml, presxml, dir).render(
|
22
|
-
format: %i(html), output_folder: "#{filename}_collection",
|
23
|
-
coverpage: File.join(dir, "cover.html")
|
24
|
-
)
|
25
|
-
end
|
26
|
-
|
27
|
-
def collection_manifest(filename, files, origxml, _presxml, dir)
|
28
|
-
File.open(File.join(dir, "#{filename}.html.yaml"), "w:UTF-8") do |f|
|
29
|
-
f.write(collectionyaml(files, origxml))
|
30
|
-
end
|
31
|
-
Metanorma::Collection.parse File.join(dir, "#{filename}.html.yaml")
|
32
|
-
end
|
33
|
-
|
34
|
-
def collection_setup(filename, dir)
|
35
|
-
FileUtils.mkdir_p "#{filename}_collection"
|
36
|
-
FileUtils.mkdir_p dir
|
37
|
-
File.open(File.join(dir, "cover.html"), "w:UTF-8") do |f|
|
38
|
-
f.write(coll_cover)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def coll_cover
|
43
|
-
<<~COVER
|
44
|
-
<html>
|
45
|
-
<head/>
|
46
|
-
<body>
|
47
|
-
<h1>{{ doctitle }}</h1>
|
48
|
-
<h2>{{ docnumber }}</h2>
|
49
|
-
<nav>{{ labels["navigation"] }}</nav>
|
50
|
-
</body>
|
51
|
-
</html>
|
52
|
-
COVER
|
53
|
-
end
|
54
|
-
|
55
|
-
def sectionsplit(xml, filename, dir)
|
56
|
-
xref_preprocess(xml)
|
57
|
-
out = emptydoc(xml)
|
58
|
-
[["//preface/*", "preface"], ["//sections/*", "sections"],
|
59
|
-
["//annex", nil],
|
60
|
-
["//bibliography/*[not(@hidden = 'true')]", "bibliography"],
|
61
|
-
["//indexsect", nil]].each_with_object([]) do |n, ret|
|
62
|
-
xml.xpath(ns(n[0])).each do |s|
|
63
|
-
ret << sectionfile(out, dir, "#{filename}.#{ret.size}", s, n[1])
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def emptydoc(xml)
|
69
|
-
out = xml.dup
|
70
|
-
out.xpath(
|
71
|
-
ns("//preface | //sections | //annex | //bibliography/clause | "\
|
72
|
-
"//bibliography/references[not(@hidden = 'true')] | //indexsect"),
|
73
|
-
).each(&:remove)
|
74
|
-
out
|
75
|
-
end
|
76
|
-
|
77
|
-
def sectionfile(xml, dir, file, chunk, parentnode)
|
78
|
-
fname = create_sectionfile(xml.dup, dir, file, chunk, parentnode)
|
79
|
-
{ order: chunk["displayorder"].to_i, url: fname,
|
80
|
-
title: titlerender(chunk) }
|
81
|
-
end
|
82
|
-
|
83
|
-
def create_sectionfile(out, dir, file, chunk, parentnode)
|
84
|
-
ins = out.at(ns("//misccontainer")) || out.at(ns("//bibdata"))
|
85
|
-
if parentnode
|
86
|
-
ins.next = "<#{parentnode}/>"
|
87
|
-
ins.next.add_child(chunk.dup)
|
88
|
-
else
|
89
|
-
ins.next = chunk.dup
|
90
|
-
end
|
91
|
-
outname = "#{file}.xml"
|
92
|
-
File.open(File.join(dir, outname), "w:UTF-8") { |f| f.write(out) }
|
93
|
-
outname
|
94
|
-
end
|
95
|
-
|
96
|
-
def xref_preprocess(xml)
|
97
|
-
svg_preprocess(xml)
|
98
|
-
key = (0...8).map { rand(65..90).chr }.join # random string
|
99
|
-
refs = eref_to_internal_eref(xml, key)
|
100
|
-
refs += xref_to_internal_eref(xml, key)
|
101
|
-
xml.root["type"] = key # to force recognition of internal refs
|
102
|
-
ins = new_hidden_ref(xml)
|
103
|
-
copy_repo_items_biblio(ins, xml)
|
104
|
-
insert_indirect_biblio(ins, refs, key)
|
105
|
-
end
|
106
|
-
|
107
|
-
def svg_preprocess(xml)
|
108
|
-
xml.xpath("//m:svg", "m" => "http://www.w3.org/2000/svg").each do |s|
|
109
|
-
m = svgmap_wrap(s)
|
110
|
-
s.xpath(".//m:a", "m" => "http://www.w3.org/2000/svg").each do |a|
|
111
|
-
next unless /^#/.match? a["href"]
|
112
|
-
|
113
|
-
a["href"] = a["href"].sub(/^#/, "")
|
114
|
-
m << "<target href='#{a['href']}'>"\
|
115
|
-
"<xref target='#{a['href']}'/></target>"
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def svgmap_wrap(svg)
|
121
|
-
ret = svg.at("./ancestor::xmlns:svgmap") and return ret
|
122
|
-
ret = svg.at("./ancestor::xmlns:figure")
|
123
|
-
ret.wrap("<svgmap/>")
|
124
|
-
svg.at("./ancestor::xmlns:svgmap")
|
125
|
-
end
|
126
|
-
|
127
|
-
def make_anchor(anchor)
|
128
|
-
"<localityStack><locality type='anchor'><referenceFrom>"\
|
129
|
-
"#{anchor}</referenceFrom></locality></localityStack>"
|
130
|
-
end
|
131
|
-
|
132
|
-
def xref_to_internal_eref(xml, key)
|
133
|
-
xml.xpath(ns("//xref")).each_with_object({}) do |x, m|
|
134
|
-
x["bibitemid"] = "#{key}_#{x['target']}"
|
135
|
-
x << make_anchor(x["target"])
|
136
|
-
m[x["bibitemid"]] = true
|
137
|
-
x.delete("target")
|
138
|
-
x["type"] = key
|
139
|
-
x.name = "eref"
|
140
|
-
end.keys
|
141
|
-
end
|
142
|
-
|
143
|
-
def eref_to_internal_eref(xml, key)
|
144
|
-
eref_to_internal_eref_select(xml).each_with_object([]) do |x, m|
|
145
|
-
url = xml.at(ns("//bibitem[@id = '#{x}']/url[@type = 'citation']"))
|
146
|
-
xml.xpath(("//*[@bibitemid = '#{x}']")).each do |e|
|
147
|
-
id = eref_to_internal_eref1(e, key, url)
|
148
|
-
id and m << id
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
def eref_to_internal_eref1(elem, key, url)
|
154
|
-
if url
|
155
|
-
elem.name = "link"
|
156
|
-
elem["target"] = url
|
157
|
-
nil
|
158
|
-
else
|
159
|
-
elem["bibitemid"] = "#{key}_#{elem['bibitemid']}"
|
160
|
-
elem << make_anchor(elem["bibitemid"])
|
161
|
-
elem["type"] = key
|
162
|
-
elem["bibitemid"]
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
def eref_to_internal_eref_select(xml)
|
167
|
-
refs = xml.xpath(("//*/@bibitemid")).map { |x| x.text } # rubocop:disable Style/SymbolProc
|
168
|
-
refs.uniq.reject do |x|
|
169
|
-
xml.at(ns("//bibitem[@id = '#{x}'][@type = 'internal']")) ||
|
170
|
-
xml.at(ns("//bibitem[@id = '#{x}']"\
|
171
|
-
"[docidentifier/@type = 'repository']"))
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
# from standoc
|
176
|
-
def new_hidden_ref(xmldoc)
|
177
|
-
ins = xmldoc.at("bibliography") or
|
178
|
-
xmldoc.root << "<bibliography/>" and ins = xmldoc.at("bibliography")
|
179
|
-
ins.add_child("<references hidden='true' normative='false'/>").first
|
180
|
-
end
|
181
|
-
|
182
|
-
def copy_repo_items_biblio(ins, xml)
|
183
|
-
xml.xpath(ns("//references/bibitem[docidentifier/@type = 'repository']"))
|
184
|
-
.each do |b|
|
185
|
-
ins << b.dup
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
def insert_indirect_biblio(ins, refs, prefix)
|
190
|
-
refs.each do |x|
|
191
|
-
ins << <<~BIBENTRY
|
192
|
-
<bibitem id="#{x}" type="internal">
|
193
|
-
<docidentifier type="repository">#{x.sub(/^#{prefix}_/, "#{prefix}/")}</docidentifier>
|
194
|
-
</bibitem>
|
195
|
-
BIBENTRY
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
def recursive_string_keys(hash)
|
200
|
-
case hash
|
201
|
-
when Hash then Hash[
|
202
|
-
hash.map { |k, v| [k.to_s, recursive_string_keys(v)] }
|
203
|
-
]
|
204
|
-
when Enumerable then hash.map { |v| recursive_string_keys(v) }
|
205
|
-
else
|
206
|
-
hash
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
def titlerender(section)
|
211
|
-
title = section.at(ns("./title")) or return "[Untitled]"
|
212
|
-
t = title.dup
|
213
|
-
t.xpath(ns(".//tab | .//br")).each { |x| x.replace(" ") }
|
214
|
-
t.xpath(ns(".//strong")).each { |x| x.replace(x.children) }
|
215
|
-
t.children.to_xml
|
216
|
-
end
|
217
|
-
|
218
|
-
def collectionyaml(files, xml)
|
219
|
-
ret = {
|
220
|
-
directives: ["presentation-xml", "bare-after-first"],
|
221
|
-
bibdata: {
|
222
|
-
title: {
|
223
|
-
type: "title-main",
|
224
|
-
language: @lang,
|
225
|
-
content: xml.at(ns("//bibdata/title")).text,
|
226
|
-
},
|
227
|
-
type: "collection",
|
228
|
-
docid: {
|
229
|
-
type: xml.at(ns("//bibdata/docidentifier/@type")).text,
|
230
|
-
id: xml.at(ns("//bibdata/docidentifier")).text,
|
231
|
-
},
|
232
|
-
},
|
233
|
-
manifest: {
|
234
|
-
level: "collection",
|
235
|
-
title: "Collection",
|
236
|
-
docref: files.sort_by { |f| f[:order] }.each.map do |f|
|
237
|
-
{ fileref: f[:url], identifier: f[:title] }
|
238
|
-
end,
|
239
|
-
},
|
240
|
-
}
|
241
|
-
recursive_string_keys(ret).to_yaml
|
242
|
-
end
|
243
|
-
end
|
244
|
-
end
|
@@ -1,190 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe IsoDoc do
|
4
|
-
it "processes section split HTML" do
|
5
|
-
FileUtils.rm_f "test.xml"
|
6
|
-
FileUtils.rm_f "test.html.yaml"
|
7
|
-
FileUtils.rm_rf "test_collection"
|
8
|
-
FileUtils.rm_rf "test_files"
|
9
|
-
input = <<~INPUT
|
10
|
-
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
11
|
-
<bibdata>
|
12
|
-
<title>ISO Title</title>
|
13
|
-
<docidentifier type="ISO">ISO 1</docidentifier>
|
14
|
-
</bibdata>
|
15
|
-
<preface>
|
16
|
-
<abstract id="A" displayorder='1'><title>abstract</title></abstract>
|
17
|
-
<introduction id="B" displayorder='2'><title>introduction</title></introduction>
|
18
|
-
</preface>
|
19
|
-
<sections>
|
20
|
-
<clause id="M" inline-header="false" obligation="normative" displayorder='4'>
|
21
|
-
<title>Clause 4</title>
|
22
|
-
<clause id="N" inline-header="false" obligation="normative">
|
23
|
-
<title>Introduction</title>
|
24
|
-
<p><xref target="A">HE</xref></p>
|
25
|
-
<p><eref bibitemid="R1">SHE</xref></p>
|
26
|
-
<svgmap>
|
27
|
-
<figure>
|
28
|
-
<svg xmlns="http://www.w3.org/2000/svg">
|
29
|
-
<a href="#A">A</a>
|
30
|
-
<a href="#B">B</a>
|
31
|
-
</svg>
|
32
|
-
<target href="B"><eref bibitemid="R1"/></target>
|
33
|
-
</figure>
|
34
|
-
</svgmap>
|
35
|
-
<figure>
|
36
|
-
<svg xmlns="http://www.w3.org/2000/svg">
|
37
|
-
<a href="#P">P</a>
|
38
|
-
</svg>
|
39
|
-
</figure>
|
40
|
-
</clause>
|
41
|
-
<clause id="O" inline-header="true" obligation="normative">
|
42
|
-
<title>Clause 4.2</title>
|
43
|
-
</clause></clause>
|
44
|
-
<admonition id="L" type="caution"><p>admonition</p></admonition>
|
45
|
-
</sections>
|
46
|
-
<annex id="P" inline-header="false" obligation="normative" displayorder='5'>
|
47
|
-
<title><strong>Annex</strong><br/>(informative)</title>
|
48
|
-
<clause id="Q" inline-header="false" obligation="normative">
|
49
|
-
<title>Annex A.1</title>
|
50
|
-
<clause id="Q1" inline-header="false" obligation="normative">
|
51
|
-
<title>Annex A.1a</title>
|
52
|
-
</clause>
|
53
|
-
<references id="Q2" normative="false">
|
54
|
-
<title>Annex Bibliography</title>
|
55
|
-
</references>
|
56
|
-
</clause>
|
57
|
-
</annex>
|
58
|
-
<annex id="P1" inline-header="false" obligation="normative" displayorder='6'>
|
59
|
-
</annex>
|
60
|
-
<bibliography><references id="R" obligation="informative" normative="true" displayorder='3'>
|
61
|
-
<title>Normative References</title>
|
62
|
-
<bibitem id="R1"><docidentifier>R1</docidentifier><title>Hello</title></bibitem>
|
63
|
-
</references><clause id="S" obligation="informative" displayorder='7'>
|
64
|
-
<title>Bibliography</title>
|
65
|
-
<references id="T" obligation="informative" normative="false">
|
66
|
-
<title>Bibliography Subsection</title>
|
67
|
-
</references>
|
68
|
-
</clause>
|
69
|
-
</bibliography>
|
70
|
-
</iso-standard>
|
71
|
-
INPUT
|
72
|
-
mock_render
|
73
|
-
IsoDoc::HtmlConvert.new({ sectionsplit: "true" })
|
74
|
-
.convert("test", input, true)
|
75
|
-
expect(File.exist?("test_collection/index.html")).to be true
|
76
|
-
expect(File.exist?("test_collection/test.0.html")).to be true
|
77
|
-
expect(File.exist?("test_collection/test.1.html")).to be true
|
78
|
-
expect(File.exist?("test_collection/test.2.html")).to be true
|
79
|
-
expect(File.exist?("test_collection/test.3.html")).to be false
|
80
|
-
expect(File.exist?("test_collection/test.4.html")).to be true
|
81
|
-
expect(File.exist?("test_collection/test.5.html")).to be true
|
82
|
-
expect(File.exist?("test_collection/test.6.html")).to be true
|
83
|
-
expect(File.exist?("test_collection/test.7.html")).to be true
|
84
|
-
expect(File.exist?("test_collection/test.8.html")).to be false
|
85
|
-
expect(File.exist?("test_files/cover.html")).to be true
|
86
|
-
expect(File.exist?("test_files/test.0.xml")).to be true
|
87
|
-
expect(File.exist?("test_files/test.1.xml")).to be true
|
88
|
-
expect(File.exist?("test_files/test.2.xml")).to be true
|
89
|
-
expect(File.exist?("test_files/test.3.xml")).to be true
|
90
|
-
expect(File.exist?("test_files/test.4.xml")).to be true
|
91
|
-
expect(File.exist?("test_files/test.5.xml")).to be true
|
92
|
-
expect(File.exist?("test_files/test.6.xml")).to be true
|
93
|
-
expect(File.exist?("test_files/test.7.xml")).to be true
|
94
|
-
expect(File.exist?("test_files/test.8.xml")).to be false
|
95
|
-
expect(File.exist?("test_files/test.html.yaml")).to be true
|
96
|
-
m = /type="([^"]+)"/.match(File.read("test_files/test.0.xml"))
|
97
|
-
file2 = Nokogiri::XML(File.read("test_files/test.2.xml"))
|
98
|
-
expect(xmlpp(file2
|
99
|
-
.at("//xmlns:eref[@bibitemid = '#{m[1]}_A']").to_xml))
|
100
|
-
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
101
|
-
<eref bibitemid="#{m[1]}_A" type="#{m[1]}">HE<localityStack><locality type="anchor"><referenceFrom>A</referenceFrom></locality></localityStack></eref>
|
102
|
-
OUTPUT
|
103
|
-
expect(xmlpp(file2
|
104
|
-
.at("//xmlns:eref[@bibitemid = '#{m[1]}_R1']").to_xml))
|
105
|
-
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
106
|
-
<eref bibitemid="#{m[1]}_R1" type="#{m[1]}">SHE<localityStack><locality type="anchor"><referenceFrom>#{m[1]}_R1</referenceFrom></locality></localityStack></eref>
|
107
|
-
OUTPUT
|
108
|
-
expect(xmlpp(file2
|
109
|
-
.at("//xmlns:bibitem[@id = '#{m[1]}_R1']").to_xml))
|
110
|
-
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
111
|
-
<bibitem id="#{m[1]}_R1" type="internal">
|
112
|
-
<docidentifier type="repository">#{m[1]}/R1</docidentifier>
|
113
|
-
</bibitem>
|
114
|
-
OUTPUT
|
115
|
-
expect(xmlpp(file2
|
116
|
-
.at("//xmlns:bibitem[@id = '#{m[1]}_A']").to_xml))
|
117
|
-
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
118
|
-
<bibitem id="#{m[1]}_A" type="internal">
|
119
|
-
<docidentifier type="repository">#{m[1]}/A</docidentifier>
|
120
|
-
</bibitem>
|
121
|
-
OUTPUT
|
122
|
-
expect(xmlpp(file2
|
123
|
-
.at("//xmlns:svgmap[1]").to_xml))
|
124
|
-
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
125
|
-
<svgmap>
|
126
|
-
<figure>
|
127
|
-
<svg xmlns="http://www.w3.org/2000/svg">
|
128
|
-
<a href="A">A</a>
|
129
|
-
<a href="B">B</a>
|
130
|
-
</svg>
|
131
|
-
<target href="B"><eref bibitemid="#{m[1]}_R1" type="#{m[1]}"><localityStack><locality type="anchor"><referenceFrom>#{m[1]}_R1</referenceFrom></locality></localityStack></eref></target>
|
132
|
-
</figure>
|
133
|
-
<target href="A"><eref bibitemid="#{m[1]}_A" type="#{m[1]}"><localityStack><locality type="anchor"><referenceFrom>A</referenceFrom></locality></localityStack></eref></target><target href="B"><eref bibitemid="#{m[1]}_B" type="#{m[1]}"><localityStack><locality type="anchor"><referenceFrom>B</referenceFrom></locality></localityStack></eref></target></svgmap>
|
134
|
-
OUTPUT
|
135
|
-
expect(xmlpp(file2
|
136
|
-
.at("//xmlns:svgmap[2]").to_xml))
|
137
|
-
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
138
|
-
<svgmap><figure>
|
139
|
-
<svg xmlns="http://www.w3.org/2000/svg">
|
140
|
-
<a href="P">P</a>
|
141
|
-
</svg>
|
142
|
-
</figure><target href="P"><eref bibitemid="#{m[1]}_P" type="#{m[1]}"><localityStack><locality type="anchor"><referenceFrom>P</referenceFrom></locality></localityStack></eref></target></svgmap>
|
143
|
-
OUTPUT
|
144
|
-
expect(File.read("test_files/test.html.yaml")).to be_equivalent_to <<~OUTPUT
|
145
|
-
---
|
146
|
-
directives:
|
147
|
-
- presentation-xml
|
148
|
-
- bare-after-first
|
149
|
-
bibdata:
|
150
|
-
title:
|
151
|
-
type: title-main
|
152
|
-
language: en
|
153
|
-
content: ISO Title
|
154
|
-
type: collection
|
155
|
-
docid:
|
156
|
-
type: ISO
|
157
|
-
id: ISO 1
|
158
|
-
manifest:
|
159
|
-
level: collection
|
160
|
-
title: Collection
|
161
|
-
docref:
|
162
|
-
- fileref: test.3.xml
|
163
|
-
identifier: "[Untitled]"
|
164
|
-
- fileref: test.0.xml
|
165
|
-
identifier: abstract
|
166
|
-
- fileref: test.1.xml
|
167
|
-
identifier: introduction
|
168
|
-
- fileref: test.6.xml
|
169
|
-
identifier: Normative References
|
170
|
-
- fileref: test.2.xml
|
171
|
-
identifier: Clause 4
|
172
|
-
- fileref: test.4.xml
|
173
|
-
identifier: Annex (informative)
|
174
|
-
- fileref: test.5.xml
|
175
|
-
identifier: "[Untitled]"
|
176
|
-
- fileref: test.7.xml
|
177
|
-
identifier: Bibliography
|
178
|
-
OUTPUT
|
179
|
-
end
|
180
|
-
|
181
|
-
private
|
182
|
-
|
183
|
-
def mock_render
|
184
|
-
original_add = ::Metanorma::CollectionRenderer.method(:render)
|
185
|
-
allow(::Metanorma::CollectionRenderer)
|
186
|
-
.to receive(:render) do |col, opts|
|
187
|
-
original_add.call(col, opts.merge(compile: { no_install_fonts: true }))
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|