isodoc 1.8.3 → 1.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isodoc/base_style/all.css +9 -0
- data/lib/isodoc/base_style/reset.css +9 -0
- data/lib/isodoc/base_style/reset.scss +11 -0
- data/lib/isodoc/class_utils.rb +18 -6
- data/lib/isodoc/convert.rb +8 -1
- data/lib/isodoc/function/blocks.rb +4 -1
- data/lib/isodoc/function/to_word_html.rb +3 -3
- data/lib/isodoc/function/utils.rb +12 -14
- data/lib/isodoc/headlesshtml_convert.rb +1 -1
- data/lib/isodoc/html_convert.rb +1 -1
- data/lib/isodoc/i18n.rb +6 -3
- data/lib/isodoc/pdf_convert.rb +1 -1
- data/lib/isodoc/presentation_function/section.rb +16 -0
- data/lib/isodoc/presentation_function/terms.rb +31 -23
- data/lib/isodoc/presentation_xml_convert.rb +1 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/xslfo_convert.rb +1 -2
- data/spec/isodoc/postproc_spec.rb +18 -16
- data/spec/isodoc/section_spec.rb +847 -601
- data/spec/isodoc/terms_spec.rb +7 -9
- data/spec/isodoc/utils_spec.rb +57 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3189a7f65994e9185f29009eb40bb6589c83f579996199d34c669b44883a6548
|
4
|
+
data.tar.gz: 8462af8b54793cbc7dda2e98a2005a8ec11d4d17657a3fb63b3f2865950cf8c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cd5b57e05c214e49e703f808799195e4b1d7b158a9e07fd4e728a369b8f1406d735eb7576e182abe28ba40529dc22a70db28f50e77f2548aed08ae0ff139d5c
|
7
|
+
data.tar.gz: 12eb151374efdde8fd26302aeecdde46e25a7db4147f4bbf1dd54256f460f8ef5f29880bbaa170171abb5d451bf11b1d1b29ff24bbba15746d28249f5ec283f6
|
@@ -68,6 +68,12 @@ code *, pre *, tt *, kbd *, samp * {
|
|
68
68
|
font-family: {{monospacefont}} !important;
|
69
69
|
font-variant-ligatures: none; }
|
70
70
|
|
71
|
+
p code, dt code, li code, label code, legend code, caption code, th code, td code,
|
72
|
+
p tt, dt tt, li tt, label tt, legend tt, caption tt, th tt, td tt,
|
73
|
+
p kbd, dt kbd, li kbd, label kbd, legend kbd, caption kbd, th kbd, td kbd,
|
74
|
+
p samp, dt samp, li samp, label samp, legend samp, caption samp, th samp, td samp {
|
75
|
+
font-size: {{monospacefontsize}}; }
|
76
|
+
|
71
77
|
article, aside, details, figcaption, figure,
|
72
78
|
footer, header, hgroup, menu, nav, section {
|
73
79
|
display: block; }
|
@@ -79,6 +85,9 @@ table {
|
|
79
85
|
h1, h2, h3, h4, h5, h6 {
|
80
86
|
font-family: {{headerfont}}; }
|
81
87
|
|
88
|
+
.h1, .h2, .h3, .h4, .h5, .h6 {
|
89
|
+
font-family: {{headerfont}}; }
|
90
|
+
|
82
91
|
blockquote, q {
|
83
92
|
quotes: none; }
|
84
93
|
blockquote:before, blockquote:after, q:before, q:after {
|
@@ -68,6 +68,12 @@ code *, pre *, tt *, kbd *, samp * {
|
|
68
68
|
font-family: {{monospacefont}} !important;
|
69
69
|
font-variant-ligatures: none; }
|
70
70
|
|
71
|
+
p code, dt code, li code, label code, legend code, caption code, th code, td code,
|
72
|
+
p tt, dt tt, li tt, label tt, legend tt, caption tt, th tt, td tt,
|
73
|
+
p kbd, dt kbd, li kbd, label kbd, legend kbd, caption kbd, th kbd, td kbd,
|
74
|
+
p samp, dt samp, li samp, label samp, legend samp, caption samp, th samp, td samp {
|
75
|
+
font-size: {{monospacefontsize}}; }
|
76
|
+
|
71
77
|
article, aside, details, figcaption, figure,
|
72
78
|
footer, header, hgroup, menu, nav, section {
|
73
79
|
display: block; }
|
@@ -79,6 +85,9 @@ table {
|
|
79
85
|
h1, h2, h3, h4, h5, h6 {
|
80
86
|
font-family: {{headerfont}}; }
|
81
87
|
|
88
|
+
.h1, .h2, .h3, .h4, .h5, .h6 {
|
89
|
+
font-family: {{headerfont}}; }
|
90
|
+
|
82
91
|
blockquote, q {
|
83
92
|
quotes: none; }
|
84
93
|
blockquote:before, blockquote:after, q:before, q:after {
|
@@ -74,6 +74,13 @@ code *, pre *, tt *, kbd *, samp * {
|
|
74
74
|
font-variant-ligatures: none;
|
75
75
|
}
|
76
76
|
|
77
|
+
p code, dt code, li code, label code, legend code, caption code, th code, td code,
|
78
|
+
p tt, dt tt, li tt, label tt, legend tt, caption tt, th tt, td tt,
|
79
|
+
p kbd, dt kbd, li kbd, label kbd, legend kbd, caption kbd, th kbd, td kbd,
|
80
|
+
p samp, dt samp, li samp, label samp, legend samp, caption samp, th samp, td samp {
|
81
|
+
font-size: $monospacefontsize;
|
82
|
+
}
|
83
|
+
|
77
84
|
article, aside, details, figcaption, figure,
|
78
85
|
footer, header, hgroup, menu, nav, section {
|
79
86
|
display: block;
|
@@ -88,6 +95,10 @@ h1, h2, h3, h4, h5, h6 {
|
|
88
95
|
font-family: $headerfont;
|
89
96
|
}
|
90
97
|
|
98
|
+
.h1, .h2, .h3, .h4, .h5, .h6 {
|
99
|
+
font-family: $headerfont;
|
100
|
+
}
|
101
|
+
|
91
102
|
blockquote, q {
|
92
103
|
quotes: none;
|
93
104
|
|
data/lib/isodoc/class_utils.rb
CHANGED
@@ -28,25 +28,37 @@ module IsoDoc
|
|
28
28
|
Liquid::Template.parse(doc)
|
29
29
|
end
|
30
30
|
|
31
|
-
def case_strict(text, casing, script)
|
31
|
+
def case_strict(text, casing, script, firstonly: true)
|
32
32
|
return text unless %w(Latn Cyrl Grek Armn).include?(script)
|
33
33
|
|
34
|
-
|
34
|
+
seen = false
|
35
|
+
text.split(/(\s+)/).map do |w|
|
36
|
+
letters = w.chars
|
37
|
+
case_strict1(letters, casing) if !seen || !firstonly
|
38
|
+
seen ||= /\S/.match?(w)
|
39
|
+
letters.join
|
40
|
+
end.join
|
41
|
+
end
|
42
|
+
|
43
|
+
def case_strict1(letters, casing)
|
44
|
+
return letters if letters.empty?
|
45
|
+
|
35
46
|
case casing
|
36
47
|
when "capital" then letters.first.upcase!
|
37
48
|
when "lowercase" then letters.first.downcase!
|
49
|
+
when "allcaps" then letters.map(&:upcase!)
|
38
50
|
end
|
39
|
-
letters.join
|
40
51
|
end
|
41
52
|
|
42
|
-
def case_with_markup(linkend, casing, script)
|
53
|
+
def case_with_markup(linkend, casing, script, firstonly: true)
|
43
54
|
seen = false
|
44
55
|
xml = Nokogiri::XML("<root>#{linkend}</root>")
|
45
56
|
xml.traverse do |b|
|
46
57
|
next unless b.text? && !seen
|
47
58
|
|
48
|
-
b.replace(Common::case_strict(b.text, casing, script
|
49
|
-
|
59
|
+
b.replace(Common::case_strict(b.text, casing, script,
|
60
|
+
firstonly: firstonly))
|
61
|
+
seen = true if firstonly
|
50
62
|
end
|
51
63
|
xml.root.children.to_xml
|
52
64
|
end
|
data/lib/isodoc/convert.rb
CHANGED
@@ -5,6 +5,7 @@ require "fileutils"
|
|
5
5
|
require "tempfile"
|
6
6
|
require_relative "i18n"
|
7
7
|
require_relative "css"
|
8
|
+
require "securerandom"
|
8
9
|
|
9
10
|
module IsoDoc
|
10
11
|
class Convert < ::IsoDoc::Common
|
@@ -103,10 +104,16 @@ module IsoDoc
|
|
103
104
|
@fn_bookmarks = {}
|
104
105
|
@baseassetpath = options[:baseassetpath]
|
105
106
|
@aligncrosselements = options[:aligncrosselements]
|
107
|
+
@tmpimagedir_suffix = tmpimagedir_suffix
|
108
|
+
@tmpfilesdir_suffix = tmpfilesdir_suffix
|
106
109
|
end
|
107
110
|
|
108
111
|
def tmpimagedir_suffix
|
109
|
-
"_images"
|
112
|
+
"_#{SecureRandom.hex(8)}_images"
|
113
|
+
end
|
114
|
+
|
115
|
+
def tmpfilesdir_suffix
|
116
|
+
"_#{SecureRandom.hex(8)}_files"
|
110
117
|
end
|
111
118
|
|
112
119
|
def html_doc_path(*file)
|
@@ -174,10 +174,13 @@ module IsoDoc
|
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
177
|
-
def para_class(
|
177
|
+
def para_class(node)
|
178
178
|
classtype = nil
|
179
179
|
classtype = "MsoCommentText" if in_comment
|
180
180
|
classtype = "Sourcecode" if @annotation
|
181
|
+
if node["type"] == "floating-title"
|
182
|
+
classtype = "h#{node['depth']}"
|
183
|
+
end
|
181
184
|
classtype
|
182
185
|
end
|
183
186
|
|
@@ -30,7 +30,7 @@ module IsoDoc
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def init_dir(filename, debug)
|
33
|
-
dir = "#{filename}
|
33
|
+
dir = "#{filename}#{@tmpfilesdir_suffix}"
|
34
34
|
unless debug
|
35
35
|
Dir.mkdir(dir, 0o777) unless File.exists?(dir)
|
36
36
|
FileUtils.rm_rf "#{dir}/*"
|
@@ -40,11 +40,11 @@ module IsoDoc
|
|
40
40
|
|
41
41
|
# tmp image dir is same directory as @filename
|
42
42
|
def tmpimagedir
|
43
|
-
@filename + tmpimagedir_suffix
|
43
|
+
@filename + @tmpimagedir_suffix
|
44
44
|
end
|
45
45
|
|
46
46
|
def rel_tmpimagedir
|
47
|
-
Pathname.new(@filename).basename.to_s + tmpimagedir_suffix
|
47
|
+
Pathname.new(@filename).basename.to_s + @tmpimagedir_suffix
|
48
48
|
end
|
49
49
|
|
50
50
|
# isodoc.css overrides any CSS injected by Html2Doc, which
|
@@ -142,9 +142,9 @@ module IsoDoc
|
|
142
142
|
|
143
143
|
def header_strip_elem?(elem)
|
144
144
|
elem.name == "img" ||
|
145
|
-
elem.name == "span" && elem["class"] == "MsoCommentReference" ||
|
146
|
-
elem.name == "a" && elem["class"] == "FootnoteRef" ||
|
147
|
-
elem.name == "span" && /mso-bookmark/.match(elem["style"])
|
145
|
+
(elem.name == "span" && elem["class"] == "MsoCommentReference") ||
|
146
|
+
(elem.name == "a" && elem["class"] == "FootnoteRef") ||
|
147
|
+
(elem.name == "span" && /mso-bookmark/.match(elem["style"]))
|
148
148
|
end
|
149
149
|
|
150
150
|
def liquid(doc)
|
@@ -192,12 +192,6 @@ module IsoDoc
|
|
192
192
|
save_dataimage(img["src"], false)
|
193
193
|
when %r{^([A-Z]:)?/}
|
194
194
|
img["src"]
|
195
|
-
=begin
|
196
|
-
if /^data:/.match? img["src"]
|
197
|
-
save_dataimage(img["src"], false)
|
198
|
-
elsif %r{^([A-Z]:)?/}.match? img["src"]
|
199
|
-
img["src"]
|
200
|
-
=end
|
201
195
|
else
|
202
196
|
File.join(@localdir, img["src"])
|
203
197
|
end
|
@@ -213,12 +207,16 @@ module IsoDoc
|
|
213
207
|
application/x-msmetafile image/x-xbitmap).include? type
|
214
208
|
end
|
215
209
|
|
216
|
-
def cleanup_entities(text)
|
210
|
+
def cleanup_entities(text, is_xml: true)
|
217
211
|
c = HTMLEntities.new
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
212
|
+
if is_xml
|
213
|
+
text.split(/([<>])/).each_slice(4).map do |a|
|
214
|
+
a[0] = c.encode(c.decode(a[0]), :hexadecimal)
|
215
|
+
a
|
216
|
+
end.join
|
217
|
+
else
|
218
|
+
c.encode(c.decode(text), :hexadecimal)
|
219
|
+
end
|
222
220
|
end
|
223
221
|
|
224
222
|
def external_path(path)
|
data/lib/isodoc/html_convert.rb
CHANGED
data/lib/isodoc/i18n.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "yaml"
|
2
|
+
require_relative "function/utils"
|
2
3
|
|
3
4
|
module IsoDoc
|
4
5
|
class I18n
|
@@ -17,7 +18,7 @@ module IsoDoc
|
|
17
18
|
end
|
18
19
|
ret
|
19
20
|
when Array then ret.map { |n| normalise_hash(n) }
|
20
|
-
when String then ret.unicode_normalize(:nfc)
|
21
|
+
when String then cleanup_entities(ret.unicode_normalize(:nfc))
|
21
22
|
else ret
|
22
23
|
end
|
23
24
|
end
|
@@ -96,8 +97,9 @@ module IsoDoc
|
|
96
97
|
xml.traverse do |n|
|
97
98
|
next unless n.text?
|
98
99
|
|
99
|
-
n.replace(n.text.gsub(/ /, "").gsub(/:/, ":")
|
100
|
-
.gsub(
|
100
|
+
n.replace(cleanup_entities(n.text.gsub(/ /, "").gsub(/:/, ":")
|
101
|
+
.gsub(/,/, "、").gsub(/\(/, "(").gsub(/\)/, ")")
|
102
|
+
.gsub(/\[/, "【").gsub(/\]/, "】"), is_xml: false))
|
101
103
|
end
|
102
104
|
xml.to_xml.gsub(/<b>/, "").gsub("</b>", "").gsub(/<\?[^>]+>/, "")
|
103
105
|
end
|
@@ -111,6 +113,7 @@ module IsoDoc
|
|
111
113
|
l10n(names[0..-2].join(", ") + " #{andword} #{names[-1]}", @lang, @script)
|
112
114
|
end
|
113
115
|
|
116
|
+
include Function::Utils
|
114
117
|
# module_function :l10n
|
115
118
|
end
|
116
119
|
end
|
data/lib/isodoc/pdf_convert.rb
CHANGED
@@ -19,6 +19,22 @@ module IsoDoc
|
|
19
19
|
prefix_name(elem, "<tab/>", "#{lbl}#{clausedelim}", "title")
|
20
20
|
end
|
21
21
|
|
22
|
+
def floattitle(docxml)
|
23
|
+
docxml.xpath(ns("//clause | //annex | //appendix | //introduction | "\
|
24
|
+
"//foreword | //preface/abstract | //acknowledgements | "\
|
25
|
+
"//terms | //definitions | //references"))
|
26
|
+
.each do |f|
|
27
|
+
floattitle1(f)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def floattitle1(elem)
|
32
|
+
level = @xrefs.anchor(elem["id"], :level, false) || "1"
|
33
|
+
elem.xpath(ns("./p[@type = 'floating-title']")).each do |p|
|
34
|
+
p["depth"] = level.to_i + 1
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
22
38
|
def annex(docxml)
|
23
39
|
docxml.xpath(ns("//annex")).each do |f|
|
24
40
|
annex1(f)
|
@@ -6,35 +6,40 @@ module IsoDoc
|
|
6
6
|
|
7
7
|
def concept1(node)
|
8
8
|
xref = node&.at(ns("./xref/@target"))&.text or
|
9
|
-
return concept_render(node, ital:
|
10
|
-
|
11
|
-
linkref: node["linkref"] || "true",
|
12
|
-
linkmention: node["linkmention"] || "false")
|
9
|
+
return concept_render(node, ital: "true", ref: "true",
|
10
|
+
linkref: "true", linkmention: "false")
|
13
11
|
if node.at(ns("//definitions//dt[@id = '#{xref}']"))
|
14
|
-
concept_render(node, ital:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
else concept_render(node, ital: node["ital"] || "true",
|
19
|
-
ref: node["ref"] || "true",
|
20
|
-
linkref: node["linkref"] || "true",
|
21
|
-
linkmention: node["linkmention"] || "false")
|
12
|
+
concept_render(node, ital: "false", ref: "false",
|
13
|
+
linkref: "true", linkmention: "false")
|
14
|
+
else concept_render(node, ital: "true", ref: "true",
|
15
|
+
linkref: "true", linkmention: "false")
|
22
16
|
end
|
23
17
|
end
|
24
18
|
|
25
|
-
def concept_render(node,
|
19
|
+
def concept_render(node, defaults)
|
20
|
+
opts, render, ref = concept_render_init(node, defaults)
|
26
21
|
node&.at(ns("./refterm"))&.remove
|
27
|
-
|
28
|
-
|
29
|
-
ref
|
30
|
-
opts[:ital] == "true" and r&.name = "em"
|
31
|
-
concept1_linkmention(ref, r, opts)
|
22
|
+
ref && opts[:ref] != "false" and render&.next = " "
|
23
|
+
opts[:ital] == "true" and render&.name = "em"
|
24
|
+
concept1_linkmention(ref, render, opts)
|
32
25
|
concept1_ref(node, ref, opts)
|
26
|
+
concept1_nonital(node, opts)
|
27
|
+
node.replace(node.children)
|
28
|
+
end
|
29
|
+
|
30
|
+
def concept1_nonital(node, opts)
|
33
31
|
if opts[:ital] == "false"
|
34
32
|
r = node.at(ns(".//renderterm"))
|
35
33
|
r&.replace(r&.children)
|
36
34
|
end
|
37
|
-
|
35
|
+
end
|
36
|
+
|
37
|
+
def concept_render_init(node, defaults)
|
38
|
+
opts = %i(ital ref linkref linkmention).each_with_object({}) do |x, m|
|
39
|
+
m[x] = node[x.to_s] || defaults[x]
|
40
|
+
end
|
41
|
+
[opts, node.at(ns("./renderterm")),
|
42
|
+
node.at(ns("./xref | ./eref | ./termref"))]
|
38
43
|
end
|
39
44
|
|
40
45
|
def concept1_linkmention(ref, renderterm, opts)
|
@@ -221,20 +226,23 @@ module IsoDoc
|
|
221
226
|
end
|
222
227
|
|
223
228
|
def termsource(docxml)
|
229
|
+
docxml.xpath(ns("//termsource/modification")).each do |f|
|
230
|
+
termsource_modification(f)
|
231
|
+
end
|
224
232
|
docxml.xpath(ns("//termsource")).each do |f|
|
225
233
|
termsource1(f)
|
226
234
|
end
|
227
235
|
end
|
228
236
|
|
229
237
|
def termsource1(elem)
|
230
|
-
|
231
|
-
|
238
|
+
while elem&.next_element&.name == "termsource"
|
239
|
+
elem << "; #{elem.next_element.remove.children.to_xml}"
|
240
|
+
end
|
232
241
|
elem.children = l10n("[#{@i18n.source}: #{elem.children.to_xml.strip}]")
|
233
|
-
elem&.next_element&.name == "termsource" and elem.next = "; "
|
234
242
|
end
|
235
243
|
|
236
244
|
def termsource_modification(mod)
|
237
|
-
mod.previous_element.next = ", #{@i18n.modified}"
|
245
|
+
mod.previous_element.next = l10n(", #{@i18n.modified}")
|
238
246
|
mod.text.strip.empty? or mod.previous = " – "
|
239
247
|
mod.elements.size == 1 and
|
240
248
|
mod.elements[0].replace(mod.elements[0].children)
|
data/lib/isodoc/version.rb
CHANGED
data/lib/isodoc/xslfo_convert.rb
CHANGED
@@ -33,7 +33,7 @@ module IsoDoc
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def tmpimagedir_suffix
|
36
|
-
"_pdfimages"
|
36
|
+
"_#{SecureRandom.hex(8)}_pdfimages"
|
37
37
|
end
|
38
38
|
|
39
39
|
def pdf_stylesheet(_docxml)
|
@@ -58,7 +58,6 @@ module IsoDoc
|
|
58
58
|
file = File.read(input_filename, encoding: "utf-8") if file.nil?
|
59
59
|
input_filename, docxml, filename = input_xml_path(input_filename,
|
60
60
|
file, debug)
|
61
|
-
warn pdf_options(docxml).merge(@options)
|
62
61
|
::Metanorma::Output::XslfoPdf.new.convert(
|
63
62
|
input_filename,
|
64
63
|
output_filename || "#{filename}.#{@suffix}",
|
@@ -726,9 +726,9 @@ RSpec.describe IsoDoc do
|
|
726
726
|
OUTPUT
|
727
727
|
end
|
728
728
|
|
729
|
-
it "moves images in HTML" do
|
729
|
+
it "moves images in HTML #1" do
|
730
730
|
FileUtils.rm_f "test.html"
|
731
|
-
FileUtils.rm_rf "
|
731
|
+
FileUtils.rm_rf Dir.glob "test_*_htmlimages"
|
732
732
|
IsoDoc::HtmlConvert.new(
|
733
733
|
{ wordstylesheet: "spec/assets/word.css",
|
734
734
|
htmlstylesheet: "spec/assets/html.scss" },
|
@@ -750,8 +750,9 @@ RSpec.describe IsoDoc do
|
|
750
750
|
html = File.read("test.html")
|
751
751
|
.sub(/^.*<main class="main-section">/m, '<main class="main-section">')
|
752
752
|
.sub(%r{</main>.*$}m, "</main>")
|
753
|
-
expect(`ls
|
754
|
-
expect(xmlpp(html.gsub(/\/[0-9a-f-]+\.png/, "/_.png"))
|
753
|
+
expect(`ls test_*_htmlimages`).to match(/\.png$/)
|
754
|
+
expect(xmlpp(html.gsub(/\/[0-9a-f-]+\.png/, "/_.png"))
|
755
|
+
.gsub(/test_[^_]+_htmlimages/, "test_htmlimages"))
|
755
756
|
.to be_equivalent_to xmlpp(<<~"OUTPUT")
|
756
757
|
<main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
|
757
758
|
<br />
|
@@ -771,7 +772,7 @@ RSpec.describe IsoDoc do
|
|
771
772
|
OUTPUT
|
772
773
|
end
|
773
774
|
|
774
|
-
it "moves images in HTML" do
|
775
|
+
it "moves images in HTML #2" do
|
775
776
|
FileUtils.rm_f "test.html"
|
776
777
|
FileUtils.rm_rf "test_htmlimages"
|
777
778
|
IsoDoc::HtmlConvert.new(
|
@@ -791,8 +792,9 @@ RSpec.describe IsoDoc do
|
|
791
792
|
html = File.read("test.html")
|
792
793
|
.sub(/^.*<main class="main-section">/m, '<main class="main-section">')
|
793
794
|
.sub(%r{</main>.*$}m, "</main>")
|
794
|
-
expect(`ls
|
795
|
-
expect(xmlpp(html.gsub(/\/[0-9a-f-]+\.png/, "/_.png"))
|
795
|
+
expect(`ls test_*_htmlimages`).to match(/\.png$/)
|
796
|
+
expect(xmlpp(html.gsub(/\/[0-9a-f-]+\.png/, "/_.png"))
|
797
|
+
.gsub(/test_[^_]+_htmlimages/, "test_htmlimages"))
|
796
798
|
.to be_equivalent_to xmlpp(<<~"OUTPUT")
|
797
799
|
<main class='main-section'>
|
798
800
|
<button onclick='topFunction()' id='myBtn' title='Go to top'>Top</button>
|
@@ -813,7 +815,6 @@ RSpec.describe IsoDoc do
|
|
813
815
|
context "when `mathvariant` attr equal to `script`" do
|
814
816
|
it "converts mathvariant text chars into associated plain chars" do
|
815
817
|
FileUtils.rm_f "test.html"
|
816
|
-
FileUtils.rm_rf "test_htmlimages"
|
817
818
|
input = <<~INPUT
|
818
819
|
<?xml version="1.0" encoding="UTF-8"?>
|
819
820
|
<iso-standard xmlns="https://www.metanorma.org/ns/iso" type="semantic" version="1.5.14">
|
@@ -865,7 +866,6 @@ RSpec.describe IsoDoc do
|
|
865
866
|
context "when complex `mathvariant` combinations" do
|
866
867
|
it "converts mathvariant text chars into associated plain chars" do
|
867
868
|
FileUtils.rm_f "test.html"
|
868
|
-
FileUtils.rm_rf "test_htmlimages"
|
869
869
|
input = <<~INPUT
|
870
870
|
<?xml version="1.0" encoding="UTF-8"?>
|
871
871
|
<iso-standard xmlns="https://www.metanorma.org/ns/iso" type="semantic" version="1.5.14">
|
@@ -975,7 +975,7 @@ RSpec.describe IsoDoc do
|
|
975
975
|
|
976
976
|
it "moves images in HTML with no file suffix" do
|
977
977
|
FileUtils.rm_f "test.html"
|
978
|
-
FileUtils.rm_rf "
|
978
|
+
FileUtils.rm_rf Dir.glob "test_*_htmlimages"
|
979
979
|
IsoDoc::HtmlConvert.new(
|
980
980
|
{ wordstylesheet: "spec/assets/word.css",
|
981
981
|
htmlstylesheet: "spec/assets/html.scss" },
|
@@ -994,8 +994,9 @@ RSpec.describe IsoDoc do
|
|
994
994
|
html = File.read("test.html")
|
995
995
|
.sub(/^.*<main class="main-section">/m, '<main class="main-section">')
|
996
996
|
.sub(%r{</main>.*$}m, "</main>")
|
997
|
-
expect(`ls
|
998
|
-
expect(xmlpp(html.gsub(/\/[0-9a-f-]+\.png/, "/_.png"))
|
997
|
+
expect(`ls test_*_htmlimages`).to match(/\.png$/)
|
998
|
+
expect(xmlpp(html.gsub(/\/[0-9a-f-]+\.png/, "/_.png"))
|
999
|
+
.gsub(/test_[^_]+_htmlimages/, "test_htmlimages"))
|
999
1000
|
.to be_equivalent_to xmlpp(<<~"OUTPUT")
|
1000
1001
|
<main class='main-section'>
|
1001
1002
|
<button onclick='topFunction()' id='myBtn' title='Go to top'>Top</button>
|
@@ -1036,8 +1037,9 @@ RSpec.describe IsoDoc do
|
|
1036
1037
|
html = File.read("spec/test.html")
|
1037
1038
|
.sub(/^.*<main class="main-section">/m, '<main class="main-section">')
|
1038
1039
|
.sub(%r{</main>.*$}m, "</main>")
|
1039
|
-
expect(`ls
|
1040
|
-
expect(xmlpp(html.gsub(/\/[0-9a-f-]+\.png/, "/_.png"))
|
1040
|
+
expect(`ls test_*_htmlimages`).to match(/\.png$/)
|
1041
|
+
expect(xmlpp(html.gsub(/\/[0-9a-f-]+\.png/, "/_.png"))
|
1042
|
+
.gsub(/test_[^_]+_htmlimages/, "test_htmlimages"))
|
1041
1043
|
.to be_equivalent_to xmlpp(<<~"OUTPUT")
|
1042
1044
|
<main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
|
1043
1045
|
<br />
|
@@ -1057,7 +1059,7 @@ RSpec.describe IsoDoc do
|
|
1057
1059
|
|
1058
1060
|
it "encodes images in HTML as data URIs" do
|
1059
1061
|
FileUtils.rm_f "test.html"
|
1060
|
-
FileUtils.rm_rf "
|
1062
|
+
FileUtils.rm_rf Dir.glob "test_*_htmlimages"
|
1061
1063
|
IsoDoc::HtmlConvert
|
1062
1064
|
.new(htmlstylesheet: "spec/assets/html.scss", datauriimage: true)
|
1063
1065
|
.convert("test", <<~"INPUT", false)
|
@@ -1093,7 +1095,7 @@ RSpec.describe IsoDoc do
|
|
1093
1095
|
|
1094
1096
|
it "encodes images in HTML as data URIs, using relative file location" do
|
1095
1097
|
FileUtils.rm_f "spec/test.html"
|
1096
|
-
FileUtils.rm_rf "
|
1098
|
+
FileUtils.rm_rf Dir.glob "test_*_htmlimages"
|
1097
1099
|
IsoDoc::HtmlConvert
|
1098
1100
|
.new({ htmlstylesheet: "assets/html.scss", datauriimage: true })
|
1099
1101
|
.convert("spec/test", <<~"INPUT", false)
|