isodoc 1.5.5 → 1.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +2 -12
  3. data/.hound.yml +3 -1
  4. data/.rubocop.yml +3 -7
  5. data/Gemfile +2 -2
  6. data/Rakefile +2 -2
  7. data/bin/rspec +1 -2
  8. data/isodoc.gemspec +11 -11
  9. data/lib/isodoc-yaml/i18n-ar.yaml +152 -0
  10. data/lib/isodoc-yaml/i18n-de.yaml +149 -0
  11. data/lib/isodoc-yaml/i18n-es.yaml +151 -0
  12. data/lib/isodoc-yaml/i18n-ru.yaml +154 -0
  13. data/lib/isodoc.rb +0 -2
  14. data/lib/isodoc/base_style/all.css +7 -0
  15. data/lib/isodoc/base_style/metanorma_word.css +7 -0
  16. data/lib/isodoc/base_style/metanorma_word.scss +8 -0
  17. data/lib/isodoc/base_style/reset.css +7 -0
  18. data/lib/isodoc/base_style/reset.scss +9 -0
  19. data/lib/isodoc/base_style/scripts.html +187 -0
  20. data/lib/isodoc/class_utils.rb +6 -5
  21. data/lib/isodoc/common.rb +2 -0
  22. data/lib/isodoc/convert.rb +30 -17
  23. data/lib/isodoc/css.rb +43 -34
  24. data/lib/isodoc/function/blocks.rb +21 -4
  25. data/lib/isodoc/function/blocks_example_note.rb +2 -2
  26. data/lib/isodoc/function/cleanup.rb +53 -45
  27. data/lib/isodoc/function/form.rb +51 -0
  28. data/lib/isodoc/function/inline.rb +37 -15
  29. data/lib/isodoc/function/references.rb +55 -42
  30. data/lib/isodoc/function/section.rb +29 -16
  31. data/lib/isodoc/function/table.rb +1 -0
  32. data/lib/isodoc/function/to_word_html.rb +33 -29
  33. data/lib/isodoc/function/utils.rb +180 -159
  34. data/lib/isodoc/gem_tasks.rb +30 -31
  35. data/lib/isodoc/headlesshtml_convert.rb +8 -7
  36. data/lib/isodoc/html_convert.rb +6 -4
  37. data/lib/isodoc/html_function/comments.rb +2 -0
  38. data/lib/isodoc/html_function/footnotes.rb +14 -7
  39. data/lib/isodoc/html_function/form.rb +62 -0
  40. data/lib/isodoc/html_function/html.rb +30 -26
  41. data/lib/isodoc/html_function/postprocess.rb +41 -82
  42. data/lib/isodoc/html_function/postprocess_footnotes.rb +59 -0
  43. data/lib/isodoc/i18n.rb +33 -31
  44. data/lib/isodoc/pdf_convert.rb +12 -16
  45. data/lib/isodoc/presentation_function/bibdata.rb +54 -30
  46. data/lib/isodoc/presentation_function/block.rb +17 -8
  47. data/lib/isodoc/presentation_function/inline.rb +84 -120
  48. data/lib/isodoc/presentation_function/math.rb +84 -0
  49. data/lib/isodoc/presentation_function/section.rb +20 -22
  50. data/lib/isodoc/presentation_xml_convert.rb +2 -1
  51. data/lib/isodoc/sassc_importer.rb +1 -1
  52. data/lib/isodoc/version.rb +1 -1
  53. data/lib/isodoc/word_function/body.rb +28 -24
  54. data/lib/isodoc/word_function/footnotes.rb +22 -15
  55. data/lib/isodoc/word_function/postprocess.rb +50 -36
  56. data/lib/isodoc/xref.rb +9 -10
  57. data/lib/isodoc/xref/xref_counter.rb +32 -17
  58. data/lib/isodoc/xref/xref_gen.rb +33 -21
  59. data/lib/isodoc/xref/xref_gen_seq.rb +60 -35
  60. data/lib/isodoc/xref/xref_sect_gen.rb +37 -35
  61. data/lib/isodoc/xslfo_convert.rb +36 -27
  62. data/spec/assets/scripts_override.html +3 -0
  63. data/spec/isodoc/blocks_spec.rb +2490 -2591
  64. data/spec/isodoc/cleanup_spec.rb +1107 -1109
  65. data/spec/isodoc/footnotes_spec.rb +1 -16
  66. data/spec/isodoc/form_spec.rb +156 -0
  67. data/spec/isodoc/i18n_spec.rb +984 -972
  68. data/spec/isodoc/inline_spec.rb +1129 -912
  69. data/spec/isodoc/lists_spec.rb +316 -315
  70. data/spec/isodoc/postproc_spec.rb +1751 -1540
  71. data/spec/isodoc/presentation_xml_spec.rb +403 -323
  72. data/spec/isodoc/ref_spec.rb +718 -723
  73. data/spec/isodoc/section_spec.rb +910 -902
  74. data/spec/isodoc/table_spec.rb +566 -556
  75. data/spec/isodoc/terms_spec.rb +251 -255
  76. data/spec/isodoc/xref_spec.rb +3041 -2992
  77. data/spec/isodoc/xslfo_convert_spec.rb +39 -0
  78. data/spec/spec_helper.rb +30 -29
  79. metadata +77 -65
