isodoc 1.2.3 → 1.2.8

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.
Files changed (56) 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 +9 -8
  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/metanorma_word.css +6 -0
  10. data/lib/isodoc/base_style/metanorma_word.scss +6 -0
  11. data/lib/isodoc/base_style/reset.css +5 -1
  12. data/lib/isodoc/base_style/reset.scss +6 -1
  13. data/lib/isodoc/convert.rb +1 -14
  14. data/lib/isodoc/function/blocks.rb +1 -0
  15. data/lib/isodoc/function/inline.rb +0 -33
  16. data/lib/isodoc/function/references.rb +5 -3
  17. data/lib/isodoc/function/table.rb +1 -0
  18. data/lib/isodoc/function/to_word_html.rb +3 -2
  19. data/lib/isodoc/function/utils.rb +1 -1
  20. data/lib/isodoc/html_function/postprocess.rb +1 -0
  21. data/lib/isodoc/i18n.rb +23 -52
  22. data/lib/isodoc/metadata.rb +44 -111
  23. data/lib/isodoc/metadata_contributor.rb +90 -0
  24. data/lib/isodoc/metadata_date.rb +11 -0
  25. data/lib/isodoc/presentation_function/bibdata.rb +96 -0
  26. data/lib/isodoc/presentation_function/block.rb +28 -9
  27. data/lib/isodoc/presentation_function/inline.rb +149 -34
  28. data/lib/isodoc/presentation_xml_convert.rb +7 -0
  29. data/lib/isodoc/version.rb +1 -1
  30. data/lib/isodoc/word_function/body.rb +12 -0
  31. data/lib/isodoc/word_function/postprocess.rb +2 -2
  32. data/lib/isodoc/word_function/table.rb +3 -2
  33. data/lib/isodoc/xref.rb +1 -0
  34. data/lib/isodoc/xref/xref_anchor.rb +8 -3
  35. data/lib/isodoc/xref/xref_counter.rb +21 -7
  36. data/lib/isodoc/xref/xref_gen.rb +29 -6
  37. data/lib/isodoc/xref/xref_sect_gen.rb +1 -1
  38. data/lib/isodoc/xslfo_convert.rb +6 -1
  39. data/spec/assets/i18n.yaml +22 -5
  40. data/spec/isodoc/blocks_spec.rb +331 -215
  41. data/spec/isodoc/footnotes_spec.rb +4 -5
  42. data/spec/isodoc/i18n_spec.rb +89 -16
  43. data/spec/isodoc/inline_spec.rb +185 -163
  44. data/spec/isodoc/metadata_spec.rb +69 -19
  45. data/spec/isodoc/postproc_spec.rb +40 -3
  46. data/spec/isodoc/presentation_xml_spec.rb +584 -1
  47. data/spec/isodoc/ref_spec.rb +5 -5
  48. data/spec/isodoc/section_spec.rb +9 -9
  49. data/spec/isodoc/table_spec.rb +306 -207
  50. data/spec/isodoc/terms_spec.rb +1 -1
  51. data/spec/isodoc/xref_spec.rb +46 -18
  52. data/spec/spec_helper.rb +6 -0
  53. metadata +35 -7
  54. data/.github/workflows/macos.yml +0 -42
  55. data/.github/workflows/ubuntu.yml +0 -62
  56. 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)
@@ -1,16 +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
  }
19
+ doctype_dict: {
20
+ brochure: broŝuro,
21
+ conference proceedings: konferencaktoj
22
+ }
23
+ stage_dict: {
24
+ published: publikigita
25
+ }
26
+ substage_dict: {
27
+ withdrawn: fortirita
28
+ }
29
+ array:
30
+ - elem1
31
+ - elem2
32
+ - {elem3: elem4, elem5: elem6}
33
+ 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'>
@@ -1218,6 +1455,7 @@ end
1218
1455
  <div id='_be9158af-7e93-4ee2-90c5-26d31c181934' style='page-break-after: avoid;page-break-inside: avoid;'><div class='formula'>
1219
1456
  <p>
