isodoc 1.2.5 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +69 -0
  3. data/README.adoc +1 -3
  4. data/isodoc.gemspec +3 -1
  5. data/lib/isodoc-yaml/i18n-en.yaml +1 -0
  6. data/lib/isodoc-yaml/i18n-fr.yaml +8 -7
  7. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
  8. data/lib/isodoc/base_style/all.css +5 -1
  9. data/lib/isodoc/base_style/blocks.scss +2 -2
  10. data/lib/isodoc/base_style/reset.css +5 -1
  11. data/lib/isodoc/base_style/reset.scss +6 -1
  12. data/lib/isodoc/base_style/typography.scss +1 -1
  13. data/lib/isodoc/convert.rb +12 -97
  14. data/lib/isodoc/css.rb +95 -0
  15. data/lib/isodoc/function/inline.rb +0 -33
  16. data/lib/isodoc/function/inline_simple.rb +4 -1
  17. data/lib/isodoc/function/lists.rb +2 -1
  18. data/lib/isodoc/function/references.rb +8 -13
  19. data/lib/isodoc/function/table.rb +10 -0
  20. data/lib/isodoc/function/to_word_html.rb +3 -2
  21. data/lib/isodoc/gem_tasks.rb +4 -0
  22. data/lib/isodoc/html_function/html.rb +1 -0
  23. data/lib/isodoc/html_function/postprocess.rb +12 -3
  24. data/lib/isodoc/i18n.rb +23 -51
  25. data/lib/isodoc/metadata.rb +42 -115
  26. data/lib/isodoc/metadata_contributor.rb +90 -0
  27. data/lib/isodoc/metadata_date.rb +11 -0
  28. data/lib/isodoc/presentation_function/bibdata.rb +79 -7
  29. data/lib/isodoc/presentation_function/block.rb +14 -9
  30. data/lib/isodoc/presentation_function/inline.rb +126 -22
  31. data/lib/isodoc/presentation_function/section.rb +6 -0
  32. data/lib/isodoc/presentation_xml_convert.rb +4 -0
  33. data/lib/isodoc/version.rb +1 -1
  34. data/lib/isodoc/word_convert.rb +0 -20
  35. data/lib/isodoc/word_function/body.rb +12 -0
  36. data/lib/isodoc/word_function/postprocess.rb +38 -80
  37. data/lib/isodoc/word_function/postprocess_cover.rb +55 -0
  38. data/lib/isodoc/word_function/table.rb +10 -0
  39. data/lib/isodoc/xref.rb +1 -0
  40. data/lib/isodoc/xref/xref_counter.rb +20 -9
  41. data/lib/isodoc/xref/xref_gen.rb +20 -2
  42. data/lib/isodoc/xslfo_convert.rb +6 -1
  43. data/spec/assets/html.scss +14 -0
  44. data/spec/assets/i18n.yaml +17 -9
  45. data/spec/isodoc/blocks_spec.rb +88 -240
  46. data/spec/isodoc/cleanup_spec.rb +0 -1
  47. data/spec/isodoc/footnotes_spec.rb +4 -5
  48. data/spec/isodoc/i18n_spec.rb +73 -38
  49. data/spec/isodoc/inline_spec.rb +177 -199
  50. data/spec/isodoc/lists_spec.rb +1 -1
  51. data/spec/isodoc/metadata_spec.rb +68 -20
  52. data/spec/isodoc/postproc_spec.rb +306 -8
  53. data/spec/isodoc/presentation_xml_spec.rb +584 -1
  54. data/spec/isodoc/ref_spec.rb +327 -12
  55. data/spec/isodoc/table_spec.rb +28 -0
  56. data/spec/isodoc/xref_spec.rb +162 -17
  57. data/spec/spec_helper.rb +6 -0
  58. metadata +35 -7
  59. data/.github/workflows/macos.yml +0 -42
  60. data/.github/workflows/ubuntu.yml +0 -62
  61. data/.github/workflows/windows.yml +0 -44
@@ -3,4 +3,18 @@
3
3
 
4
4
  p {
5
5
  font-family: $bodyfont;
6
+ font-size: $normalfontsize;
7
+ }
8
+ code {
9
+ font-family: $monospacefont;
10
+ font-size: $monospacefontsize;
11
+ }
12
+ aside {
13
+ font-size: $footnotefontsize;
14
+ }
15
+ h1 {
16
+ font-family: $headerfont;
17
+ }
18
+ p.note {
19
+ font-size: $smallerfontsize;
6
20
  }