@@ -1,136 +1,141 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe IsoDoc do
4
- it "generates file based on string input" do
5
- FileUtils.rm_f "test.presentation.xml"
6
- IsoDoc::PresentationXMLConvert.new({filename: "test"}).convert("test", <<~"INPUT", false)
7
- <iso-standard xmlns="http://riboseinc.com/isoxml">
8
- <bibdata>
9
- <title language="en">test</title>
10
- </bibdata>
11
- <preface><foreword>
12
- <note>
13
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
14
- </note>
15
- </foreword></preface>
16
- </iso-standard>
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
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~INPUT, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(<<~OUTPUT)
23
- <iso-standard xmlns="http://riboseinc.com/isoxml">
24
- <bibdata>
25
- <title language="en">test</title>
22
+ it "localises numbers in MathML" do
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'>
39
+ <bibdata>
40
+ <title language='en'>test</title>
26
41
  </bibdata>
27
42
  <preface>
28
- <p>
29
- <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>64212149677264515</mn></math></stem>
30
- <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>642121496772645.15</mn></math></stem>
31
- <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>30000</mn></math></stem>
32
- <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>
33
- </preface>
34
- </iso-standard>
35
- INPUT
36
- <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
37
- <bibdata>
38
- <title language='en'>test</title>
39
- </bibdata>
40
-
41
- <preface>
42
- <p>
43
- 64,212,149,677,264,515
44
- 642,121,496,772,645.15 30,000
45
- <stem type='MathML'>
46
- <math xmlns='http://www.w3.org/1998/Math/MathML'>
47
- <mi>P</mi>
48
- <mfenced open='(' close=')'>
49
- <mrow>
50
- <mi>X</mi>
51
- <mo>&#x2265;</mo>
52
- <msub>
53
- <mrow>
54
- <mi>X</mi>
55
- </mrow>
56
- <mrow>
57
- <mo>max</mo>
58
- </mrow>
59
- </msub>
60
- </mrow>
61
- </mfenced>
62
- <mo>=</mo>
63
- <munderover>
64
- <mrow>
65
- <mo>&#x2211;</mo>
66
- </mrow>
67
- <mrow>
68
- <mrow>
69
- <mi>j</mi>
70
- <mo>=</mo>
71
- <msub>
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=')'>
72
50
  <mrow>
73
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>
74
61
  </mrow>
62
+ </mfenced>
63
+ <mo>=</mo>
64
+ <munderover>
75
65
  <mrow>
76
- <mo>max</mo>
66
+ <mo>&#x2211;</mo>
77
67
  </mrow>
