isodoc 1.2.2 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +64 -0
  3. data/isodoc.gemspec +3 -1
  4. data/lib/isodoc-yaml/i18n-fr.yaml +1 -1
  5. data/lib/isodoc/base_style/all.css +5 -1
  6. data/lib/isodoc/base_style/metanorma_word.css +6 -0
  7. data/lib/isodoc/base_style/metanorma_word.scss +6 -0
  8. data/lib/isodoc/base_style/reset.css +5 -1
  9. data/lib/isodoc/base_style/reset.scss +6 -1
  10. data/lib/isodoc/convert.rb +1 -14
  11. data/lib/isodoc/function/blocks.rb +1 -0
  12. data/lib/isodoc/function/cleanup.rb +1 -1
  13. data/lib/isodoc/function/references.rb +4 -2
  14. data/lib/isodoc/function/section.rb +13 -1
  15. data/lib/isodoc/function/table.rb +1 -0
  16. data/lib/isodoc/function/to_word_html.rb +4 -0
  17. data/lib/isodoc/function/utils.rb +1 -1
  18. data/lib/isodoc/html_function/html.rb +1 -0
  19. data/lib/isodoc/i18n.rb +8 -50
  20. data/lib/isodoc/metadata.rb +44 -111
  21. data/lib/isodoc/metadata_contributor.rb +90 -0
  22. data/lib/isodoc/metadata_date.rb +11 -0
  23. data/lib/isodoc/presentation_function/bibdata.rb +96 -0
  24. data/lib/isodoc/presentation_function/block.rb +14 -0
  25. data/lib/isodoc/presentation_function/inline.rb +27 -14
  26. data/lib/isodoc/presentation_xml_convert.rb +4 -0
  27. data/lib/isodoc/version.rb +1 -1
  28. data/lib/isodoc/word_function/body.rb +1 -0
  29. data/lib/isodoc/word_function/postprocess.rb +2 -2
  30. data/lib/isodoc/word_function/table.rb +3 -2
  31. data/lib/isodoc/xref.rb +1 -0
  32. data/lib/isodoc/xref/xref_anchor.rb +8 -3
  33. data/lib/isodoc/xref/xref_counter.rb +21 -7
  34. data/lib/isodoc/xref/xref_gen.rb +29 -6
  35. data/lib/isodoc/xref/xref_sect_gen.rb +1 -1
  36. data/lib/isodoc/xslfo_convert.rb +6 -1
  37. data/spec/assets/i18n.yaml +16 -0
  38. data/spec/isodoc/blocks_spec.rb +330 -215
  39. data/spec/isodoc/cleanup_spec.rb +3 -1
  40. data/spec/isodoc/i18n_spec.rb +68 -16
  41. data/spec/isodoc/inline_spec.rb +47 -5
  42. data/spec/isodoc/metadata_spec.rb +69 -19
  43. data/spec/isodoc/postproc_spec.rb +39 -3
  44. data/spec/isodoc/ref_spec.rb +3 -3
  45. data/spec/isodoc/section_spec.rb +134 -10
  46. data/spec/isodoc/table_spec.rb +306 -207
  47. data/spec/isodoc/terms_spec.rb +1 -1
  48. data/spec/isodoc/xref_spec.rb +46 -18
  49. data/spec/spec_helper.rb +6 -0
  50. metadata +35 -7
  51. data/.github/workflows/macos.yml +0 -42
  52. data/.github/workflows/ubuntu.yml +0 -62
  53. data/.github/workflows/windows.yml +0 -44
@@ -2,6 +2,29 @@ require_relative "xref_gen_seq.rb"
2
2
 
3
3
  module IsoDoc::XrefGen
4
4
  module Blocks
5
+ NUMBERED_BLOCKS = %w(termnote termexample note example requirement
6
+ recommendation permission figure table formula admonition sourcecode).freeze
7
+
8
+ def amend_preprocess(xmldoc)
9
+ xmldoc.xpath(ns("//amend[newcontent]")).each do |a|
10
+ autonum = amend_autonums(a)
11
+ NUMBERED_BLOCKS.each do |b|
12
+ a.xpath(ns("./newcontent//#{b}")).each_with_index do |e, i|
13
+ autonum[b] and i == 0 and e["number"] = autonum[b]
14
+ !autonum[b] and e["unnumbered"] = "true"
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ def amend_autonums(a)
21
+ autonum = {}
22
+ a.xpath(ns("./autonumber")).each do |n|
23
+ autonum[n["type"]] = n.text
24
+ end
25
+ autonum
26
+ end
27
+
5
28
  def termnote_label(n)
