isodoc 1.3.1 → 1.5.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 +17 -33
- data/isodoc.gemspec +3 -2
- data/lib/isodoc-yaml/i18n-en.yaml +55 -0
- data/lib/isodoc-yaml/i18n-fr.yaml +56 -0
- data/lib/isodoc/convert.rb +2 -1
- data/lib/isodoc/function/inline.rb +1 -1
- data/lib/isodoc/function/inline_simple.rb +6 -0
- data/lib/isodoc/function/section.rb +1 -1
- data/lib/isodoc/function/to_word_html.rb +3 -2
- data/lib/isodoc/function/utils.rb +4 -4
- data/lib/isodoc/html_function/html.rb +6 -0
- data/lib/isodoc/html_function/mathvariant_to_plain.rb +82 -0
- data/lib/isodoc/html_function/postprocess.rb +32 -19
- data/lib/isodoc/metadata_contributor.rb +4 -3
- data/lib/isodoc/presentation_function/block.rb +6 -0
- data/lib/isodoc/presentation_function/inline.rb +5 -1
- data/lib/isodoc/presentation_function/section.rb +3 -0
- data/lib/isodoc/presentation_xml_convert.rb +1 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/inline.rb +2 -2
- data/lib/isodoc/word_function/postprocess_cover.rb +1 -1
- data/lib/isodoc/xref/xref_counter.rb +44 -12
- data/lib/isodoc/xref/xref_sect_gen.rb +34 -27
- data/spec/isodoc/blocks_spec.rb +83 -74
- data/spec/isodoc/inline_spec.rb +5 -3
- data/spec/isodoc/metadata_spec.rb +3 -1
- data/spec/isodoc/postproc_spec.rb +168 -3
- data/spec/isodoc/presentation_xml_spec.rb +5 -5
- data/spec/isodoc/xref_spec.rb +310 -2
- metadata +24 -9
@@ -17,9 +17,10 @@ module IsoDoc
|
|
17
17
|
def extract_person_affiliations(authors)
|
18
18
|
authors.reduce([]) do |m, a|
|
19
19
|
name = a&.at(ns('./affiliation/organization/name'))&.text
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
subdivs = a&.xpath(ns('./affiliation/organization/subdivision'))&.map(&:text)&.join(", ")
|
21
|
+
name and subdivs and !subdivs.empty? and name = l10n("#{name}, #{subdivs}", @lang, @script)
|
22
|
+
location = a&.at(ns('./affiliation/organization/address/formattedAddress'))&.text
|
23
|
+
m << (!name.nil? && !location.nil? ? l10n("#{name}, #{location}", @lang, @script) :
|
23
24
|
(name || location || ''))
|
24
25
|
m
|
25
26
|
end
|
@@ -211,7 +211,11 @@ module IsoDoc
|
|
211
211
|
def mathml1(f, locale)
|
212
212
|
localize_maths(f, locale)
|
213
213
|
return unless f.elements.size == 1 && f.elements.first.name == "mn"
|
214
|
-
f.
|
214
|
+
if f.parent.name == "stem"
|
215
|
+
f.parent.replace(f.at("./m:mn", MATHML).children)
|
216
|
+
else
|
217
|
+
f.replace(f.at("./m:mn", MATHML).children)
|
218
|
+
end
|
215
219
|
end
|
216
220
|
|
217
221
|
def variant(docxml)
|
data/lib/isodoc/version.rb
CHANGED
@@ -24,7 +24,7 @@ module IsoDoc::WordFunction
|
|
24
24
|
|
25
25
|
def imgsrc(node)
|
26
26
|
ret = svg_to_emf(node) and return ret
|
27
|
-
return node["src"] unless %r{^data:
|
27
|
+
return node["src"] unless %r{^data:}.match node["src"]
|
28
28
|
save_dataimage(node["src"])
|
29
29
|
end
|
30
30
|
|
@@ -45,7 +45,7 @@ module IsoDoc::WordFunction
|
|
45
45
|
def svg_to_emf(node)
|
46
46
|
return unless node["mimetype"] == "image/svg+xml"
|
47
47
|
uri = node["src"]
|
48
|
-
%r{^data:
|
48
|
+
%r{^data:}.match(uri) and uri = save_dataimage(uri)
|
49
49
|
ret = svg_to_emf_filename(uri)
|
50
50
|
File.exists?(ret) and return ret
|
51
51
|
exe = inkscape_installed? or return nil
|
@@ -96,7 +96,7 @@ module IsoDoc::WordFunction
|
|
96
96
|
def generate_header(filename, _dir)
|
97
97
|
return nil unless @header
|
98
98
|
template = IsoDoc::Common.liquid(File.read(@header, encoding: "UTF-8"))
|
99
|
-
meta = @meta.get.merge(@labels
|
99
|
+
meta = @meta.get.merge(@labels ? { labels: @labels } : {}).merge(@meta.labels ? { labels: @meta.labels } : {})
|
100
100
|
meta[:filename] = filename
|
101
101
|
params = meta.map { |k, v| [k.to_s, v] }.to_h
|
102
102
|
Tempfile.open(%w(header html), :encoding => "utf-8") do |f|
|
@@ -2,41 +2,56 @@ require "roman-numerals"
|
|
2
2
|
|
3
3
|
module IsoDoc::XrefGen
|
4
4
|
class Counter
|
5
|
-
def initialize(num = 0)
|
5
|
+
def initialize(num = 0, opts = {numerals: :arabic})
|
6
6
|
@num = num
|
7
7
|
@letter = ""
|
8
8
|
@subseq = ""
|
9
9
|
@letter_override = nil
|
10
10
|
@number_override = nil
|
11
|
+
@style = opts[:numerals]
|
11
12
|
@base = ""
|
13
|
+
if num.is_a? String
|
14
|
+
if /^\d+$/.match(num)
|
15
|
+
@num = num.to_i
|
16
|
+
else
|
17
|
+
@num = nil
|
18
|
+
@base = num[0..-2]
|
19
|
+
@letter = num[-1]
|
20
|
+
end
|
21
|
+
end
|
12
22
|
end
|
13
23
|
|
14
24
|
def new_subseq_increment(node)
|
15
25
|
@subseq = node["subsequence"]
|
16
|
-
@num += 1
|
26
|
+
@num += 1 unless @num.nil?
|
17
27
|
@letter = node["subsequence"] ? "a" : ""
|
18
28
|
@base = ""
|
19
29
|
if node["number"]
|
20
|
-
/^(?<b>.*?)(?<n>\d*)(?<a>[a-
|
30
|
+
/^(?<b>.*?)(?<n>\d*)(?<a>[a-zA-Z]*)$/ =~ node["number"]
|
21
31
|
if !n.empty? || !a.empty?
|
22
32
|
@letter_override = @letter = a unless a.empty?
|
23
33
|
@number_override = @num = n.to_i unless n.empty?
|
24
34
|
@base = b
|
25
35
|
else
|
26
36
|
@letter_override = node["number"]
|
27
|
-
@letter = @letter_override if /^[a-
|
37
|
+
@letter = @letter_override if /^[a-zA-Z]$/.match(@letter_override)
|
28
38
|
end
|
29
39
|
end
|
30
40
|
end
|
31
41
|
|
32
42
|
def sequence_increment(node)
|
33
43
|
if node["number"]
|
34
|
-
@base = ""
|
35
|
-
@number_override = node["number"]
|
44
|
+
@base = @letter_override = @number_override = ""
|
36
45
|
/^(?<b>.*?)(?<n>\d+)$/ =~ node["number"]
|
37
|
-
|
46
|
+
if blank?(n)
|
47
|
+
@num = nil
|
48
|
+
@base = node["number"][0..-2]
|
49
|
+
@letter = @letter_override = node["number"][-1]
|
50
|
+
else
|
51
|
+
@number_override = node["number"]
|
38
52
|
@num = n.to_i
|
39
53
|
@base = b
|
54
|
+
@letter = ""
|
40
55
|
end
|
41
56
|
else
|
42
57
|
@num += 1
|
@@ -47,9 +62,20 @@ module IsoDoc::XrefGen
|
|
47
62
|
if node["number"]
|
48
63
|
@base = ""
|
49
64
|
@letter_override = node["number"]
|
50
|
-
/^(?<b>.*?)(?<n>\d*)(?<a>[a-
|
51
|
-
|
52
|
-
|
65
|
+
/^(?<b>.*?)(?<n>\d*)(?<a>[a-zA-Z])$/ =~ node["number"]
|
66
|
+
if blank?(a)
|
67
|
+
if /^\d+$/.match(node["number"])
|
68
|
+
@letter_override = @letter = ""
|
69
|
+
@number_override = @num = node["number"].to_i
|
70
|
+
else
|
71
|
+
/^(?<b>.*)(?<a>[a-zA-Z])$/ =~ node["number"]
|
72
|
+
unless blank?(a)
|
73
|
+
@letter = @letter_override = a
|
74
|
+
@base = b
|
75
|
+
end
|
76
|
+
end
|
77
|
+
else
|
78
|
+
@letter_override = @letter = a
|
53
79
|
@base = b
|
54
80
|
@number_override = @num = n.to_i unless n.empty?
|
55
81
|
end
|
@@ -58,11 +84,15 @@ module IsoDoc::XrefGen
|
|
58
84
|
end
|
59
85
|
end
|
60
86
|
|
87
|
+
def blank?(x)
|
88
|
+
x.nil? || x.empty?
|
89
|
+
end
|
90
|
+
|
61
91
|
def increment(node)
|
62
92
|
return self if node["unnumbered"]
|
63
93
|
@letter_override = nil
|
64
94
|
@number_override = nil
|
65
|
-
if node["subsequence"] != @subseq
|
95
|
+
if node["subsequence"] != @subseq && !(blank?(node["subsequence"]) && blank?(@subseq))
|
66
96
|
new_subseq_increment(node)
|
67
97
|
elsif @letter.empty?
|
68
98
|
sequence_increment(node)
|
@@ -73,7 +103,9 @@ module IsoDoc::XrefGen
|
|
73
103
|
end
|
74
104
|
|
75
105
|
def print
|
76
|
-
|
106
|
+
num = @number_override || @num
|
107
|
+
num_out = @style == :roman && !num.nil? ? RomanNumerals.to_roman(num) : num
|
108
|
+
"#{@base}#{num_out}#{@letter_override || @letter}"
|
77
109
|
end
|
78
110
|
|
79
111
|
def ol_type(list, depth)
|
@@ -1,23 +1,25 @@
|
|
1
1
|
module IsoDoc::XrefGen
|
2
2
|
module Sections
|
3
3
|
def back_anchor_names(docxml)
|
4
|
-
|
5
|
-
|
4
|
+
i = Counter.new("@")
|
5
|
+
docxml.xpath(ns("//annex")).each do |c|
|
6
|
+
i.increment(c)
|
7
|
+
annex_names(c, i.print)
|
8
|
+
end
|
9
|
+
docxml.xpath(ns(@klass.bibliography_xpath)).each do |b|
|
10
|
+
preface_names(b)
|
11
|
+
end
|
12
|
+
docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |ref|
|
13
|
+
reference_names(ref)
|
6
14
|
end
|
7
|
-
docxml.xpath(
|
8
|
-
ns(@klass.bibliography_xpath)).each do |b|
|
9
|
-
preface_names(b)
|
10
|
-
end
|
11
|
-
docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |ref|
|
12
|
-
reference_names(ref)
|
13
|
-
end
|
14
15
|
end
|
15
16
|
|
16
17
|
def initial_anchor_names(d)
|
17
18
|
d.xpath(ns("//preface/*")).each { |c| c.element? and preface_names(c) }
|
18
19
|
# potentially overridden in middle_section_asset_names()
|
19
20
|
sequential_asset_names(d.xpath(ns("//preface/*")))
|
20
|
-
n =
|
21
|
+
n = Counter.new
|
22
|
+
n = section_names(d.at(ns("//clause[@type = 'scope']")), n, 1)
|
21
23
|
n = section_names(d.at(ns(@klass.norm_ref_xpath)), n, 1)
|
22
24
|
n = section_names(d.at(ns("//sections/terms | "\
|
23
25
|
"//sections/clause[descendant::terms]")), n, 1)
|
@@ -52,8 +54,7 @@ module IsoDoc::XrefGen
|
|
52
54
|
label = title || parent_title
|
53
55
|
@anchors[clause["id"]] =
|
54
56
|
{ label: nil, level: level, xref: label, type: "clause" }
|
55
|
-
clause.xpath(ns(SUBCLAUSES)).
|
56
|
-
each_with_index do |c, i|
|
57
|
+
clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i|
|
57
58
|
preface_names1(c, c.at(ns("./title"))&.text, "#{label} #{i+1}",
|
58
59
|
level + 1)
|
59
60
|
end
|
@@ -67,21 +68,22 @@ module IsoDoc::XrefGen
|
|
67
68
|
sequential_asset_names(d.xpath(ns(middle_sections)))
|
68
69
|
end
|
69
70
|
|
70
|
-
def clause_names(docxml,
|
71
|
-
docxml.xpath(ns(@klass.middle_clause)).each_with_index do |c, i|
|
72
|
-
section_names(c,
|
71
|
+
def clause_names(docxml, n)
|
72
|
+
docxml.xpath(ns(@klass.middle_clause(docxml))).each_with_index do |c, i|
|
73
|
+
section_names(c, n, 1)
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
76
77
|
def section_names(clause, num, lvl)
|
77
78
|
return num if clause.nil?
|
78
|
-
num
|
79
|
+
num.increment(clause)
|
79
80
|
@anchors[clause["id"]] =
|
80
|
-
{ label: num.
|
81
|
+
{ label: num.print, xref: l10n("#{@labels["clause"]} #{num.print}"), level: lvl,
|
81
82
|
type: "clause" }
|
82
|
-
|
83
|
-
|
84
|
-
|
83
|
+
i = Counter.new
|
84
|
+
clause.xpath(ns(SUBCLAUSES)).each do |c|
|
85
|
+
i.increment(c)
|
86
|
+
section_names1(c, "#{num.print}.#{i.print}", lvl + 1)
|
85
87
|
end
|
86
88
|
num
|
87
89
|
end
|
@@ -90,9 +92,10 @@ module IsoDoc::XrefGen
|
|
90
92
|
@anchors[clause["id"]] =
|
91
93
|
{ label: num, level: level, xref: l10n("#{@labels["clause"]} #{num}"),
|
92
94
|
type: "clause" }
|
93
|
-
|
94
|
-
|
95
|
-
|
95
|
+
i = Counter.new
|
96
|
+
clause.xpath(ns(SUBCLAUSES)).each do |c|
|
97
|
+
i.increment(c)
|
98
|
+
section_names1(c, "#{num}.#{i.print}", level + 1)
|
96
99
|
end
|
97
100
|
end
|
98
101
|
|
@@ -118,8 +121,10 @@ module IsoDoc::XrefGen
|
|
118
121
|
if a = single_annex_special_section(clause)
|
119
122
|
annex_names1(a, "#{num}", 1)
|
120
123
|
else
|
121
|
-
|
122
|
-
|
124
|
+
i = Counter.new
|
125
|
+
clause.xpath(ns(SUBCLAUSES)).each do |c|
|
126
|
+
i.increment(c)
|
127
|
+
annex_names1(c, "#{num}.#{i.print}", 2)
|
123
128
|
end
|
124
129
|
end
|
125
130
|
hierarchical_asset_names(clause, num)
|
@@ -128,8 +133,10 @@ module IsoDoc::XrefGen
|
|
128
133
|
def annex_names1(clause, num, level)
|
129
134
|
@anchors[clause["id"]] = { label: num, xref: "#{@labels["annex"]} #{num}",
|
130
135
|
level: level, type: "clause" }
|
131
|
-
|
132
|
-
|
136
|
+
i = Counter.new
|
137
|
+
clause.xpath(ns(SUBCLAUSES)).each_with_index do |c|
|
138
|
+
i.increment(c)
|
139
|
+
annex_names1(c, "#{num}.#{i.print}", level + 1)
|
133
140
|
end
|
134
141
|
end
|
135
142
|
|
data/spec/isodoc/blocks_spec.rb
CHANGED
@@ -534,7 +534,7 @@ INPUT
|
|
534
534
|
<div>
|
535
535
|
<h1 class='ForewordTitle'>Foreword</h1>
|
536
536
|
<p id='A'>
|
537
|
-
ABC
|
537
|
+
ABC
|
538
538
|
<div id='B' class='Note'>
|
539
539
|
<p>
|
540
540
|
<span class='note_label'>NOTE 1</span>
|
@@ -611,8 +611,8 @@ INPUT
|
|
611
611
|
OUTPUT
|
612
612
|
end
|
613
613
|
|
614
|
-
it "processes figures
|
615
|
-
|
614
|
+
it "processes figures" do
|
615
|
+
input = <<~INPUT
|
616
616
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
617
617
|
<preface><foreword>
|
618
618
|
<figure id="figureA-1" keep-with-next="true" keep-lines-together="true">
|
@@ -620,6 +620,7 @@ OUTPUT
|
|
620
620
|
<image src="rice_images/rice_image1.png" height="20" width="30" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png" alt="alttext" title="titletxt"/>
|
621
621
|
<image src="rice_images/rice_image1.png" height="20" width="auto" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f1" mimetype="image/png"/>
|
622
622
|
<image src="data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7" height="20" width="auto" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f2" mimetype="image/png"/>
|
623
|
+
<image src="data:application/xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+Cjw/eG1sLXN0eWxlc2hlZXQgdHlwZT0idGV4dC94c2wiIGhyZWY9Ii4uLy4uLy4uL3hzbC9yZXNfZG9jL2ltZ2ZpbGUueHNsIj8+CjwhRE9DVFlQRSBpbWdmaWxlLmNvbnRlbnQgU1lTVEVNICIuLi8uLi8uLi9kdGQvdGV4dC5lbnQiPgo8aW1nZmlsZS5jb250ZW50IG1vZHVsZT0iZnVuZGFtZW50YWxzX29mX3Byb2R1Y3RfZGVzY3JpcHRpb25fYW5kX3N1cHBvcnQiIGZpbGU9ImFjdGlvbl9zY2hlbWFleHBnMS54bWwiPgo8aW1nIHNyYz0iYWN0aW9uX3NjaGVtYWV4cGcxLmdpZiI+CjxpbWcuYXJlYSBzaGFwZT0icmVjdCIgY29vcmRzPSIyMTAsMTg2LDM0MywyMjciIGhyZWY9Ii4uLy4uL3Jlc291cmNlcy9iYXNpY19hdHRyaWJ1dGVfc2NoZW1hL2Jhc2ljX2F0dHJpYnV0ZV9zY2hlbWEueG1sIiAvPgo8aW1nLmFyZWEgc2hhcGU9InJlY3QiIGNvb3Jkcz0iMTAsMTAsOTYsNTEiIGhyZWY9Ii4uLy4uL3Jlc291cmNlcy9hY3Rpb25fc2NoZW1hL2FjdGlvbl9zY2hlbWEueG1sIiAvPgo8aW1nLmFyZWEgc2hhcGU9InJlY3QiIGNvb3Jkcz0iMjEwLDI2NCwzNTgsMzA1IiBocmVmPSIuLi8uLi9yZXNvdXJjZXMvc3VwcG9ydF9yZXNvdXJjZV9zY2hlbWEvc3VwcG9ydF9yZXNvdXJjZV9zY2hlbWEueG1sIiAvPgo8L2ltZz4KPC9pbWdmaWxlLmNvbnRlbnQ+Cg==" height="20" width="auto" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f2" mimetype="application/xml"/>
|
623
624
|
<fn reference="a">
|
624
625
|
<p id="_ef2c85b8-5a5a-4ecd-a1e6-92acefaaa852">The time <stem type="AsciiMath">t_90</stem> was estimated to be 18,2 min for this example.</p>
|
625
626
|
</fn>
|
@@ -629,16 +630,18 @@ OUTPUT
|
|
629
630
|
</dl>
|
630
631
|
</figure>
|
631
632
|
<figure id="figure-B">
|
632
|
-
<pre alt="A B">A
|
633
|
+
<pre alt="A B">A <
|
633
634
|
B</pre>
|
634
635
|
</figure>
|
635
636
|
<figure id="figure-C" unnumbered="true">
|
636
|
-
<pre>A
|
637
|
+
<pre>A <
|
637
638
|
B</pre>
|
638
639
|
</figure>
|
639
640
|
</foreword></preface>
|
640
641
|
</iso-standard>
|
641
642
|
INPUT
|
643
|
+
|
644
|
+
presxml = <<~OUTPUT
|
642
645
|
<?xml version='1.0'?>
|
643
646
|
<iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
|
644
647
|
<preface><foreword>
|
@@ -647,6 +650,7 @@ B</pre>
|
|
647
650
|
<image src="rice_images/rice_image1.png" height="20" width="30" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png" alt="alttext" title="titletxt"/>
|
648
651
|
<image src="rice_images/rice_image1.png" height="20" width="auto" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f1" mimetype="image/png"/>
|
649
652
|
<image src="data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7" height="20" width="auto" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f2" mimetype="image/png"/>
|
653
|
+
<image src='data:application/xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+Cjw/eG1sLXN0eWxlc2hlZXQgdHlwZT0idGV4dC94c2wiIGhyZWY9Ii4uLy4uLy4uL3hzbC9yZXNfZG9jL2ltZ2ZpbGUueHNsIj8+CjwhRE9DVFlQRSBpbWdmaWxlLmNvbnRlbnQgU1lTVEVNICIuLi8uLi8uLi9kdGQvdGV4dC5lbnQiPgo8aW1nZmlsZS5jb250ZW50IG1vZHVsZT0iZnVuZGFtZW50YWxzX29mX3Byb2R1Y3RfZGVzY3JpcHRpb25fYW5kX3N1cHBvcnQiIGZpbGU9ImFjdGlvbl9zY2hlbWFleHBnMS54bWwiPgo8aW1nIHNyYz0iYWN0aW9uX3NjaGVtYWV4cGcxLmdpZiI+CjxpbWcuYXJlYSBzaGFwZT0icmVjdCIgY29vcmRzPSIyMTAsMTg2LDM0MywyMjciIGhyZWY9Ii4uLy4uL3Jlc291cmNlcy9iYXNpY19hdHRyaWJ1dGVfc2NoZW1hL2Jhc2ljX2F0dHJpYnV0ZV9zY2hlbWEueG1sIiAvPgo8aW1nLmFyZWEgc2hhcGU9InJlY3QiIGNvb3Jkcz0iMTAsMTAsOTYsNTEiIGhyZWY9Ii4uLy4uL3Jlc291cmNlcy9hY3Rpb25fc2NoZW1hL2FjdGlvbl9zY2hlbWEueG1sIiAvPgo8aW1nLmFyZWEgc2hhcGU9InJlY3QiIGNvb3Jkcz0iMjEwLDI2NCwzNTgsMzA1IiBocmVmPSIuLi8uLi9yZXNvdXJjZXMvc3VwcG9ydF9yZXNvdXJjZV9zY2hlbWEvc3VwcG9ydF9yZXNvdXJjZV9zY2hlbWEueG1sIiAvPgo8L2ltZz4KPC9pbWdmaWxlLmNvbnRlbnQ+Cg==' height='20' width='auto' id='_8357ede4-6d44-4672-bac4-9a85e82ab7f2' mimetype='application/xml'/>
|
650
654
|
<fn reference="a">
|
651
655
|
<p id="_ef2c85b8-5a5a-4ecd-a1e6-92acefaaa852">The time <stem type="AsciiMath">t_90</stem> was estimated to be 18,2 min for this example.</p>
|
652
656
|
</fn>
|
@@ -657,47 +661,18 @@ B</pre>
|
|
657
661
|
</figure>
|
658
662
|
<figure id="figure-B">
|
659
663
|
<name>Figure 2</name>
|
660
|
-
<pre alt="A B">A
|
664
|
+
<pre alt="A B">A <
|
661
665
|
B</pre>
|
662
666
|
</figure>
|
663
667
|
<figure id="figure-C" unnumbered="true">
|
664
|
-
<pre>A
|
668
|
+
<pre>A <
|
665
669
|
B</pre>
|
666
670
|
</figure>
|
667
671
|
</foreword></preface>
|
668
672
|
</iso-standard>
|
669
673
|
OUTPUT
|
670
|
-
end
|
671
674
|
|
672
|
-
|
673
|
-
expect(xmlpp(strip_guid(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
674
|
-
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
675
|
-
<preface><foreword>
|
676
|
-
<figure id="figureA-1" keep-with-next="true" keep-lines-together="true">
|
677
|
-
<name>Figure 1 — Split-it-right <em>sample</em> divider<fn reference="1"><p>X</p></fn></name>
|
678
|
-
<image src="rice_images/rice_image1.png" height="20" width="30" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png" alt="alttext" title="titletxt"/>
|
679
|
-
<image src="rice_images/rice_image1.png" height="20" width="auto" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f1" mimetype="image/png"/>
|
680
|
-
<image src="data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7" height="20" width="auto" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f2" mimetype="image/png"/>
|
681
|
-
<fn reference="a">
|
682
|
-
<p id="_ef2c85b8-5a5a-4ecd-a1e6-92acefaaa852">The time <stem type="AsciiMath">t_90</stem> was estimated to be 18,2 min for this example.</p>
|
683
|
-
</fn>
|
684
|
-
<dl>
|
685
|
-
<dt>A</dt>
|
686
|
-
<dd><p>B</p></dd>
|
687
|
-
</dl>
|
688
|
-
</figure>
|
689
|
-
<figure id="figure-B">
|
690
|
-
<name>Figure 2</name>
|
691
|
-
<pre alt="A B">A <
|
692
|
-
B</pre>
|
693
|
-
</figure>
|
694
|
-
<figure id="figure-C" unnumbered="true">
|
695
|
-
<pre>A <
|
696
|
-
B</pre>
|
697
|
-
</figure>
|
698
|
-
</foreword></preface>
|
699
|
-
</iso-standard>
|
700
|
-
INPUT
|
675
|
+
html = <<~OUTPUT
|
701
676
|
#{HTML_HDR}
|
702
677
|
<br/>
|
703
678
|
<div>
|
@@ -707,6 +682,7 @@ B</pre>
|
|
707
682
|
<img src="rice_images/rice_image1.png" height="20" width="30" alt="alttext" title="titletxt"/>
|
708
683
|
<img src="rice_images/rice_image1.png" height="20" width="auto"/>
|
709
684
|
<img src="data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7" height="20" width="auto"/>
|
685
|
+
<img src='data:application/xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+Cjw/eG1sLXN0eWxlc2hlZXQgdHlwZT0idGV4dC94c2wiIGhyZWY9Ii4uLy4uLy4uL3hzbC9yZXNfZG9jL2ltZ2ZpbGUueHNsIj8+CjwhRE9DVFlQRSBpbWdmaWxlLmNvbnRlbnQgU1lTVEVNICIuLi8uLi8uLi9kdGQvdGV4dC5lbnQiPgo8aW1nZmlsZS5jb250ZW50IG1vZHVsZT0iZnVuZGFtZW50YWxzX29mX3Byb2R1Y3RfZGVzY3JpcHRpb25fYW5kX3N1cHBvcnQiIGZpbGU9ImFjdGlvbl9zY2hlbWFleHBnMS54bWwiPgo8aW1nIHNyYz0iYWN0aW9uX3NjaGVtYWV4cGcxLmdpZiI+CjxpbWcuYXJlYSBzaGFwZT0icmVjdCIgY29vcmRzPSIyMTAsMTg2LDM0MywyMjciIGhyZWY9Ii4uLy4uL3Jlc291cmNlcy9iYXNpY19hdHRyaWJ1dGVfc2NoZW1hL2Jhc2ljX2F0dHJpYnV0ZV9zY2hlbWEueG1sIiAvPgo8aW1nLmFyZWEgc2hhcGU9InJlY3QiIGNvb3Jkcz0iMTAsMTAsOTYsNTEiIGhyZWY9Ii4uLy4uL3Jlc291cmNlcy9hY3Rpb25fc2NoZW1hL2FjdGlvbl9zY2hlbWEueG1sIiAvPgo8aW1nLmFyZWEgc2hhcGU9InJlY3QiIGNvb3Jkcz0iMjEwLDI2NCwzNTgsMzA1IiBocmVmPSIuLi8uLi9yZXNvdXJjZXMvc3VwcG9ydF9yZXNvdXJjZV9zY2hlbWEvc3VwcG9ydF9yZXNvdXJjZV9zY2hlbWEueG1sIiAvPgo8L2ltZz4KPC9pbWdmaWxlLmNvbnRlbnQ+Cg==' height='20' width='auto'/>
|
710
686
|
<a href="#_" class="TableFootnoteRef">a</a><aside class="footnote"><div id="fn:_"><span><span id="_" class="TableFootnoteRef">a</span>  </span>
|
711
687
|
<p id="_">The time <span class="stem">(#(t_90)#)</span> was estimated to be 18,2 min for this example.</p>
|
712
688
|
</div></aside>
|
@@ -717,12 +693,12 @@ B</pre>
|
|
717
693
|
</a>
|
718
694
|
</p></div>
|
719
695
|
<div class="figure" id="figure-B">
|
720
|
-
<pre>A
|
696
|
+
<pre>A <
|
721
697
|
B</pre>
|
722
698
|
<p class="FigureTitle" style="text-align:center;">Figure 2</p>
|
723
699
|
</div>
|
724
700
|
<div class="figure" id="figure-C">
|
725
|
-
<pre>A
|
701
|
+
<pre>A <
|
726
702
|
B</pre>
|
727
703
|
</div>
|
728
704
|
</div>
|
@@ -734,38 +710,8 @@ B</pre>
|
|
734
710
|
</body>
|
735
711
|
</html>
|
736
712
|
OUTPUT
|
737
|
-
end
|
738
713
|
|
739
|
-
|
740
|
-
FileUtils.rm_rf "spec/assets/odf1.emf"
|
741
|
-
expect(xmlpp(strip_guid(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(/['"][^'".]+\.gif['"]/, "'_.gif'").gsub(/mso-bookmark:_Ref\d+/, "mso-bookmark:_Ref")))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
742
|
-
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
743
|
-
<preface><foreword>
|
744
|
-
<figure id="figureA-1" keep-with-next="true" keep-lines-together="true">
|
745
|
-
<name>Figure 1 — Split-it-right <em>sample</em> divider<fn reference="1"><p>X</p></fn></name>
|
746
|
-
<image src="rice_images/rice_image1.png" height="20" width="30" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png" alt="alttext" title="titletxt"/>
|
747
|
-
<image src="rice_images/rice_image1.png" height="20" width="auto" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f1" mimetype="image/png"/>
|
748
|
-
<image src="data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7" height="20" width="auto" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f2" mimetype="image/png"/>
|
749
|
-
<fn reference="a">
|
750
|
-
<p id="_ef2c85b8-5a5a-4ecd-a1e6-92acefaaa852">The time <stem type="AsciiMath">t_90</stem> was estimated to be 18,2 min for this example.</p>
|
751
|
-
</fn>
|
752
|
-
<dl>
|
753
|
-
<dt>A</dt>
|
754
|
-
<dd><p>B</p></dd>
|
755
|
-
</dl>
|
756
|
-
</figure>
|
757
|
-
<figure id="figure-B">
|
758
|
-
<name>Figure 2</name>
|
759
|
-
<pre alt="A B">A <
|
760
|
-
B</pre>
|
761
|
-
</figure>
|
762
|
-
<figure id="figure-C" unnumbered="true">
|
763
|
-
<pre>A <
|
764
|
-
B</pre>
|
765
|
-
</figure>
|
766
|
-
</foreword></preface>
|
767
|
-
</iso-standard>
|
768
|
-
INPUT
|
714
|
+
word = <<~OUTPUT
|
769
715
|
<html xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
|
770
716
|
<head><style/></head>
|
771
717
|
<body lang="EN-US" link="blue" vlink="#954F72">
|
@@ -781,6 +727,7 @@ B</pre>
|
|
781
727
|
<img src="rice_images/rice_image1.png" height="20" width="30" alt="alttext" title="titletxt"/>
|
782
728
|
<img src="rice_images/rice_image1.png" height='20' width='auto'/>
|
783
729
|
<img src='_.gif' height='20' width='auto'/>
|
730
|
+
<img src='_.xml' height='20' width='auto'/>
|
784
731
|
<a href="#_" class="TableFootnoteRef">a</a><aside><div id="ftn_"><span><span id="_" class="TableFootnoteRef">a</span><span style="mso-tab-count:1">  </span></span>
|
785
732
|
<p id="_">The time <span class="stem">(#(t_90)#)</span> was estimated to be 18,2 min for this example.</p>
|
786
733
|
</div></aside>
|
@@ -795,12 +742,12 @@ B</pre>
|
|
795
742
|
</p>
|
796
743
|
</div>
|
797
744
|
<div class="figure" id="figure-B">
|
798
|
-
<pre>A
|
745
|
+
<pre>A <
|
799
746
|
B</pre>
|
800
747
|
<p class="FigureTitle" style="text-align:center;">Figure 2</p>
|
801
748
|
</div>
|
802
749
|
<div id='figure-C' class='figure'>
|
803
|
-
<pre>A
|
750
|
+
<pre>A < B</pre>
|
804
751
|
</div>
|
805
752
|
</div>
|
806
753
|
<p> </p>
|
@@ -815,17 +762,22 @@ B</pre>
|
|
815
762
|
</body>
|
816
763
|
</html>
|
817
764
|
OUTPUT
|
765
|
+
expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true).gsub(/\</, "<"))).to be_equivalent_to xmlpp(presxml)
|
766
|
+
expect(xmlpp(strip_guid(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true)))).to be_equivalent_to xmlpp(html)
|
767
|
+
FileUtils.rm_rf "spec/assets/odf1.emf"
|
768
|
+
expect(xmlpp(strip_guid(IsoDoc::WordConvert.new({}).convert("test", presxml, true).gsub(/['"][^'".]+\.(gif|xml)['"]/, "'_.\\1'").gsub(/mso-bookmark:_Ref\d+/, "mso-bookmark:_Ref")))).to be_equivalent_to xmlpp(word)
|
818
769
|
end
|
819
770
|
|
820
771
|
it "converts SVG (Word)" do
|
821
772
|
FileUtils.rm_rf "spec/assets/odf1.emf"
|
822
|
-
expect(xmlpp(strip_guid(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true).gsub(/['"][^'".]+(?<!odf1)(?<!odf)\.emf['"]/, "'_.emf'").gsub(/mso-bookmark:_Ref\d+/, "mso-bookmark:_Ref")))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
773
|
+
expect(xmlpp(strip_guid(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true).gsub(/['"][^'".]+(?<!odf1)(?<!odf)\.emf['"]/, "'_.emf'").gsub(/['"][^'".]+\.(gif|xml)['"]/, "'_.\\1'").gsub(/mso-bookmark:_Ref\d+/, "mso-bookmark:_Ref")))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
823
774
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
824
775
|
<preface><foreword>
|
825
776
|
<figure id="figureA-1">
|
826
777
|
<image src="spec/assets/odf.svg" mimetype="image/svg+xml"/>
|
827
778
|
<image src="spec/assets/odf1.svg" mimetype="image/svg+xml"/>
|
828
779
|
<image src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj4KICA8Y2lyY2xlIGZpbGw9IiMwMDkiIHI9IjQ1IiBjeD0iNTAiIGN5PSI1MCIvPgogIDxwYXRoIGQ9Ik0zMywyNkg3OEEzNywzNywwLDAsMSwzMyw4M1Y1N0g1OVY0M0gzM1oiIGZpbGw9IiNGRkYiLz4KPC9zdmc+Cg==" id="_d3731866-1a07-435a-a6c2-1acd41023a4e" mimetype="image/svg+xml" height="auto" width="auto"/>
|
780
|
+
<image src="data:application/xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+Cjw/eG1sLXN0eWxlc2hlZXQgdHlwZT0idGV4dC94c2wiIGhyZWY9Ii4uLy4uLy4uL3hzbC9yZXNfZG9jL2ltZ2ZpbGUueHNsIj8+CjwhRE9DVFlQRSBpbWdmaWxlLmNvbnRlbnQgU1lTVEVNICIuLi8uLi8uLi9kdGQvdGV4dC5lbnQiPgo8aW1nZmlsZS5jb250ZW50IG1vZHVsZT0iZnVuZGFtZW50YWxzX29mX3Byb2R1Y3RfZGVzY3JpcHRpb25fYW5kX3N1cHBvcnQiIGZpbGU9ImFjdGlvbl9zY2hlbWFleHBnMS54bWwiPgo8aW1nIHNyYz0iYWN0aW9uX3NjaGVtYWV4cGcxLmdpZiI+CjxpbWcuYXJlYSBzaGFwZT0icmVjdCIgY29vcmRzPSIyMTAsMTg2LDM0MywyMjciIGhyZWY9Ii4uLy4uL3Jlc291cmNlcy9iYXNpY19hdHRyaWJ1dGVfc2NoZW1hL2Jhc2ljX2F0dHJpYnV0ZV9zY2hlbWEueG1sIiAvPgo8aW1nLmFyZWEgc2hhcGU9InJlY3QiIGNvb3Jkcz0iMTAsMTAsOTYsNTEiIGhyZWY9Ii4uLy4uL3Jlc291cmNlcy9hY3Rpb25fc2NoZW1hL2FjdGlvbl9zY2hlbWEueG1sIiAvPgo8aW1nLmFyZWEgc2hhcGU9InJlY3QiIGNvb3Jkcz0iMjEwLDI2NCwzNTgsMzA1IiBocmVmPSIuLi8uLi9yZXNvdXJjZXMvc3VwcG9ydF9yZXNvdXJjZV9zY2hlbWEvc3VwcG9ydF9yZXNvdXJjZV9zY2hlbWEueG1sIiAvPgo8L2ltZz4KPC9pbWdmaWxlLmNvbnRlbnQ+Cg==" height="20" width="auto" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f2" mimetype="application/xml"/>
|
829
781
|
</figure>
|
830
782
|
</foreword></preface>
|
831
783
|
</iso-standard>
|
@@ -852,6 +804,7 @@ B</pre>
|
|
852
804
|
<img src='spec/assets/odf.emf'/>
|
853
805
|
<img src='spec/assets/odf1.emf'/>
|
854
806
|
<img src='_.emf' height='auto' width='auto'/>
|
807
|
+
<img src='_.xml' height='20' width='auto'/>
|
855
808
|
</div>
|
856
809
|
</div>
|
857
810
|
<p> </p>
|
@@ -2734,7 +2687,7 @@ expect(( File.read("test.html").gsub(%r{^.*<h1 class="ForewordTitle">Foreword</h
|
|
2734
2687
|
expect(File.exist?("test.html.err")).to be true
|
2735
2688
|
end
|
2736
2689
|
|
2737
|
-
it "
|
2690
|
+
it "ignores passthrough with incompatible format" do
|
2738
2691
|
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
2739
2692
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
2740
2693
|
<preface><foreword>
|
@@ -2754,6 +2707,62 @@ expect(( File.read("test.html").gsub(%r{^.*<h1 class="ForewordTitle">Foreword</h
|
|
2754
2707
|
OUTPUT
|
2755
2708
|
end
|
2756
2709
|
|
2710
|
+
it "processes svgmap" do
|
2711
|
+
expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~INPUT, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(<<~OUTPUT)
|
2712
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
2713
|
+
<sections>
|
2714
|
+
<svgmap id='_'>
|
2715
|
+
<target href='http://www.example.com'>
|
2716
|
+
<xref target='ref1'>Computer</xref>
|
2717
|
+
</target>
|
2718
|
+
</svgmap>
|
2719
|
+
<figure id='_'>
|
2720
|
+
<image src='action_schemaexpg1.svg' id='_' mimetype='image/svg+xml' height='auto' width='auto'/>
|
2721
|
+
</figure>
|
2722
|
+
<svgmap id='_'>
|
2723
|
+
<figure id='_'>
|
2724
|
+
<image src='action_schemaexpg2.svg' id='_' mimetype='image/svg+xml' height='auto' width='auto' alt='Workmap'/>
|
2725
|
+
</figure>
|
2726
|
+
<target href='mn://support_resource_schema'>
|
2727
|
+
<eref bibitemid='express_action_schema' citeas=''>
|
2728
|
+
<localityStack>
|
2729
|
+
<locality type='anchor'>
|
2730
|
+
<referenceFrom>action_schema.basic</referenceFrom>
|
2731
|
+
</locality>
|
2732
|
+
</localityStack>
|
2733
|
+
Coffee
|
2734
|
+
</eref>
|
2735
|
+
</target>
|
2736
|
+
</svgmap>
|
2737
|
+
</sections>
|
2738
|
+
<bibliography>
|
2739
|
+
<references hidden='true' normative='false'>
|
2740
|
+
<bibitem id='express_action_schema' type='internal'>
|
2741
|
+
<docidentifier type='repository'>express/action_schema</docidentifier>
|
2742
|
+
</bibitem>
|
2743
|
+
</references>
|
2744
|
+
</bibliography>
|
2745
|
+
</iso-standard>
|
2746
|
+
INPUT
|
2747
|
+
<iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
|
2748
|
+
<sections>
|
2749
|
+
<figure id='_'>
|
2750
|
+
<image src='action_schemaexpg1.svg' id='_' mimetype='image/svg+xml' height='auto' width='auto'/>
|
2751
|
+
</figure>
|
2752
|
+
<figure id='_'>
|
2753
|
+
<image src='action_schemaexpg2.svg' id='_' mimetype='image/svg+xml' height='auto' width='auto' alt='Workmap'/>
|
2754
|
+
</figure>
|
2755
|
+
</sections>
|
2756
|
+
<bibliography>
|
2757
|
+
<references hidden='true' normative='false'>
|
2758
|
+
<bibitem id='express_action_schema' type='internal'>
|
2759
|
+
<docidentifier type='repository'>express/action_schema</docidentifier>
|
2760
|
+
</bibitem>
|
2761
|
+
</references>
|
2762
|
+
</bibliography>
|
2763
|
+
</iso-standard>
|
2764
|
+
OUTPUT
|
2757
2765
|
|
2766
|
+
end
|
2758
2767
|
|
2759
2768
|
end
|