78
- </msub>
79
- </mrow>
80
- </mrow>
81
- <mrow>
82
- <mn>1,000</mn>
83
- </mrow>
84
- </munderover>
85
- <mfenced open='(' close=')'>
86
- <mtable>
87
- <mtr>
88
- <mtd>
89
- <mn>1,000</mn>
90
- </mtd>
91
- </mtr>
92
- <mtr>
93
- <mtd>
94
- <mi>j</mi>
95
- </mtd>
96
- </mtr>
97
- </mtable>
98
- </mfenced>
99
- <msup>
100
- <mrow>
101
- <mi>p</mi>
102
- </mrow>
103
- <mrow>
104
- <mi>j</mi>
105
- </mrow>
106
- </msup>
107
- <msup>
108
- <mrow>
109
- <mfenced open='(' close=')'>
110
- <mrow>
111
- <mn>1</mn>
112
- <mo>&#x2212;</mo>
113
- <mi>p</mi>
114
- </mrow>
115
- </mfenced>
116
- </mrow>
117
- <mrow>
118
- <mrow>
119
- <mn>1.003</mn>
120
- <mo>&#x2212;</mo>
121
- <mi>j</mi>
122
- </mrow>
123
- </mrow>
124
- </msup>
125
- </math>
126
- </stem>
127
- </p>
128
- </preface>
129
- </iso-standard>
130
- OUTPUT
131
- end
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>&#x2212;</mo>
114
+ <mi>p</mi>
115
+ </mrow>
116
+ </mfenced>
117
+ </mrow>
118
+ <mrow>
119
+ <mrow>
120
+ <mn>1.003</mn>
121
+ <mo>&#x2212;</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
+ 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)
136
+ end
132
137
 
133
- context 'when twitter_cldr_localiser_symbols has additional options' do
138
+ context "when twitter_cldr_localiser_symbols has additional options" do
134
139
  let(:input) do
135
140
  <<~INPUT
136
141
  <iso-standard xmlns="http://riboseinc.com/isoxml">
@@ -362,246 +367,321 @@ end
362
367
  {
363
368
  fraction_group_digits: 2,
364
369
  fraction_group: "'",
365
- precision: 5
370
+ precision: 5,
366
371
  }
367
372
  end
368
373
 
369
374
  before do
370
375
  allow_any_instance_of(IsoDoc::PresentationXMLConvert)
371
- .to(receive(:twitter_cldr_localiser_symbols).and_return(additional_symbols))
376
+ .to(receive(:twitter_cldr_localiser_symbols)
377
+ .and_return(additional_symbols))
372
378
  end
373
379
 
374
380
  it "Supports twitter_cldr_localiser_symbols fraction options" do
375
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true))
376
- .sub(%r{<localized-strings>.*</localized-strings>}m, ""))
381
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
382
+ .convert("test", input, true))
383
+ .sub(%r{<localized-strings>.*</localized-strings>}m, ""))
377
384
  .to(be_equivalent_to(xmlpp(output)))
378
385
  end
379
386
  end
380
387
 
381
- it "localises numbers in MathML in French" do
382
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~INPUT, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(<<~OUTPUT)
383
- <iso-standard xmlns="http://riboseinc.com/isoxml">
384
- <bibdata>
385
- <title language="en">test</title>
386
- <language>fr</language>
388
+ it "localises numbers in MathML in French" do
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'>
403
+ <bibdata>
404
+ <title language='en'>test</title>
405
+ <language current='true'>fr</language>
387
406
  </bibdata>
388
407
  <preface>
389
- <p><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>30000</mn></math>
390
- <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>
391
- </preface>
392
- </iso-standard>
393
- INPUT
394
- <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
395
- <bibdata>
396
- <title language='en'>test</title>
397
- <language current='true'>fr</language>
398
- </bibdata>
399
-
400
- <preface>
401
- <p>
402
- 30&#x202F;000
403
- <stem type='MathML'>
404
- <math xmlns='http://www.w3.org/1998/Math/MathML'>
405
- <mi>P</mi>
406
- <mfenced open='(' close=')'>
407
- <mrow>
408
- <mi>X</mi>
409
- <mo>&#x2265;</mo>
410
- <msub>
411
- <mrow>
412
- <mi>X</mi>
413
- </mrow>
414
- <mrow>
415
- <mo>max</mo>
416
- </mrow>
417
- </msub>
418
- </mrow>
419
- </mfenced>
420
- <mo>=</mo>
421
- <munderover>
422
- <mrow>
423
- <mo>&#x2211;</mo>
424
- </mrow>
425
- <mrow>
426
- <mrow>
427
- <mi>j</mi>
428
- <mo>=</mo>
429
- <msub>
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=')'>
430
414
  <mrow>