@@ -1,25 +1,33 @@
1
- foreword: Antaŭparolo
1
+ foreword: Antaŭparolo
2
2
  introduction: Enkonduko
3
- clause: klaŭzo
4
- table: Tabelo
3
+ clause: klaŭzo
4
+ table: tabelo
5
5
  source: SOURCE
6
6
  modified: modified
7
7
  scope: Amplekso
8
8
  symbols: Simboloj kai mallongigitaj terminoj
9
9
  annex: Aldono
10
- normref: Normaj citaĵoj
10
+ normref: Normaj citaĵoj
11
11
  bibliography: Bibliografio
12
12
  inform_annex: informa
13
- all_parts: ĉiuj partoj
13
+ all_parts: ĉiuj partoj
14
+ norm_annex: normative
15
+ note: NOTO
14
16
  locality: {
15
17
  table: Tabelo
16
- }
18
+ }
17
19
  doctype_dict: {
18
- brochure: broŝuro
19
- }
20
+ brochure: broŝuro,
21
+ conference proceedings: konferencaktoj
22
+ }
20
23
  stage_dict: {
21
24
  published: publikigita
22
25
  }
23
26
  substage_dict: {
24
27
  withdrawn: fortirita
25
- }
28
+ }
29
+ array:
30
+ - elem1
31
+ - elem2
32
+ - {elem3: elem4, elem5: elem6}
33
+ void:
@@ -87,32 +87,18 @@ RSpec.describe IsoDoc do
87
87
  <standard-document xmlns="https://www.metanorma.org/ns/standoc" type="presentation">
88
88
  <bibdata type="standard">
89
89
  <title language="en" format="text/plain">Document title</title>
90
- <language>en</language>
91
- <script>Latn</script>
90
+ <language current="true">en</language>
91
+ <script current="true">Latn</script>
92
92
  <status>
93
- <stage>published</stage>
93
+ <stage language="">published</stage>
94
94
  </status>
95
95
  <copyright>
96
96
  <from>2020</from>
97
97
  </copyright>
98
98
  <ext>
99
- <doctype>article</doctype>
99
+ <doctype language="">article</doctype>
100
100
  </ext>
101
101
  </bibdata>
102
- <local_bibdata type='standard'>
103
- <title language='en' format='text/plain'>Document title</title>
104
- <language>en</language>
105
- <script>Latn</script>
106
- <status>
107
- <stage>published</stage>
108
- </status>
109
- <copyright>
110
- <from>2020</from>
111
- </copyright>
112
- <ext>
113
- <doctype>article</doctype>
114
- </ext>
115
- </local_bibdata>
116
102
  <sections>
117
103
  <clause id="A" inline-header="false" obligation="normative">
118
104
  <title depth="1">1.<tab/>Change Clause</title>
@@ -248,7 +234,7 @@ RSpec.describe IsoDoc do
248
234
  </body>
249
235
  </html>
250
236
  OUTPUT
251
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
237
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(presxml)
252
238
  expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
253
239
  end
254
240
 
@@ -1469,6 +1455,7 @@ end
1469
1455
  <div id='_be9158af-7e93-4ee2-90c5-26d31c181934' style='page-break-after: avoid;page-break-inside: avoid;'><div class='formula'>
1470
1456
  <p>
