isodoc 1.2.6 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +64 -0
- data/isodoc.gemspec +2 -1
- data/lib/isodoc/base_style/all.css +4 -0
- data/lib/isodoc/base_style/reset.css +4 -0
- data/lib/isodoc/base_style/reset.scss +5 -0
- data/lib/isodoc/convert.rb +1 -14
- data/lib/isodoc/function/to_word_html.rb +1 -0
- data/lib/isodoc/metadata.rb +28 -109
- data/lib/isodoc/metadata_contributor.rb +90 -0
- data/lib/isodoc/metadata_date.rb +6 -0
- data/lib/isodoc/presentation_function/bibdata.rb +78 -6
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/postprocess.rb +1 -1
- data/spec/assets/i18n.yaml +11 -4
- data/spec/isodoc/blocks_spec.rb +87 -240
- data/spec/isodoc/i18n_spec.rb +52 -38
- data/spec/isodoc/metadata_spec.rb +47 -6
- data/spec/isodoc/ref_spec.rb +2 -5
- data/spec/spec_helper.rb +2 -0
- metadata +20 -7
- data/.github/workflows/macos.yml +0 -42
- data/.github/workflows/ubuntu.yml +0 -62
- data/.github/workflows/windows.yml +0 -44
data/lib/isodoc/version.rb
CHANGED
@@ -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|
|
data/spec/assets/i18n.yaml
CHANGED
@@ -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:
|
data/spec/isodoc/blocks_spec.rb
CHANGED
@@ -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
|
2244
|
-
|
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
|
-
|
2299
|
-
|
2300
|
-
|
2301
|
-
<
|
2302
|
-
<
|
2303
|
-
|
2304
|
-
|
2305
|
-
|
2306
|
-
|
2307
|
-
</
|
2308
|
-
<
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
2322
|
-
|
2323
|
-
|
2324
|
-
<
|
2325
|
-
|
2326
|
-
|
2327
|
-
|
2328
|
-
|
2329
|
-
|
2330
|
-
|
2331
|
-
|
2332
|
-
|
2333
|
-
|
2334
|
-
|
2335
|
-
|
2336
|
-
|
2337
|
-
|
2338
|
-
|
2339
|
-
|
2340
|
-
|
2341
|
-
|
2342
|
-
|
2343
|
-
|
2344
|
-
|
2345
|
-
|
2346
|
-
|
2347
|
-
|
2348
|
-
|
2349
|
-
|
2350
|
-
|
2351
|
-
|
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
|
-
|
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
|
+
  (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
|
-
 
|
2383
|
+
  if (success)
|
2467
2384
|
<br/>
|
2468
|
-
 
|
2469
|
-
success-response)
|
2385
|
+
  recommendation(label: success-response)
|
2470
2386
|
<br/>
|
2471
|
-
 
|
2387
|
+
  end
|
2472
2388
|
<br/>
|
2473
|
-
   
|
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
|
2690
|
-
|
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
|
-
|
2702
|
-
|
2703
|
-
|
2704
|
-
|
2705
|
-
|
2706
|
-
|
2707
|
-
|
2708
|
-
</
|
2709
|
-
|
2710
|
-
|
2711
|
-
|
2712
|
-
|
2713
|
-
|
2714
|
-
  
|
2715
|
-
<strong>A</strong>
|
2716
|
-
<br/>
|
2717
|
-
        
|
2718
|
-
<smallcap>B</smallcap>
|
2719
|
-
</p>
|
2720
|
-
<p id='_'>
|
2721
|
-
  
|
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 — Label</name><p id="_">  <strong>A</strong><br/>
|
2626
|
+
        <smallcap>B</smallcap></p>
|
2627
|
+
<p id="_">  <em>C</em></p></figure>
|
2628
|
+
</foreword></preface>
|
2629
|
+
</itu-standard>
|
2630
|
+
|
2728
2631
|
OUTPUT
|
2729
|
-
end
|
2730
2632
|
|
2731
|
-
|
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 — Label</name>
|
2744
|
-
<p id='_'>
|
2745
|
-
  
|
2746
|
-
<strong>A</strong>
|
2747
|
-
<br/>
|
2748
|
-
        
|
2749
|
-
<smallcap>B</smallcap>
|
2750
|
-
</p>
|
2751
|
-
<p id='_'>
|
2752
|
-
  
|
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::
|
2778
|
-
|
2779
|
-
|
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 — Label</name>
|
2789
|
-
<p id='_'>
|
2790
|
-
  
|
2791
|
-
<strong>A</strong>
|
2792
|
-
<br/>
|
2793
|
-
        
|
2794
|
-
<smallcap>B</smallcap>
|
2795
|
-
</p>
|
2796
|
-
<p id='_'>
|
2797
|
-
  
|
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>  <b>A</b><br/>
|
2807
2654
|
        <span style="font-variant:small-caps;">B</span></p>
|