isodoc 1.2.6 → 1.4.0

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 (63) 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 +2 -1
  5. data/lib/isodoc-yaml/i18n-en.yaml +56 -0
  6. data/lib/isodoc-yaml/i18n-fr.yaml +64 -7
  7. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
  8. data/lib/isodoc/base_style/all.css +4 -0
  9. data/lib/isodoc/base_style/blocks.scss +2 -2
  10. data/lib/isodoc/base_style/reset.css +4 -0
  11. data/lib/isodoc/base_style/reset.scss +5 -0
  12. data/lib/isodoc/base_style/typography.scss +1 -1
  13. data/lib/isodoc/convert.rb +13 -98
  14. data/lib/isodoc/css.rb +95 -0
  15. data/lib/isodoc/function/inline.rb +0 -33
  16. data/lib/isodoc/function/inline_simple.rb +4 -1
  17. data/lib/isodoc/function/lists.rb +2 -1
  18. data/lib/isodoc/function/references.rb +8 -13
  19. data/lib/isodoc/function/section.rb +1 -1
  20. data/lib/isodoc/function/table.rb +10 -0
  21. data/lib/isodoc/function/to_word_html.rb +2 -2
  22. data/lib/isodoc/gem_tasks.rb +4 -0
  23. data/lib/isodoc/html_function/html.rb +1 -0
  24. data/lib/isodoc/html_function/mathvariant_to_plain.rb +82 -0
  25. data/lib/isodoc/html_function/postprocess.rb +41 -20
  26. data/lib/isodoc/i18n.rb +15 -2
  27. data/lib/isodoc/metadata.rb +28 -109
  28. data/lib/isodoc/metadata_contributor.rb +91 -0
  29. data/lib/isodoc/metadata_date.rb +6 -0
  30. data/lib/isodoc/presentation_function/bibdata.rb +79 -7
  31. data/lib/isodoc/presentation_function/block.rb +14 -9
  32. data/lib/isodoc/presentation_function/inline.rb +126 -22
  33. data/lib/isodoc/presentation_function/section.rb +9 -0
  34. data/lib/isodoc/presentation_xml_convert.rb +5 -0
  35. data/lib/isodoc/version.rb +1 -1
  36. data/lib/isodoc/word_convert.rb +0 -20
  37. data/lib/isodoc/word_function/body.rb +12 -0
  38. data/lib/isodoc/word_function/postprocess.rb +38 -80
  39. data/lib/isodoc/word_function/postprocess_cover.rb +55 -0
  40. data/lib/isodoc/word_function/table.rb +10 -0
  41. data/lib/isodoc/xref.rb +1 -0
  42. data/lib/isodoc/xref/xref_counter.rb +20 -9
  43. data/lib/isodoc/xref/xref_gen.rb +20 -2
  44. data/lib/isodoc/xref/xref_sect_gen.rb +1 -1
  45. data/spec/assets/html.scss +14 -0
  46. data/spec/assets/i18n.yaml +17 -9
  47. data/spec/isodoc/blocks_spec.rb +89 -241
  48. data/spec/isodoc/cleanup_spec.rb +0 -1
  49. data/spec/isodoc/footnotes_spec.rb +4 -5
  50. data/spec/isodoc/i18n_spec.rb +73 -38
  51. data/spec/isodoc/inline_spec.rb +177 -199
  52. data/spec/isodoc/lists_spec.rb +1 -1
  53. data/spec/isodoc/metadata_spec.rb +50 -7
  54. data/spec/isodoc/postproc_spec.rb +472 -11
  55. data/spec/isodoc/presentation_xml_spec.rb +584 -1
  56. data/spec/isodoc/ref_spec.rb +327 -12
  57. data/spec/isodoc/table_spec.rb +28 -0
  58. data/spec/isodoc/xref_spec.rb +162 -17
  59. data/spec/spec_helper.rb +2 -0
  60. metadata +22 -7
  61. data/.github/workflows/macos.yml +0 -42
  62. data/.github/workflows/ubuntu.yml +0 -62
  63. data/.github/workflows/windows.yml +0 -44
