isodoc 1.6.3 → 1.6.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@
3
3
  require "spec_helper"
4
4
  require "fileutils"
5
5
 
6
- OPTIONS = { wordstylesheet: "spec/assets/word.css",
6
+ options = { wordstylesheet: "spec/assets/word.css",
7
7
  htmlstylesheet: "spec/assets/html.scss" }
8
8
 
9
9
  RSpec.describe IsoDoc do
@@ -191,6 +191,7 @@ RSpec.describe IsoDoc do
191
191
  htmlcoverpage: "spec/assets/htmlcover.html",
192
192
  htmlintropage: "spec/assets/htmlintro.html",
193
193
  scripts: "spec/assets/scripts.html",
194
+ scripts_override: "spec/assets/scripts_override.html",
194
195
  i18nyaml: "spec/assets/i18n.yaml",
195
196
  ulstyle: "l1",
196
197
  olstyle: "l2" },
@@ -215,6 +216,7 @@ RSpec.describe IsoDoc do
215
216
  expect(html).to match(/an empty html cover page/)
216
217
  expect(html).to match(/an empty html intro page/)
217
218
  expect(html).to match(/This is > a script/)
219
+ expect(html).to match(/This is > also a script/)
218
220
  expect(html).not_to match(/CDATA/)
219
221
  expect(html).to match(%r{Anta&#x16D;parolo</h1>})
220
222
  expect(html).to match(%r{html-override})
@@ -957,7 +959,9 @@ RSpec.describe IsoDoc do
957
959
  it "moves images in HTML, using relative file location" do
958
960
  FileUtils.rm_f "spec/test.html"
959
961
  FileUtils.rm_rf "spec/test_htmlimages"
960
- IsoDoc::HtmlConvert.new({ wordstylesheet: "assets/word.css", htmlstylesheet: "assets/html.scss" })
962
+ IsoDoc::HtmlConvert
963
+ .new(wordstylesheet: "assets/word.css",
964
+ htmlstylesheet: "assets/html.scss")
961
965
  .convert("spec/test", <<~"INPUT", false)
962
966
  <iso-standard xmlns="http://riboseinc.com/isoxml">
963
967
  <preface><foreword>
@@ -996,7 +1000,7 @@ RSpec.describe IsoDoc do
996
1000
  it "encodes images in HTML as data URIs" do
997
1001
  FileUtils.rm_f "test.html"
998
1002
  FileUtils.rm_rf "test_htmlimages"
999
- IsoDoc::HtmlConvert.new({ htmlstylesheet: "spec/assets/html.scss", datauriimage: true })
1003
+ IsoDoc::HtmlConvert.new(htmlstylesheet: "spec/assets/html.scss", datauriimage: true)
1000
1004
  .convert("test", <<~"INPUT", false)
1001
1005
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1002
1006
  <preface><foreword>
@@ -1064,7 +1068,7 @@ RSpec.describe IsoDoc do
1064
1068
  it "processes IsoXML terms for HTML" do
1065
1069
  FileUtils.rm_f "test.html"
1066
1070
  FileUtils.rm_f "test.doc"
1067
- IsoDoc::HtmlConvert.new(OPTIONS)
1071
+ IsoDoc::HtmlConvert.new(options)
1068
1072
  .convert("test", <<~"INPUT", false)
1069
1073
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1070
1074
  <sections>
@@ -1121,7 +1125,7 @@ RSpec.describe IsoDoc do
1121
1125
  it "processes empty term modifications" do
1122
1126
  FileUtils.rm_f "test.html"
1123
1127
  FileUtils.rm_f "test.doc"
1124
- IsoDoc::HtmlConvert.new(OPTIONS)
1128
+ IsoDoc::HtmlConvert.new(options)
1125
1129
  .convert("test", <<~"INPUT", false)
1126
1130
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1127
1131
  <sections>
@@ -1158,7 +1162,7 @@ RSpec.describe IsoDoc do
1158
1162
  it "creates continuation styles for multiparagraph list items in Word" do
1159
1163
  FileUtils.rm_f "test.doc"
1160
1164
  FileUtils.rm_f "test.html"
1161
- IsoDoc::WordConvert.new(OPTIONS)
1165
+ IsoDoc::WordConvert.new(options)
1162
1166
  .convert("test", <<~"INPUT", false)
1163
1167
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1164
1168
  <preface><foreword>
@@ -1269,7 +1273,7 @@ RSpec.describe IsoDoc do
1269
1273
  it "does not lose HTML escapes in postprocessing" do
1270
1274
  FileUtils.rm_f "test.doc"
1271
1275
  FileUtils.rm_f "test.html"
1272
- IsoDoc::HtmlConvert.new(OPTIONS)
1276
+ IsoDoc::HtmlConvert.new(options)
1273
1277
  .convert("test", <<~"INPUT", false)
1274
1278
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1275
1279
  <preface><foreword>
@@ -1300,7 +1304,7 @@ RSpec.describe IsoDoc do
1300
1304
  it "does not lose HTML escapes in postprocessing (Word)" do
1301
1305
  FileUtils.rm_f "test.doc"
1302
1306
  FileUtils.rm_f "test.html"
1303
- IsoDoc::WordConvert.new(OPTIONS)
1307
+ IsoDoc::WordConvert.new(options)
1304
1308
  .convert("test", <<~"INPUT", false)
1305
1309
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1306
1310
  <preface><foreword>
@@ -1331,7 +1335,7 @@ RSpec.describe IsoDoc do
1331
1335
  it "propagates example style to paragraphs in postprocessing (Word)" do
1332
1336
  FileUtils.rm_f "test.doc"
1333
1337
  FileUtils.rm_f "test.html"
1334
- IsoDoc::WordConvert.new(OPTIONS).convert("test", <<~"INPUT", false)
1338
+ IsoDoc::WordConvert.new(options).convert("test", <<~"INPUT", false)
1335
1339
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1336
1340
  <preface><foreword>
1337
1341
  <example id="samplecode">
@@ -1362,7 +1366,7 @@ RSpec.describe IsoDoc do
1362
1366
  it "deals with image captions (Word)" do
1363
1367
  FileUtils.rm_f "test.doc"
1364
1368
  FileUtils.rm_f "test.html"
1365
- IsoDoc::WordConvert.new(OPTIONS)
1369
+ IsoDoc::WordConvert.new(options)
1366
1370
  .convert("test", <<~"INPUT", false)
1367
1371
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1368
1372
  <preface><foreword>
@@ -1396,7 +1400,7 @@ RSpec.describe IsoDoc do
1396
1400
  it "deals with empty table titles (Word)" do
1397
1401
  FileUtils.rm_f "test.doc"
1398
1402
  FileUtils.rm_f "test.html"
1399
- IsoDoc::WordConvert.new(OPTIONS)
1403
+ IsoDoc::WordConvert.new(options)
1400
1404
  .convert("test", <<~"INPUT", false)
1401
1405
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1402
1406
  <preface><foreword>
@@ -1457,22 +1461,21 @@ RSpec.describe IsoDoc do
1457
1461
  it "propagates alignment of table cells (Word)" do
1458
1462
  FileUtils.rm_f "test.doc"
1459
1463
  FileUtils.rm_f "test.html"
1460
- IsoDoc::WordConvert.new(OPTIONS)
1464
+ IsoDoc::WordConvert.new(options)
1461
1465
  .convert("test", <<~"INPUT", false)
1462
- #{' '}
1463
- <iso-standard xmlns="http://riboseinc.com/isoxml">
1464
- <preface><foreword>
1465
- <table id="_fe12b8f8-6858-4cd6-af7d-d4b6f3ebd1a7" unnumbered="true"><thead><tr>
1466
- <td rowspan="2" align="left">
1467
- <p id="_c47d9b39-adb2-431d-9320-78cb148fdb56">Output wavelength</p>
1468
- <p id="_c47d9b39-adb2-431d-9320-78cb148fdb57">Output wavelength</p>
1469
- </td>
1470
- <th colspan="3" align="right"><p id="_c47d9b39-adb2-431d-9320-78cb148fdb58">Predictive wavelengths</p></th>
1471
- </tr>
1472
- </thead>
1473
- </table>
1474
- </preface>
1475
- </iso-standard>
1466
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1467
+ <preface><foreword>
1468
+ <table id="_fe12b8f8-6858-4cd6-af7d-d4b6f3ebd1a7" unnumbered="true"><thead><tr>
1469
+ <td rowspan="2" align="left">
1470
+ <p id="_c47d9b39-adb2-431d-9320-78cb148fdb56">Output wavelength</p>
1471
+ <p id="_c47d9b39-adb2-431d-9320-78cb148fdb57">Output wavelength</p>
1472
+ </td>
1473
+ <th colspan="3" align="right"><p id="_c47d9b39-adb2-431d-9320-78cb148fdb58">Predictive wavelengths</p></th>
1474
+ </tr>
1475
+ </thead>
1476
+ </table>
1477
+ </preface>
1478
+ </iso-standard>
1476
1479
  INPUT
1477
1480
  word = File.read("test.doc")
1478
1481
  .sub(/^.*<div class="WordSection2">/m, '<div class="WordSection2" xmlns:m="m">')
@@ -1517,7 +1520,7 @@ RSpec.describe IsoDoc do
1517
1520
  end
1518
1521
 
1519
1522
  it "cleans up boilerplate" do
1520
- expect(xmlpp(IsoDoc::HtmlConvert.new({ wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.scss", filename: "test" }).html_preface(Nokogiri::XML(<<~INPUT)).to_xml).sub(/^.*<main/m, "<main").sub(%r{</main>.*$}m, "</main>")).to be_equivalent_to xmlpp(<<~"OUTPUT")
1523
+ input = <<~INPUT
1521
1524
  <html>
1522
1525
  <head/>
1523
1526
  <body>
@@ -1535,6 +1538,7 @@ RSpec.describe IsoDoc do
1535
1538
  </body>
1536
1539
  </html>
1537
1540
  INPUT
1541
+ html = <<~OUTPUT
1538
1542
  <main class='main-section'>
1539
1543
  <button onclick='topFunction()' id='myBtn' title='Go to top'>Top</button>
1540
1544
  <hr/>
@@ -1552,27 +1556,7 @@ RSpec.describe IsoDoc do
1552
1556
  </div>
1553
1557
  </main>
1554
1558
  OUTPUT
1555
- end
1556
-
1557
- it "cleans up boilerplate (Word)" do
1558
- expect(xmlpp(IsoDoc::WordConvert.new({ wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.scss", filename: "test" }).word_cleanup(Nokogiri::XML(<<~INPUT)).to_xml).sub(/^.*<main/m, "<main").sub(%r{</main>.*$}m, "</main>")).to be_equivalent_to xmlpp(<<~"OUTPUT")
1559
- <html>
1560
- <head/>
1561
- <body>
1562
- <div class="main-section">
1563
- <div id="boilerplate-copyright"> <h1>Copyright</h1> </div>
1564
- <div id="boilerplate-license"> <h1>License</h1> </div>
1565
- <div id="boilerplate-legal"> <h1>Legal</h1> </div>
1566
- <div id="boilerplate-feedback"> <h1>Feedback</h1> </div>
1567
- <hr/>
1568
- <div id="boilerplate-feedback-destination"/>
1569
- <div id="boilerplate-legal-destination"/>
1570
- <div id="boilerplate-license-destination"/>
1571
- <div id="boilerplate-copyright-destination"/>
1572
- </div>
1573
- </body>
1574
- </html>
1575
- INPUT
1559
+ doc = <<~OUTPUT
1576
1560
  <html>
1577
1561
  <head/>
1578
1562
  <body>
@@ -1594,6 +1578,18 @@ RSpec.describe IsoDoc do
1594
1578
  </body>
1595
1579
  </html>
1596
1580
  OUTPUT
1581
+ expect(xmlpp(IsoDoc::HtmlConvert
1582
+ .new(wordstylesheet: "spec/assets/word.css",
1583
+ htmlstylesheet: "spec/assets/html.scss", filename: "test")
1584
+ .html_preface(Nokogiri::XML(input)).to_xml)
1585
+ .sub(/^.*<main/m, "<main").sub(%r{</main>.*$}m, "</main>"))
1586
+ .to be_equivalent_to xmlpp(html)
1587
+ expect(xmlpp(IsoDoc::WordConvert
1588
+ .new(wordstylesheet: "spec/assets/word.css",
1589
+ htmlstylesheet: "spec/assets/html.scss", filename: "test")
1590
+ .word_cleanup(Nokogiri::XML(input)).to_xml)
1591
+ .sub(/^.*<main/m, "<main").sub(%r{</main>.*$}m, "</main>"))
1592
+ .to be_equivalent_to xmlpp(doc)
1597
1593
  end
1598
1594
 
1599
1595
  it "deals with landscape and portrait pagebreaks (Word)" do
@@ -1796,7 +1792,7 @@ RSpec.describe IsoDoc do
1796
1792
  end
1797
1793
 
1798
1794
  it "expands out nested tables in Word" do
1799
- expect(xmlpp(IsoDoc::WordConvert.new({ wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.scss", filename: "test" }).word_cleanup(Nokogiri::XML(<<~INPUT)).to_xml).sub(/^.*<main/m, "<main").sub(%r{</main>.*$}m, "</main>")).to be_equivalent_to xmlpp(<<~"OUTPUT")
1795
+ input = <<~INPUT
1800
1796
  <html>
1801
1797
  <head/>
1802
1798
  <body>
@@ -1818,6 +1814,7 @@ RSpec.describe IsoDoc do
1818
1814
  </body>
1819
1815
  </html>
1820
1816
  INPUT
1817
+ output = <<~OUTPUT
1821
1818
  <html>
1822
1819
  <head/>
1823
1820
  <body>
@@ -1913,10 +1910,16 @@ RSpec.describe IsoDoc do
1913
1910
  </body>
1914
1911
  </html>
1915
1912
  OUTPUT
1913
+ expect(xmlpp(IsoDoc::WordConvert
1914
+ .new(wordstylesheet: "spec/assets/word.css",
1915
+ htmlstylesheet: "spec/assets/html.scss", filename: "test")
1916
+ .word_cleanup(Nokogiri::XML(input)).to_xml)
1917
+ .sub(/^.*<main/m, "<main").sub(%r{</main>.*$}m, "</main>"))
1918
+ .to be_equivalent_to xmlpp(output)
1916
1919
  end
1917
1920
 
1918
1921
  it "allocate widths to tables (Word)" do
1919
- expect(xmlpp(IsoDoc::WordConvert.new({ wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.scss", filename: "test" }).word_cleanup(Nokogiri::XML(<<~INPUT)).to_xml).sub(/^.*<main/m, "<main").sub(%r{</main>.*$}m, "</main>")).to be_equivalent_to xmlpp(<<~"OUTPUT")
1922
+ input = <<~INPUT
1920
1923
  <html xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
1921
1924
  <head><style/></head>
1922
1925
  <body lang='EN-US' link='blue' vlink='#954F72'>
@@ -2050,6 +2053,7 @@ RSpec.describe IsoDoc do
2050
2053
  </body>
2051
2054
  </html>
2052
2055
  INPUT
2056
+ output = <<~OUTPUT
2053
2057
  <html xmlns:epub='http://www.idpf.org/2007/ops' lang='en'>
2054
2058
  <head>
2055
2059
  <style/>
@@ -2185,5 +2189,62 @@ RSpec.describe IsoDoc do
2185
2189
  </body>
2186
2190
  </html>
2187
2191
  OUTPUT
2192
+ expect(xmlpp(IsoDoc::WordConvert
2193
+ .new(wordstylesheet: "spec/assets/word.css",
2194
+ htmlstylesheet: "spec/assets/html.scss", filename: "test")
2195
+ .word_cleanup(Nokogiri::XML(input)).to_xml)
2196
+ .sub(/^.*<main/m, "<main").sub(%r{</main>.*$}m, "</main>"))
2197
+ .to be_equivalent_to xmlpp(output)
2198
+ end
2199
+
2200
+ it "generates bare HTML file" do
2201
+ FileUtils.rm_f "test.html"
2202
+ IsoDoc::HtmlConvert.new(
2203
+ { bare: true,
2204
+ htmlstylesheet: "spec/assets/html.scss",
2205
+ filename: "test" },
2206
+ ).convert("test", <<~"INPUT", false)
2207
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
2208
+ <bibdata>
2209
+ <title language="en">test</title>
2210
+ </bibdata>
2211
+ <boilerplate>
2212
+ <feedback-statement>
2213
+ <clause><title>I am boilerplate</title></clause>
2214
+ </feedback-statement>
2215
+ </boilerplate>
2216
+ <preface><foreword>
2217
+ <note>
2218
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
2219
+ </note>
2220
+ </foreword></preface>
2221
+ </iso-standard>
2222
+ INPUT
2223
+ output = <<~OUTPUT
2224
+ <body lang='en' xml:lang='en'>
2225
+ <main class='main-section'>
2226
+ <button onclick='topFunction()' id='myBtn' title='Go to top'>Top</button>
2227
+ <br/>
2228
+ <div>
2229
+ <h1 class='ForewordTitle'>Foreword</h1>
2230
+ <div class='Note'>
2231
+ <p>
2232
+ &#xA0; These results are based on a study carried out on three
2233
+ different types of kernel.
2234
+ </p>
2235
+ </div>
2236
+ </div>
2237
+ <p class='zzSTDTitle1'>test</p>
2238
+ </main>
2239
+ <script/>
2240
+ </body>
2241
+ OUTPUT
2242
+ expect(File.exist?("test.html")).to be true
2243
+ html = File.read("test.html")
2244
+ .sub(%r{^.*<body}m, "<body")
2245
+ .sub(%r{</body>.*$}m, "</body>")
2246
+ .gsub(%r{<script.+?</script>}m, "<script/>")
2247
+ .sub(%r{(<script/>\s+)+}m, "<script/>")
2248
+ expect(xmlpp(html)).to be_equivalent_to xmlpp(output)
2188
2249
  end
2189
2250
  end
@@ -20,36 +20,55 @@ RSpec.describe IsoDoc do
20
20
  end
21
21
 
22
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">
23
+ input = <<~INPUT
24
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
25
+ <bibdata>
26
+ <title language="en">test</title>
27
+ </bibdata>
28
+ <preface>
29
+ <p>
30
+ <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>64212149677264515</mn></math></stem>
31
+ <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>642121496772645.15</mn></math></stem>
32
+ <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>30000</mn></math></stem>
33
+ <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>
34
+ </preface>
35
+ </iso-standard>
36
+ INPUT
37
+ output = <<~OUTPUT
38
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
26
39
  <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=')'>
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>&#x2265;</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>&#x2211;</mo>
67
+ </mrow>
68
+ <mrow>
50
69
  <mrow>
51
- <mi>X</mi>
52
- <mo>&#x2265;</mo>
70
+ <mi>j</mi>
71
+ <mo>=</mo>
53
72
  <msub>
54
73
  <mrow>
55
74
  <mi>X</mi>
@@ -59,76 +78,61 @@ RSpec.describe IsoDoc do
59
78
  </mrow>
60
79
  </msub>
61
80
  </mrow>
62
- </mfenced>
63
- <mo>=</mo>
64
- <munderover>
65
- <mrow>
66
- <mo>&#x2211;</mo>
67
- </mrow>
68
- <mrow>
69
- <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>
70
95
  <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>&#x2212;</mo>
114
- <mi>p</mi>
115
- </mrow>
116
- </mfenced>
117
- </mrow>
118
- <mrow>
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=')'>
119
111
  <mrow>
120
- <mn>1.003</mn>
112
+ <mn>1</mn>
121
113
  <mo>&#x2212;</mo>
122
- <mi>j</mi>
114
+ <mi>p</mi>
123
115
  </mrow>
116
+ </mfenced>
117
+ </mrow>
118
+ <mrow>
119
+ <mrow>
120
+ <mn>1.003</mn>
121
+ <mo>&#x2212;</mo>
122
+ <mi>j</mi>
124
123
  </mrow>
125
- </msup>
126
- </math>
127
- </stem>
128
- </p>
129
- </preface>
130
- </iso-standard>
131
- OUTPUT
124
+ </mrow>
125
+ </msup>
126
+ </math>
127
+ </stem>
128
+ </p>
129
+ </preface>
130
+ </iso-standard>
131
+ OUTPUT
132
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
133
+ .convert("test", input, true))
134
+ .sub(%r{<localized-strings>.*</localized-strings>}m, ""))
135
+ .to be_equivalent_to xmlpp(output)
132
136
  end
133
137
 
134
138
  context "when twitter_cldr_localiser_symbols has additional options" do
@@ -369,7 +373,8 @@ RSpec.describe IsoDoc do
369
373
 
370
374
  before do
371
375
  allow_any_instance_of(IsoDoc::PresentationXMLConvert)
372
- .to(receive(:twitter_cldr_localiser_symbols).and_return(additional_symbols))
376
+ .to(receive(:twitter_cldr_localiser_symbols)
377
+ .and_return(additional_symbols))
373
378
  end
374
379
 
375
380
  it "Supports twitter_cldr_localiser_symbols fraction options" do
@@ -381,34 +386,53 @@ RSpec.describe IsoDoc do
381
386
  end
382
387
 
383
388
  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">
389
+ input = <<~INPUT
390
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
391
+ <bibdata>
392
+ <title language="en">test</title>
393
+ <language>fr</language>
394
+ </bibdata>
395
+ <preface>
396
+ <p><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>30000</mn></math>
397
+ <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>
398
+ </preface>
399
+ </iso-standard>
400
+ INPUT
401
+ output = <<~OUTPUT
402
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
387
403
  <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&#x202F;000
405
- <stem type='MathML'>
406
- <math xmlns='http://www.w3.org/1998/Math/MathML'>
407
- <mi>P</mi>
408
- <mfenced open='(' close=')'>
404
+ <title language='en'>test</title>
405
+ <language current='true'>fr</language>
406
+ </bibdata>
407
+ <preface>
408
+ <p>
409
+ 30&#x202F;000
410
+ <stem type='MathML'>
411
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
412
+ <mi>P</mi>
413
+ <mfenced open='(' close=')'>
414
+ <mrow>
415
+ <mi>X</mi>
416
+ <mo>&#x2265;</mo>
417
+ <msub>
418
+ <mrow>
419
+ <mi>X</mi>
420
+ </mrow>
421
+ <mrow>
422
+ <mo>max</mo>
423
+ </mrow>
424
+ </msub>
425
+ </mrow>
426
+ </mfenced>
427
+ <mo>=</mo>
428
+ <munderover>
429
+ <mrow>
430
+ <mo>&#x2211;</mo>
431
+ </mrow>
432
+ <mrow>
409
433
  <mrow>
410
- <mi>X</mi>
411
- <mo>&#x2265;</mo>
434
+ <mi>j</mi>
435
+ <mo>=</mo>
412
436
  <msub>
413
437
  <mrow>
414
438
  <mi>X</mi>
@@ -418,109 +442,113 @@ RSpec.describe IsoDoc do
418
442
  </mrow>
419
443
  </msub>
420
444
  </mrow>
421
- </mfenced>
422
- <mo>=</mo>
423
- <munderover>
424
- <mrow>
425
- <mo>&#x2211;</mo>
426
- </mrow>
427
- <mrow>
428
- <mrow>
445
+ </mrow>
446
+ <mrow>
447
+ <mn>1&#x202F;000</mn>
448
+ </mrow>
449
+ </munderover>
450
+ <mfenced open='(' close=')'>
451
+ <mtable>
452
+ <mtr>
453
+ <mtd>
454
+ <mn>1&#x202F;000</mn>
455
+ </mtd>
456
+ </mtr>
457
+ <mtr>
458
+ <mtd>
429
459
  <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&#x202F;000</mn>
443
- </mrow>
444
- </munderover>
445
- <mfenced open='(' close=')'>
446
- <mtable>
447
- <mtr>
448
- <mtd>
449
- <mn>1&#x202F;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>&#x2212;</mo>
473
- <mi>p</mi>
474
- </mrow>
475
- </mfenced>
476
- </mrow>
477
- <mrow>
460
+ </mtd>
461
+ </mtr>
462
+ </mtable>
463
+ </mfenced>
464
+ <msup>
465
+ <mrow>
466
+ <mi>p</mi>
467
+ </mrow>
468
+ <mrow>
469
+ <mi>j</mi>
470
+ </mrow>
471
+ </msup>
472
+ <msup>
473
+ <mrow>
474
+ <mfenced open='(' close=')'>
478
475
  <mrow>
479
- <mn>1,003</mn>
476
+ <mn>1</mn>
480
477
  <mo>&#x2212;</mo>
481
- <mi>j</mi>
478
+ <mi>p</mi>
482
479
  </mrow>
480
+ </mfenced>
481
+ </mrow>
482
+ <mrow>
483
+ <mrow>
484
+ <mn>1,003</mn>
485
+ <mo>&#x2212;</mo>
486
+ <mi>j</mi>
483
487
  </mrow>
484
- </msup>
485
- </math>
486
- </stem>
487
- </p>
488
- </preface>
489
- </iso-standard>
490
- OUTPUT
488
+ </mrow>
489
+ </msup>
490
+ </math>
491
+ </stem>
492
+ </p>
493
+ </preface>
494
+ </iso-standard>
495
+ OUTPUT
496
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
497
+ .convert("test", input, true))
498
+ .sub(%r{<localized-strings>.*</localized-strings>}m, ""))
499
+ .to be_equivalent_to xmlpp(output)
491
500
  end
492
501
 
493
502
  it "customises localisation of numbers" do
494
503
  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>
504
+ input = <<~INPUT
505
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
506
+ <bibdata>
507
+ <title language="en">test</title>
508
+ <language>fr</language>
509
+ </bibdata>
510
+ <preface>
511
+ <p><stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>30000</mn></math></stem>
512
+ <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>
513
+ </preface>
514
+ </iso-standard>
515
+ INPUT
516
+ output = <<~OUTPUT
517
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
518
+ <bibdata>
519
+ <title language='en'>test</title>
520
+ <language current='true'>fr</language>
501
521
  </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>
513
522
 
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=')'>
523
+ <preface>
524
+ <p>
525
+ 30'000
526
+ <stem type='MathML'>
527
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
528
+ <mi>P</mi>
529
+ <mfenced open='(' close=')'>
530
+ <mrow>
531
+ <mi>X</mi>
532
+ <mo>&#x2265;</mo>
533
+ <msub>
534
+ <mrow>
535
+ <mi>X</mi>
536
+ </mrow>
537
+ <mrow>
538
+ <mo>max</mo>
539
+ </mrow>
540
+ </msub>
541
+ </mrow>
542
+ </mfenced>
543
+ <mo>=</mo>
544
+ <munderover>
545
+ <mrow>
546
+ <mo>&#x2211;</mo>
547
+ </mrow>
548
+ <mrow>
521
549
  <mrow>
522
- <mi>X</mi>
523
- <mo>&#x2265;</mo>
550
+ <mi>j</mi>
551
+ <mo>=</mo>
524
552
  <msub>
525
553
  <mrow>
526
554
  <mi>X</mi>
@@ -530,81 +558,130 @@ RSpec.describe IsoDoc do
530
558
  </mrow>
531
559
  </msub>
532
560
  </mrow>
533
- </mfenced>
534
- <mo>=</mo>
535
- <munderover>
536
- <mrow>
537
- <mo>&#x2211;</mo>
538
- </mrow>
539
- <mrow>
540
- <mrow>
561
+ </mrow>
562
+ <mrow>
563
+ <mn>1'000</mn>
564
+ </mrow>
565
+ </munderover>
566
+ <mfenced open='(' close=')'>
567
+ <mtable>
568
+ <mtr>
569
+ <mtd>
570
+ <mn>1'000</mn>
571
+ </mtd>
572
+ </mtr>
573
+ <mtr>
574
+ <mtd>
541
575
  <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>
552
- </mrow>
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>&#x2212;</mo>
585
- <mi>p</mi>
586
- </mrow>
587
- </mfenced>
588
- </mrow>
589
- <mrow>
576
+ </mtd>
577
+ </mtr>
578
+ </mtable>
579
+ </mfenced>
580
+ <msup>
581
+ <mrow>
582
+ <mi>p</mi>
583
+ </mrow>
584
+ <mrow>
585
+ <mi>j</mi>
586
+ </mrow>
587
+ </msup>
588
+ <msup>
589
+ <mrow>
590
+ <mfenced open='(' close=')'>
590
591
  <mrow>
591
- <mn>1,003</mn>
592
+ <mn>0,0000032</mn>
592
593
  <mo>&#x2212;</mo>
593
- <mi>j</mi>
594
+ <mi>p</mi>
594
595
  </mrow>
596
+ </mfenced>
597
+ </mrow>
598
+ <mrow>
599
+ <mrow>
600
+ <mn>1,003</mn>
601
+ <mo>&#x2212;</mo>
602
+ <mi>j</mi>
595
603
  </mrow>
596
- </msup>
597
- </math>
598
- </stem>
599
- </p>
600
- </preface>
601
- </iso-standard>
602
- OUTPUT
604
+ </mrow>
605
+ </msup>
606
+ </math>
607
+ </stem>
608
+ </p>
609
+ </preface>
610
+ </iso-standard>
611
+ OUTPUT
612
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
613
+ .convert("test", input, true))
614
+ .sub(%r{<localized-strings>.*</localized-strings>}m, ""))
615
+ .to be_equivalent_to xmlpp(output)
616
+ end
617
+
618
+ it "resolve address components" do
619
+ input = <<~INPUT
620
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
621
+ <bibdata>
622
+ <contributor>
623
+ <role type='author'/>
624
+ <person>
625
+ <name>
626
+ <completename>Fred Flintstone</completename>
627
+ </name>
628
+ <affiliation>
629
+ <organization>
630
+ <name>Slate Rock and Gravel Company</name>
631
+ <address>
632
+ <street>1 Infinity Loop</street>
633
+ <city>Cupertino</city>
634
+ <state>CA</state>
635
+ <country>USA</country>
636
+ <postcode>95014</postcode>
637
+ </address>
638
+ </organization>
639
+ </affiliation>
640
+ </person>
641
+ </contributor>
642
+ </bibdata>
643
+ </iso-standard>
644
+ INPUT
645
+ output = <<~OUTPUT
646
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
647
+ <bibdata>
648
+ <contributor>
649
+ <role type='author'/>
650
+ <person>
651
+ <name>
652
+ <completename>Fred Flintstone</completename>
653
+ </name>
654
+ <affiliation>
655
+ <organization>
656
+ <name>Slate Rock and Gravel Company</name>
657
+ <address>
658
+ <formattedAddress>
659
+ 1 Infinity Loop
660
+ <br/>
661
+ Cupertino
662
+ <br/>
663
+ CA
664
+ <br/>
665
+ USA 95014
666
+ </formattedAddress>
667
+ </address>
668
+ </organization>
669
+ </affiliation>
670
+ </person>
671
+ </contributor>
672
+ </bibdata>
673
+ </iso-standard>
674
+ OUTPUT
675
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
676
+ .convert("test", input, true))
677
+ .sub(%r{<localized-strings>.*</localized-strings>}m, ""))
678
+ .to be_equivalent_to xmlpp(output)
603
679
  end
604
680
 
605
681
  private
606
682
 
607
683
  def mock_symbols
608
- allow_any_instance_of(::IsoDoc::PresentationXMLConvert).to receive(:twitter_cldr_localiser_symbols).and_return(group: "'")
684
+ allow_any_instance_of(::IsoDoc::PresentationXMLConvert)
685
+ .to receive(:twitter_cldr_localiser_symbols).and_return(group: "'")
609
686
  end
610
687
  end