isodoc 1.5.5 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/isodoc.gemspec +10 -10
- data/lib/isodoc/base_style/all.css +7 -0
- data/lib/isodoc/base_style/metanorma_word.css +7 -0
- data/lib/isodoc/base_style/metanorma_word.scss +8 -0
- data/lib/isodoc/base_style/reset.css +7 -0
- data/lib/isodoc/base_style/reset.scss +9 -0
- data/lib/isodoc/base_style/scripts.html +187 -0
- data/lib/isodoc/class_utils.rb +6 -5
- data/lib/isodoc/convert.rb +24 -15
- data/lib/isodoc/css.rb +14 -9
- data/lib/isodoc/function/inline.rb +31 -10
- data/lib/isodoc/function/to_word_html.rb +19 -9
- data/lib/isodoc/function/utils.rb +1 -0
- data/lib/isodoc/pdf_convert.rb +1 -3
- data/lib/isodoc/presentation_function/inline.rb +31 -19
- data/lib/isodoc/presentation_xml_convert.rb +1 -1
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/xslfo_convert.rb +36 -27
- data/spec/isodoc/footnotes_spec.rb +1 -16
- data/spec/isodoc/inline_spec.rb +34 -0
- data/spec/isodoc/postproc_spec.rb +36 -12
- data/spec/isodoc/presentation_xml_spec.rb +345 -342
- data/spec/isodoc/section_spec.rb +910 -902
- data/spec/isodoc/table_spec.rb +566 -556
- data/spec/isodoc/terms_spec.rb +252 -256
- data/spec/isodoc/xref_spec.rb +2991 -2994
- data/spec/isodoc/xslfo_convert_spec.rb +39 -0
- data/spec/spec_helper.rb +30 -29
- metadata +67 -65
data/spec/isodoc/inline_spec.rb
CHANGED
@@ -590,6 +590,8 @@ OUTPUT
|
|
590
590
|
<eref type="inline" bibitemid="ISO712" citeas="ISO 712">A</eref>
|
591
591
|
<eref type="inline" bibitemid="ISO712"><locality type="anchor"><referenceFrom>1</referenceFrom></locality></eref>
|
592
592
|
<eref type="inline" bibitemid="ISO712"><locality type="anchor"><referenceFrom>1</referenceFrom></locality><locality type="clause"><referenceFrom>1</referenceFrom></locality></eref>
|
593
|
+
<eref type="inline" droploc="true" bibitemid="ISO712"><locality type="anchor"><referenceFrom>1</referenceFrom></locality><locality type="clause"><referenceFrom>1</referenceFrom></locality></eref>
|
594
|
+
<eref type="inline" case="lowercase" bibitemid="ISO712"><locality type="anchor"><referenceFrom>1</referenceFrom></locality><locality type="clause"><referenceFrom>1</referenceFrom></locality></eref>
|
593
595
|
</p>
|
594
596
|
</foreword></preface>
|
595
597
|
<bibliography><references id="_normative_references" obligation="informative" normative="true"><title>Normative References</title>
|
@@ -626,6 +628,8 @@ OUTPUT
|
|
626
628
|
<eref type="inline" bibitemid="ISO712" citeas="ISO 712">A</eref>
|
627
629
|
<eref type="inline" bibitemid="ISO712"><locality type="anchor"><referenceFrom>1</referenceFrom></locality>ISO 712</eref>
|
628
630
|
<eref type="inline" bibitemid="ISO712"><locality type="anchor"><referenceFrom>1</referenceFrom></locality><locality type="clause"><referenceFrom>1</referenceFrom></locality>ISO 712, Clause 1</eref>
|
631
|
+
<eref type="inline" droploc="true" bibitemid="ISO712"><locality type="anchor"><referenceFrom>1</referenceFrom></locality><locality type="clause"><referenceFrom>1</referenceFrom></locality>ISO 712, 1</eref>
|
632
|
+
<eref type="inline" case="lowercase" bibitemid="ISO712"><locality type="anchor"><referenceFrom>1</referenceFrom></locality><locality type="clause"><referenceFrom>1</referenceFrom></locality>ISO 712, clause 1</eref>
|
629
633
|
</p>
|
630
634
|
</foreword></preface>
|
631
635
|
<bibliography><references id="_normative_references" obligation="informative" normative="true"><title depth='1'>1.<tab/>Normative References</title>
|
@@ -665,6 +669,8 @@ html = <<~OUTPUT
|
|
665
669
|
<a href="#ISO712">A</a>
|
666
670
|
<a href='#ISO712'>ISO 712</a>
|
667
671
|
<a href='#ISO712'>ISO 712, Clause 1</a>
|
672
|
+
<a href='#ISO712'>ISO 712, 1</a>
|
673
|
+
<a href='#ISO712'>ISO 712, clause 1</a>
|
668
674
|
</p>
|
669
675
|
</div>
|
670
676
|
<p class="zzSTDTitle1"/>
|
@@ -1017,4 +1023,32 @@ INPUT
|
|
1017
1023
|
OUTPUT
|
1018
1024
|
end
|
1019
1025
|
|
1026
|
+
it "processes add, del" do
|
1027
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
1028
|
+
<itu-standard xmlns="https://www.calconnect.org/standards/itu">
|
1029
|
+
<preface><foreword id="A">
|
1030
|
+
<add>ABC <xref target="A"></add> <del><strong>B</strong></del>
|
1031
|
+
</foreword></preface>
|
1032
|
+
</itu-standard>
|
1033
|
+
INPUT
|
1034
|
+
#{HTML_HDR}
|
1035
|
+
<br/>
|
1036
|
+
<div id='A'>
|
1037
|
+
<h1 class='ForewordTitle'>Foreword</h1>
|
1038
|
+
<span class='addition'>
|
1039
|
+
ABC
|
1040
|
+
<a href='#A'/>
|
1041
|
+
<span class='deletion'>
|
1042
|
+
<b>B</b>
|
1043
|
+
</span>
|
1044
|
+
</span>
|
1045
|
+
</div>
|
1046
|
+
<p class='zzSTDTitle1'/>
|
1047
|
+
</div>
|
1048
|
+
</body>
|
1049
|
+
</html>
|
1050
|
+
OUTPUT
|
1051
|
+
end
|
1052
|
+
|
1053
|
+
|
1020
1054
|
end
|
@@ -27,6 +27,27 @@ RSpec.describe IsoDoc do
|
|
27
27
|
expect(html).to match(/delimiters: \[\['\(#\(', '\)#\)'\]\]/)
|
28
28
|
end
|
29
29
|
|
30
|
+
it "generates file in a remote directory" do
|
31
|
+
FileUtils.rm_f "spec/assets/test.doc"
|
32
|
+
FileUtils.rm_f "spec/assets/test.html"
|
33
|
+
IsoDoc::HtmlConvert.new({wordstylesheet: "word.css", htmlstylesheet: "html.scss", filename: "test"}).convert("spec/assets/test", <<~"INPUT", false)
|
34
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
35
|
+
<bibdata>
|
36
|
+
<title language="en">test</title>
|
37
|
+
</bibdata>
|
38
|
+
<preface><foreword>
|
39
|
+
<note>
|
40
|
+
<p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
|
41
|
+
</note>
|
42
|
+
</foreword></preface>
|
43
|
+
</iso-standard>
|
44
|
+
INPUT
|
45
|
+
expect(File.exist?("spec/assets/test.html")).to be true
|
46
|
+
html = File.read("spec/assets/test.html")
|
47
|
+
expect(html).to match(%r{<title>test</title>})
|
48
|
+
expect(html).to match(/another empty stylesheet/)
|
49
|
+
end
|
50
|
+
|
30
51
|
it "ignores Liquid markup in the document body" do
|
31
52
|
FileUtils.rm_f "test.doc"
|
32
53
|
FileUtils.rm_f "test.html"
|
@@ -108,17 +129,19 @@ expect(File.exist?("test.doc")).to be true
|
|
108
129
|
it "generates HTML output docs with null configuration from file" do
|
109
130
|
FileUtils.rm_f "spec/assets/iso.doc"
|
110
131
|
FileUtils.rm_f "spec/assets/iso.html"
|
111
|
-
IsoDoc::HtmlConvert.new({wordstylesheet: "
|
132
|
+
IsoDoc::HtmlConvert.new({wordstylesheet: "word.css", htmlstylesheet: "html.scss"}).convert("spec/assets/iso.xml", nil, false)
|
112
133
|
expect(File.exist?("spec/assets/iso.html")).to be true
|
113
134
|
html = File.read("spec/assets/iso.html")
|
114
135
|
expect(html).to match(/another empty stylesheet/)
|
115
136
|
expect(html).to match(%r{https://use.fontawesome.com})
|
116
137
|
expect(html).to match(%r{libs/jquery})
|
138
|
+
expect(html).to include "$('#toggle')"
|
139
|
+
expect(html).not_to match(/CDATA/)
|
117
140
|
end
|
118
141
|
|
119
142
|
it "generates Headless HTML output docs with null configuration from file" do
|
120
143
|
FileUtils.rm_f "spec/assets/iso.html"
|
121
|
-
IsoDoc::HeadlessHtmlConvert.new({wordstylesheet: "
|
144
|
+
IsoDoc::HeadlessHtmlConvert.new({wordstylesheet: "word.css", htmlstylesheet: "html.scss"}).convert("spec/assets/iso.xml", nil, false)
|
122
145
|
expect(File.exist?("spec/assets/iso.headless.html")).to be true
|
123
146
|
html = File.read("spec/assets/iso.headless.html")
|
124
147
|
expect(html).not_to match(/another empty stylesheet/)
|
@@ -132,7 +155,7 @@ expect(File.exist?("test.doc")).to be true
|
|
132
155
|
|
133
156
|
it "generates Word output docs with null configuration from file" do
|
134
157
|
FileUtils.rm_f "spec/assets/iso.doc"
|
135
|
-
IsoDoc::WordConvert.new({wordstylesheet: "
|
158
|
+
IsoDoc::WordConvert.new({wordstylesheet: "word.css", htmlstylesheet: "html.scss"}).convert("spec/assets/iso.xml", nil, false)
|
136
159
|
expect(File.exist?("spec/assets/iso.doc")).to be true
|
137
160
|
word = File.read("spec/assets/iso.doc")
|
138
161
|
expect(word).to match(/one empty stylesheet/)
|
@@ -217,8 +240,7 @@ expect(File.exist?("test.doc")).to be true
|
|
217
240
|
expect(word).to match(/p\.note \{[^}]*?font-size: 28pt/m)
|
218
241
|
expect(word).to match(/aside \{[^}]*?font-size: 27pt/m)
|
219
242
|
expect(word).to match(/a third empty stylesheet/)
|
220
|
-
|
221
|
-
expect(word).to match(/test_files\/header.html/)
|
243
|
+
expect(word).to match(/Content-Disposition: inline; filename="filelist.xml"/)
|
222
244
|
expect(word).to match(/an empty word cover page/)
|
223
245
|
expect(word).to match(/an empty word intro page/)
|
224
246
|
expect(word).to match(%r{Antaŭparolo</h1>})
|
@@ -248,7 +270,7 @@ expect(File.exist?("test.doc")).to be true
|
|
248
270
|
expect(word).to match(/aside \{[^}]*?font-size: 9pt/m)
|
249
271
|
expect(word).to match(/a third empty stylesheet/)
|
250
272
|
#expect(word).to match(/<title>test<\/title>/)
|
251
|
-
expect(word).to match(/
|
273
|
+
expect(word).to match(/Content-Disposition: inline; filename="filelist.xml"/)
|
252
274
|
expect(word).to match(/an empty word cover page/)
|
253
275
|
expect(word).to match(/an empty word intro page/)
|
254
276
|
expect(word).to match(%r{Antaŭparolo</h1>})
|
@@ -339,10 +361,12 @@ expect(File.exist?("test.doc")).to be true
|
|
339
361
|
</bibdata>
|
340
362
|
</iso-standard>
|
341
363
|
INPUT
|
342
|
-
word = File.read("test.doc")
|
343
|
-
sub(
|
364
|
+
word = File.read("test.doc")
|
365
|
+
.sub(%r{^.*Content-ID: <header.html>}m, "Content-ID: <header.html>")
|
366
|
+
.sub(/------=_NextPart.*$/m, "")
|
344
367
|
expect(word).to be_equivalent_to <<~"OUTPUT"
|
345
|
-
Content-
|
368
|
+
Content-ID: <header.html>
|
369
|
+
Content-Disposition: inline; filename="header.html"
|
346
370
|
Content-Transfer-Encoding: base64
|
347
371
|
Content-Type: text/html charset="utf-8"
|
348
372
|
Ci8qIGFuIGVtcHR5IGhlYWRlciAqLwoKU1RBUlQgRE9DIElEOiAKICAgICAgICAgICAxMDAwCiAg
|
@@ -356,7 +380,7 @@ ICAgICAgIDogRU5EIERPQyBJRAoKRklMRU5BTUU6IHRlc3QKCg==
|
|
356
380
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
357
381
|
<sections>
|
358
382
|
<clause id="A" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
|
359
|
-
<title>Introduction<bookmark id="Q"/> to this<fn reference="1">
|
383
|
+
<title>Introduction<bookmark id="Q"/> to this <image src="spec/assets/rice_image1.png" id="_" mimetype="image/png"/> <fn reference="1">
|
360
384
|
<p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p>
|
361
385
|
</fn></title>
|
362
386
|
</clause>
|
@@ -826,7 +850,7 @@ TOCLEVEL
|
|
826
850
|
it "moves images in HTML, using relative file location" do
|
827
851
|
FileUtils.rm_f "spec/test.html"
|
828
852
|
FileUtils.rm_rf "spec/test_htmlimages"
|
829
|
-
IsoDoc::HtmlConvert.new({wordstylesheet: "
|
853
|
+
IsoDoc::HtmlConvert.new({wordstylesheet: "assets/word.css", htmlstylesheet: "assets/html.scss"}).convert("spec/test", <<~"INPUT", false)
|
830
854
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
831
855
|
<preface><foreword>
|
832
856
|
<figure id="_">
|
@@ -895,7 +919,7 @@ TOCLEVEL
|
|
895
919
|
it "encodes images in HTML as data URIs, using relative file location" do
|
896
920
|
FileUtils.rm_f "spec/test.html"
|
897
921
|
FileUtils.rm_rf "spec/test_htmlimages"
|
898
|
-
IsoDoc::HtmlConvert.new({htmlstylesheet: "
|
922
|
+
IsoDoc::HtmlConvert.new({htmlstylesheet: "assets/html.scss", datauriimage: true}).convert("spec/test", <<~"INPUT", false)
|
899
923
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
900
924
|
<preface><foreword>
|
901
925
|
<figure id="_">
|
@@ -1,136 +1,137 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe IsoDoc do
|
4
|
-
it "generates file based on string input" do
|
5
|
-
|
6
|
-
IsoDoc::PresentationXMLConvert.new({filename: "test"})
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
4
|
+
it "generates file based on string input" do
|
5
|
+
FileUtils.rm_f "test.presentation.xml"
|
6
|
+
IsoDoc::PresentationXMLConvert.new({ filename: "test" })
|
7
|
+
.convert("test", <<~"INPUT", false)
|
8
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
9
|
+
<bibdata>
|
10
|
+
<title language="en">test</title>
|
11
|
+
</bibdata>
|
12
|
+
<preface><foreword>
|
13
|
+
<note>
|
14
|
+
<p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
|
15
|
+
</note>
|
16
|
+
</foreword></preface>
|
17
|
+
</iso-standard>
|
17
18
|
INPUT
|
18
19
|
expect(File.exist?("test.presentation.xml")).to be true
|
19
20
|
end
|
20
21
|
|
21
|
-
it "localises numbers in MathML" do
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
<
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
</iso-standard>
|
130
|
-
|
131
|
-
end
|
22
|
+
it "localises numbers in MathML" do
|
23
|
+
expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
|
24
|
+
.convert("test", <<~INPUT, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(<<~OUTPUT)
|
25
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
26
|
+
<bibdata>
|
27
|
+
<title language="en">test</title>
|
28
|
+
</bibdata>
|
29
|
+
<preface>
|
30
|
+
<p>
|
31
|
+
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>64212149677264515</mn></math></stem>
|
32
|
+
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>642121496772645.15</mn></math></stem>
|
33
|
+
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>30000</mn></math></stem>
|
34
|
+
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>P</mi><mfenced open="(" close=")"><mrow><mi>X</mi><mo>≥</mo><msub><mrow><mi>X</mi></mrow><mrow><mo>max</mo></mrow></msub></mrow></mfenced><mo>=</mo><munderover><mrow><mo>∑</mo></mrow><mrow><mrow><mi>j</mi><mo>=</mo><msub><mrow><mi>X</mi></mrow><mrow><mo>max</mo></mrow></msub></mrow></mrow><mrow><mn>1000</mn></mrow></munderover><mfenced open="(" close=")"><mtable><mtr><mtd><mn>1000</mn></mtd></mtr><mtr><mtd><mi>j</mi></mtd></mtr></mtable></mfenced><msup><mrow><mi>p</mi></mrow><mrow><mi>j</mi></mrow></msup><msup><mrow><mfenced open="(" close=")"><mrow><mn>1</mn><mo>−</mo><mi>p</mi></mrow></mfenced></mrow><mrow><mrow><mn>1.003</mn><mo>−</mo><mi>j</mi></mrow></mrow></msup></math></stem></p>
|
35
|
+
</preface>
|
36
|
+
</iso-standard>
|
37
|
+
INPUT
|
38
|
+
<iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
|
39
|
+
<bibdata>
|
40
|
+
<title language='en'>test</title>
|
41
|
+
</bibdata>
|
42
|
+
<preface>
|
43
|
+
<p>
|
44
|
+
64,212,149,677,264,515
|
45
|
+
642,121,496,772,645.15 30,000
|
46
|
+
<stem type='MathML'>
|
47
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
48
|
+
<mi>P</mi>
|
49
|
+
<mfenced open='(' close=')'>
|
50
|
+
<mrow>
|
51
|
+
<mi>X</mi>
|
52
|
+
<mo>≥</mo>
|
53
|
+
<msub>
|
54
|
+
<mrow>
|
55
|
+
<mi>X</mi>
|
56
|
+
</mrow>
|
57
|
+
<mrow>
|
58
|
+
<mo>max</mo>
|
59
|
+
</mrow>
|
60
|
+
</msub>
|
61
|
+
</mrow>
|
62
|
+
</mfenced>
|
63
|
+
<mo>=</mo>
|
64
|
+
<munderover>
|
65
|
+
<mrow>
|
66
|
+
<mo>∑</mo>
|
67
|
+
</mrow>
|
68
|
+
<mrow>
|
69
|
+
<mrow>
|
70
|
+
<mi>j</mi>
|
71
|
+
<mo>=</mo>
|
72
|
+
<msub>
|
73
|
+
<mrow>
|
74
|
+
<mi>X</mi>
|
75
|
+
</mrow>
|
76
|
+
<mrow>
|
77
|
+
<mo>max</mo>
|
78
|
+
</mrow>
|
79
|
+
</msub>
|
80
|
+
</mrow>
|
81
|
+
</mrow>
|
82
|
+
<mrow>
|
83
|
+
<mn>1,000</mn>
|
84
|
+
</mrow>
|
85
|
+
</munderover>
|
86
|
+
<mfenced open='(' close=')'>
|
87
|
+
<mtable>
|
88
|
+
<mtr>
|
89
|
+
<mtd>
|
90
|
+
<mn>1,000</mn>
|
91
|
+
</mtd>
|
92
|
+
</mtr>
|
93
|
+
<mtr>
|
94
|
+
<mtd>
|
95
|
+
<mi>j</mi>
|
96
|
+
</mtd>
|
97
|
+
</mtr>
|
98
|
+
</mtable>
|
99
|
+
</mfenced>
|
100
|
+
<msup>
|
101
|
+
<mrow>
|
102
|
+
<mi>p</mi>
|
103
|
+
</mrow>
|
104
|
+
<mrow>
|
105
|
+
<mi>j</mi>
|
106
|
+
</mrow>
|
107
|
+
</msup>
|
108
|
+
<msup>
|
109
|
+
<mrow>
|
110
|
+
<mfenced open='(' close=')'>
|
111
|
+
<mrow>
|
112
|
+
<mn>1</mn>
|
113
|
+
<mo>−</mo>
|
114
|
+
<mi>p</mi>
|
115
|
+
</mrow>
|
116
|
+
</mfenced>
|
117
|
+
</mrow>
|
118
|
+
<mrow>
|
119
|
+
<mrow>
|
120
|
+
<mn>1.003</mn>
|
121
|
+
<mo>−</mo>
|
122
|
+
<mi>j</mi>
|
123
|
+
</mrow>
|
124
|
+
</mrow>
|
125
|
+
</msup>
|
126
|
+
</math>
|
127
|
+
</stem>
|
128
|
+
</p>
|
129
|
+
</preface>
|
130
|
+
</iso-standard>
|
131
|
+
OUTPUT
|
132
|
+
end
|
132
133
|
|
133
|
-
context
|
134
|
+
context "when twitter_cldr_localiser_symbols has additional options" do
|
134
135
|
let(:input) do
|
135
136
|
<<~INPUT
|
136
137
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
@@ -362,7 +363,7 @@ end
|
|
362
363
|
{
|
363
364
|
fraction_group_digits: 2,
|
364
365
|
fraction_group: "'",
|
365
|
-
precision: 5
|
366
|
+
precision: 5,
|
366
367
|
}
|
367
368
|
end
|
368
369
|
|
@@ -372,234 +373,236 @@ end
|
|
372
373
|
end
|
373
374
|
|
374
375
|
it "Supports twitter_cldr_localiser_symbols fraction options" do
|
375
|
-
expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
|
376
|
-
|
376
|
+
expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
|
377
|
+
.convert("test", input, true))
|
378
|
+
.sub(%r{<localized-strings>.*</localized-strings>}m, ""))
|
377
379
|
.to(be_equivalent_to(xmlpp(output)))
|
378
380
|
end
|
379
381
|
end
|
380
382
|
|
381
|
-
it "localises numbers in MathML in French" do
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
<
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
</iso-standard>
|
488
|
-
|
489
|
-
end
|
383
|
+
it "localises numbers in MathML in French" do
|
384
|
+
expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
|
385
|
+
.convert("test", <<~INPUT, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(<<~OUTPUT)
|
386
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
387
|
+
<bibdata>
|
388
|
+
<title language="en">test</title>
|
389
|
+
<language>fr</language>
|
390
|
+
</bibdata>
|
391
|
+
<preface>
|
392
|
+
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>30000</mn></math>
|
393
|
+
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>P</mi><mfenced open="(" close=")"><mrow><mi>X</mi><mo>≥</mo><msub><mrow><mi>X</mi></mrow><mrow><mo>max</mo></mrow></msub></mrow></mfenced><mo>=</mo><munderover><mrow><mo>∑</mo></mrow><mrow><mrow><mi>j</mi><mo>=</mo><msub><mrow><mi>X</mi></mrow><mrow><mo>max</mo></mrow></msub></mrow></mrow><mrow><mn>1000</mn></mrow></munderover><mfenced open="(" close=")"><mtable><mtr><mtd><mn>1000</mn></mtd></mtr><mtr><mtd><mi>j</mi></mtd></mtr></mtable></mfenced><msup><mrow><mi>p</mi></mrow><mrow><mi>j</mi></mrow></msup><msup><mrow><mfenced open="(" close=")"><mrow><mn>1</mn><mo>−</mo><mi>p</mi></mrow></mfenced></mrow><mrow><mrow><mn>1.003</mn><mo>−</mo><mi>j</mi></mrow></mrow></msup></math></stem></p>
|
394
|
+
</preface>
|
395
|
+
</iso-standard>
|
396
|
+
INPUT
|
397
|
+
<iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
|
398
|
+
<bibdata>
|
399
|
+
<title language='en'>test</title>
|
400
|
+
<language current='true'>fr</language>
|
401
|
+
</bibdata>
|
402
|
+
<preface>
|
403
|
+
<p>
|
404
|
+
30 000
|
405
|
+
<stem type='MathML'>
|
406
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
407
|
+
<mi>P</mi>
|
408
|
+
<mfenced open='(' close=')'>
|
409
|
+
<mrow>
|
410
|
+
<mi>X</mi>
|
411
|
+
<mo>≥</mo>
|
412
|
+
<msub>
|
413
|
+
<mrow>
|
414
|
+
<mi>X</mi>
|
415
|
+
</mrow>
|
416
|
+
<mrow>
|
417
|
+
<mo>max</mo>
|
418
|
+
</mrow>
|
419
|
+
</msub>
|
420
|
+
</mrow>
|
421
|
+
</mfenced>
|
422
|
+
<mo>=</mo>
|
423
|
+
<munderover>
|
424
|
+
<mrow>
|
425
|
+
<mo>∑</mo>
|
426
|
+
</mrow>
|
427
|
+
<mrow>
|
428
|
+
<mrow>
|
429
|
+
<mi>j</mi>
|
430
|
+
<mo>=</mo>
|
431
|
+
<msub>
|
432
|
+
<mrow>
|
433
|
+
<mi>X</mi>
|
434
|
+
</mrow>
|
435
|
+
<mrow>
|
436
|
+
<mo>max</mo>
|
437
|
+
</mrow>
|
438
|
+
</msub>
|
439
|
+
</mrow>
|
440
|
+
</mrow>
|
441
|
+
<mrow>
|
442
|
+
<mn>1 000</mn>
|
443
|
+
</mrow>
|
444
|
+
</munderover>
|
445
|
+
<mfenced open='(' close=')'>
|
446
|
+
<mtable>
|
447
|
+
<mtr>
|
448
|
+
<mtd>
|
449
|
+
<mn>1 000</mn>
|
450
|
+
</mtd>
|
451
|
+
</mtr>
|
452
|
+
<mtr>
|
453
|
+
<mtd>
|
454
|
+
<mi>j</mi>
|
455
|
+
</mtd>
|
456
|
+
</mtr>
|
457
|
+
</mtable>
|
458
|
+
</mfenced>
|
459
|
+
<msup>
|
460
|
+
<mrow>
|
461
|
+
<mi>p</mi>
|
462
|
+
</mrow>
|
463
|
+
<mrow>
|
464
|
+
<mi>j</mi>
|
465
|
+
</mrow>
|
466
|
+
</msup>
|
467
|
+
<msup>
|
468
|
+
<mrow>
|
469
|
+
<mfenced open='(' close=')'>
|
470
|
+
<mrow>
|
471
|
+
<mn>1</mn>
|
472
|
+
<mo>−</mo>
|
473
|
+
<mi>p</mi>
|
474
|
+
</mrow>
|
475
|
+
</mfenced>
|
476
|
+
</mrow>
|
477
|
+
<mrow>
|
478
|
+
<mrow>
|
479
|
+
<mn>1,003</mn>
|
480
|
+
<mo>−</mo>
|
481
|
+
<mi>j</mi>
|
482
|
+
</mrow>
|
483
|
+
</mrow>
|
484
|
+
</msup>
|
485
|
+
</math>
|
486
|
+
</stem>
|
487
|
+
</p>
|
488
|
+
</preface>
|
489
|
+
</iso-standard>
|
490
|
+
OUTPUT
|
491
|
+
end
|
490
492
|
|
491
|
-
it "customises localisation of numbers" do
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
<
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
493
|
+
it "customises localisation of numbers" do
|
494
|
+
mock_symbols
|
495
|
+
expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
|
496
|
+
.convert("test", <<~INPUT, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(<<~OUTPUT)
|
497
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
498
|
+
<bibdata>
|
499
|
+
<title language="en">test</title>
|
500
|
+
<language>fr</language>
|
501
|
+
</bibdata>
|
502
|
+
<preface>
|
503
|
+
<p><stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>30000</mn></math></stem>
|
504
|
+
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>P</mi><mfenced open="(" close=")"><mrow><mi>X</mi><mo>≥</mo><msub><mrow><mi>X</mi></mrow><mrow><mo>max</mo></mrow></msub></mrow></mfenced><mo>=</mo><munderover><mrow><mo>∑</mo></mrow><mrow><mrow><mi>j</mi><mo>=</mo><msub><mrow><mi>X</mi></mrow><mrow><mo>max</mo></mrow></msub></mrow></mrow><mrow><mn>1000</mn></mrow></munderover><mfenced open="(" close=")"><mtable><mtr><mtd><mn>1000</mn></mtd></mtr><mtr><mtd><mi>j</mi></mtd></mtr></mtable></mfenced><msup><mrow><mi>p</mi></mrow><mrow><mi>j</mi></mrow></msup><msup><mrow><mfenced open="(" close=")"><mrow><mn>0.0000032</mn><mo>−</mo><mi>p</mi></mrow></mfenced></mrow><mrow><mrow><mn>1.003</mn><mo>−</mo><mi>j</mi></mrow></mrow></msup></math></stem></p>
|
505
|
+
</preface>
|
506
|
+
</iso-standard>
|
507
|
+
INPUT
|
508
|
+
<iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
|
509
|
+
<bibdata>
|
510
|
+
<title language='en'>test</title>
|
511
|
+
<language current='true'>fr</language>
|
512
|
+
</bibdata>
|
510
513
|
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
<mrow>
|
519
|
-
<mi>X</mi>
|
520
|
-
<mo>≥</mo>
|
521
|
-
<msub>
|
522
|
-
<mrow>
|
523
|
-
<mi>X</mi>
|
524
|
-
</mrow>
|
525
|
-
<mrow>
|
526
|
-
<mo>max</mo>
|
527
|
-
</mrow>
|
528
|
-
</msub>
|
529
|
-
</mrow>
|
530
|
-
</mfenced>
|
531
|
-
<mo>=</mo>
|
532
|
-
<munderover>
|
533
|
-
<mrow>
|
534
|
-
<mo>∑</mo>
|
535
|
-
</mrow>
|
536
|
-
<mrow>
|
537
|
-
<mrow>
|
538
|
-
<mi>j</mi>
|
539
|
-
<mo>=</mo>
|
540
|
-
<msub>
|
514
|
+
<preface>
|
515
|
+
<p>
|
516
|
+
30'000
|
517
|
+
<stem type='MathML'>
|
518
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
519
|
+
<mi>P</mi>
|
520
|
+
<mfenced open='(' close=')'>
|
541
521
|
<mrow>
|
542
522
|
<mi>X</mi>
|
523
|
+
<mo>≥</mo>
|
524
|
+
<msub>
|
525
|
+
<mrow>
|
526
|
+
<mi>X</mi>
|
527
|
+
</mrow>
|
528
|
+
<mrow>
|
529
|
+
<mo>max</mo>
|
530
|
+
</mrow>
|
531
|
+
</msub>
|
532
|
+
</mrow>
|
533
|
+
</mfenced>
|
534
|
+
<mo>=</mo>
|
535
|
+
<munderover>
|
536
|
+
<mrow>
|
537
|
+
<mo>∑</mo>
|
543
538
|
</mrow>
|
544
539
|
<mrow>
|
545
|
-
<
|
540
|
+
<mrow>
|
541
|
+
<mi>j</mi>
|
542
|
+
<mo>=</mo>
|
543
|
+
<msub>
|
544
|
+
<mrow>
|
545
|
+
<mi>X</mi>
|
546
|
+
</mrow>
|
547
|
+
<mrow>
|
548
|
+
<mo>max</mo>
|
549
|
+
</mrow>
|
550
|
+
</msub>
|
551
|
+
</mrow>
|
546
552
|
</mrow>
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
</
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
</
|
592
|
-
</
|
593
|
-
</
|
594
|
-
</
|
595
|
-
</
|
596
|
-
|
597
|
-
|
598
|
-
</iso-standard>
|
599
|
-
OUTPUT
|
600
|
-
end
|
553
|
+
<mrow>
|
554
|
+
<mn>1'000</mn>
|
555
|
+
</mrow>
|
556
|
+
</munderover>
|
557
|
+
<mfenced open='(' close=')'>
|
558
|
+
<mtable>
|
559
|
+
<mtr>
|
560
|
+
<mtd>
|
561
|
+
<mn>1'000</mn>
|
562
|
+
</mtd>
|
563
|
+
</mtr>
|
564
|
+
<mtr>
|
565
|
+
<mtd>
|
566
|
+
<mi>j</mi>
|
567
|
+
</mtd>
|
568
|
+
</mtr>
|
569
|
+
</mtable>
|
570
|
+
</mfenced>
|
571
|
+
<msup>
|
572
|
+
<mrow>
|
573
|
+
<mi>p</mi>
|
574
|
+
</mrow>
|
575
|
+
<mrow>
|
576
|
+
<mi>j</mi>
|
577
|
+
</mrow>
|
578
|
+
</msup>
|
579
|
+
<msup>
|
580
|
+
<mrow>
|
581
|
+
<mfenced open='(' close=')'>
|
582
|
+
<mrow>
|
583
|
+
<mn>0,0000032</mn>
|
584
|
+
<mo>−</mo>
|
585
|
+
<mi>p</mi>
|
586
|
+
</mrow>
|
587
|
+
</mfenced>
|
588
|
+
</mrow>
|
589
|
+
<mrow>
|
590
|
+
<mrow>
|
591
|
+
<mn>1,003</mn>
|
592
|
+
<mo>−</mo>
|
593
|
+
<mi>j</mi>
|
594
|
+
</mrow>
|
595
|
+
</mrow>
|
596
|
+
</msup>
|
597
|
+
</math>
|
598
|
+
</stem>
|
599
|
+
</p>
|
600
|
+
</preface>
|
601
|
+
</iso-standard>
|
602
|
+
OUTPUT
|
603
|
+
end
|
601
604
|
|
602
|
-
private
|
605
|
+
private
|
603
606
|
|
604
607
|
def mock_symbols
|
605
608
|
allow_any_instance_of(::IsoDoc::PresentationXMLConvert).to receive(:twitter_cldr_localiser_symbols).and_return(group: "'")
|