@@ -75,5 +75,60 @@ module IsoDoc::WordFunction
75
75
  toc.sub(/(<p class="MsoToc1">)/,
76
76
  %{\\1#{word_toc_preface(level)}}) + WORD_TOC_SUFFIX1
77
77
  end
78
+
79
+ def authority_cleanup1(docxml, klass)
80
+ dest = docxml.at("//div[@id = 'boilerplate-#{klass}-destination']")
81
+ auth = docxml.at("//div[@id = 'boilerplate-#{klass}' or @class = 'boilerplate-#{klass}']")
82
+ auth&.xpath(".//h1[not(text())] | .//h2[not(text())]")&.each { |h| h.remove }
83
+ auth&.xpath(".//h1 | .//h2")&.each do |h|
84
+ h.name = "p"
85
+ h["class"] = "TitlePageSubhead"
86
+ end
87
+ dest and auth and dest.replace(auth.remove)
88
+ end
89
+
90
+ def authority_cleanup(docxml)
91
+ %w(copyright license legal feedback).each do |t|
92
+ authority_cleanup1(docxml, t)
93
+ end
94
+ end
95
+
96
+ def generate_header(filename, _dir)
97
+ return nil unless @header
98
+ template = IsoDoc::Common.liquid(File.read(@header, encoding: "UTF-8"))
99
+ meta = @meta.get.merge(@labels || {}).merge(@meta.labels || {})
100
+ meta[:filename] = filename
101
+ params = meta.map { |k, v| [k.to_s, v] }.to_h
102
+ Tempfile.open(%w(header html), :encoding => "utf-8") do |f|
103
+ f.write(template.render(params))
104
+ f
105
+ end
106
+ end
107
+
108
+ def word_section_breaks(docxml)
109
+ @landscapestyle = ""
110
+ word_section_breaks1(docxml, "WordSection2")
111
+ word_section_breaks1(docxml, "WordSection3")
112
+ word_remove_pb_before_annex(docxml)
113
+ docxml.xpath("//br[@orientation]").each { |br| br.delete("orientation") }
114
+ end
115
+
116
+ def word_section_breaks1(docxml, sect)
117
+ docxml.xpath("//div[@class = '#{sect}']//br[@orientation]").reverse.
118
+ each_with_index do |br, i|
119
+ @landscapestyle += "\ndiv.#{sect}_#{i} {page:#{sect}#{br["orientation"] == "landscape" ? "L" : "P"};}\n"
120
+ split_at_section_break(docxml, sect, br, i)
121
+ end
122
+ end
123
+
124
+ def split_at_section_break(docxml, sect, br, i)
125
+ move = br.parent.xpath("following::node()") &
126
+ br.document.xpath("//div[@class = '#{sect}']//*")
127
+ ins = docxml.at("//div[@class = '#{sect}']").after("<div class='#{sect}_#{i}'/>").next_element
128
+ move.each do |m|
129
+ next if m.at("./ancestor::div[@class = '#{sect}_#{i}']")
130
+ ins << m.remove
131
+ end
132
+ end
78
133
  end
79
134
  end
@@ -43,11 +43,21 @@ module IsoDoc::WordFunction
43
43
  }))
44
44
  end
45
45
 
46
+ def colgroup(node, t)
47
+ colgroup = node.at(ns("./colgroup")) or return
48
+ t.colgroup do |cg|
49
+ colgroup.xpath(ns("./col")).each do |c|
50
+ cg.col **{ width: c["width"] }
51
+ end
52
+ end
53
+ end
54
+
46
55
  def table_parse(node, out)
47
56
  @in_table = true
48
57
  table_title_parse(node, out)
49
58
  out.div **{ align: "center", class: "table_container" } do |div|
50
59
  div.table **table_attrs(node) do |t|