6
29
  @labels["termnote"].gsub(/%/, n.to_s)
7
30
  end
@@ -13,7 +36,7 @@ module IsoDoc::XrefGen
13
36
  return if n["id"].nil? || n["id"].empty?
14
37
  c.increment(n)
15
38
  @anchors[n["id"]] =
16
- { label: termnote_label(c.print), type: "termnote",
39
+ { label: termnote_label(c.print), type: "termnote", value: c.print,
17
40
  xref: l10n("#{anchor(t['id'], :xref)}, "\
18
41
  "#{@labels["note_xref"]} #{c.print}") }
19
42
  end
@@ -27,9 +50,9 @@ module IsoDoc::XrefGen
27
50
  examples.each do |n|
28
51
  return if n["id"].nil? || n["id"].empty?
29
52
  c.increment(n)
30
- idx = examples.size == 1 ? "" : c.print
53
+ idx = examples.size == 1 && !n["number"] ? "" : c.print
31
54
  @anchors[n["id"]] = {
32
- type: "termexample", label: idx,
55
+ type: "termexample", label: idx, value: c.print,
33
56
  xref: l10n("#{anchor(t['id'], :xref)}, "\
34
57
  "#{@labels["example_xref"]} #{c.print}") }
35
58
  end
@@ -54,7 +77,7 @@ module IsoDoc::XrefGen
54
77
  c = Counter.new
55
78
  notes.each do |n|
56
79
  next if @anchors[n["id"]] || n["id"].nil? || n["id"].empty?
57
- idx = notes.size == 1 ? "" : " #{c.increment(n).print}"
80
+ idx = notes.size == 1 && !n["number"] ? "" : " #{c.increment(n).print}"
58
81
  @anchors[n["id"]] = anchor_struct(idx, n, @labels["note_xref"],
59
82
  "note", false)
60
83
  end
@@ -76,7 +99,7 @@ module IsoDoc::XrefGen
76
99
  notes.each do |n|
77
100
  next if @anchors[n["id"]]
78
101
  next if n["id"].nil? || n["id"].empty?
79
- idx = notes.size == 1 ? "" : " #{c.increment(n).print}"
102
+ idx = notes.size == 1 && !n["number"] ? "" : " #{c.increment(n).print}"
80
103
  @anchors[n["id"]] = anchor_struct(idx, n, @labels["example_xref"],
81
104
  "example", n["unnumbered"])
82
105
  end
@@ -91,7 +114,7 @@ module IsoDoc::XrefGen
91
114
  c = Counter.new
92
115
  notes.each do |n|
93
116
  next if n["id"].nil? || n["id"].empty?
94
- idx = notes.size == 1 ? "" : " #{c.increment(n).print}"
117
+ idx = notes.size == 1 && !n["number"] ? "" : " #{c.increment(n).print}"
95
118
  @anchors[n["id"]] = anchor_struct(idx, n, @labels["list"], "list", false)
96
119
  list_item_anchor_names(n, @anchors[n["id"]], 1, "", notes.size != 1)
97
120
  end
@@ -113,7 +113,7 @@ module IsoDoc::XrefGen
113
113
 
114
114
  def annex_names(clause, num)
115
115
  @anchors[clause["id"]] = { label: annex_name_lbl(clause, num),
116
- type: "clause",
116
+ type: "clause", value: num.to_s,
117
117
  xref: "#{@labels["annex"]} #{num}", level: 1 }
118
118
  if a = single_annex_special_section(clause)
119
119
  annex_names1(a, "#{num}", 1)
@@ -23,6 +23,10 @@ module IsoDoc
23
23
  nil
24
24
  end
25
25
 
26
+ def pdf_options(docxml)
27
+ ""
28
+ end
29
+
26
30
  def convert(input_filename, file = nil, debug = false, output_filename = nil)
27
31
  file = File.read(input_filename, encoding: "utf-8") if file.nil?
28
32
  docxml, filename, dir = convert_init(file, input_filename, debug)
@@ -34,7 +38,8 @@ module IsoDoc
34
38
  FileUtils.rm_rf dir
35
39
  ::Metanorma::Output::XslfoPdf.new.convert(input_filename,
36
40
  output_filename || "#{filename}.#{@suffix}",
37
- File.join(@libdir, pdf_stylesheet(docxml)))
41
+ File.join(@libdir, pdf_stylesheet(docxml)),
42
+ pdf_options(docxml))
38
43
  end
