isodoc 1.6.0 → 1.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) 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 +4 -8
  5. data/Rakefile +2 -2
  6. data/bin/rspec +1 -2
  7. data/isodoc.gemspec +4 -3
  8. data/lib/isodoc-yaml/i18n-ar.yaml +152 -0
  9. data/lib/isodoc-yaml/i18n-de.yaml +149 -0
  10. data/lib/isodoc-yaml/i18n-en.yaml +1 -0
  11. data/lib/isodoc-yaml/i18n-es.yaml +151 -0
  12. data/lib/isodoc-yaml/i18n-fr.yaml +1 -0
  13. data/lib/isodoc-yaml/i18n-ru.yaml +154 -0
  14. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
  15. data/lib/isodoc.rb +0 -2
  16. data/lib/isodoc/common.rb +2 -0
  17. data/lib/isodoc/convert.rb +10 -4
  18. data/lib/isodoc/css.rb +30 -26
  19. data/lib/isodoc/function/blocks.rb +26 -8
  20. data/lib/isodoc/function/blocks_example_note.rb +2 -2
  21. data/lib/isodoc/function/cleanup.rb +53 -45
  22. data/lib/isodoc/function/form.rb +51 -0
  23. data/lib/isodoc/function/inline.rb +8 -7
  24. data/lib/isodoc/function/references.rb +71 -77
  25. data/lib/isodoc/function/section.rb +28 -16
  26. data/lib/isodoc/function/table.rb +22 -22
  27. data/lib/isodoc/function/terms.rb +6 -7
  28. data/lib/isodoc/function/to_word_html.rb +19 -25
  29. data/lib/isodoc/function/utils.rb +180 -160
  30. data/lib/isodoc/gem_tasks.rb +36 -38
  31. data/lib/isodoc/headlesshtml_convert.rb +8 -7
  32. data/lib/isodoc/html_convert.rb +10 -4
  33. data/lib/isodoc/html_function/comments.rb +14 -12
  34. data/lib/isodoc/html_function/footnotes.rb +14 -7
  35. data/lib/isodoc/html_function/form.rb +62 -0
  36. data/lib/isodoc/html_function/html.rb +30 -26
  37. data/lib/isodoc/html_function/postprocess.rb +191 -226
  38. data/lib/isodoc/html_function/postprocess_footnotes.rb +59 -0
  39. data/lib/isodoc/html_function/sectionsplit.rb +230 -0
  40. data/lib/isodoc/i18n.rb +33 -31
  41. data/lib/isodoc/metadata.rb +22 -20
  42. data/lib/isodoc/metadata_contributor.rb +31 -28
  43. data/lib/isodoc/pdf_convert.rb +11 -13
  44. data/lib/isodoc/presentation_function/bibdata.rb +54 -30
  45. data/lib/isodoc/presentation_function/block.rb +17 -8
  46. data/lib/isodoc/presentation_function/inline.rb +72 -120
  47. data/lib/isodoc/presentation_function/math.rb +84 -0
  48. data/lib/isodoc/presentation_function/section.rb +55 -19
  49. data/lib/isodoc/presentation_xml_convert.rb +2 -0
  50. data/lib/isodoc/sassc_importer.rb +1 -1
  51. data/lib/isodoc/version.rb +1 -1
  52. data/lib/isodoc/word_function/body.rb +28 -24
  53. data/lib/isodoc/word_function/footnotes.rb +22 -15
  54. data/lib/isodoc/word_function/postprocess.rb +50 -36
  55. data/lib/isodoc/xref.rb +11 -10
  56. data/lib/isodoc/xref/xref_counter.rb +32 -17
  57. data/lib/isodoc/xref/xref_gen.rb +33 -21
  58. data/lib/isodoc/xref/xref_gen_seq.rb +60 -35
  59. data/lib/isodoc/xref/xref_sect_gen.rb +37 -35
  60. data/spec/assets/scripts_override.html +3 -0
  61. data/spec/isodoc/blocks_spec.rb +2258 -2622
  62. data/spec/isodoc/cleanup_spec.rb +1103 -1107
  63. data/spec/isodoc/form_spec.rb +156 -0
  64. data/spec/isodoc/i18n_spec.rb +802 -917
  65. data/spec/isodoc/inline_spec.rb +1105 -921
  66. data/spec/isodoc/lists_spec.rb +316 -315
  67. data/spec/isodoc/metadata_spec.rb +384 -379
  68. data/spec/isodoc/postproc_spec.rb +1783 -1549
  69. data/spec/isodoc/presentation_xml_spec.rb +355 -278
  70. data/spec/isodoc/ref_spec.rb +718 -723
  71. data/spec/isodoc/section_spec.rb +216 -199
  72. data/spec/isodoc/sectionsplit_spec.rb +190 -0
  73. data/spec/isodoc/table_spec.rb +41 -42
  74. data/spec/isodoc/terms_spec.rb +84 -84
  75. data/spec/isodoc/xref_spec.rb +1024 -930
  76. metadata +33 -7
@@ -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 displayorder="1">
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
@@ -252,7 +256,7 @@ RSpec.describe IsoDoc do
252
256
  </bibdata>
253
257
 
254
258
  <preface>
255
- <p>
259
+ <p displayorder="1">
256
260
  30,000
257
261
  <stem type='MathML'>
258
262
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
@@ -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 displayorder="1">
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 displayorder="1">
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