isodoc 1.2.6 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "1.2.6".freeze
2
+ VERSION = "1.2.7".freeze
3
3
  end
@@ -183,7 +183,7 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
183
183
  def generate_header(filename, _dir)
184
184
  return nil unless @header
185
185
  template = IsoDoc::Common.liquid(File.read(@header, encoding: "UTF-8"))
186
- meta = @meta.get
186
+ meta = @meta.get.merge(@labels || {}).merge(@meta.labels || {})
187
187
  meta[:filename] = filename
188
188
  params = meta.map { |k, v| [k.to_s, v] }.to_h
189
189
  Tempfile.open(%w(header html), :encoding => "utf-8") do |f|
@@ -11,15 +11,22 @@ normref: Normaj citaĵoj
11
11
  bibliography: Bibliografio
12
12
  inform_annex: informa
13
13
  all_parts: ĉiuj partoj
14
+ norm_annex: normative
14
15
  locality: {
15
16
  table: Tabelo
16
- }
17
+ }
17
18
  doctype_dict: {
18
- brochure: broŝuro
19
- }
19
+ brochure: broŝuro,
20
+ conference proceedings: konferencaktoj
21
+ }
20
22
  stage_dict: {
21
23
  published: publikigita
22
24
  }
23
25
  substage_dict: {
24
26
  withdrawn: fortirita
25
- }
27
+ }
28
+ array:
29
+ - elem1
30
+ - elem2
31
+ - {elem3: elem4, elem5: elem6}
32
+ 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
 
@@ -2240,8 +2226,8 @@ end
2240
2226
  OUTPUT
2241
2227
  end
2242
2228
 
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")
2229
+ it "processes requirements in French" do
2230
+ input = <<~INPUT
2245
2231
  <iso-standard xmlns="http://riboseinc.com/isoxml">
2246
2232
  <bibdata>
2247
2233
  <language>fr</language>
@@ -2295,133 +2281,63 @@ end
2295
2281
  </foreword></preface>
2296
2282
  </iso-standard>
2297
2283
  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>
2284
+
2285
+ presxml = <<~OUTPUT
2286
+ <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
2287
+ <bibdata>
2288
+ <language current="true">fr</language>
2289
+ <script current="true">Latn</script>
2290
+ </bibdata>
2291
+ <preface><foreword>
2292
+ <requirement id="A" unnumbered="true"><name>Exigence</name>
2293
+ <title>A New Requirement</title>
2294
+ <label>/ogc/recommendation/wfs/2</label>
2295
+ <inherit>/ss/584/2015/level/1</inherit>
2296
+ <subject>user</subject>
2297
+ <description>
2298
+ <p id="_">I recommend <em>this</em>.</p>
2299
+ </description>
2300
+ <specification exclude="true" type="tabular">
2301
+ <p id="_">This is the object of the recommendation:</p>
2302
+ <table id="_">
2303
+ <tbody>
2304
+ <tr>
2305
+ <td style="text-align:left;">Object</td>
2306
+ <td style="text-align:left;">Value</td>
2307
+ </tr>
2308
+ <tr>
2309
+ <td style="text-align:left;">Mission</td>
2310
+ <td style="text-align:left;">Accomplished</td>
2311
+ </tr>
2312
+ </tbody>
2313
+ </table>
2314
+ </specification>
2315
+ <description>
2316
+ <p id="_">As for the measurement targets,</p>
2317
+ </description>
2318
+ <measurement-target exclude="false">
2319
+ <p id="_">The measurement target shall be measured as:</p>
2320
+ <formula id="B"><name>1</name>
2321
+ <stem type="AsciiMath">r/1 = 0</stem>
2322
+ </formula>
2323
+ </measurement-target>
2324
+ <verification exclude="false">
2325
+ <p id="_">The following code will be run for verification:</p>
2326
+ <sourcecode id="_">CoreRoot(success): HttpResponse
2327
+ if (success)
2328
+ recommendation(label: success-response)
2329
+ end
2330
+ </sourcecode>
2331
+ </verification>
2332
+ <import exclude="true">
2333
+ <sourcecode id="_">success-response()</sourcecode>
2334
+ </import>
2335
+ </requirement>
2336
+ </foreword></preface>
2337
+ </iso-standard>
2362
2338
  OUTPUT
2363
- end
2364
2339
 
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
2340
+ html = <<~OUTPUT
2425
2341
  #{HTML_HDR.gsub(/"en"/, '"fr"')}
2426
2342
  <br/>
2427
2343
  <div>
@@ -2454,6 +2370,7 @@ end
2454
2370
  <div id='B'><div class='formula'>
2455
2371
  <p>
2456
2372
  <span class='stem'>(#(r/1 = 0)#)</span>
2373
+ &#160; (1)
2457
2374
  </p>
2458
2375
  </div>
2459
2376
  </div>
@@ -2463,14 +2380,12 @@ end
2463
2380
  <pre id='_' class='prettyprint '>
2464
2381
  CoreRoot(success): HttpResponse
2465
2382
  <br/>
2466
- &#160;&#160;&#160;&#160;&#160; if (success)
2383
+ &#160; if (success)
2467
2384
  <br/>
2468
- &#160;&#160;&#160;&#160;&#160; recommendation(label:
2469
- success-response)
2385
+ &#160; recommendation(label: success-response)
2470
2386
  <br/>
2471
- &#160;&#160;&#160;&#160;&#160; end
2387
+ &#160; end
2472
2388
  <br/>
2473
- &#160;&#160;&#160;
2474
2389
  </pre>
2475
2390
  </div>
2476
2391
  </div>
@@ -2480,6 +2395,8 @@ end
2480
2395
  </body>
2481
2396
  </html>
2482
2397
  OUTPUT
2398
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(presxml)
2399
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
2483
2400
  end
2484
2401
 
2485
2402
  it "processes recommendation (Presentation XML)" do
@@ -2686,8 +2603,8 @@ end
2686
2603
  OUTPUT
2687
2604
  end
2688
2605
 
2689
- it "processes pseudocode (Presentation XML)" do
2690
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2606
+ it "processes pseudocode" do
2607
+ input = <<~INPUT
2691
2608
  <itu-standard xmlns="http://riboseinc.com/isoxml">
2692
2609
  <bibdata>
2693
2610
  <language>en</language>
@@ -2698,65 +2615,22 @@ end
2698
2615
  <p id="_">  <em>C</em></p></figure>
2699
2616
  </preface></itu-standard>
2700
2617
  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>
2618
+
2619
+ presxml = <<~OUTPUT
2620
+ <itu-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
2621
+ <bibdata>
2622
+ <language current="true">en</language>
2623
+ </bibdata>
2624
+ <preface><foreword>
2625
+ <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/>
2626
+ &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;<smallcap>B</smallcap></p>
2627
+ <p id="_">&#xA0;&#xA0;<em>C</em></p></figure>
2628
+ </foreword></preface>
2629
+ </itu-standard>
2630
+
2728
2631
  OUTPUT
2729
- end
2730
2632
 
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
2633
+ html = <<~OUTPUT
2760
2634
  #{HTML_HDR}
2761
2635
  <br/>
2762
2636
  <div>
@@ -2770,38 +2644,11 @@ INPUT
2770
2644
  </body>
2771
2645
  </html>
2772
2646
  OUTPUT
2773
- end
2774
2647
 
2775
- it "processes pseudocode (Word)" do
2776
2648
  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
2649
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(presxml)
2650
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
2651
+ IsoDoc::WordConvert.new({}).convert("test", presxml, false)
2805
2652
  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
2653
  <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
2654
  &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;<span style="font-variant:small-caps;">B</span></p>