39
44
 
40
45
  def xref_parse(node, out)
@@ -11,6 +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
  }
18
+ doctype_dict: {
19
+ brochure: broŝuro,
20
+ conference proceedings: konferencaktoj
21
+ }
22
+ stage_dict: {
23
+ published: publikigita
24
+ }
25
+ substage_dict: {
26
+ withdrawn: fortirita
27
+ }
28
+ array:
29
+ - elem1
30
+ - elem2
31
+ - {elem3: elem4, elem5: elem6}
32
+ void:
@@ -1,6 +1,243 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe IsoDoc do
4
+ it "processes amend blocks" do
5
+ input = <<~INPUT
6
+ <standard-document xmlns='https://www.metanorma.org/ns/standoc'>
7
+ <bibdata type='standard'>
8
+ <title language='en' format='text/plain'>Document title</title>
9
+ <language>en</language>
10
+ <script>Latn</script>
11
+ <status>
12
+ <stage>published</stage>
13
+ </status>
14
+ <copyright>
15
+ <from>2020</from>
16
+ </copyright>
17
+ <ext>
18
+ <doctype>article</doctype>
19
+ </ext>
20
+ </bibdata>
21
+ <sections>
22
+ <clause id='A' inline-header='false' obligation='normative'>
23
+ <title>Change Clause</title>
24
+ <amend id='B' change='modify' path='//table[2]' path_end='//table[2]/following-sibling:example[1]' title='Change'>
25
+ <autonumber type='table'>2</autonumber>
26
+ <autonumber type='example'>7</autonumber>
27
+ <description>
28
+ <p id='C'>
29
+ <em>
30
+ This table contains information on polygon cells which are not
31
+ included in ISO 10303-52. Remove table 2 completely and replace
32
+ with:
33
+ </em>
34
+ </p>
35
+ </description>
36
+ <newcontent id='D'>
37
+ <table id='E'>
38
+ <name>Edges of triangle and quadrilateral cells</name>
39
+ <tbody>
40
+ <tr>
41
+ <th colspan='2' valign='middle' align='center'>triangle</th>
42
+ <th colspan='2' valign='middle' align='center'>quadrilateral</th>
43
+ </tr>
44
+ <tr>
45
+ <td valign='middle' align='center'>edge</td>
46
+ <td valign='middle' align='center'>vertices</td>
47
+ <td valign='middle' align='center'>edge</td>
48
+ <td valign='middle' align='center'>vertices</td>
49
+ </tr>
50
+ <tr>
51
+ <td valign='middle' align='center'>1</td>
52
+ <td valign='middle' align='center'>1, 2</td>
53
+ <td valign='middle' align='center'>1</td>
54
+ <td valign='middle' align='center'>1, 2</td>
55
+ </tr>
56
+ <tr>
57
+ <td valign='middle' align='center'>2</td>
58
+ <td valign='middle' align='center'>2, 3</td>
59
+ <td valign='middle' align='center'>2</td>
60
+ <td valign='middle' align='center'>2, 3</td>
61
+ </tr>
62
+ <tr>
63
+ <td valign='middle' align='center'>3</td>
64
+ <td valign='middle' align='center'>3, 1</td>
65
+ <td valign='middle' align='center'>3</td>
66
+ <td valign='middle' align='center'>3, 4</td>
67
+ </tr>
68
+ <tr>
69
+ <td valign='top' align='left'/>
70
+ <td valign='top' align='left'/>
71
+ <td valign='middle' align='center'>4</td>
72
+ <td valign='middle' align='center'>4, 1</td>
73
+ </tr>
74
+ </tbody>
75
+ </table>
76
+ <figure id="H"><name>Figure</name></figure>
77
+ <example id='F'>
78
+ <p id='G'>This is not generalised further.</p>
79
+ </example>
80
+ </newcontent>
81
+ </amend>
82
+ </clause>
83
+ </sections>
84
+ </standard-document>
85
+ INPUT
86
+ presxml = <<~OUTPUT
87
+ <standard-document xmlns="https://www.metanorma.org/ns/standoc" type="presentation">
88
+ <bibdata type="standard">
89
+ <title language="en" format="text/plain">Document title</title>
90
+ <language current="true">en</language>
91
+ <script current="true">Latn</script>
92
+ <status>
93
+ <stage language="">published</stage>
94
+ </status>
95
+ <copyright>
96
+ <from>2020</from>
97
+ </copyright>
98
+ <ext>
99
+ <doctype language="">article</doctype>
100
+ </ext>
101
+ </bibdata>
102
+ <sections>
103
+ <clause id="A" inline-header="false" obligation="normative">
104
+ <title depth="1">1.<tab/>Change Clause</title>
105
+ <p id="C">
106
+ <em>
107
+ This table contains information on polygon cells which are not
108
+ included in ISO 10303-52. Remove table 2 completely and replace
109
+ with:
110
+ </em>
111
+ </p>
112
+ <quote id="D">
113
+ <table id="E" number="2">
114
+ <name>Table 2&#xA0;&#x2014; Edges of triangle and quadrilateral cells</name>
115
+ <tbody>
116
+ <tr>
117
+ <th colspan="2" valign="middle" align="center">triangle</th>
118
+ <th colspan="2" valign="middle" align="center">quadrilateral</th>
119
+ </tr>
120
+ <tr>
121
+ <td valign="middle" align="center">edge</td>
122
+ <td valign="middle" align="center">vertices</td>
123
+ <td valign="middle" align="center">edge</td>
124
+ <td valign="middle" align="center">vertices</td>
125
+ </tr>
126
+ <tr>
127
+ <td valign="middle" align="center">1</td>
128
+ <td valign="middle" align="center">1, 2</td>
129
+ <td valign="middle" align="center">1</td>
130
+ <td valign="middle" align="center">1, 2</td>
131
+ </tr>
132
+ <tr>
133
+ <td valign="middle" align="center">2</td>
134
+ <td valign="middle" align="center">2, 3</td>
135
+ <td valign="middle" align="center">2</td>
136
+ <td valign="middle" align="center">2, 3</td>
137
+ </tr>
138
+ <tr>
139
+ <td valign="middle" align="center">3</td>
140
+ <td valign="middle" align="center">3, 1</td>
141
+ <td valign="middle" align="center">3</td>
142
+ <td valign="middle" align="center">3, 4</td>
143
+ </tr>
144
+ <tr>
145
+ <td valign="top" align="left"/>
146
+ <td valign="top" align="left"/>
147
+ <td valign="middle" align="center">4</td>
148
+ <td valign="middle" align="center">4, 1</td>
149
+ </tr>
150
+ </tbody>
151
+ </table>
152
+ <figure id="H" unnumbered="true"><name>Figure</name></figure>
153
+ <example id="F" number="7"><name>EXAMPLE 7</name>
154
+ <p id="G">This is not generalised further.</p>
155
+ </example>
156
+ </quote>
157
+ </clause>
158
+ </sections>
159
+ </standard-document>
160
+ OUTPUT
161
+ html = <<~OUTPUT
162
+ <html lang='en'>
163
+ <head/>
164
+ <body lang='en'>
165
+ <div class='title-section'>
166
+ <p>&#160;</p>
167
+ </div>
168
+ <br/>
169
+ <div class='prefatory-section'>
170
+ <p>&#160;</p>
171
+ </div>
172
+ <br/>
173
+ <div class='main-section'>
174
+ <p class='zzSTDTitle1'>Document title</p>
175
+ <div id='A'>
176
+ <h1>1.&#160; Change Clause</h1>
177
+ <p id='C'>
178
+ <i>
179
+ This table contains information on polygon cells which are not
180
+ included in ISO 10303-52. Remove table 2 completely and replace
181
+ with:
182
+ </i>
183
+ </p>
184
+ <div class='Quote' id="D">
185
+ <p class='TableTitle' style='text-align:center;'>Table 2&#160;&#8212; Edges of triangle and quadrilateral cells</p>
186
+ <table id='E' class='MsoISOTable' style='border-width:1px;border-spacing:0;'>
187
+ <tbody>
188
+ <tr>
189
+ <th colspan='2' style='font-weight:bold;text-align:center;vertical-align:middle;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;' scope='row'>triangle</th>
190
+ <th colspan='2' style='font-weight:bold;text-align:center;vertical-align:middle;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;' scope='row'>quadrilateral</th>
191
+ </tr>
192
+ <tr>
193
+ <td style='text-align:center;vertical-align:middle;border-top:none;border-bottom:solid windowtext 1.0pt;'>edge</td>
194
+ <td style='text-align:center;vertical-align:middle;border-top:none;border-bottom:solid windowtext 1.0pt;'>vertices</td>
195
+ <td style='text-align:center;vertical-align:middle;border-top:none;border-bottom:solid windowtext 1.0pt;'>edge</td>
196
+ <td style='text-align:center;vertical-align:middle;border-top:none;border-bottom:solid windowtext 1.0pt;'>vertices</td>
197
+ </tr>
198
+ <tr>
199
+ <td style='text-align:center;vertical-align:middle;border-top:none;border-bottom:solid windowtext 1.0pt;'>1</td>
200
+ <td style='text-align:center;vertical-align:middle;border-top:none;border-bottom:solid windowtext 1.0pt;'>1, 2</td>
201
+ <td style='text-align:center;vertical-align:middle;border-top:none;border-bottom:solid windowtext 1.0pt;'>1</td>
202
+ <td style='text-align:center;vertical-align:middle;border-top:none;border-bottom:solid windowtext 1.0pt;'>1, 2</td>
203
+ </tr>
204
+ <tr>
205
+ <td style='text-align:center;vertical-align:middle;border-top:none;border-bottom:solid windowtext 1.0pt;'>2</td>
206
+ <td style='text-align:center;vertical-align:middle;border-top:none;border-bottom:solid windowtext 1.0pt;'>2, 3</td>
207
+ <td style='text-align:center;vertical-align:middle;border-top:none;border-bottom:solid windowtext 1.0pt;'>2</td>
208
+ <td style='text-align:center;vertical-align:middle;border-top:none;border-bottom:solid windowtext 1.0pt;'>2, 3</td>
209
+ </tr>
210
+ <tr>
211
+ <td style='text-align:center;vertical-align:middle;border-top:none;border-bottom:solid windowtext 1.0pt;'>3</td>
212
+ <td style='text-align:center;vertical-align:middle;border-top:none;border-bottom:solid windowtext 1.0pt;'>3, 1</td>
213
+ <td style='text-align:center;vertical-align:middle;border-top:none;border-bottom:solid windowtext 1.0pt;'>3</td>
214
+ <td style='text-align:center;vertical-align:middle;border-top:none;border-bottom:solid windowtext 1.0pt;'>3, 4</td>
215
+ </tr>
216
+ <tr>
217
+ <td style='text-align:left;vertical-align:top;border-top:none;border-bottom:solid windowtext 1.5pt;'/>
218
+ <td style='text-align:left;vertical-align:top;border-top:none;border-bottom:solid windowtext 1.5pt;'/>
219
+ <td style='text-align:center;vertical-align:middle;border-top:none;border-bottom:solid windowtext 1.5pt;'>4</td>
220
+ <td style='text-align:center;vertical-align:middle;border-top:none;border-bottom:solid windowtext 1.5pt;'>4, 1</td>
221
+ </tr>
222
+ </tbody>
223
+ </table>
224
+ <div id='H' class='figure'>
225
+ <p class='FigureTitle' style='text-align:center;'>Figure</p>
226
+ </div>
227
+ <div id='F' class='example'>
228
+ <p class='example-title'>EXAMPLE 7</p>
229
+ <p id='G'>This is not generalised further.</p>
230
+ </div>
231
+ </div>
232
+ </div>
233
+ </div>
234
+ </body>
235
+ </html>
236
+ OUTPUT
237
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(presxml)
238
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
239
+ end
240
+
4
241
  it "processes unlabelled notes (Presentation XML)" do