431
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>
432
425
  </mrow>
426
+ </mfenced>
427
+ <mo>=</mo>
428
+ <munderover>
433
429
  <mrow>
434
- <mo>max</mo>
430
+ <mo>&#x2211;</mo>
435
431
  </mrow>
436
- </msub>
437
- </mrow>
438
- </mrow>
439
- <mrow>
440
- <mn>1&#x202F;000</mn>
441
- </mrow>
442
- </munderover>
443
- <mfenced open='(' close=')'>
444
- <mtable>
445
- <mtr>
446
- <mtd>
447
- <mn>1&#x202F;000</mn>
448
- </mtd>
449
- </mtr>
450
- <mtr>
451
- <mtd>
452
- <mi>j</mi>
453
- </mtd>
454
- </mtr>
455
- </mtable>
456
- </mfenced>
457
- <msup>
458
- <mrow>
459
- <mi>p</mi>
460
- </mrow>
461
- <mrow>
462
- <mi>j</mi>
463
- </mrow>
464
- </msup>
465
- <msup>
466
- <mrow>
467
- <mfenced open='(' close=')'>
468
- <mrow>
469
- <mn>1</mn>
470
- <mo>&#x2212;</mo>
471
- <mi>p</mi>
472
- </mrow>
473
- </mfenced>
474
- </mrow>
475
- <mrow>
476
- <mrow>
477
- <mn>1,003</mn>
478
- <mo>&#x2212;</mo>
479
- <mi>j</mi>
480
- </mrow>
481
- </mrow>
482
- </msup>
483
- </math>
484
- </stem>
485
- </p>
486
- </preface>
487
- </iso-standard>
488
- OUTPUT
489
- end
490
-
491
- it "customises localisation of numbers" do
492
- mock_symbols
493
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~INPUT, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(<<~OUTPUT)
494
- <iso-standard xmlns="http://riboseinc.com/isoxml">
495
- <bibdata>
496
- <title language="en">test</title>
497
- <language>fr</language>
498
- </bibdata>
499
- <preface>
500
- <p><stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>30000</mn></math></stem>
501
- <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>
432
+ <mrow>
433
+ <mrow>
434
+ <mi>j</mi>
435
+ <mo>=</mo>
436
+ <msub>
437
+ <mrow>
438
+ <mi>X</mi>
439
+ </mrow>
440
+ <mrow>
441
+ <mo>max</mo>
442
+ </mrow>
443
+ </msub>
444
+ </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>
459
+ <mi>j</mi>
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=')'>
475
+ <mrow>
476
+ <mn>1</mn>
477
+ <mo>&#x2212;</mo>
478
+ <mi>p</mi>
479
+ </mrow>
480
+ </mfenced>
481
+ </mrow>
482
+ <mrow>
483
+ <mrow>
484
+ <mn>1,003</mn>
485
+ <mo>&#x2212;</mo>
486
+ <mi>j</mi>
487
+ </mrow>
488
+ </mrow>
489
+ </msup>
490
+ </math>
491
+ </stem>
492
+ </p>
502
493
  </preface>
503
- </iso-standard>
504
- INPUT
505
- <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
506
- <bibdata>
507
- <title language='en'>test</title>
508
- <language current='true'>fr</language>
509
- </bibdata>
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)
500
+ end
510
501
 
511
- <preface>
512
- <p>
513
- 30'000
514
- <stem type='MathML'>
515
- <math xmlns='http://www.w3.org/1998/Math/MathML'>
516
- <mi>P</mi>
517
- <mfenced open='(' close=')'>
518
- <mrow>
519
- <mi>X</mi>
520
- <mo>&#x2265;</mo>
521
- <msub>
502
+ it "customises localisation of numbers" do
503
+ mock_symbols
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>
521
+ </bibdata>
522
+
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=')'>
522
530
  <mrow>