60
+ colgroup(node, t)
51
61
  thead_parse(node, t)
52
62
  tbody_parse(node, t)
53
63
  tfoot_parse(node, t)
@@ -49,6 +49,7 @@ module IsoDoc
49
49
  note_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
50
50
  example_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
51
51
  list_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
52
+ bookmark_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
52
53
  end
53
54
 
54
55
  def ns(xpath)
@@ -2,8 +2,8 @@ require "roman-numerals"
2
2
 
3
3
  module IsoDoc::XrefGen
4
4
  class Counter
5
- def initialize
6
- @num = 0
5
+ def initialize(num = 0)
6
+ @num = num
7
7
  @letter = ""
8
8
  @subseq = ""
9
9
  @letter_override = nil
@@ -76,13 +76,24 @@ module IsoDoc::XrefGen
76
76
  "#{@base}#{@number_override || @num}#{@letter_override || @letter}"
77
77
  end
78
78
 
79
- def listlabel(depth)
80
- return @num.to_s if [2, 7].include? depth
81
- return (96 + @num).chr.to_s if [1, 6].include? depth
82
- return (64 + @num).chr.to_s if [4, 9].include? depth
83
- return RomanNumerals.to_roman(@num).downcase if [3, 8].include? depth
84
- return RomanNumerals.to_roman(@num).upcase if [5, 10].include? depth
85
- return @num.to_s
79
+ def ol_type(list, depth)
80
+ return list["type"].to_sym if list["type"]
81
+ return :arabic if [2, 7].include? depth
82
+ return :alphabet if [1, 6].include? depth
83
+ return :alphabet_upper if [4, 9].include? depth
84
+ return :roman if [3, 8].include? depth
85
+ return :roman_upper if [5, 10].include? depth
86
+ return :arabic
87
+ end
88
+
89
+ def listlabel(list, depth)
90
+ case ol_type(list, depth)
91
+ when :arabic then @num.to_s
92
+ when :alphabet then (96 + @num).chr.to_s
93
+ when :alphabet_upper then (64 + @num).chr.to_s
94
+ when :roman then RomanNumerals.to_roman(@num).downcase
95
+ when :roman_upper then RomanNumerals.to_roman(@num).upcase
96
+ end
86
97
  end
87
98
  end
88
99
  end
@@ -66,6 +66,10 @@ module IsoDoc::XrefGen
66
66
  "//sections/clause | //sections/definitions | "\
67
67
  "//bibliography/references | //bibliography/clause".freeze
68
68
 
69
+ def sections_xpath
70
+ SECTIONS_XPATH
71
+ end
72
+
69
73
  CHILD_NOTES_XPATH =
70
74
  "./*[not(self::xmlns:clause) and not(self::xmlns:appendix) and "\
71
75
  "not(self::xmlns:terms) and not(self::xmlns:definitions)]//xmlns:note | "\
@@ -123,9 +127,9 @@ module IsoDoc::XrefGen
123
127
  end
124
128
 
125
129
  def list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list)
126
- c = Counter.new
130
+ c = Counter.new(list["start"] ? list["start"].to_i - 1 : 0)
127
131
  list.xpath(ns("./li")).each do |li|
128
- label = c.increment(li).listlabel(depth)
132
+ label = c.increment(li).listlabel(list, depth)
129
133
  label = "#{prev_label}.#{label}" unless prev_label.empty?
130
134
  label = "#{list_anchor[:xref]} #{label}" if refer_list
131
135
  li["id"] and @anchors[li["id"]] =
@@ -136,5 +140,19 @@ module IsoDoc::XrefGen
136
140
  end
137
141
  end
138
142
  end