5
242
  expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
6
243
  <iso-standard xmlns="http://riboseinc.com/isoxml">
@@ -12,7 +249,7 @@ RSpec.describe IsoDoc do
12
249
  </iso-standard>
13
250
  INPUT
14
251
  <?xml version='1.0'?>
15
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
252
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
16
253
  <preface>
17
254
  <foreword>
18
255
  <note id='A' keep-with-next='true' keep-lines-together='true'>
@@ -115,7 +352,7 @@ OUTPUT
115
352
  </iso-standard>
116
353
  INPUT
117
354
  <?xml version='1.0'?>
118
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
355
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
119
356
  <preface>
120
357
  <foreword>
121
358
  <note id='note1'>
@@ -403,7 +640,7 @@ B</pre>
403
640
  </iso-standard>
404
641
  INPUT
405
642
  <?xml version='1.0'?>
406
- <iso-standard xmlns="http://riboseinc.com/isoxml">
643
+ <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
407
644
  <preface><foreword>
408
645
  <figure id="figureA-1" keep-with-next="true" keep-lines-together="true">
409
646
  <name>Figure 1&#xA0;&#x2014; Split-it-right <em>sample</em> divider<fn reference="1"><p>X</p></fn></name>
@@ -703,7 +940,7 @@ OUTPUT
703
940
  </iso-standard>