1471
1457
  <span class='stem'>(#(r = 1 %)#)</span>
1458
+ <span style='mso-tab-count:1'>&#160; </span>
1472
1459
  </p>
1473
1460
  </div>
1474
1461
  <p>where</p>
@@ -2240,8 +2227,8 @@ end
2240
2227
  OUTPUT
2241
2228
  end
2242
2229
 
2243
- it "processes requirements in French (Presentation XML)" do
2244
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2230
+ it "processes requirements in French" do
2231
+ input = <<~INPUT
2245
2232
  <iso-standard xmlns="http://riboseinc.com/isoxml">
2246
2233
  <bibdata>
2247
2234
  <language>fr</language>
@@ -2295,133 +2282,63 @@ end
2295
2282
  </foreword></preface>
2296
2283
  </iso-standard>
2297
2284
  INPUT
2298
- <?xml version='1.0'?>
2299
- <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
2300
- <bibdata>
2301
- <language>fr</language>
2302
- <script>Latn</script>
2303
- </bibdata>
2304
- <local_bibdata>
2305
- <language>fr</language>
2306
- <script>Latn</script>
2307
- </local_bibdata>
2308
- <preface>
2309
- <foreword>
2310
- <requirement id='A' unnumbered='true'>
2311
- <name>Exigence</name>
2312
- <title>A New Requirement</title>
2313
- <label>/ogc/recommendation/wfs/2</label>
2314
- <inherit>/ss/584/2015/level/1</inherit>
2315
- <subject>user</subject>
2316
- <description>
2317
- <p id='_'>
2318
- I recommend
2319
- <em>this</em>
2320
- .
2321
- </p>
2322
- </description>
2323
- <specification exclude='true' type='tabular'>
2324
- <p id='_'>This is the object of the recommendation:</p>
2325
- <table id='_'>
2326
- <tbody>
2327
- <tr>
2328
- <td style='text-align:left;'>Object</td>
2329
- <td style='text-align:left;'>Value</td>
2330
- </tr>
2331
- <tr>
2332
- <td style='text-align:left;'>Mission</td>
2333
- <td style='text-align:left;'>Accomplished</td>
2334
- </tr>
2335
- </tbody>
2336
- </table>
2337
- </specification>
2338
- <description>
2339
- <p id='_'>As for the measurement targets,</p>
2340
- </description>
2341
- <measurement-target exclude='false'>
2342
- <p id='_'>The measurement target shall be measured as:</p>
2343
- <formula id='B'>
2344
- <name>1</name>
2345
- <stem type='AsciiMath'>r/1 = 0</stem>
2346
- </formula>
2347
- </measurement-target>
2348
- <verification exclude='false'>
2349
- <p id='_'>The following code will be run for verification:</p>
2350
- <sourcecode id='_'>
2351
- CoreRoot(success): HttpResponse if (success) recommendation(label:
2352
- success-response) end
2353
- </sourcecode>
2354
- </verification>
2355
- <import exclude='true'>
2356
- <sourcecode id='_'>success-response()</sourcecode>
2357
- </import>
2358
- </requirement>
2359
- </foreword>
2360
- </preface>
2361
- </iso-standard>
2285
+
2286
+ presxml = <<~OUTPUT
2287
+ <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
2288
+ <bibdata>
2289
+ <language current="true">fr</language>
2290
+ <script current="true">Latn</script>
2291
+ </bibdata>
2292
+ <preface><foreword>
2293
+ <requirement id="A" unnumbered="true"><name>Exigence</name>
2294
+ <title>A New Requirement</title>
2295
+ <label>/ogc/recommendation/wfs/2</label>
2296
+ <inherit>/ss/584/2015/level/1</inherit>
2297
+ <subject>user</subject>
2298
+ <description>
2299
+ <p id="_">I recommend <em>this</em>.</p>
2300
+ </description>
2301
+ <specification exclude="true" type="tabular">
2302
+ <p id="_">This is the object of the recommendation:</p>
2303
+ <table id="_">
2304
+ <tbody>
2305
+ <tr>
2306
+ <td style="text-align:left;">Object</td>
2307
+ <td style="text-align:left;">Value</td>
2308
+ </tr>
2309
+ <tr>
2310
+ <td style="text-align:left;">Mission</td>
2311
+ <td style="text-align:left;">Accomplished</td>
2312
+ </tr>
2313
+ </tbody>
2314
+ </table>
2315
+ </specification>
2316
+ <description>
2317
+ <p id="_">As for the measurement targets,</p>
2318
+ </description>
2319
+ <measurement-target exclude="false">
2320
+ <p id="_">The measurement target shall be measured as:</p>
2321
+ <formula id="B"><name>1</name>
2322
+ <stem type="AsciiMath">r/1 = 0</stem>
2323
+ </formula>
2324
+ </measurement-target>
2325
+ <verification exclude="false">
2326
+ <p id="_">The following code will be run for verification:</p>
2327
+ <sourcecode id="_">CoreRoot(success): HttpResponse
2328
+ if (success)
2329
+ recommendation(label: success-response)
2330
+ end
2331
+ </sourcecode>
2332
+ </verification>
2333
+ <import exclude="true">
2334
+ <sourcecode id="_">success-response()</sourcecode>
2335
+ </import>
2336
+ </requirement>
2337
+ </foreword></preface>
2338
+ </iso-standard>
2362
2339
  OUTPUT
2363
- end
2364
2340
 
2365
- it "processes requirements in French (HTML)" do
2366
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2367
- <iso-standard xmlns="http://riboseinc.com/isoxml">
2368
- <bibdata>
2369
- <language>fr</language>
2370
- <script>Latn</script>
2371
- </bibdata>
2372
- <local_bibdata>
2373
- <language>fr</language>
2374
- <script>Latn</script>
2375
- </local_bibdata>
2376
- <preface><foreword>
2377
- <requirement id="A" unnumbered="true">
2378
- <name>Exigence</name>
2379
- <title>A New Requirement</title>
2380
- <label>/ogc/recommendation/wfs/2</label>
2381
- <inherit>/ss/584/2015/level/1</inherit>
2382
- <subject>user</subject>
2383
- <description>
2384
- <p id="_">I recommend <em>this</em>.</p>
2385
- </description>
2386
- <specification exclude="true" type="tabular">
2387
- <p id="_">This is the object of the recommendation:</p>
2388
- <table id="_">
2389
- <tbody>
2390
- <tr>
2391
- <td style="text-align:left;">Object</td>
2392
- <td style="text-align:left;">Value</td>
2393
- </tr>
2394
- <tr>
2395
- <td style="text-align:left;">Mission</td>
2396
- <td style="text-align:left;">Accomplished</td>
2397
- </tr>
2398
- </tbody>
2399
- </table>
2400
- </specification>
2401
- <description>
2402
- <p id="_">As for the measurement targets,</p>
2403
- </description>
2404
- <measurement-target exclude="false">
2405
- <p id="_">The measurement target shall be measured as:</p>
2406
- <formula id="B">
2407
- <stem type="AsciiMath">r/1 = 0</stem>
2408
- </formula>
2409
- </measurement-target>
2410
- <verification exclude="false">
2411
- <p id="_">The following code will be run for verification:</p>
2412
- <sourcecode id="_">CoreRoot(success): HttpResponse
2413
- if (success)
2414
- recommendation(label: success-response)
2415
- end
2416
- </sourcecode>
2417
- </verification>
2418
- <import exclude="true">
2419
- <sourcecode id="_">success-response()</sourcecode>
2420
- </import>
2421
- </requirement>
2422
- </foreword></preface>
2423
- </iso-standard>
2424
- INPUT
2341
+ html = <<~OUTPUT
2425
2342
  #{HTML_HDR.gsub(/"en"/, '"fr"')}
2426
2343
  <br/>
2427
2344
  <div>
@@ -2454,6 +2371,7 @@ end
2454
2371
  <div id='B'><div class='formula'>
2455
2372
  <p>
2456
2373
  <span class='stem'>(#(r/1 = 0)#)</span>
2374
+ &#160; (1)
2457
2375
  </p>
2458
2376
  </div>
2459
2377
  </div>
@@ -2463,14 +2381,12 @@ end
2463
2381
  <pre id='_' class='prettyprint '>
2464
2382
  CoreRoot(success): HttpResponse
2465
2383
  <br/>
2466
- &#160;&#160;&#160;&#160;&#160; if (success)
2384
+ &#160; if (success)
2467
2385
  <br/>
2468
- &#160;&#160;&#160;&#160;&#160; recommendation(label:
2469
- success-response)
2386
+ &#160; recommendation(label: success-response)
2470
2387
  <br/>
2471
- &#160;&#160;&#160;&#160;&#160; end
2388
+ &#160; end
2472
2389
  <br/>
2473
- &#160;&#160;&#160;
2474
2390
  </pre>
2475
2391
  </div>
2476
2392
  </div>
@@ -2480,6 +2396,8 @@ end
2480
2396
  </body>
2481
2397
  </html>
2482
2398
  OUTPUT
2399
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(presxml)
2400
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
2483
2401
  end
2484
2402
 
2485
2403
  it "processes recommendation (Presentation XML)" do
@@ -2686,8 +2604,8 @@ end
2686
2604
  OUTPUT
2687
2605
  end
2688
2606
 
2689
- it "processes pseudocode (Presentation XML)" do
2690
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2607
+ it "processes pseudocode" do
2608
+ input = <<~INPUT
2691
2609
  <itu-standard xmlns="http://riboseinc.com/isoxml">
2692
2610
  <bibdata>
2693
2611
  <language>en</language>
@@ -2698,65 +2616,22 @@ end
2698
2616
  <p id="_">  <em>C</em></p></figure>
2699
2617
  </preface></itu-standard>
2700
2618
  INPUT
2701
- <?xml version='1.0'?>
2702
- <itu-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
2703
- <bibdata>
2704
- <language>en</language>
2705
- </bibdata>
2706
- <local_bibdata>
2707
- <language>en</language>
2708
- </local_bibdata>
2709
- <preface>
2710
- <foreword>
2711
- <figure id='_' class='pseudocode' keep-with-next='true' keep-lines-together='true'>
2712
- <name>Figure 1&#xA0;&#x2014; Label</name>
2713
- <p id='_'>
2714
- &#xA0;&#xA0;
2715
- <strong>A</strong>
2716
- <br/>
2717
- &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;
2718
- <smallcap>B</smallcap>
2719
- </p>
2720
- <p id='_'>
2721
- &#xA0;&#xA0;
2722
- <em>C</em>
2723
- </p>
2724
- </figure>
2725
- </foreword>
2726
- </preface>
2727
- </itu-standard>
2619
+
2620
+ presxml = <<~OUTPUT
2621
+ <itu-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
2622
+ <bibdata>
2623
+ <language current="true">en</language>
2624
+ </bibdata>
2625
+ <preface><foreword>
2626
+ <figure id="_" class="pseudocode" keep-with-next="true" keep-lines-together="true"><name>Figure 1&#xA0;&#x2014; Label</name><p id="_">&#xA0;&#xA0;<strong>A</strong><br/>
2627
+ &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;<smallcap>B</smallcap></p>
2628
+ <p id="_">&#xA0;&#xA0;<em>C</em></p></figure>
2629
+ </foreword></preface>
2630
+ </itu-standard>
2631
+
2728
2632
  OUTPUT
2729
- end
2730
2633
 
2731
- it "processes pseudocode (HTML)" do
2732
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2733
- <itu-standard xmlns='http://riboseinc.com/isoxml'>
2734
- <bibdata>
2735
- <language>en</language>
2736
- </bibdata>
2737
- <local_bibdata>
2738
- <language>en</language>
2739
- </local_bibdata>
2740
- <preface>
2741
- <foreword>
2742
- <figure id='_' class='pseudocode' keep-with-next='true' keep-lines-together='true'>
2743
- <name>Figure 1&#xA0;&#x2014; Label</name>
2744
- <p id='_'>
2745
- &#xA0;&#xA0;
2746
- <strong>A</strong>
2747
- <br/>
2748
- &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;
2749
- <smallcap>B</smallcap>
2750
- </p>
2751
- <p id='_'>
2752
- &#xA0;&#xA0;
2753
- <em>C</em>
2754
- </p>
2755
- </figure>
2756
- </foreword>
2757
- </preface>
2758
- </itu-standard>
2759
- INPUT
2634
+ html = <<~OUTPUT
2760
2635
  #{HTML_HDR}
2761
2636
  <br/>
2762
2637
  <div>
@@ -2770,38 +2645,11 @@ INPUT
2770
2645
  </body>
2771
2646
  </html>
2772
2647
  OUTPUT
2773
- end
2774
2648
 
2775
- it "processes pseudocode (Word)" do
2776
2649
  FileUtils.rm_f "test.doc"
2777
- IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", false)
2778
- <itu-standard xmlns='http://riboseinc.com/isoxml'>
2779
- <bibdata>
2780
- <language>en</language>
2781
- </bibdata>
2782
- <local_bibdata>
2783
- <language>en</language>
2784
- </local_bibdata>
2785
- <preface>
2786
- <foreword>
2787
- <figure id='_' class='pseudocode' keep-with-next='true' keep-lines-together='true'>
2788
- <name>Figure 1&#xA0;&#x2014; Label</name>
2789
- <p id='_'>
2790
- &#xA0;&#xA0;
2791
- <strong>A</strong>
2792
- <br/>
2793
- &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;
2794
- <smallcap>B</smallcap>
2795
- </p>
2796
- <p id='_'>
2797
- &#xA0;&#xA0;
2798
- <em>C</em>
2799
- </p>
2800
- </figure>
2801
- </foreword>
2802
- </preface>
2803
- </itu-standard>
2804
- INPUT
2650
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(presxml)
2651
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
2652
+ IsoDoc::WordConvert.new({}).convert("test", presxml, false)
2805
2653
  expect(xmlpp( File.read("test.doc").gsub(%r{^.*<h1 class="ForewordTitle">Foreword</h1>}m, "").gsub(%r{</div>.*}m, "</div>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2806
2654
  <div class="pseudocode" style='page-break-after: avoid;page-break-inside: avoid;'><a name="_" id="_"></a><p class="pseudocode"><a name="_" id="_"></a>&#xA0;&#xA0;<b>A</b><br/>
2807
2655
  &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;<span style="font-variant:small-caps;">B</span></p>