143
+
144
+ def bookmark_anchor_names(sections)
145
+ sections.each do |s|
146
+ notes = s.xpath(ns(".//bookmark")) - s.xpath(ns(".//clause//bookmark")) -
147
+ s.xpath(ns(".//appendix//bookmark"))
148
+ notes.each do |n|
149
+ next if n["id"].nil? || n["id"].empty?
150
+ @anchors[n["id"]] = {
151
+ type: "bookmark", label: nil, value: nil,
152
+ xref: @anchors[s["id"]][:xref] }
153
+ end
154
+ bookmark_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
155
+ end
156
+ end
139
157
  end
140
158
  end
@@ -68,7 +68,7 @@ module IsoDoc::XrefGen
68
68
  end
69
69
 
70
70
  def clause_names(docxml, sect_num)
71
- docxml.xpath(ns(@klass.middle_clause)).each_with_index do |c, i|
71
+ docxml.xpath(ns(@klass.middle_clause(docxml))).each_with_index do |c, i|
72
72
  section_names(c, (i + sect_num), 1)
73
73
  end
74
74
  end
@@ -3,4 +3,18 @@
3
3
 
4
4
  p {
5
5
  font-family: $bodyfont;
6
+ font-size: $normalfontsize;
7
+ }
8
+ code {
9
+ font-family: $monospacefont;
10
+ font-size: $monospacefontsize;
11
+ }
12
+ aside {
13
+ font-size: $footnotefontsize;
14
+ }
15
+ h1 {
16
+ font-family: $headerfont;
17
+ }
18
+ p.note {
19
+ font-size: $smallerfontsize;
6
20
  }
@@ -1,25 +1,33 @@
1
- foreword: Antaŭparolo
1
+ foreword: Antaŭparolo
2
2
  introduction: Enkonduko
3
- clause: klaŭzo
4
- table: Tabelo
3
+ clause: klaŭzo
4
+ table: tabelo
5
5
  source: SOURCE
6
6
  modified: modified
7
7
  scope: Amplekso
8
8
  symbols: Simboloj kai mallongigitaj terminoj
9
9
  annex: Aldono
10
- normref: Normaj citaĵoj
10
+ normref: Normaj citaĵoj
11
11
  bibliography: Bibliografio
12
12
  inform_annex: informa
13
- all_parts: ĉiuj partoj
13
+ all_parts: ĉiuj partoj
14
+ norm_annex: normative
15
+ note: NOTO
14
16
  locality: {
15
17
  table: Tabelo
16
- }
18
+ }
17
19
  doctype_dict: {
18
- brochure: broŝuro
19
- }
20
+ brochure: broŝuro,
21
+ conference proceedings: konferencaktoj
22
+ }
20
23
  stage_dict: {
21
24
  published: publikigita
22
25
  }
23
26
  substage_dict: {
24
27
  withdrawn: fortirita
25
- }
28
+ }
29
+ array:
30
+ - elem1
31
+ - elem2
32
+ - {elem3: elem4, elem5: elem6}
33
+ void:
@@ -87,32 +87,18 @@ RSpec.describe IsoDoc do
87
87
  <standard-document xmlns="https://www.metanorma.org/ns/standoc" type="presentation">
88
88
  <bibdata type="standard">
89
89
  <title language="en" format="text/plain">Document title</title>
90
- <language>en</language>
91
- <script>Latn</script>
90
+ <language current="true">en</language>
91
+ <script current="true">Latn</script>
92
92
  <status>
93
- <stage>published</stage>
93
+ <stage language="">published</stage>
94
94
  </status>
95
95
  <copyright>
96
96
  <from>2020</from>
97
97
  </copyright>
98
98
  <ext>
99
- <doctype>article</doctype>
99
+ <doctype language="">article</doctype>
100
100
  </ext>
101
101
  </bibdata>
102
- <local_bibdata type='standard'>
103
- <title language='en' format='text/plain'>Document title</title>
104
- <language>en</language>
105
- <script>Latn</script>
106
- <status>
107
- <stage>published</stage>
108
- </status>
109
- <copyright>
110
- <from>2020</from>
111
- </copyright>
112
- <ext>
113
- <doctype>article</doctype>
114
- </ext>
115
- </local_bibdata>
116
102
  <sections>