704
941
  INPUT
705
942
  <?xml version='1.0'?>
706
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
943
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
707
944
  <preface>
708
945
  <foreword>
709
946
  <example id='samplecode' keep-with-next='true' keep-lines-together='true'>
@@ -819,7 +1056,7 @@ OUTPUT
819
1056
  </iso-standard>
820
1057
  INPUT
821
1058
  <?xml version='1.0'?>
822
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
1059
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
823
1060
  <preface>
824
1061
  <foreword>
825
1062
  <example id='samplecode'>
@@ -855,7 +1092,7 @@ Que?
855
1092
  </iso-standard>
856
1093
  INPUT
857
1094
  <?xml version='1.0'?>
858
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
1095
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
859
1096
  <preface>
860
1097
  <foreword>
861
1098
  <sourcecode lang='ruby' id='samplecode'>
@@ -1093,7 +1330,7 @@ Que?
1093
1330
  </iso-standard>
1094
1331
  INPUT
1095
1332
  <?xml version='1.0'?>
1096
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
1333
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1097
1334
  <preface>
1098
1335
  <foreword>
1099
1336
  <formula id='_be9158af-7e93-4ee2-90c5-26d31c181934' unnumbered='true' keep-with-next='true' keep-lines-together='true'>
@@ -1346,7 +1583,7 @@ it "processes blockquotes (Presentation XML)" do
1346
1583
  </iso-standard>