523
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>
524
541
  </mrow>
542
+ </mfenced>
543
+ <mo>=</mo>
544
+ <munderover>
525
545
  <mrow>
526
- <mo>max</mo>
546
+ <mo>&#x2211;</mo>
527
547
  </mrow>
528
- </msub>
529
- </mrow>
530
- </mfenced>
531
- <mo>=</mo>
532
- <munderover>
533
- <mrow>
534
- <mo>&#x2211;</mo>
535
- </mrow>
536
- <mrow>
537
- <mrow>
538
- <mi>j</mi>
539
- <mo>=</mo>
540
- <msub>
541
- <mrow>
542
- <mi>X</mi>
543
- </mrow>
548
+ <mrow>
544
549
  <mrow>
545
- <mo>max</mo>
550
+ <mi>j</mi>
551
+ <mo>=</mo>
552
+ <msub>
553
+ <mrow>
554
+ <mi>X</mi>
555
+ </mrow>
556
+ <mrow>
557
+ <mo>max</mo>
558
+ </mrow>
559
+ </msub>
546
560
  </mrow>
547
- </msub>
548
- </mrow>
549
- </mrow>
550
- <mrow>
551
- <mn>1'000</mn>
552
- </mrow>
553
- </munderover>
554
- <mfenced open='(' close=')'>
555
- <mtable>
556
- <mtr>
557
- <mtd>
561
+ </mrow>
562
+ <mrow>
558
563
  <mn>1'000</mn>
559
- </mtd>
560
- </mtr>
561
- <mtr>
562
- <mtd>
563
- <mi>j</mi>
564
- </mtd>
565
- </mtr>
566
- </mtable>
567
- </mfenced>
568
- <msup>
569
- <mrow>
570
- <mi>p</mi>
571
- </mrow>
572
- <mrow>
573
- <mi>j</mi>
574
- </mrow>
575
- </msup>
576
- <msup>
577
- <mrow>
564
+ </mrow>
565
+ </munderover>
578
566
  <mfenced open='(' close=')'>
567
+ <mtable>
568
+ <mtr>
569
+ <mtd>
570
+ <mn>1'000</mn>
571
+ </mtd>
572
+ </mtr>
573
+ <mtr>
574
+ <mtd>
575
+ <mi>j</mi>
576
+ </mtd>
577
+ </mtr>
578
+ </mtable>
579
+ </mfenced>
580
+ <msup>
579
581
  <mrow>
580
- <mn>0,0000032</mn>
581
- <mo>&#x2212;</mo>
582
582
  <mi>p</mi>
583
583
  </mrow>
584
- </mfenced>
585
- </mrow>
586
- <mrow>
587
- <mrow>
588
- <mn>1,003</mn>
589
- <mo>&#x2212;</mo>
590
- <mi>j</mi>
591
- </mrow>
592
- </mrow>
593
- </msup>
594
- </math>
595
- </stem>
596
- </p>
597
- </preface>
598
- </iso-standard>
599
- OUTPUT
600
- end
584
+ <mrow>
585
+ <mi>j</mi>
586
+ </mrow>
587
+ </msup>
588
+ <msup>
589
+ <mrow>
590
+ <mfenced open='(' close=')'>
591
+ <mrow>
592
+ <mn>0,0000032</mn>
593
+ <mo>&#x2212;</mo>
594
+ <mi>p</mi>
595
+ </mrow>
596
+ </mfenced>
597
+ </mrow>
598
+ <mrow>
599
+ <mrow>
600
+ <mn>1,003</mn>
601
+ <mo>&#x2212;</mo>
602
+ <mi>j</mi>
603
+ </mrow>
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)
679
+ end
601
680
 
602
- private
681
+ private
603
682
 
604
683
  def mock_symbols
605
- 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: "'")
606
686
  end
607
687
  end