117
103
  <clause id="A" inline-header="false" obligation="normative">
118
104
  <title depth="1">1.<tab/>Change Clause</title>
@@ -248,7 +234,7 @@ RSpec.describe IsoDoc do
248
234
  </body>
249
235
  </html>
250
236
  OUTPUT
251
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
237
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(presxml)
252
238
  expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
253
239
  end
254
240
 
@@ -548,7 +534,7 @@ INPUT
548
534
  <div>
549
535
  <h1 class='ForewordTitle'>Foreword</h1>
550
536
  <p id='A'>
551
- ABC
537
+ ABC
552
538
  <div id='B' class='Note'>
553
539
  <p>
554
540
  <span class='note_label'>NOTE 1</span>
@@ -1469,6 +1455,7 @@ end
1469
1455
  <div id='_be9158af-7e93-4ee2-90c5-26d31c181934' style='page-break-after: avoid;page-break-inside: avoid;'><div class='formula'>
1470
1456
  <p>
1471
1457
  <span class='stem'>(#(r = 1 %)#)</span>
1458
+ <span style='mso-tab-count:1'>&#160; </span>
1472
1459
  </p>
1473
1460
  </div>
1474
1461
  <p>where</p>
@@ -2240,8 +2227,8 @@ end
2240
2227
  OUTPUT
2241
2228
  end
2242
2229
 
2243
- it "processes requirements in French (Presentation XML)" do
2244
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2230
+ it "processes requirements in French" do
2231
+ input = <<~INPUT
2245
2232
  <iso-standard xmlns="http://riboseinc.com/isoxml">
2246
2233
  <bibdata>
2247
2234
  <language>fr</language>
@@ -2295,133 +2282,63 @@ end
2295
2282
  </foreword></preface>
2296
2283
  </iso-standard>
2297
2284
  INPUT
2298
- <?xml version='1.0'?>
2299
- <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
2300
- <bibdata>
2301
- <language>fr</language>
2302
- <script>Latn</script>
2303
- </bibdata>
2304
- <local_bibdata>
2305
- <language>fr</language>
2306
- <script>Latn</script>
2307
- </local_bibdata>
2308
- <preface>
2309
- <foreword>
2310
- <requirement id='A' unnumbered='true'>
2311
- <name>Exigence</name>
2312
- <title>A New Requirement</title>
2313
- <label>/ogc/recommendation/wfs/2</label>
2314
- <inherit>/ss/584/2015/level/1</inherit>
2315
- <subject>user</subject>
2316
- <description>
2317
- <p id='_'>
2318
- I recommend
2319
- <em>this</em>
2320
- .
2321
- </p>
2322
- </description>
2323
- <specification exclude='true' type='tabular'>
2324
- <p id='_'>This is the object of the recommendation:</p>
2325
- <table id='_'>
2326
- <tbody>
2327
- <tr>
2328
- <td style='text-align:left;'>Object</td>
2329
- <td style='text-align:left;'>Value</td>
2330
- </tr>
2331
- <tr>
2332
- <td style='text-align:left;'>Mission</td>
2333
- <td style='text-align:left;'>Accomplished</td>
2334
- </tr>
2335
- </tbody>
2336
- </table>
2337
- </specification>
2338
- <description>
2339
- <p id='_'>As for the measurement targets,</p>
2340
- </description>
2341
- <measurement-target exclude='false'>
2342
- <p id='_'>The measurement target shall be measured as:</p>
2343
- <formula id='B'>
2344
- <name>1</name>
2345
- <stem type='AsciiMath'>r/1 = 0</stem>
2346
- </formula>
2347
- </measurement-target>
2348
- <verification exclude='false'>
2349
- <p id='_'>The following code will be run for verification:</p>
2350
- <sourcecode id='_'>
2351
- CoreRoot(success): HttpResponse if (success) recommendation(label:
2352
- success-response) end
2353
- </sourcecode>
2354
- </verification>
2355
- <import exclude='true'>
2356
- <sourcecode id='_'>success-response()</sourcecode>
2357
- </import>
2358
- </requirement>
2359
- </foreword>
2360
- </preface>
2361
- </iso-standard>
2285
+
2286
+ presxml = <<~OUTPUT
2287
+ <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
2288
+ <bibdata>
2289
+ <language current="true">fr</language>
2290
+ <script current="true">Latn</script>
2291
+ </bibdata>
2292
+ <preface><foreword>
2293
+ <requirement id="A" unnumbered="true"><name>Exigence</name>
2294
+ <title>A New Requirement</title>
2295
+ <label>/ogc/recommendation/wfs/2</label>
2296
+ <inherit>/ss/584/2015/level/1</inherit>
2297
+ <subject>user</subject>
2298
+ <description>
2299
+ <p id="_">I recommend <em>this</em>.</p>
2300
+ </description>
2301
+ <specification exclude="true" type="tabular">
2302
+ <p id="_">This is the object of the recommendation:</p>
2303
+ <table id="_">
2304
+ <tbody>
2305
+ <tr>
2306
+ <td style="text-align:left;">Object</td>
2307
+ <td style="text-align:left;">Value</td>
2308
+ </tr>
2309
+ <tr>
2310
+ <td style="text-align:left;">Mission</td>
2311
+ <td style="text-align:left;">Accomplished</td>
2312
+ </tr>
2313
+ </tbody>
2314
+ </table>
2315
+ </specification>
2316
+ <description>
2317
+ <p id="_">As for the measurement targets,</p>
2318
+ </description>
2319
+ <measurement-target exclude="false">
2320
+ <p id="_">The measurement target shall be measured as:</p>
2321
+ <formula id="B"><name>1</name>
2322
+ <stem type="AsciiMath">r/1 = 0</stem>
2323
+ </formula>
2324
+ </measurement-target>
2325
+ <verification exclude="false">
2326
+ <p id="_">The following code will be run for verification:</p>
2327
+ <sourcecode id="_">CoreRoot(success): HttpResponse
2328
+ if (success)
2329
+ recommendation(label: success-response)
2330
+ end
2331
+ </sourcecode>
2332
+ </verification>
2333
+ <import exclude="true">
2334
+ <sourcecode id="_">success-response()</sourcecode>
2335
+ </import>
2336
+ </requirement>
2337
+ </foreword></preface>
2338
+ </iso-standard>
2362
2339
  OUTPUT
2363
- end
2364
2340
 
2365
- it "processes requirements in French (HTML)" do
2366
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2367
- <iso-standard xmlns="http://riboseinc.com/isoxml">
2368
- <bibdata>
2369
- <language>fr</language>
2370
- <script>Latn</script>
2371
- </bibdata>
2372
- <local_bibdata>
2373
- <language>fr</language>
2374
- <script>Latn</script>
2375
- </local_bibdata>
2376
- <preface><foreword>
2377
- <requirement id="A" unnumbered="true">
2378
- <name>Exigence</name>
2379
- <title>A New Requirement</title>
2380
- <label>/ogc/recommendation/wfs/2</label>
2381
- <inherit>/ss/584/2015/level/1</inherit>
2382
- <subject>user</subject>
2383
- <description>
2384
- <p id="_">I recommend <em>this</em>.</p>
2385
- </description>
2386
- <specification exclude="true" type="tabular">
2387
- <p id="_">This is the object of the recommendation:</p>
2388
- <table id="_">
2389
- <tbody>
2390
- <tr>
2391
- <td style="text-align:left;">Object</td>
2392
- <td style="text-align:left;">Value</td>
2393
- </tr>
2394
- <tr>
2395
- <td style="text-align:left;">Mission</td>
2396
- <td style="text-align:left;">Accomplished</td>
2397
- </tr>
2398
- </tbody>
2399
- </table>
2400
- </specification>
2401
- <description>
2402
- <p id="_">As for the measurement targets,</p>
2403
- </description>
2404
- <measurement-target exclude="false">
2405
- <p id="_">The measurement target shall be measured as:</p>
2406
- <formula id="B">
2407
- <stem type="AsciiMath">r/1 = 0</stem>
2408
- </formula>
2409
- </measurement-target>
2410
- <verification exclude="false">
2411
- <p id="_">The following code will be run for verification:</p>
2412
- <sourcecode id="_">CoreRoot(success): HttpResponse
2413
- if (success)
2414
- recommendation(label: success-response)
2415
- end
2416
- </sourcecode>
2417
- </verification>
2418
- <import exclude="true">
2419
- <sourcecode id="_">success-response()</sourcecode>
2420
- </import>
2421
- </requirement>
2422
- </foreword></preface>
2423
- </iso-standard>
2424
- INPUT
2341
+ html = <<~OUTPUT
2425
2342
  #{HTML_HDR.gsub(/"en"/, '"fr"')}
2426
2343
  <br/>
2427
2344
  <div>
@@ -2454,6 +2371,7 @@ end
2454
2371
  <div id='B'><div class='formula'>
2455
2372
  <p>
2456
2373
  <span class='stem'>(#(r/1 = 0)#)</span>
2374
+ &#160; (1)
2457
2375
  </p>
2458
2376
  </div>
2459
2377
  </div>
@@ -2463,14 +2381,12 @@ end
2463
2381
  <pre id='_' class='prettyprint '>
2464
2382
  CoreRoot(success): HttpResponse
2465
2383
  <br/>
2466
- &#160;&#160;&#160;&#160;&#160; if (success)
2384
+ &#160; if (success)
2467
2385
  <br/>
2468
- &#160;&#160;&#160;&#160;&#160; recommendation(label:
2469
- success-response)
2386
+ &#160; recommendation(label: success-response)
2470
2387
  <br/>
2471
- &#160;&#160;&#160;&#160;&#160; end
2388
+ &#160; end
2472
2389
  <br/>
2473
- &#160;&#160;&#160;
2474
2390
  </pre>
2475
2391
  </div>
2476
2392
  </div>
@@ -2480,6 +2396,8 @@ end
2480
2396
  </body>
2481
2397
  </html>
2482
2398
  OUTPUT
2399
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(presxml)
2400
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
2483
2401
  end
2484
2402
 
2485
2403
  it "processes recommendation (Presentation XML)" do
@@ -2686,8 +2604,8 @@ end
2686
2604
  OUTPUT
2687
2605
  end
2688
2606
 
2689
- it "processes pseudocode (Presentation XML)" do
2690
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2607
+ it "processes pseudocode" do
2608
+ input = <<~INPUT
2691
2609
  <itu-standard xmlns="http://riboseinc.com/isoxml">
2692
2610
  <bibdata>
2693
2611
  <language>en</language>
@@ -2698,65 +2616,22 @@ end
2698
2616
  <p id="_">  <em>C</em></p></figure>
2699
2617
  </preface></itu-standard>
2700
2618
  INPUT
2701
- <?xml version='1.0'?>
2702
- <itu-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
2703
- <bibdata>
2704
- <language>en</language>
2705
- </bibdata>
2706
- <local_bibdata>
2707
- <language>en</language>
2708
- </local_bibdata>
2709
- <preface>
2710
- <foreword>
2711
- <figure id='_' class='pseudocode' keep-with-next='true' keep-lines-together='true'>
2712
- <name>Figure 1&#xA0;&#x2014; Label</name>
2713
- <p id='_'>
2714
- &#xA0;&#xA0;
2715
- <strong>A</strong>
2716
- <br/>
2717
- &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;
2718
- <smallcap>B</smallcap>
2719
- </p>
2720
- <p id='_'>
2721
- &#xA0;&#xA0;
2722
- <em>C</em>
2723
- </p>
2724
- </figure>
2725
- </foreword>
2726
- </preface>
2727
- </itu-standard>
2619
+
2620
+ presxml = <<~OUTPUT
2621
+ <itu-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
2622
+ <bibdata>
2623
+ <language current="true">en</language>
2624
+ </bibdata>
2625
+ <preface><foreword>
2626
+ <figure id="_" class="pseudocode" keep-with-next="true" keep-lines-together="true"><name>Figure 1&#xA0;&#x2014; Label</name><p id="_">&#xA0;&#xA0;<strong>A</strong><br/>
2627
+ &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;<smallcap>B</smallcap></p>
2628
+ <p id="_">&#xA0;&#xA0;<em>C</em></p></figure>
2629
+ </foreword></preface>
2630
+ </itu-standard>
2631
+
2728
2632
  OUTPUT
2729
- end
2730
2633
 
2731
- it "processes pseudocode (HTML)" do
2732
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2733
- <itu-standard xmlns='http://riboseinc.com/isoxml'>
2734
- <bibdata>
2735
- <language>en</language>
2736
- </bibdata>
2737
- <local_bibdata>
2738
- <language>en</language>
2739
- </local_bibdata>
2740
- <preface>
2741
- <foreword>
2742
- <figure id='_' class='pseudocode' keep-with-next='true' keep-lines-together='true'>
2743
- <name>Figure 1&#xA0;&#x2014; Label</name>
2744
- <p id='_'>
2745
- &#xA0;&#xA0;
2746
- <strong>A</strong>
2747
- <br/>
2748
- &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;
2749
- <smallcap>B</smallcap>
2750
- </p>
2751
- <p id='_'>
2752
- &#xA0;&#xA0;
2753
- <em>C</em>
2754
- </p>
2755
- </figure>
2756
- </foreword>
2757
- </preface>
2758
- </itu-standard>
2759
- INPUT
2634
+ html = <<~OUTPUT
2760
2635
  #{HTML_HDR}
2761
2636
  <br/>
2762
2637
  <div>
@@ -2770,38 +2645,11 @@ INPUT
2770
2645
  </body>
2771
2646
  </html>
2772
2647
  OUTPUT
2773
- end
2774
2648
 
2775
- it "processes pseudocode (Word)" do
2776
2649
  FileUtils.rm_f "test.doc"
2777
- IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", false)
2778
- <itu-standard xmlns='http://riboseinc.com/isoxml'>
2779
- <bibdata>
2780
- <language>en</language>
2781
- </bibdata>
2782
- <local_bibdata>
2783
- <language>en</language>
2784
- </local_bibdata>
2785
- <preface>
2786
- <foreword>
2787
- <figure id='_' class='pseudocode' keep-with-next='true' keep-lines-together='true'>
2788
- <name>Figure 1&#xA0;&#x2014; Label</name>
2789
- <p id='_'>
2790
- &#xA0;&#xA0;
2791
- <strong>A</strong>
2792
- <br/>
2793
- &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;
2794
- <smallcap>B</smallcap>
2795
- </p>
2796
- <p id='_'>
2797
- &#xA0;&#xA0;
2798
- <em>C</em>
2799
- </p>
2800
- </figure>
2801
- </foreword>
2802
- </preface>
2803
- </itu-standard>
2804
- INPUT
2650
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(presxml)
2651
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
2652
+ IsoDoc::WordConvert.new({}).convert("test", presxml, false)
2805
2653
  expect(xmlpp( File.read("test.doc").gsub(%r{^.*<h1 class="ForewordTitle">Foreword</h1>}m, "").gsub(%r{</div>.*}m, "</div>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2806
2654
  <div class="pseudocode" style='page-break-after: avoid;page-break-inside: avoid;'><a name="_" id="_"></a><p class="pseudocode"><a name="_" id="_"></a>&#xA0;&#xA0;<b>A</b><br/>
2807
2655
  &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;<span style="font-variant:small-caps;">B</span></p>