1347
1584
  INPUT
1348
1585
  <?xml version='1.0'?>
1349
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
1586
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1350
1587
  <preface>
1351
1588
  <foreword>
1352
1589
  <quote id='_044bd364-c832-4b78-8fea-92242402a1d1'>
@@ -1485,7 +1722,7 @@ it "processes blockquotes (Presentation XML)" do
1485
1722
  </iso-standard>
1486
1723
  INPUT
1487
1724
  <?xml version='1.0'?>
1488
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
1725
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1489
1726
  <preface>
1490
1727
  <foreword>
1491
1728
  <permission id='_' keep-with-next='true' keep-lines-together='true'>
@@ -1845,7 +2082,7 @@ Inherits: <a href='#rfc2616'>RFC 2616 (HTTP/1.1)</a>
1845
2082
  </iso-standard>
1846
2083
  INPUT
1847
2084
  <?xml version='1.0'?>
1848
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
2085
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1849
2086
  <preface>
1850
2087
  <foreword>
1851
2088
  <requirement id='A' unnumbered='true' keep-with-next='true' keep-lines-together='true'>
@@ -1989,8 +2226,8 @@ end
1989
2226
  OUTPUT
1990
2227
  end
1991
2228
 
1992
- it "processes requirements in French (Presentation XML)" do
1993
- 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
1994
2231
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1995
2232
  <bibdata>
1996
2233
  <language>fr</language>
@@ -2044,125 +2281,63 @@ end
2044
2281
  </foreword></preface>
2045
2282
  </iso-standard>
2046
2283
  INPUT
2047
- <?xml version='1.0'?>
2048
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
2049
- <bibdata>
2050
- <language>fr</language>
2051
- <script>Latn</script>
2052
- </bibdata>
2053
- <preface>
2054
- <foreword>
2055
- <requirement id='A' unnumbered='true'>
2056
- <name>Exigence</name>
2057
- <title>A New Requirement</title>
2058
- <label>/ogc/recommendation/wfs/2</label>
2059
- <inherit>/ss/584/2015/level/1</inherit>
2060
- <subject>user</subject>
2061
- <description>
2062
- <p id='_'>
2063
- I recommend
2064
- <em>this</em>
2065
- .
2066
- </p>
2067
- </description>
2068
- <specification exclude='true' type='tabular'>
2069
- <p id='_'>This is the object of the recommendation:</p>
2070
- <table id='_'>
2071
- <tbody>
2072
- <tr>
2073
- <td style='text-align:left;'>Object</td>
2074
- <td style='text-align:left;'>Value</td>
2075
- </tr>
2076
- <tr>
2077
- <td style='text-align:left;'>Mission</td>
2078
- <td style='text-align:left;'>Accomplished</td>
2079
- </tr>
2080
- </tbody>
2081
- </table>
2082
- </specification>
2083
- <description>
2084
- <p id='_'>As for the measurement targets,</p>
2085
- </description>
2086
- <measurement-target exclude='false'>
2087
- <p id='_'>The measurement target shall be measured as:</p>
2088
- <formula id='B'>
2089
- <name>1</name>
2090
- <stem type='AsciiMath'>r/1 = 0</stem>
2091
- </formula>
2092
- </measurement-target>
2093
- <verification exclude='false'>
2094
- <p id='_'>The following code will be run for verification:</p>
2095
- <sourcecode id='_'>
2096
- CoreRoot(success): HttpResponse if (success) recommendation(label:
2097
- success-response) end
2098
- </sourcecode>
2099
- </verification>
2100
- <import exclude='true'>
2101
- <sourcecode id='_'>success-response()</sourcecode>
2102
- </import>
2103
- </requirement>
2104
- </foreword>
2105
- </preface>
2106
- </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>
2107
2338
  OUTPUT