1220
1457
  <span class='stem'>(#(r = 1 %)#)</span>
1458
+ <span style='mso-tab-count:1'>&#160; </span>
1221
1459
  </p>
1222
1460
  </div>
1223
1461
  <p>where</p>
@@ -1346,7 +1584,7 @@ it "processes blockquotes (Presentation XML)" do
1346
1584
  </iso-standard>
1347
1585
  INPUT
1348
1586
  <?xml version='1.0'?>
1349
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
1587
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1350
1588
  <preface>
1351
1589
  <foreword>
1352
1590
  <quote id='_044bd364-c832-4b78-8fea-92242402a1d1'>
@@ -1485,7 +1723,7 @@ it "processes blockquotes (Presentation XML)" do
1485
1723
  </iso-standard>
1486
1724
  INPUT
1487
1725
  <?xml version='1.0'?>
1488
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
1726
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1489
1727
  <preface>
1490
1728
  <foreword>
1491
1729
  <permission id='_' keep-with-next='true' keep-lines-together='true'>
@@ -1845,7 +2083,7 @@ Inherits: <a href='#rfc2616'>RFC 2616 (HTTP/1.1)</a>
1845
2083
  </iso-standard>
1846
2084
  INPUT
1847
2085
  <?xml version='1.0'?>
1848
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
2086
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1849
2087
  <preface>
1850
2088
  <foreword>
1851
2089
  <requirement id='A' unnumbered='true' keep-with-next='true' keep-lines-together='true'>
@@ -1989,8 +2227,8 @@ end
1989
2227
  OUTPUT
1990
2228
  end
1991
2229
 
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")
2230
+ it "processes requirements in French" do
2231
+ input = <<~INPUT
1994
2232
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1995
2233
  <bibdata>
1996
2234
  <language>fr</language>
@@ -2044,125 +2282,63 @@ end
2044
2282
  </foreword></preface>
2045
2283
  </iso-standard>
2046
2284
  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>
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>
2107
2339
  OUTPUT
2108
- end
2109
2340
 
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
2341
+ html = <<~OUTPUT
2166
2342
  #{HTML_HDR.gsub(/"en"/, '"fr"')}
2167
2343
  <br/>
2168
2344
  <div>
@@ -2195,6 +2371,7 @@ end
2195
2371
  <div id='B'><div class='formula'>
2196
2372
  <p>
2197
2373
  <span class='stem'>(#(r/1 = 0)#)</span>
2374
+ &#160; (1)
2198
2375
  </p>
2199
2376
  </div>
2200
2377
  </div>
@@ -2204,14 +2381,12 @@ end
2204
2381
  <pre id='_' class='prettyprint '>
2205
2382
  CoreRoot(success): HttpResponse
2206
2383
  <br/>
2207
- &#160;&#160;&#160;&#160;&#160; if (success)
2384
+ &#160; if (success)
2208
2385
  <br/>
2209
- &#160;&#160;&#160;&#160;&#160; recommendation(label:
2210
- success-response)
2386
+ &#160; recommendation(label: success-response)
2211
2387
  <br/>
2212
- &#160;&#160;&#160;&#160;&#160; end
2388
+ &#160; end
2213
2389
  <br/>
2214
- &#160;&#160;&#160;
2215
2390
  </pre>
2216
2391
  </div>
2217
2392
  </div>
@@ -2221,6 +2396,8 @@ end
2221
2396
  </body>
2222
2397
  </html>
2223
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)
2224
2401
  end
2225
2402
 
2226
2403
  it "processes recommendation (Presentation XML)" do
@@ -2276,7 +2453,7 @@ end
2276
2453
  </iso-standard>
2277
2454
  INPUT
2278
2455
  <?xml version='1.0'?>
2279
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
2456
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
2280
2457
  <preface>
2281
2458
  <foreword>
2282
2459
  <recommendation id='_' obligation='shall,could' keep-with-next='true' keep-lines-together='true'>
@@ -2427,8 +2604,8 @@ end
2427
2604
  OUTPUT
2428
2605
  end
2429
2606
 
2430
- it "processes pseudocode (Presentation XML)" do
2431
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2607
+ it "processes pseudocode" do
2608
+ input = <<~INPUT
2432
2609
  <itu-standard xmlns="http://riboseinc.com/isoxml">
2433
2610
  <bibdata>
2434
2611
  <language>en</language>
@@ -2439,59 +2616,22 @@ end
2439
2616
  <p id="_">  <em>C</em></p></figure>
2440
2617
  </preface></itu-standard>
2441
2618
  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>
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
+
2466
2632
  OUTPUT
2467
- end
2468
2633
 
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
2634
+ html = <<~OUTPUT
2495
2635
  #{HTML_HDR}
2496
2636
  <br/>
2497
2637
  <div>
@@ -2505,35 +2645,11 @@ INPUT
2505
2645
  </body>
2506
2646
  </html>
2507
2647
  OUTPUT
2508
- end
2509
2648
 
2510
- it "processes pseudocode (Word)" do
2511
2649
  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
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)
2537
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")
2538
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/>
2539
2655
  &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;<span style="font-variant:small-caps;">B</span></p>