2108
- end
2109
2339
 
2110
- it "processes requirements in French (HTML)" do
2111
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2112
- <iso-standard xmlns="http://riboseinc.com/isoxml">
2113
- <bibdata>
2114
- <language>fr</language>
2115
- <script>Latn</script>
2116
- </bibdata>
2117
- <preface><foreword>
2118
- <requirement id="A" unnumbered="true">
2119
- <name>Exigence</name>
2120
- <title>A New Requirement</title>
2121
- <label>/ogc/recommendation/wfs/2</label>
2122
- <inherit>/ss/584/2015/level/1</inherit>
2123
- <subject>user</subject>
2124
- <description>
2125
- <p id="_">I recommend <em>this</em>.</p>
2126
- </description>
2127
- <specification exclude="true" type="tabular">
2128
- <p id="_">This is the object of the recommendation:</p>
2129
- <table id="_">
2130
- <tbody>
2131
- <tr>
2132
- <td style="text-align:left;">Object</td>
2133
- <td style="text-align:left;">Value</td>
2134
- </tr>
2135
- <tr>
2136
- <td style="text-align:left;">Mission</td>
2137
- <td style="text-align:left;">Accomplished</td>
2138
- </tr>
2139
- </tbody>
2140
- </table>
2141
- </specification>
2142
- <description>
2143
- <p id="_">As for the measurement targets,</p>
2144
- </description>
2145
- <measurement-target exclude="false">
2146
- <p id="_">The measurement target shall be measured as:</p>
2147
- <formula id="B">
2148
- <stem type="AsciiMath">r/1 = 0</stem>
2149
- </formula>
2150
- </measurement-target>
2151
- <verification exclude="false">
2152
- <p id="_">The following code will be run for verification:</p>
2153
- <sourcecode id="_">CoreRoot(success): HttpResponse
2154
- if (success)
2155
- recommendation(label: success-response)
2156
- end
2157
- </sourcecode>
2158
- </verification>
2159
- <import exclude="true">
2160
- <sourcecode id="_">success-response()</sourcecode>
2161
- </import>
2162
- </requirement>
2163
- </foreword></preface>
2164
- </iso-standard>
2165
- INPUT
2340
+ html = <<~OUTPUT
2166
2341
  #{HTML_HDR.gsub(/"en"/, '"fr"')}
2167
2342
  <br/>
2168
2343
  <div>
@@ -2195,6 +2370,7 @@ end
2195
2370
  <div id='B'><div class='formula'>
2196
2371
  <p>
2197
2372
  <span class='stem'>(#(r/1 = 0)#)</span>
2373
+ &#160; (1)
2198
2374
  </p>
2199
2375
  </div>
2200
2376
  </div>
@@ -2204,14 +2380,12 @@ end
2204
2380
  <pre id='_' class='prettyprint '>
2205
2381
  CoreRoot(success): HttpResponse
2206
2382
  <br/>
2207
- &#160;&#160;&#160;&#160;&#160; if (success)
2383
+ &#160; if (success)
2208
2384
  <br/>
2209
- &#160;&#160;&#160;&#160;&#160; recommendation(label:
2210
- success-response)
2385
+ &#160; recommendation(label: success-response)
2211
2386
  <br/>
2212
- &#160;&#160;&#160;&#160;&#160; end
2387
+ &#160; end
2213
2388
  <br/>
2214
- &#160;&#160;&#160;
2215
2389
  </pre>
2216
2390
  </div>
2217
2391
  </div>
@@ -2221,6 +2395,8 @@ end
2221
2395
  </body>
2222
2396
  </html>
2223
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)
2224
2400
  end
2225
2401
 
2226
2402
  it "processes recommendation (Presentation XML)" do
@@ -2276,7 +2452,7 @@ end
2276
2452
  </iso-standard>
2277
2453
  INPUT
2278
2454
  <?xml version='1.0'?>
2279
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
2455
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
2280
2456
  <preface>
2281
2457
  <foreword>
2282
2458
  <recommendation id='_' obligation='shall,could' keep-with-next='true' keep-lines-together='true'>
@@ -2427,8 +2603,8 @@ end
2427
2603
  OUTPUT
2428
2604
  end
2429
2605
 
2430
- it "processes pseudocode (Presentation XML)" do
2431
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2606
+ it "processes pseudocode" do
2607
+ input = <<~INPUT
2432
2608
  <itu-standard xmlns="http://riboseinc.com/isoxml">
2433
2609
  <bibdata>
2434
2610
  <language>en</language>
@@ -2439,59 +2615,22 @@ end
2439
2615
  <p id="_">  <em>C</em></p></figure>
2440
2616
  </preface></itu-standard>
2441
2617
  INPUT
2442
- <?xml version='1.0'?>
2443
- <itu-standard xmlns='http://riboseinc.com/isoxml'>
2444
- <bibdata>
2445
- <language>en</language>
2446
- </bibdata>
2447
- <preface>
2448
- <foreword>
2449
- <figure id='_' class='pseudocode' keep-with-next='true' keep-lines-together='true'>
2450
- <name>Figure 1&#xA0;&#x2014; Label</name>
2451
- <p id='_'>
2452
- &#xA0;&#xA0;
2453
- <strong>A</strong>
2454
- <br/>
2455
- &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;
2456
- <smallcap>B</smallcap>
2457
- </p>
2458
- <p id='_'>
2459
- &#xA0;&#xA0;
2460
- <em>C</em>
2461
- </p>
2462
- </figure>
2463
- </foreword>
2464
- </preface>
2465
- </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
+
2466
2631
  OUTPUT
2467
- end
2468
2632
 
2469
- it "processes pseudocode (HTML)" do
2470
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2471
- <itu-standard xmlns='http://riboseinc.com/isoxml'>
2472
- <bibdata>
2473
- <language>en</language>
2474
- </bibdata>
2475
- <preface>
2476
- <foreword>
2477
- <figure id='_' class='pseudocode' keep-with-next='true' keep-lines-together='true'>
2478
- <name>Figure 1&#xA0;&#x2014; Label</name>
2479
- <p id='_'>
2480
- &#xA0;&#xA0;
2481
- <strong>A</strong>
2482
- <br/>
2483
- &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;
2484
- <smallcap>B</smallcap>
2485
- </p>
2486
- <p id='_'>
2487
- &#xA0;&#xA0;
2488
- <em>C</em>
2489
- </p>
2490
- </figure>
2491
- </foreword>
2492
- </preface>
2493
- </itu-standard>
2494
- INPUT
2633
+ html = <<~OUTPUT
2495
2634
  #{HTML_HDR}
2496
2635
  <br/>
2497
2636
  <div>
@@ -2505,35 +2644,11 @@ INPUT
2505
2644
  </body>
2506
2645
  </html>
2507
2646
  OUTPUT
2508
- end
2509
2647
 
2510
- it "processes pseudocode (Word)" do
2511
2648
  FileUtils.rm_f "test.doc"
2512
- IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", false)
2513
- <itu-standard xmlns='http://riboseinc.com/isoxml'>
2514
- <bibdata>
2515
- <language>en</language>
2516
- </bibdata>
2517
- <preface>
2518
- <foreword>
2519
- <figure id='_' class='pseudocode' keep-with-next='true' keep-lines-together='true'>
2520
- <name>Figure 1&#xA0;&#x2014; Label</name>
2521
- <p id='_'>
2522
- &#xA0;&#xA0;
2523
- <strong>A</strong>
2524
- <br/>
2525
- &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;
2526
- <smallcap>B</smallcap>
2527
- </p>
2528
- <p id='_'>
2529
- &#xA0;&#xA0;
2530
- <em>C</em>
2531
- </p>
2532
- </figure>
2533
- </foreword>
2534
- </preface>
2535
- </itu-standard>
2536
- 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)
2537
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")
2538
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/>
2539
2654
  &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;<span style="font-variant:small-caps;">B</span></p>