isodoc 1.6.3 → 1.6.7.1

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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +2 -12
  3. data/.hound.yml +3 -1
  4. data/.rubocop.yml +4 -6
  5. data/isodoc.gemspec +3 -2
  6. data/lib/isodoc-yaml/i18n-en.yaml +1 -0
  7. data/lib/isodoc-yaml/i18n-fr.yaml +1 -0
  8. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
  9. data/lib/isodoc.rb +0 -2
  10. data/lib/isodoc/convert.rb +7 -1
  11. data/lib/isodoc/function/blocks.rb +5 -4
  12. data/lib/isodoc/function/cleanup.rb +52 -43
  13. data/lib/isodoc/function/inline.rb +7 -7
  14. data/lib/isodoc/function/references.rb +33 -52
  15. data/lib/isodoc/function/section.rb +28 -16
  16. data/lib/isodoc/function/table.rb +21 -22
  17. data/lib/isodoc/function/terms.rb +6 -7
  18. data/lib/isodoc/function/to_word_html.rb +6 -3
  19. data/lib/isodoc/function/utils.rb +181 -163
  20. data/lib/isodoc/gem_tasks.rb +8 -9
  21. data/lib/isodoc/headlesshtml_convert.rb +8 -7
  22. data/lib/isodoc/html_convert.rb +5 -1
  23. data/lib/isodoc/html_function/comments.rb +14 -12
  24. data/lib/isodoc/html_function/footnotes.rb +14 -7
  25. data/lib/isodoc/html_function/html.rb +30 -26
  26. data/lib/isodoc/html_function/postprocess.rb +191 -182
  27. data/lib/isodoc/html_function/sectionsplit.rb +230 -0
  28. data/lib/isodoc/metadata.rb +22 -20
  29. data/lib/isodoc/metadata_contributor.rb +31 -28
  30. data/lib/isodoc/pdf_convert.rb +11 -13
  31. data/lib/isodoc/presentation_function/bibdata.rb +50 -22
  32. data/lib/isodoc/presentation_function/inline.rb +20 -15
  33. data/lib/isodoc/presentation_function/section.rb +38 -1
  34. data/lib/isodoc/presentation_xml_convert.rb +2 -0
  35. data/lib/isodoc/version.rb +1 -1
  36. data/lib/isodoc/word_function/postprocess.rb +50 -36
  37. data/lib/isodoc/xref.rb +2 -0
  38. data/lib/isodoc/xref/xref_gen_seq.rb +60 -35
  39. data/lib/isodoc/xref/xref_sect_gen.rb +4 -4
  40. data/spec/assets/scripts_override.html +3 -0
  41. data/spec/isodoc/blocks_spec.rb +373 -685
  42. data/spec/isodoc/cleanup_spec.rb +40 -42
  43. data/spec/isodoc/i18n_spec.rb +694 -821
  44. data/spec/isodoc/inline_spec.rb +482 -328
  45. data/spec/isodoc/metadata_spec.rb +384 -379
  46. data/spec/isodoc/postproc_spec.rb +163 -55
  47. data/spec/isodoc/presentation_xml_spec.rb +355 -278
  48. data/spec/isodoc/ref_spec.rb +5 -5
  49. data/spec/isodoc/section_spec.rb +216 -199
  50. data/spec/isodoc/sectionsplit_spec.rb +190 -0
  51. data/spec/isodoc/table_spec.rb +41 -42
  52. data/spec/isodoc/terms_spec.rb +84 -84
  53. data/spec/isodoc/xref_spec.rb +974 -932
  54. metadata +22 -5
data/lib/isodoc/xref.rb CHANGED
@@ -11,6 +11,8 @@ module IsoDoc
11
11
  include XrefGen::Blocks
12
12
  include XrefGen::Sections
13
13
 
14
+ attr_reader :klass
15
+
14
16
  def initialize(lang, script, klass, i18n, options = {})
15
17
  @anchors = {}
16
18
  @lang = lang
@@ -8,25 +8,27 @@ module IsoDoc::XrefGen
8
8
  "-"
9
9
  end
10
10
 
11
- def subfigure_increment(j, c, t)
12
- if t.parent.name == "figure" then j += 1
11
+ def subfigure_increment(idx, counter, elem)
12
+ if elem.parent.name == "figure" then idx += 1
13
13
  else
14
- j = 0
15
- c.increment(t)
14
+ idx = 0
15
+ counter.increment(elem)
16
16
  end
17
- j
17
+ idx
18
18
  end
19
19
 
20
20
  def sequential_figure_names(clause)
21
21
  c = Counter.new
22
22
  j = 0
23
- clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).
24
- each do |t|
23
+ clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
24
+ .each do |t|
25
25
  j = subfigure_increment(j, c, t)
26
26
  label = c.print + (j.zero? ? "" : "-#{j}")
27
27
  next if t["id"].nil? || t["id"].empty?
28
- @anchors[t["id"]] =
29
- anchor_struct(label, nil, @labels["figure"], "figure", t["unnumbered"])
28
+
29
+ @anchors[t["id"]] = anchor_struct(
30
+ label, nil, @labels["figure"], "figure", t["unnumbered"]
31
+ )
30
32
  end
31
33
  end
32
34
 
@@ -34,8 +36,11 @@ module IsoDoc::XrefGen
34
36
  c = Counter.new
35
37
  clause.xpath(ns(".//table")).each do |t|
36
38
  next if t["id"].nil? || t["id"].empty?
37
- @anchors[t["id"]] = anchor_struct(c.increment(t).print, nil,
38
- @labels["table"], "table", t["unnumbered"])
39
+
40
+ @anchors[t["id"]] = anchor_struct(
41
+ c.increment(t).print, nil,
42
+ @labels["table"], "table", t["unnumbered"]
43
+ )
39
44
  end
40
45
  end
41
46
 
@@ -43,10 +48,12 @@ module IsoDoc::XrefGen
43
48
  c = Counter.new
44
49
  clause.xpath(ns(".//formula")).each do |t|
45
50
  next if t["id"].nil? || t["id"].empty?
46
- @anchors[t["id"]] =
47
- anchor_struct(c.increment(t).print, t,
48
- t["inequality"] ? @labels["inequality"] : @labels["formula"],
49
- "formula", t["unnumbered"])
51
+
52
+ @anchors[t["id"]] = anchor_struct(
53
+ c.increment(t).print, t,
54
+ t["inequality"] ? @labels["inequality"] : @labels["formula"],
55
+ "formula", t["unnumbered"]
56
+ )
50
57
  end
51
58
  end
52
59
 
@@ -57,22 +64,27 @@ module IsoDoc::XrefGen
57
64
  c = Counter.new
58
65
  clause.xpath(ns(".//#{klass}#{FIRST_LVL_REQ}")).each do |t|
59
66
  next if t["id"].nil? || t["id"].empty?
67
+
60
68
  id = c.increment(t).print
61
69
  @anchors[t["id"]] = anchor_struct(id, t, label, klass, t["unnumbered"])
62
70
  sequential_permission_names2(t, id)
63
71
  end
64
72
  end
65
73
 
66
- def sequential_permission_names2(t, id)
67
- sequential_permission_names1(t, id, "permission", @labels["permission"])
68
- sequential_permission_names1(t, id, "requirement", @labels["requirement"])
69
- sequential_permission_names1(t, id, "recommendation", @labels["recommendation"])
74
+ def sequential_permission_names2(elem, ident)
75
+ sequential_permission_names1(elem, ident, "permission",
76
+ @labels["permission"])
77
+ sequential_permission_names1(elem, ident, "requirement",
78
+ @labels["requirement"])
79
+ sequential_permission_names1(elem, ident, "recommendation",
80
+ @labels["recommendation"])
70
81
  end
71
82
 
72
83
  def sequential_permission_names1(block, lbl, klass, label)
73
84
  c = Counter.new
74
85
  block.xpath(ns("./#{klass}")).each do |t|
75
86
  next if t["id"].nil? || t["id"].empty?
87
+
76
88
  id = "#{lbl}#{hierfigsep}#{c.increment(t).print}"
77
89
  @anchors[t["id"]] = anchor_struct(id, t, label, klass, t["unnumbered"])
78
90
  sequential_permission_names2(t, id)
@@ -85,20 +97,22 @@ module IsoDoc::XrefGen
85
97
  sequential_formula_names(clause)
86
98
  sequential_permission_names(clause, "permission", @labels["permission"])
87
99
  sequential_permission_names(clause, "requirement", @labels["requirement"])
88
- sequential_permission_names(clause, "recommendation", @labels["recommendation"])
100
+ sequential_permission_names(clause, "recommendation",
101
+ @labels["recommendation"])
89
102
  end
90
103
 
91
104
  def hierarchical_figure_names(clause, num)
92
105
  c = Counter.new
93
106
  j = 0
94
- clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).
95
- each do |t|
107
+ clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
108
+ .each do |t|
96
109
  j = subfigure_increment(j, c, t)
97
110
  label = "#{num}#{hiersep}#{c.print}" +
98
111
  (j.zero? ? "" : "#{hierfigsep}#{j}")
99
112
  next if t["id"].nil? || t["id"].empty?
100
- @anchors[t["id"]] = anchor_struct(label, nil, @labels["figure"], "figure",
101
- t["unnumbered"])
113
+
114
+ @anchors[t["id"]] = anchor_struct(label, nil, @labels["figure"],
115
+ "figure", t["unnumbered"])
102
116
  end
103
117
  end
104
118
 
@@ -106,6 +120,7 @@ module IsoDoc::XrefGen
106
120
  c = Counter.new
107
121
  clause.xpath(ns(".//table")).each do |t|
108
122
  next if t["id"].nil? || t["id"].empty?
123
+
109
124
  @anchors[t["id"]] =
110
125
  anchor_struct("#{num}#{hiersep}#{c.increment(t).print}",
111
126
  nil, @labels["table"], "table", t["unnumbered"])
@@ -116,7 +131,8 @@ module IsoDoc::XrefGen
116
131
  hierarchical_table_names(clause, num)
117
132
  hierarchical_figure_names(clause, num)
118
133
  hierarchical_formula_names(clause, num)
119
- hierarchical_permission_names(clause, num, "permission", @labels["permission"])
134
+ hierarchical_permission_names(clause, num, "permission",
135
+ @labels["permission"])
120
136
  hierarchical_permission_names(clause, num, "requirement",
121
137
  @labels["requirement"])
122
138
  hierarchical_permission_names(clause, num, "recommendation",
@@ -127,10 +143,12 @@ module IsoDoc::XrefGen
127
143
  c = Counter.new
128
144
  clause.xpath(ns(".//formula")).each do |t|
129
145
  next if t["id"].nil? || t["id"].empty?
130
- @anchors[t["id"]] =
131
- anchor_struct("#{num}#{hiersep}#{c.increment(t).print}", nil,
132
- t["inequality"] ? @labels["inequality"] : @labels["formula"],
133
- "formula", t["unnumbered"])
146
+
147
+ @anchors[t["id"]] = anchor_struct(
148
+ "#{num}#{hiersep}#{c.increment(t).print}", nil,
149
+ t["inequality"] ? @labels["inequality"] : @labels["formula"],
150
+ "formula", t["unnumbered"]
151
+ )
134
152
  end
135
153
  end
136
154
 
@@ -138,24 +156,31 @@ module IsoDoc::XrefGen
138
156
  c = Counter.new
139
157
  clause.xpath(ns(".//#{klass}#{FIRST_LVL_REQ}")).each do |t|
140
158
  next if t["id"].nil? || t["id"].empty?
159
+
141
160
  id = "#{num}#{hiersep}#{c.increment(t).print}"
142
- @anchors[t["id"]] = anchor_struct(id, nil, label, klass, t["unnumbered"])
161
+ @anchors[t["id"]] =
162
+ anchor_struct(id, nil, label, klass, t["unnumbered"])
143
163
  hierarchical_permission_names2(t, id)
144
164
  end
145
165
  end
146
166
 
147
- def hierarchical_permission_names2(t, id)
148
- hierarchical_permission_names1(t, id, "permission", @labels["permission"])
149
- hierarchical_permission_names1(t, id, "requirement", @labels["requirement"])
150
- hierarchical_permission_names1(t, id, "recommendation", @labels["recommendation"])
167
+ def hierarchical_permission_names2(elem, ident)
168
+ hierarchical_permission_names1(elem, ident, "permission",
169
+ @labels["permission"])
170
+ hierarchical_permission_names1(elem, ident, "requirement",
171
+ @labels["requirement"])
172
+ hierarchical_permission_names1(elem, ident, "recommendation",
173
+ @labels["recommendation"])
151
174
  end
152
175
 
153
176
  def hierarchical_permission_names1(block, lbl, klass, label)
154
177
  c = Counter.new
155
178
  block.xpath(ns("./#{klass}")).each do |t|
156
179
  next if t["id"].nil? || t["id"].empty?
180
+
157
181
  id = "#{lbl}#{hierfigsep}#{c.increment(t).print}"
158
- @anchors[t["id"]] = anchor_struct(id, nil, label, klass, t["unnumbered"])
182
+ @anchors[t["id"]] =
183
+ anchor_struct(id, nil, label, klass, t["unnumbered"])
159
184
  hierarchical_permission_names2(t, id)
160
185
  end
161
186
  end
@@ -60,17 +60,17 @@ module IsoDoc::XrefGen
60
60
  end
61
61
  end
62
62
 
63
- def middle_section_asset_names(d)
63
+ def middle_section_asset_names(doc)
64
64
  middle_sections = "//clause[@type = 'scope'] | "\
65
65
  "#{@klass.norm_ref_xpath} | "\
66
66
  "//sections/terms | //preface/* | "\
67
67
  "//sections/definitions | //clause[parent::sections]"
68
- sequential_asset_names(d.xpath(ns(middle_sections)))
68
+ sequential_asset_names(doc.xpath(ns(middle_sections)))
69
69
  end
70
70
 
71
- def clause_names(docxml, n)
71
+ def clause_names(docxml, num)
72
72
  docxml.xpath(ns(@klass.middle_clause(docxml))).each_with_index do |c, _i|
73
- section_names(c, n, 1)
73
+ section_names(c, num, 1)
74
74
  end
75
75
  end
76
76
 
@@ -0,0 +1,3 @@
1
+ <script>
2
+ This is > also a script
3
+ </script>
@@ -100,7 +100,7 @@ RSpec.describe IsoDoc do
100
100
  </ext>
101
101
  </bibdata>
102
102
  <sections>
103
- <clause id="A" inline-header="false" obligation="normative">
103
+ <clause id="A" inline-header="false" obligation="normative" displayorder="1">
104
104
  <title depth="1">1.<tab/>Change Clause</title>
105
105
  <p id="C">
106
106
  <em>
@@ -256,7 +256,7 @@ RSpec.describe IsoDoc do
256
256
  <?xml version='1.0'?>
257
257
  <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
258
258
  <preface>
259
- <foreword>
259
+ <foreword displayorder="1">
260
260
  <note id='A' keep-with-next='true' keep-lines-together='true'>
261
261
  <name>NOTE</name>
262
262
  <p id='_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f'>
@@ -332,7 +332,7 @@ RSpec.describe IsoDoc do
332
332
  <?xml version='1.0'?>
333
333
  <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
334
334
  <preface>
335
- <foreword>
335
+ <foreword displayorder="1">
336
336
  <note id='note1'>
337
337
  <name>NOTE 1</name>
338
338
  <p id='_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f'>
@@ -472,96 +472,90 @@ RSpec.describe IsoDoc do
472
472
  end
473
473
 
474
474
  it "processes paragraphs containing notes" do
475
- expect(xmlpp(strip_guid(IsoDoc::HtmlConvert.new({})
476
- .convert("test", <<~"INPUT", true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
477
- <iso-standard xmlns="http://riboseinc.com/isoxml">
478
- <preface><foreword>
479
- <p id="A">ABC <note id="B"><name>NOTE 1</name><p id="C">XYZ</p></note>
480
- <note id="B1"><name>NOTE 2</name><p id="C1">XYZ1</p></note></p>
481
- </foreword></preface>
482
- </iso-standard>
483
- INPUT
484
- #{HTML_HDR}
485
- <br/>
486
- <div>
487
- <h1 class='ForewordTitle'>Foreword</h1>
488
- <p id='A'>
489
- ABC
490
- <div id='B' class='Note'>
491
- <p>
492
- <span class='note_label'>NOTE 1</span>
493
- &#160; XYZ
494
- </p>
495
- </div>
496
- <div id='B1' class='Note'>
497
- <p>
498
- <span class='note_label'>NOTE 2</span>
499
- &#160; XYZ1
500
- </p>
501
- </div>
502
- </p>
503
- </div>
504
- <p class='zzSTDTitle1'/>
505
- </div>
506
- </body>
507
- </html>
508
- OUTPUT
509
- end
510
-
511
- it "processes paragraphs containing notes (Word)" do
512
- expect(xmlpp(strip_guid(IsoDoc::WordConvert.new({})
513
- .convert("test", <<~"INPUT", true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
514
- <iso-standard xmlns="http://riboseinc.com/isoxml">
515
- <preface><foreword>
516
- <p id="A">ABC <note id="B"><name>NOTE 1</name><p id="C">XYZ</p></note>
517
- <note id="B1"><name>NOTE 2</name><p id="C1">XYZ1</p></note></p>
518
- </foreword></preface>
519
- </iso-standard>
520
- INPUT
521
- <html xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
522
- <head>
523
- <style/>
524
- </head>
525
- <body lang='EN-US' link='blue' vlink='#954F72'>
526
- <div class='WordSection1'>
527
- <p>&#160;</p>
528
- </div>
529
- <p>
530
- <br clear='all' class='section'/>
531
- </p>
532
- <div class='WordSection2'>
533
- <p>
534
- <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
535
- </p>
536
- <div>
537
- <h1 class='ForewordTitle'>Foreword</h1>
538
- <p id='A'>ABC </p>
539
- <div id='B' class='Note'>
540
- <p class='Note'>
541
- <span class='note_label'>NOTE 1</span>
542
- <span style='mso-tab-count:1'>&#160; </span>
543
- XYZ
544
- </p>
545
- </div>
546
- <div id='B1' class='Note'>
547
- <p class='Note'>
548
- <span class='note_label'>NOTE 2</span>
549
- <span style='mso-tab-count:1'>&#160; </span>
550
- XYZ1
475
+ input = <<~INPUT
476
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
477
+ <preface><foreword>
478
+ <p id="A">ABC <note id="B"><name>NOTE 1</name><p id="C">XYZ</p></note>
479
+ <note id="B1"><name>NOTE 2</name><p id="C1">XYZ1</p></note></p>
480
+ </foreword></preface>
481
+ </iso-standard>
482
+ INPUT
483
+ html = <<~OUTPUT
484
+ #{HTML_HDR}
485
+ <br/>
486
+ <div>
487
+ <h1 class='ForewordTitle'>Foreword</h1>
488
+ <p id='A'>
489
+ ABC
490
+ <div id='B' class='Note'>
491
+ <p>
492
+ <span class='note_label'>NOTE 1</span>
493
+ &#160; XYZ
494
+ </p>
495
+ </div>
496
+ <div id='B1' class='Note'>
497
+ <p>
498
+ <span class='note_label'>NOTE 2</span>
499
+ &#160; XYZ1
500
+ </p>
501
+ </div>
551
502
  </p>
552
503
  </div>
504
+ <p class='zzSTDTitle1'/>
553
505
  </div>
554
- <p>&#160;</p>
555
- </div>
506
+ </body>
507
+ </html>
508
+ OUTPUT
509
+
510
+ doc = <<~OUTPUT
511
+ <html xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
512
+ <head>
513
+ <style/>
514
+ </head>
515
+ <body lang='EN-US' link='blue' vlink='#954F72'>
516
+ <div class='WordSection1'>
517
+ <p>&#160;</p>
518
+ </div>
519
+ <p>
520
+ <br clear='all' class='section'/>
521
+ </p>
522
+ <div class='WordSection2'>
556
523
  <p>
557
- <br clear='all' class='section'/>
524
+ <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
558
525
  </p>
559
- <div class='WordSection3'>
560
- <p class='zzSTDTitle1'/>
526
+ <div>
527
+ <h1 class='ForewordTitle'>Foreword</h1>
528
+ <p id='A'>ABC </p>
529
+ <div id='B' class='Note'>
530
+ <p class='Note'>
531
+ <span class='note_label'>NOTE 1</span>
532
+ <span style='mso-tab-count:1'>&#160; </span>
533
+ XYZ
534
+ </p>
535
+ </div>
536
+ <div id='B1' class='Note'>
537
+ <p class='Note'>
538
+ <span class='note_label'>NOTE 2</span>
539
+ <span style='mso-tab-count:1'>&#160; </span>
540
+ XYZ1
541
+ </p>
542
+ </div>
561
543
  </div>
562
- </body>
563
- </html>
564
- OUTPUT
544
+ <p>&#160;</p>
545
+ </div>
546
+ <p>
547
+ <br clear='all' class='section'/>
548
+ </p>
549
+ <div class='WordSection3'>
550
+ <p class='zzSTDTitle1'/>
551
+ </div>
552
+ </body>
553
+ </html>
554
+ OUTPUT
555
+ expect(xmlpp(strip_guid(IsoDoc::HtmlConvert.new({})
556
+ .convert("test", input, true)))).to be_equivalent_to xmlpp(html)
557
+ expect(xmlpp(strip_guid(IsoDoc::WordConvert.new({})
558
+ .convert("test", input, true)))).to be_equivalent_to xmlpp(doc)
565
559
  end
566
560
 
567
561
  it "processes figures" do
@@ -597,7 +591,7 @@ RSpec.describe IsoDoc do
597
591
  presxml = <<~OUTPUT
598
592
  <?xml version='1.0'?>
599
593
  <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
600
- <preface><foreword>
594
+ <preface><foreword displayorder="1">
601
595
  <figure id="figureA-1" keep-with-next="true" keep-lines-together="true">
602
596
  <name>Figure 1&#xA0;&#x2014; Split-it-right <em>sample</em> divider<fn reference="1"><p>X</p></fn></name>
603
597
  <image src="rice_images/rice_image1.png" height="20" width="30" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png" alt="alttext" title="titletxt"/>
@@ -741,7 +735,7 @@ RSpec.describe IsoDoc do
741
735
  presxml = <<~OUTPUT
742
736
  <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
743
737
  <preface>
744
- <foreword>
738
+ <foreword displayorder="1">
745
739
  <figure id='figureA-1'>
746
740
  <name>Figure 1</name>
747
741
  <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'>
@@ -823,7 +817,7 @@ RSpec.describe IsoDoc do
823
817
 
824
818
  it "converts SVG (Word)" do
825
819
  FileUtils.rm_rf "spec/assets/odf1.emf"
826
- expect(xmlpp(strip_guid(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true).gsub(/['"][^'".]+(?<!odf1)(?<!odf)\.emf['"]/, "'_.emf'").gsub(/['"][^'".]+\.(gif|xml)['"]/, "'_.\\1'").gsub(/mso-bookmark:_Ref\d+/, "mso-bookmark:_Ref")))).to be_equivalent_to xmlpp(<<~"OUTPUT")
820
+ input = <<~INPUT
827
821
  <iso-standard xmlns="http://riboseinc.com/isoxml">
828
822
  <preface><foreword>
829
823
  <figure id="figureA-1">
@@ -835,6 +829,7 @@ RSpec.describe IsoDoc do
835
829
  </foreword></preface>
836
830
  </iso-standard>
837
831
  INPUT
832
+ output = <<~OUTPUT
838
833
  <html xmlns:epub='http://www.idpf.org/2007/ops' lang='en'>
839
834
  <head>
840
835
  <style>
@@ -871,6 +866,12 @@ RSpec.describe IsoDoc do
871
866
  </body>
872
867
  </html>
873
868
  OUTPUT
869
+ expect(xmlpp(strip_guid(IsoDoc::WordConvert.new({})
870
+ .convert("test", input, true)
871
+ .gsub(/['"][^'".]+(?<!odf1)(?<!odf)\.emf['"]/, "'_.emf'")
872
+ .gsub(/['"][^'".]+\.(gif|xml)['"]/, "'_.\\1'")
873
+ .gsub(/mso-bookmark:_Ref\d+/, "mso-bookmark:_Ref"))))
874
+ .to be_equivalent_to xmlpp(output)
874
875
  end
875
876
 
876
877
  context "disable inkscape" do
@@ -881,58 +882,63 @@ RSpec.describe IsoDoc do
881
882
  allow_any_instance_of(IsoDoc::WordFunction::Body)
882
883
  .to receive(:inkscape_installed?)
883
884
 
884
- expect(xmlpp(strip_guid(IsoDoc::WordConvert.new({})
885
- .convert("test", <<~"INPUT", true).gsub(/['"][^'".]+(?<!odf1)(?<!odf)\.svg['"]/, "'_.svg'").gsub(/mso-bookmark:_Ref\d+/, "mso-bookmark:_Ref")))).to be_equivalent_to xmlpp(<<~"OUTPUT")
886
- <iso-standard xmlns="http://riboseinc.com/isoxml">
887
- <preface><foreword>
888
- <figure id="figureA-1">
889
- <image src="spec/assets/odf.svg" mimetype="image/svg+xml"/>
890
- <image src="spec/assets/odf1.svg" mimetype="image/svg+xml"/>
891
- <image src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj4KICA8Y2lyY2xlIGZpbGw9IiMwMDkiIHI9IjQ1IiBjeD0iNTAiIGN5PSI1MCIvPgogIDxwYXRoIGQ9Ik0zMywyNkg3OEEzNywzNywwLDAsMSwzMyw4M1Y1N0g1OVY0M0gzM1oiIGZpbGw9IiNGRkYiLz4KPC9zdmc+Cg==" id="_d3731866-1a07-435a-a6c2-1acd41023a4e" mimetype="image/svg+xml" height="auto" width="auto"/>
892
- </figure>
893
- </foreword></preface>
894
- </iso-standard>
885
+ input = <<~INPUT
886
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
887
+ <preface><foreword>
888
+ <figure id="figureA-1">
889
+ <image src="spec/assets/odf.svg" mimetype="image/svg+xml"/>
890
+ <image src="spec/assets/odf1.svg" mimetype="image/svg+xml"/>
891
+ <image src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj4KICA8Y2lyY2xlIGZpbGw9IiMwMDkiIHI9IjQ1IiBjeD0iNTAiIGN5PSI1MCIvPgogIDxwYXRoIGQ9Ik0zMywyNkg3OEEzNywzNywwLDAsMSwzMyw4M1Y1N0g1OVY0M0gzM1oiIGZpbGw9IiNGRkYiLz4KPC9zdmc+Cg==" id="_d3731866-1a07-435a-a6c2-1acd41023a4e" mimetype="image/svg+xml" height="auto" width="auto"/>
892
+ </figure>
893
+ </foreword></preface>
894
+ </iso-standard>
895
895
  INPUT
896
- <html xmlns:epub='http://www.idpf.org/2007/ops' lang='en'>
897
- <head>
898
- <style>
899
- </style>
900
- </head>
901
- <body lang='EN-US' link='blue' vlink='#954F72'>
902
- <div class='WordSection1'>
903
- <p>&#160;</p>
904
- </div>
905
- <p>
906
- <br clear='all' class='section'/>
907
- </p>
908
- <div class='WordSection2'>
909
- <p>
910
- <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
911
- </p>
912
- <div>
913
- <h1 class='ForewordTitle'>Foreword</h1>
914
- <div id='figureA-1' class='figure'>
915
- <img src='spec/assets/odf.emf'/>
916
- <img src='spec/assets/odf1.svg'/>
917
- <img src='_.svg' height='auto' width='auto'/>
918
- </div>
919
- </div>
920
- <p>&#160;</p>
921
- </div>
922
- <p>
923
- <br clear='all' class='section'/>
924
- </p>
925
- <div class='WordSection3'>
926
- <p class='zzSTDTitle1'/>
927
- </div>
928
- </body>
929
- </html>
896
+ output = <<~OUTPUT
897
+ <html xmlns:epub='http://www.idpf.org/2007/ops' lang='en'>
898
+ <head>
899
+ <style>
900
+ </style>
901
+ </head>
902
+ <body lang='EN-US' link='blue' vlink='#954F72'>
903
+ <div class='WordSection1'>
904
+ <p>&#160;</p>
905
+ </div>
906
+ <p>
907
+ <br clear='all' class='section'/>
908
+ </p>
909
+ <div class='WordSection2'>
910
+ <p>
911
+ <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
912
+ </p>
913
+ <div>
914
+ <h1 class='ForewordTitle'>Foreword</h1>
915
+ <div id='figureA-1' class='figure'>
916
+ <img src='spec/assets/odf.emf'/>
917
+ <img src='spec/assets/odf1.svg'/>
918
+ <img src='_.svg' height='auto' width='auto'/>
919
+ </div>
920
+ </div>
921
+ <p>&#160;</p>
922
+ </div>
923
+ <p>
924
+ <br clear='all' class='section'/>
925
+ </p>
926
+ <div class='WordSection3'>
927
+ <p class='zzSTDTitle1'/>
928
+ </div>
929
+ </body>
930
+ </html>
930
931
  OUTPUT
932
+ expect(xmlpp(strip_guid(IsoDoc::WordConvert.new({})
933
+ .convert("test", input, true)
934
+ .gsub(/['"][^'".]+(?<!odf1)(?<!odf)\.svg['"]/, "'_.svg'")
935
+ .gsub(/mso-bookmark:_Ref\d+/, "mso-bookmark:_Ref"))))
936
+ .to be_equivalent_to xmlpp(output)
931
937
  end
932
938
  end
933
939
 
934
- it "processes examples (Presentation XML)" do
935
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
940
+ it "processes examples" do
941
+ input = <<~INPUT
936
942
  <iso-standard xmlns="http://riboseinc.com/isoxml">
937
943
  <preface><foreword>
938
944
  <example id="samplecode" keep-with-next="true" keep-lines-together="true">
@@ -945,10 +951,11 @@ RSpec.describe IsoDoc do
945
951
  </foreword></preface>
946
952
  </iso-standard>
947
953
  INPUT
954
+ presxml = <<~OUTPUT
948
955
  <?xml version='1.0'?>
949
956
  <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
950
957
  <preface>
951
- <foreword>
958
+ <foreword displayorder="1">
952
959
  <example id='samplecode' keep-with-next='true' keep-lines-together='true'>
953
960
  <name>EXAMPLE&#xA0;&#x2014; Title</name>
954
961
  <p>Hello</p>
@@ -960,22 +967,8 @@ RSpec.describe IsoDoc do
960
967
  </preface>
961
968
  </iso-standard>
962
969
  OUTPUT
963
- end
964
970
 
965
- it "processes examples (HTML)" do
966
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
967
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
968
- <preface>
969
- <foreword>
970
- <example id='samplecode' keep-with-next='true' keep-lines-together='true'>
971
- <name>EXAMPLE&#xA0;&#x2014; Title</name>
972
- <p>Hello</p>
973
- <sourcecode id='X'><name>Sample</name></sourcecode>
974
- </example>
975
- </foreword>
976
- </preface>
977
- </iso-standard>
978
- INPUT
971
+ html = <<~OUTPUT
979
972
  #{HTML_HDR}
980
973
  <br/>
981
974
  <div>
@@ -983,7 +976,12 @@ RSpec.describe IsoDoc do
983
976
  <div id="samplecode" class="example" style="page-break-after: avoid;page-break-inside: avoid;">
984
977
  <p class="example-title">EXAMPLE&#160;&#8212; Title</p>
985
978
  <p>Hello</p>
986
- <pre id='X' class='prettyprint '/>
979
+ <pre id='X' class='prettyprint '>
980
+ <br/>
981
+ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;
982
+ <br/>
983
+ &#160;&#160;&#160;&#160;&#160;&#160;&#160;
984
+ </pre>
987
985
  <p class='SourceTitle' style='text-align:center;'>Sample</p>
988
986
  </div>
989
987
  </div>
@@ -992,22 +990,7 @@ RSpec.describe IsoDoc do
992
990
  </body>
993
991
  </html>
994
992
  OUTPUT
995
- end
996
-
997
- it "processes examples (Word)" do
998
- expect(xmlpp(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
999
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
1000
- <preface>
1001
- <foreword>
1002
- <example id='samplecode' keep-with-next='true' keep-lines-together='true'>
1003
- <name>EXAMPLE&#xA0;&#x2014; Title</name>
1004
- <p>Hello</p>
1005
- <sourcecode id='X'><name>Sample</name></sourcecode>
1006
- </example>
1007
- </foreword>
1008
- </preface>
1009
- </iso-standard>
1010
- INPUT
993
+ doc = <<~OUTPUT
1011
994
  <html xmlns:epub='http://www.idpf.org/2007/ops' lang='en'><head><style>
1012
995
  </style>
1013
996
  </head>
@@ -1027,7 +1010,12 @@ RSpec.describe IsoDoc do
1027
1010
  <div id='samplecode' class='example' style='page-break-after: avoid;page-break-inside: avoid;'>
1028
1011
  <p class='example-title'>EXAMPLE&#160;&#8212; Title</p>
1029
1012
  <p>Hello</p>
1030
- <p id='X' class='Sourcecode'/>
1013
+ <p id='X' class='Sourcecode'>
1014
+ <br/>
1015
+ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;
1016
+ <br/>
1017
+ &#160;&#160;&#160;&#160;&#160;&#160;&#160;
1018
+ </p>
1031
1019
  <p class='SourceTitle' style='text-align:center;'>Sample</p>
1032
1020
  </div>
1033
1021
  </div>
@@ -1042,10 +1030,16 @@ RSpec.describe IsoDoc do
1042
1030
  </body>
1043
1031
  </html>
1044
1032
  OUTPUT
1033
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
1034
+ .convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
1035
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
1036
+ .convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
1037
+ expect(xmlpp(IsoDoc::WordConvert.new({})
1038
+ .convert("test", presxml, true))).to be_equivalent_to xmlpp(doc)
1045
1039
  end
1046
1040
 
1047
1041
  it "processes sequences of examples" do
1048
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1042
+ input = <<~INPUT
1049
1043
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1050
1044
  <preface><foreword>
1051
1045
  <example id="samplecode">
@@ -1061,10 +1055,11 @@ RSpec.describe IsoDoc do
1061
1055
  </foreword></preface>
1062
1056
  </iso-standard>
1063
1057
  INPUT
1058
+ output = <<~OUTPUT
1064
1059
  <?xml version='1.0'?>
1065
1060
  <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1066
1061
  <preface>
1067
- <foreword>
1062
+ <foreword displayorder="1">
1068
1063
  <example id='samplecode'>
1069
1064
  <name>EXAMPLE 1</name>
1070
1065
  <p>Hello</p>
@@ -1081,10 +1076,12 @@ RSpec.describe IsoDoc do
1081
1076
  </preface>
1082
1077
  </iso-standard>
1083
1078
  OUTPUT
1079
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
1080
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
1084
1081
  end
1085
1082
 
1086
- it "processes sourcecode (Presentation XML)" do
1087
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1083
+ it "processes sourcecode" do
1084
+ input = <<~INPUT
1088
1085
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1089
1086
  <preface><foreword>
1090
1087
  <sourcecode lang="ruby" id="samplecode">
@@ -1097,10 +1094,11 @@ RSpec.describe IsoDoc do
1097
1094
  </foreword></preface>
1098
1095
  </iso-standard>
1099
1096
  INPUT
1097
+ presxml = <<~OUTPUT
1100
1098
  <?xml version='1.0'?>
1101
1099
  <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1102
1100
  <preface>
1103
- <foreword>
1101
+ <foreword displayorder="1">
1104
1102
  <sourcecode lang='ruby' id='samplecode'>
1105
1103
  <name>
1106
1104
  Figure 1&#xA0;&#x2014; Ruby
@@ -1113,102 +1111,62 @@ RSpec.describe IsoDoc do
1113
1111
  </preface>
1114
1112
  </iso-standard>
1115
1113
  OUTPUT
1116
- end
1117
1114
 
1118
- it "processes sourcecode (HTML)" do
1119
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1120
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
1121
- <preface>
1122
- <foreword>
1123
- <sourcecode lang='ruby' id='samplecode'>
1124
- <name>
1125
- Figure 1&#xA0;&#x2014; Ruby
1126
- <em>code</em>
1127
- </name>
1128
- puts x
1129
- </sourcecode>
1130
- <sourcecode unnumbered='true'>
1131
- Que?
1132
- </sourcecode>
1133
- </foreword>
1134
- </preface>
1135
- </iso-standard>
1136
- INPUT
1115
+ html = <<~OUTPUT
1137
1116
  #{HTML_HDR}
1138
1117
  <br/>
1139
1118
  <div>
1140
1119
  <h1 class="ForewordTitle">Foreword</h1>
1141
- <pre id="samplecode" class="prettyprint lang-rb"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br/>&#160; puts x<br/></pre>
1120
+ <pre id="samplecode" class="prettyprint lang-rb"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; puts x<br/>&#160;&#160;&#160;&#160;&#160;</pre>
1142
1121
  <p class="SourceTitle" style="text-align:center;">Figure 1&#160;&#8212; Ruby <i>code</i></p>
1143
- <pre class='prettyprint '>
1144
- <br/>
1145
- Que?
1146
- <br/>
1147
- </pre>
1122
+ <pre class='prettyprint '> Que? </pre>
1148
1123
  </div>
1149
1124
  <p class="zzSTDTitle1"/>
1150
1125
  </div>
1151
1126
  </body>
1152
1127
  </html>
1153
1128
  OUTPUT
1154
- end
1155
1129
 
1156
- it "processes sourcecode (Word)" do
1157
- expect(xmlpp(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1158
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
1159
- <preface>
1160
- <foreword>
1161
- <sourcecode lang='ruby' id='samplecode'>
1162
- <name>
1163
- Figure 1&#xA0;&#x2014; Ruby
1164
- <em>code</em>
1165
- </name>
1166
- puts x
1167
- </sourcecode>
1168
- <sourcecode unnumbered='true'>
1169
- Que?
1170
- </sourcecode>
1171
- </foreword>
1172
- </preface>
1173
- </iso-standard>
1174
- INPUT
1175
- <html xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
1176
- <head><style/></head>
1177
- <body lang="EN-US" link="blue" vlink="#954F72">
1178
- <div class="WordSection1">
1179
- <p>&#160;</p>
1180
- </div>
1181
- <p>
1182
- <br clear="all" class="section"/>
1183
- </p>
1184
- <div class="WordSection2">
1185
- <p>
1186
- <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
1187
- </p>
1188
- <div>
1189
- <h1 class="ForewordTitle">Foreword</h1>
1190
- <p id="samplecode" class="Sourcecode"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br/>&#160; puts x<br/></p><p class="SourceTitle" style="text-align:center;">Figure 1&#160;&#8212; Ruby <i>code</i></p>
1191
- <p class='Sourcecode'>
1192
- <br/>
1193
- Que?
1194
- <br/>
1130
+ doc = <<~OUTPUT
1131
+ <html xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
1132
+ <head><style/></head>
1133
+ <body lang="EN-US" link="blue" vlink="#954F72">
1134
+ <div class="WordSection1">
1135
+ <p>&#160;</p>
1136
+ </div>
1137
+ <p>
1138
+ <br clear="all" class="section"/>
1139
+ </p>
1140
+ <div class="WordSection2">
1141
+ <p>
1142
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
1143
+ </p>
1144
+ <div>
1145
+ <h1 class="ForewordTitle">Foreword</h1>
1146
+ <p id="samplecode" class="Sourcecode"><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; puts x<br/>&#160;&#160;&#160;&#160;&#160; </p><p class="SourceTitle" style="text-align:center;">Figure 1&#160;&#8212; Ruby <i>code</i></p>
1147
+ <p class='Sourcecode'> Que? </p>
1148
+ </div>
1149
+ <p>&#160;</p>
1150
+ </div>
1151
+ <p>
1152
+ <br clear="all" class="section"/>
1195
1153
  </p>
1196
- </div>
1197
- <p>&#160;</p>
1198
- </div>
1199
- <p>
1200
- <br clear="all" class="section"/>
1201
- </p>
1202
- <div class="WordSection3">
1203
- <p class="zzSTDTitle1"/>
1204
- </div>
1205
- </body>
1206
- </html>
1154
+ <div class="WordSection3">
1155
+ <p class="zzSTDTitle1"/>
1156
+ </div>
1157
+ </body>
1158
+ </html>
1207
1159
  OUTPUT
1160
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
1161
+ .convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
1162
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
1163
+ .convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
1164
+ expect(xmlpp(IsoDoc::WordConvert.new({})
1165
+ .convert("test", presxml, true))).to be_equivalent_to xmlpp(doc)
1208
1166
  end
1209
1167
 
1210
1168
  it "processes sourcecode with escapes preserved" do
1211
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1169
+ input = <<~INPUT
1212
1170
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1213
1171
  <preface><foreword>
1214
1172
  <sourcecode id="samplecode">
@@ -1218,6 +1176,7 @@ RSpec.describe IsoDoc do
1218
1176
  </foreword></preface>
1219
1177
  </iso-standard>
1220
1178
  INPUT
1179
+ output = <<~OUTPUT
1221
1180
  #{HTML_HDR}
1222
1181
  <br/>
1223
1182
  <div>
@@ -1230,10 +1189,12 @@ RSpec.describe IsoDoc do
1230
1189
  </body>
1231
1190
  </html>
1232
1191
  OUTPUT
1192
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
1193
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
1233
1194
  end
1234
1195
 
1235
1196
  it "processes sourcecode with annotations" do
1236
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1197
+ input = <<~INPUT
1237
1198
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1238
1199
  <preface><foreword>
1239
1200
  <sourcecode id="_">puts "Hello, world." <callout target="A">1</callout>
@@ -1247,6 +1208,7 @@ RSpec.describe IsoDoc do
1247
1208
  </foreword></preface>
1248
1209
  </iso-standard>
1249
1210
  INPUT
1211
+ output = <<~OUTPUT
1250
1212
  #{HTML_HDR}
1251
1213
  <br/>
1252
1214
  <div>
@@ -1258,10 +1220,12 @@ RSpec.describe IsoDoc do
1258
1220
  </body>
1259
1221
  </html>
1260
1222
  OUTPUT
1223
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
1224
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
1261
1225
  end
1262
1226
 
1263
1227
  it "processes admonitions" do
1264
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1228
+ input = <<~INPUT
1265
1229
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1266
1230
  <preface><foreword>
1267
1231
  <admonition id="_70234f78-64e5-4dfc-8b6f-f3f037348b6a" type="caution" keep-with-next="true" keep-lines-together="true">
@@ -1270,6 +1234,7 @@ RSpec.describe IsoDoc do
1270
1234
  </foreword></preface>
1271
1235
  </iso-standard>
1272
1236
  INPUT
1237
+ output = <<~OUTPUT
1273
1238
  #{HTML_HDR}
1274
1239
  <br/>
1275
1240
  <div>
@@ -1283,10 +1248,12 @@ RSpec.describe IsoDoc do
1283
1248
  </body>
1284
1249
  </html>
1285
1250
  OUTPUT
1251
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
1252
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
1286
1253
  end
1287
1254
 
1288
1255
  it "processes admonitions with titles" do
1289
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1256
+ input = <<~INPUT
1290
1257
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1291
1258
  <preface><foreword>
1292
1259
  <admonition id="_70234f78-64e5-4dfc-8b6f-f3f037348b6a" type="caution">
@@ -1296,6 +1263,7 @@ RSpec.describe IsoDoc do
1296
1263
  </foreword></preface>
1297
1264
  </iso-standard>
1298
1265
  INPUT
1266
+ output = <<~OUTPUT
1299
1267
  #{HTML_HDR}
1300
1268
  <br/>
1301
1269
  <div>
@@ -1309,10 +1277,12 @@ RSpec.describe IsoDoc do
1309
1277
  </body>
1310
1278
  </html>
1311
1279
  OUTPUT
1280
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
1281
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
1312
1282
  end
1313
1283
 
1314
- it "processes formulae (PresentationXML)" do
1315
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1284
+ it "processes formulae" do
1285
+ input = <<~INPUT
1316
1286
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1317
1287
  <preface><foreword>
1318
1288
  <formula id="_be9158af-7e93-4ee2-90c5-26d31c181934" unnumbered="true" keep-with-next="true" keep-lines-together="true">
@@ -1335,43 +1305,9 @@ RSpec.describe IsoDoc do
1335
1305
  </foreword></preface>
1336
1306
  </iso-standard>
1337
1307
  INPUT
1338
- <?xml version='1.0'?>
1339
- <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1340
- <preface>
1341
- <foreword>
1342
- <formula id='_be9158af-7e93-4ee2-90c5-26d31c181934' unnumbered='true' keep-with-next='true' keep-lines-together='true'>
1343
- <stem type='AsciiMath'>r = 1 %</stem>
1344
- <dl id='_e4fe94fe-1cde-49d9-b1ad-743293b7e21d'>
1345
- <dt>
1346
- <stem type='AsciiMath'>r</stem>
1347
- </dt>
1348
- <dd>
1349
- <p id='_1b99995d-ff03-40f5-8f2e-ab9665a69b77'>is the repeatability limit.</p>
1350
- </dd>
1351
- </dl>
1352
- <note id='_83083c7a-6c85-43db-a9fa-4d8edd0c9fc0'>
1353
- <name>NOTE</name>
1354
- <p id='_511aaa98-4116-42af-8e5b-c87cdf5bfdc8'>
1355
- [durationUnits] is essentially a duration statement without the "P"
1356
- prefix. "P" is unnecessary because between "G" and "U" duration is
1357
- always expressed.
1358
- </p>
1359
- </note>
1360
- </formula>
1361
- <formula id='_be9158af-7e93-4ee2-90c5-26d31c181935'>
1362
- <name>1</name>
1363
- <stem type='AsciiMath'>r = 1 %</stem>
1364
- </formula>
1365
- </foreword>
1366
- </preface>
1367
- </iso-standard>
1368
- OUTPUT
1369
- end
1370
-
1371
- it "processes formulae (HTML)" do
1372
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1373
- <iso-standard xmlns="http://riboseinc.com/isoxml">
1374
- <preface><foreword>
1308
+ presxml = <<~INPUT
1309
+ <iso-standard xmlns="http://riboseinc.com/isoxml" type='presentation'>
1310
+ <preface><foreword displayorder="1">
1375
1311
  <formula id="_be9158af-7e93-4ee2-90c5-26d31c181934" unnumbered="true" keep-with-next="true" keep-lines-together="true">
1376
1312
  <stem type="AsciiMath">r = 1 %</stem>
1377
1313
  <dl id="_e4fe94fe-1cde-49d9-b1ad-743293b7e21d">
@@ -1393,6 +1329,7 @@ RSpec.describe IsoDoc do
1393
1329
  </foreword></preface>
1394
1330
  </iso-standard>
1395
1331
  INPUT
1332
+ html = <<~OUTPUT
1396
1333
  #{HTML_HDR}
1397
1334
  <br/>
1398
1335
  <div>
@@ -1413,33 +1350,8 @@ RSpec.describe IsoDoc do
1413
1350
  </body>
1414
1351
  </html>
1415
1352
  OUTPUT
1416
- end
1417
1353
 
1418
- it "processes formulae (Word)" do
1419
- expect(xmlpp(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1420
- <iso-standard xmlns="http://riboseinc.com/isoxml">
1421
- <preface><foreword>
1422
- <formula id="_be9158af-7e93-4ee2-90c5-26d31c181934" unnumbered="true" keep-with-next="true" keep-lines-together="true">
1423
- <stem type="AsciiMath">r = 1 %</stem>
1424
- <dl id="_e4fe94fe-1cde-49d9-b1ad-743293b7e21d">
1425
- <dt>
1426
- <stem type="AsciiMath">r</stem>
1427
- </dt>
1428
- <dd>
1429
- <p id="_1b99995d-ff03-40f5-8f2e-ab9665a69b77">is the repeatability limit.</p>
1430
- </dd>
1431
- </dl>
1432
- <note id="_83083c7a-6c85-43db-a9fa-4d8edd0c9fc0">
1433
- <name>NOTE</name>
1434
- <p id="_511aaa98-4116-42af-8e5b-c87cdf5bfdc8">[durationUnits] is essentially a duration statement without the "P" prefix. "P" is unnecessary because between "G" and "U" duration is always expressed.</p>
1435
- </note>
1436
- </formula>
1437
- <formula id="_be9158af-7e93-4ee2-90c5-26d31c181935"><name>1</name>
1438
- <stem type="AsciiMath">r = 1 %</stem>
1439
- </formula>
1440
- </foreword></preface>
1441
- </iso-standard>
1442
- INPUT
1354
+ word = <<~OUTPUT
1443
1355
  <html xmlns:epub='http://www.idpf.org/2007/ops' lang='en'>
1444
1356
  <head>
1445
1357
  <style>
@@ -1507,10 +1419,16 @@ RSpec.describe IsoDoc do
1507
1419
  </body>
1508
1420
  </html>
1509
1421
  OUTPUT
1422
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
1423
+ .convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
1424
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
1425
+ .convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
1426
+ expect(xmlpp(IsoDoc::WordConvert.new({})
1427
+ .convert("test", presxml, true))).to be_equivalent_to xmlpp(word)
1510
1428
  end
1511
1429
 
1512
1430
  it "processes paragraph attributes" do
1513
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1431
+ input = <<~INPUT
1514
1432
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1515
1433
  <preface><foreword>
1516
1434
  <p align="left" id="_08bfe952-d57f-4150-9c95-5d52098cc2a8">Vache Equipment<br/>
@@ -1520,6 +1438,7 @@ RSpec.describe IsoDoc do
1520
1438
  </foreword></preface>
1521
1439
  </iso-standard>
1522
1440
  INPUT
1441
+ html = <<~OUTPUT
1523
1442
  #{HTML_HDR}
1524
1443
  <br/>
1525
1444
  <div>
@@ -1535,19 +1454,8 @@ RSpec.describe IsoDoc do
1535
1454
  </body>
1536
1455
  </html>
1537
1456
  OUTPUT
1538
- end
1539
1457
 
1540
- it "processes paragraph attributes (Word)" do
1541
- expect(xmlpp(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1542
- <iso-standard xmlns="http://riboseinc.com/isoxml">
1543
- <preface><foreword>
1544
- <p align="left" id="_08bfe952-d57f-4150-9c95-5d52098cc2a8">Vache Equipment<br/>
1545
- Fictitious<br/>
1546
- World</p>
1547
- <p align="justify" keep-with-next="true" keep-lines-together="true">Justify</p>
1548
- </foreword></preface>
1549
- </iso-standard>
1550
- INPUT
1458
+ word = <<~OUTPUT
1551
1459
  <html xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
1552
1460
  <head><style/></head>
1553
1461
  <body lang="EN-US" link="blue" vlink="#954F72">
@@ -1574,10 +1482,14 @@ RSpec.describe IsoDoc do
1574
1482
  </body>
1575
1483
  </html>
1576
1484
  OUTPUT
1485
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
1486
+ .convert("test", input, true))).to be_equivalent_to xmlpp(html)
1487
+ expect(xmlpp(IsoDoc::WordConvert.new({})
1488
+ .convert("test", input, true))).to be_equivalent_to xmlpp(word)
1577
1489
  end
1578
1490
 
1579
- it "processes blockquotes (Presentation XML)" do
1580
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1491
+ it "processes blockquotes" do
1492
+ input = <<~INPUT
1581
1493
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1582
1494
  <preface><foreword>
1583
1495
  <quote id="_044bd364-c832-4b78-8fea-92242402a1d1">
@@ -1588,37 +1500,10 @@ RSpec.describe IsoDoc do
1588
1500
  </foreword></preface>
1589
1501
  </iso-standard>
1590
1502
  INPUT
1591
- <?xml version='1.0'?>
1592
- <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1593
- <preface>
1594
- <foreword>
1595
- <quote id='_044bd364-c832-4b78-8fea-92242402a1d1'>
1596
- <source type='inline' bibitemid='ISO7301' citeas='ISO 7301:2011'>
1597
- <locality type='clause'>
1598
- <referenceFrom>1</referenceFrom>
1599
- </locality>ISO 7301:2011, Clause 1
1600
- </source>
1601
- <author>ISO</author>
1602
- <p id='_d4fd0a61-f300-4285-abe6-602707590e53'>
1603
- This International Standard gives the minimum specifications for rice
1604
- (
1605
- <em>Oryza sativa</em>
1606
- L.) which is subject to international trade. It is applicable to the
1607
- following types: husked rice and milled rice, parboiled or not,
1608
- intended for direct human consumption. It is neither applicable to
1609
- other products derived from rice, nor to waxy rice (glutinous rice).
1610
- </p>
1611
- </quote>
1612
- </foreword>
1613
- </preface>
1614
- </iso-standard>
1615
- OUTPUT
1616
- end
1617
1503
 
1618
- it "processes blockquotes (HTML)" do
1619
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1620
- <iso-standard xmlns="http://riboseinc.com/isoxml">
1621
- <preface><foreword>
1504
+ presxml = <<~INPUT
1505
+ <iso-standard xmlns="http://riboseinc.com/isoxml" type='presentation'>
1506
+ <preface><foreword displayorder="1">
1622
1507
  <quote id="_044bd364-c832-4b78-8fea-92242402a1d1">
1623
1508
  <source type="inline" bibitemid="ISO7301" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>1</referenceFrom></locality>ISO 7301:2011, Clause 1</source>
1624
1509
  <author>ISO</author>
@@ -1627,21 +1512,26 @@ RSpec.describe IsoDoc do
1627
1512
  </foreword></preface>
1628
1513
  </iso-standard>
1629
1514
  INPUT
1515
+ html = <<~OUTPUT
1630
1516
  #{HTML_HDR}
1631
- <br/>
1632
- <div>
1633
- <h1 class="ForewordTitle">Foreword</h1>
1634
- <div class="Quote" id="_044bd364-c832-4b78-8fea-92242402a1d1">
1517
+ <br/>
1518
+ <div>
1519
+ <h1 class="ForewordTitle">Foreword</h1>
1520
+ <div class="Quote" id="_044bd364-c832-4b78-8fea-92242402a1d1">
1635
1521
 
1636
1522
 
1637
- <p id="_d4fd0a61-f300-4285-abe6-602707590e53">This International Standard gives the minimum specifications for rice (<i>Oryza sativa</i> L.) which is subject to international trade. It is applicable to the following types: husked rice and milled rice, parboiled or not, intended for direct human consumption. It is neither applicable to other products derived from rice, nor to waxy rice (glutinous rice).</p>
1638
- <p class="QuoteAttribution">&#8212; ISO, <a href="#ISO7301">ISO 7301:2011, Clause 1</a></p></div>
1639
- </div>
1640
- <p class="zzSTDTitle1"/>
1641
- </div>
1642
- </body>
1643
- </html>
1523
+ <p id="_d4fd0a61-f300-4285-abe6-602707590e53">This International Standard gives the minimum specifications for rice (<i>Oryza sativa</i> L.) which is subject to international trade. It is applicable to the following types: husked rice and milled rice, parboiled or not, intended for direct human consumption. It is neither applicable to other products derived from rice, nor to waxy rice (glutinous rice).</p>
1524
+ <p class="QuoteAttribution">&#8212; ISO, <a href="#ISO7301">ISO 7301:2011, Clause 1</a></p></div>
1525
+ </div>
1526
+ <p class="zzSTDTitle1"/>
1527
+ </div>
1528
+ </body>
1529
+ </html>
1644
1530
  OUTPUT
1531
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
1532
+ .convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
1533
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
1534
+ .convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
1645
1535
  end
1646
1536
 
1647
1537
  it "processes term domains" do
@@ -1670,273 +1560,11 @@ RSpec.describe IsoDoc do
1670
1560
  OUTPUT
1671
1561
  end
1672
1562
 
1673
- it "processes permissions (Presentation XML)" do
1674
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1675
- <iso-standard xmlns="http://riboseinc.com/isoxml">
1676
- <preface><foreword>
1677
- <permission id="_" keep-with-next="true" keep-lines-together="true">
1678
- <label>/ogc/recommendation/wfs/2</label>
1679
- <inherit>/ss/584/2015/level/1</inherit>
1680
- <inherit><eref type="inline" bibitemid="rfc2616" citeas="RFC 2616">RFC 2616 (HTTP/1.1)</eref></inherit>
1681
- <subject>user</subject>
1682
- <classification> <tag>control-class</tag> <value>Technical</value> </classification><classification> <tag>priority</tag> <value>P0</value> </classification><classification> <tag>family</tag> <value>System and Communications Protection</value> </classification><classification> <tag>family</tag> <value>System and Communications Protocols</value> </classification>
1683
- <description>
1684
- <p id="_">I recommend <em>this</em>.</p>
1685
- </description>
1686
- <specification exclude="true" type="tabular">
1687
- <p id="_">This is the object of the recommendation:</p>
1688
- <table id="_">
1689
- <tbody>
1690
- <tr>
1691
- <td style="text-align:left;">Object</td>
1692
- <td style="text-align:left;">Value</td>
1693
- </tr>
1694
- <tr>
1695
- <td style="text-align:left;">Mission</td>
1696
- <td style="text-align:left;">Accomplished</td>
1697
- </tr>
1698
- </tbody>
1699
- </table>
1700
- </specification>
1701
- <description>
1702
- <p id="_">As for the measurement targets,</p>
1703
- </description>
1704
- <measurement-target exclude="false">
1705
- <p id="_">The measurement target shall be measured as:</p>
1706
- <formula id="_">
1707
- <stem type="AsciiMath">r/1 = 0</stem>
1708
- </formula>
1709
- </measurement-target>
1710
- <verification exclude="false">
1711
- <p id="_">The following code will be run for verification:</p>
1712
- <sourcecode id="_">CoreRoot(success): HttpResponse
1713
- if (success)
1714
- recommendation(label: success-response)
1715
- end
1716
- </sourcecode>
1717
- </verification>
1718
- <import exclude="true">
1719
- <sourcecode id="_">success-response()</sourcecode>
1720
- </import>
1721
- </permission>
1722
- </foreword></preface>
1723
- <bibliography><references id="_bibliography" obligation="informative" normative="false">
1724
- <title>Bibliography</title>
1725
- <bibitem id="rfc2616" type="standard"> <fetched>2020-03-27</fetched> <title format="text/plain" language="en" script="Latn">Hypertext Transfer Protocol — HTTP/1.1</title> <uri type="xml">https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2616.xml</uri> <uri type="src">https://www.rfc-editor.org/info/rfc2616</uri> <docidentifier type="IETF">RFC 2616</docidentifier> <docidentifier type="rfc-anchor">RFC2616</docidentifier> <docidentifier type="DOI">10.17487/RFC2616</docidentifier> <date type="published"> <on>1999-06</on> </date> <contributor> <role type="author"/> <person> <name> <completename language="en">R. Fielding</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Gettys</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Mogul</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">H. Frystyk</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">L. Masinter</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">P. Leach</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">T. Berners-Lee</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <language>en</language> <script>Latn</script> <abstract format="text/plain" language="en" script="Latn">HTTP has been in use by the World-Wide Web global information initiative since 1990. This specification defines the protocol referred to as “HTTP/1.1”, and is an update to RFC 2068. [STANDARDS-TRACK]</abstract> <series type="main"> <title format="text/plain" language="en" script="Latn">RFC</title> <number>2616</number> </series> <place>Fremont, CA</place></bibitem>
1726
- </references></bibliography>
1727
- </iso-standard>
1728
- INPUT
1729
- <?xml version='1.0'?>
1730
- <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1731
- <preface>
1732
- <foreword>
1733
- <permission id='_' keep-with-next='true' keep-lines-together='true'>
1734
- <name>Permission 1</name>
1735
- <label>/ogc/recommendation/wfs/2</label>
1736
- <inherit>/ss/584/2015/level/1</inherit>
1737
- <inherit>
1738
- <eref type='inline' bibitemid='rfc2616' citeas='RFC 2616'>RFC 2616 (HTTP/1.1)</eref>
1739
- </inherit>
1740
- <subject>user</subject>
1741
- <classification>
1742
- <tag>control-class</tag>
1743
- <value>Technical</value>
1744
- </classification>
1745
- <classification>
1746
- <tag>priority</tag>
1747
- <value>P0</value>
1748
- </classification>
1749
- <classification>
1750
- <tag>family</tag>
1751
- <value>System and Communications Protection</value>
1752
- </classification>
1753
- <classification>
1754
- <tag>family</tag>
1755
- <value>System and Communications Protocols</value>
1756
- </classification>
1757
- <description>
1758
- <p id='_'>
1759
- I recommend
1760
- <em>this</em>
1761
- .
1762
- </p>
1763
- </description>
1764
- <specification exclude='true' type='tabular'>
1765
- <p id='_'>This is the object of the recommendation:</p>
1766
- <table id='_'>
1767
- <tbody>
1768
- <tr>
1769
- <td style='text-align:left;'>Object</td>
1770
- <td style='text-align:left;'>Value</td>
1771
- </tr>
1772
- <tr>
1773
- <td style='text-align:left;'>Mission</td>
1774
- <td style='text-align:left;'>Accomplished</td>
1775
- </tr>
1776
- </tbody>
1777
- </table>
1778
- </specification>
1779
- <description>
1780
- <p id='_'>As for the measurement targets,</p>
1781
- </description>
1782
- <measurement-target exclude='false'>
1783
- <p id='_'>The measurement target shall be measured as:</p>
1784
- <formula id='_'>
1785
- <name>1</name>
1786
- <stem type='AsciiMath'>r/1 = 0</stem>
1787
- </formula>
1788
- </measurement-target>
1789
- <verification exclude='false'>
1790
- <p id='_'>The following code will be run for verification:</p>
1791
- <sourcecode id='_'>
1792
- CoreRoot(success): HttpResponse if (success) recommendation(label:
1793
- success-response) end
1794
- </sourcecode>
1795
- </verification>
1796
- <import exclude='true'>
1797
- <sourcecode id='_'>success-response()</sourcecode>
1798
- </import>
1799
- </permission>
1800
- </foreword>
1801
- </preface>
1802
- <bibliography>
1803
- <references id='_bibliography' obligation='informative' normative='false'>
1804
- <title depth="1">Bibliography</title>
1805
- <bibitem id='rfc2616' type='standard'>
1806
- <fetched>2020-03-27</fetched>
1807
- <title format='text/plain' language='en' script='Latn'>Hypertext Transfer Protocol&#x2009;&#x2014;&#x2009;HTTP/1.1</title>
1808
- <uri type='xml'>https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2616.xml</uri>
1809
- <uri type='src'>https://www.rfc-editor.org/info/rfc2616</uri>
1810
- <docidentifier type='IETF'>RFC 2616</docidentifier>
1811
- <docidentifier type='rfc-anchor'>RFC2616</docidentifier>
1812
- <docidentifier type='DOI'>10.17487/RFC2616</docidentifier>
1813
- <date type='published'>
1814
- <on>1999-06</on>
1815
- </date>
1816
- <contributor>
1817
- <role type='author'/>
1818
- <person>
1819
- <name>
1820
- <completename language='en'>R. Fielding</completename>
1821
- </name>
1822
- <affiliation>
1823
- <organization>
1824
- <name>IETF</name>
1825
- <abbreviation>IETF</abbreviation>
1826
- </organization>
1827
- </affiliation>
1828
- </person>
1829
- </contributor>
1830
- <contributor>
1831
- <role type='author'/>
1832
- <person>
1833
- <name>
1834
- <completename language='en'>J. Gettys</completename>
1835
- </name>
1836
- <affiliation>
1837
- <organization>
1838
- <name>IETF</name>
1839
- <abbreviation>IETF</abbreviation>
1840
- </organization>
1841
- </affiliation>
1842
- </person>
1843
- </contributor>
1844
- <contributor>
1845
- <role type='author'/>
1846
- <person>
1847
- <name>
1848
- <completename language='en'>J. Mogul</completename>
1849
- </name>
1850
- <affiliation>
1851
- <organization>
1852
- <name>IETF</name>
1853
- <abbreviation>IETF</abbreviation>
1854
- </organization>
1855
- </affiliation>
1856
- </person>
1857
- </contributor>
1858
- <contributor>
1859
- <role type='author'/>
1860
- <person>
1861
- <name>
1862
- <completename language='en'>H. Frystyk</completename>
1863
- </name>
1864
- <affiliation>
1865
- <organization>
1866
- <name>IETF</name>
1867
- <abbreviation>IETF</abbreviation>
1868
- </organization>
1869
- </affiliation>
1870
- </person>
1871
- </contributor>
1872
- <contributor>
1873
- <role type='author'/>
1874
- <person>
1875
- <name>
1876
- <completename language='en'>L. Masinter</completename>
1877
- </name>
1878
- <affiliation>
1879
- <organization>
1880
- <name>IETF</name>
1881
- <abbreviation>IETF</abbreviation>
1882
- </organization>
1883
- </affiliation>
1884
- </person>
1885
- </contributor>
1886
- <contributor>
1887
- <role type='author'/>
1888
- <person>
1889
- <name>
1890
- <completename language='en'>P. Leach</completename>
1891
- </name>
1892
- <affiliation>
1893
- <organization>
1894
- <name>IETF</name>
1895
- <abbreviation>IETF</abbreviation>
1896
- </organization>
1897
- </affiliation>
1898
- </person>
1899
- </contributor>
1900
- <contributor>
1901
- <role type='author'/>
1902
- <person>
1903
- <name>
1904
- <completename language='en'>T. Berners-Lee</completename>
1905
- </name>
1906
- <affiliation>
1907
- <organization>
1908
- <name>IETF</name>
1909
- <abbreviation>IETF</abbreviation>
1910
- </organization>
1911
- </affiliation>
1912
- </person>
1913
- </contributor>
1914
- <language>en</language>
1915
- <script>Latn</script>
1916
- <abstract format='text/plain' language='en' script='Latn'>
1917
- HTTP has been in use by the World-Wide Web global information
1918
- initiative since 1990. This specification defines the protocol
1919
- referred to as &#x201C;HTTP/1.1&#x201D;, and is an update to RFC 2068.
1920
- [STANDARDS-TRACK]
1921
- </abstract>
1922
- <series type='main'>
1923
- <title format='text/plain' language='en' script='Latn'>RFC</title>
1924
- <number>2616</number>
1925
- </series>
1926
- <place>Fremont, CA</place>
1927
- </bibitem>
1928
- </references>
1929
- </bibliography>
1930
- </iso-standard>
1931
- OUTPUT
1932
- end
1933
-
1934
- it "processes permissions (HTML)" do
1935
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1563
+ it "processes permissions" do
1564
+ input = <<~INPUT
1936
1565
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1937
1566
  <preface><foreword>
1938
1567
  <permission id="_" keep-with-next="true" keep-lines-together="true">
1939
- <name>Permission 1</name>
1940
1568
  <label>/ogc/recommendation/wfs/2</label>
1941
1569
  <inherit>/ss/584/2015/level/1</inherit>
1942
1570
  <inherit><eref type="inline" bibitemid="rfc2616" citeas="RFC 2616">RFC 2616 (HTTP/1.1)</eref></inherit>
@@ -1982,52 +1610,112 @@ RSpec.describe IsoDoc do
1982
1610
  </import>
1983
1611
  </permission>
1984
1612
  </foreword></preface>
1985
- <bibliography><references id="_bibliography" obligation="informative" normative="false">
1613
+ <bibliography><references id="_bibliography" obligation="informative" normative="false" displayorder="2">
1986
1614
  <title>Bibliography</title>
1987
1615
  <bibitem id="rfc2616" type="standard"> <fetched>2020-03-27</fetched> <title format="text/plain" language="en" script="Latn">Hypertext Transfer Protocol — HTTP/1.1</title> <uri type="xml">https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2616.xml</uri> <uri type="src">https://www.rfc-editor.org/info/rfc2616</uri> <docidentifier type="IETF">RFC 2616</docidentifier> <docidentifier type="rfc-anchor">RFC2616</docidentifier> <docidentifier type="DOI">10.17487/RFC2616</docidentifier> <date type="published"> <on>1999-06</on> </date> <contributor> <role type="author"/> <person> <name> <completename language="en">R. Fielding</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Gettys</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Mogul</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">H. Frystyk</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">L. Masinter</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">P. Leach</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">T. Berners-Lee</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <language>en</language> <script>Latn</script> <abstract format="text/plain" language="en" script="Latn">HTTP has been in use by the World-Wide Web global information initiative since 1990. This specification defines the protocol referred to as “HTTP/1.1”, and is an update to RFC 2068. [STANDARDS-TRACK]</abstract> <series type="main"> <title format="text/plain" language="en" script="Latn">RFC</title> <number>2616</number> </series> <place>Fremont, CA</place></bibitem>
1988
1616
  </references></bibliography>
1989
1617
  </iso-standard>
1990
1618
  INPUT
1991
- #{HTML_HDR}
1992
- <br/>
1993
- <div>
1994
- <h1 class="ForewordTitle">Foreword</h1>
1995
- <div class="permission" id='_' style='page-break-after: avoid;page-break-inside: avoid;'>
1996
- <p class="RecommendationTitle">Permission 1:<br/>/ogc/recommendation/wfs/2</p>
1997
- <p><i>Subject: user<br/>
1998
- Inherits: /ss/584/2015/level/1
1999
- <br/>
2000
- Inherits: <a href='#rfc2616'>RFC 2616 (HTTP/1.1)</a>
2001
- <br/>Control-class: Technical<br/>Priority: P0<br/>Family: System and Communications Protection<br/>Family: System and Communications Protocols</i></p>
2002
- <div class="requirement-description">
2003
- <p id="_">I recommend <i>this</i>.</p>
2004
- </div>
2005
- <div class="requirement-description">
2006
- <p id="_">As for the measurement targets,</p>
2007
- </div>
2008
- <div class="requirement-measurement-target">
2009
- <p id="_">The measurement target shall be measured as:</p>
2010
- <div id="_"><div class="formula"><p><span class="stem">(#(r/1 = 0)#)</span></p></div></div>
2011
- </div>
2012
- <div class="requirement-verification">
2013
- <p id="_">The following code will be run for verification:</p>
2014
- <pre id="_" class="prettyprint ">CoreRoot(success): HttpResponse<br/>&#160;&#160;&#160;&#160;&#160; if (success)<br/>&#160;&#160;&#160;&#160;&#160; recommendation(label: success-response)<br/>&#160;&#160;&#160;&#160;&#160; end<br/>&#160;&#160;&#160; </pre>
1619
+ presxml = <<~OUTPUT
1620
+ <iso-standard xmlns="http://riboseinc.com/isoxml" type='presentation'>
1621
+ <preface><foreword displayorder='1'>
1622
+ <permission id="_" keep-with-next="true" keep-lines-together="true">
1623
+ <name>Permission 1</name>
1624
+ <label>/ogc/recommendation/wfs/2</label>
1625
+ <inherit>/ss/584/2015/level/1</inherit>
1626
+ <inherit><eref type="inline" bibitemid="rfc2616" citeas="RFC 2616">RFC 2616 (HTTP/1.1)</eref></inherit>
1627
+ <subject>user</subject>
1628
+ <classification> <tag>control-class</tag> <value>Technical</value> </classification><classification> <tag>priority</tag> <value>P0</value> </classification><classification> <tag>family</tag> <value>System and Communications Protection</value> </classification><classification> <tag>family</tag> <value>System and Communications Protocols</value> </classification>
1629
+ <description>
1630
+ <p id="_">I recommend <em>this</em>.</p>
1631
+ </description>
1632
+ <specification exclude="true" type="tabular">
1633
+ <p id="_">This is the object of the recommendation:</p>
1634
+ <table id="_">
1635
+ <tbody>
1636
+ <tr>
1637
+ <td style="text-align:left;">Object</td>
1638
+ <td style="text-align:left;">Value</td>
1639
+ </tr>
1640
+ <tr>
1641
+ <td style="text-align:left;">Mission</td>
1642
+ <td style="text-align:left;">Accomplished</td>
1643
+ </tr>
1644
+ </tbody>
1645
+ </table>
1646
+ </specification>
1647
+ <description>
1648
+ <p id="_">As for the measurement targets,</p>
1649
+ </description>
1650
+ <measurement-target exclude="false">
1651
+ <p id="_">The measurement target shall be measured as:</p>
1652
+ <formula id="_">
1653
+ <name>1</name>
1654
+ <stem type="AsciiMath">r/1 = 0</stem>
1655
+ </formula>
1656
+ </measurement-target>
1657
+ <verification exclude="false">
1658
+ <p id="_">The following code will be run for verification:</p>
1659
+ <sourcecode id="_">CoreRoot(success): HttpResponse
1660
+ if (success)
1661
+ recommendation(label: success-response)
1662
+ end
1663
+ </sourcecode>
1664
+ </verification>
1665
+ <import exclude="true">
1666
+ <sourcecode id="_">success-response()</sourcecode>
1667
+ </import>
1668
+ </permission>
1669
+ </foreword></preface>
1670
+ <bibliography><references id="_bibliography" obligation="informative" normative="false" displayorder='2'>
1671
+ <title depth='1'>Bibliography</title>
1672
+ <bibitem id="rfc2616" type="standard"> <fetched>2020-03-27</fetched> <title format="text/plain" language="en" script="Latn">Hypertext Transfer Protocol — HTTP/1.1</title> <uri type="xml">https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2616.xml</uri> <uri type="src">https://www.rfc-editor.org/info/rfc2616</uri> <docidentifier type="IETF">IETF RFC 2616</docidentifier> <docidentifier type="rfc-anchor">RFC2616</docidentifier> <docidentifier type="DOI">DOI 10.17487/RFC2616</docidentifier> <date type="published"> <on>1999-06</on> </date> <contributor> <role type="author"/> <person> <name> <completename language="en">R. Fielding</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Gettys</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Mogul</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">H. Frystyk</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">L. Masinter</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">P. Leach</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">T. Berners-Lee</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <language>en</language> <script>Latn</script> <abstract format="text/plain" language="en" script="Latn">HTTP has been in use by the World-Wide Web global information initiative since 1990. This specification defines the protocol referred to as “HTTP/1.1”, and is an update to RFC 2068. [STANDARDS-TRACK]</abstract> <series type="main"> <title format="text/plain" language="en" script="Latn">RFC</title> <number>2616</number> </series> <place>Fremont, CA</place></bibitem>
1673
+ </references></bibliography>
1674
+ </iso-standard>
1675
+ OUTPUT
1676
+ html = <<~OUTPUT
1677
+ #{HTML_HDR}
1678
+ <br/>
1679
+ <div>
1680
+ <h1 class="ForewordTitle">Foreword</h1>
1681
+ <div class="permission" id='_' style='page-break-after: avoid;page-break-inside: avoid;'>
1682
+ <p class="RecommendationTitle">Permission 1:<br/>/ogc/recommendation/wfs/2</p>
1683
+ <p><i>Subject: user<br/>
1684
+ Inherits: /ss/584/2015/level/1
1685
+ <br/>
1686
+ Inherits: <a href='#rfc2616'>RFC 2616 (HTTP/1.1)</a>
1687
+ <br/>Control-class: Technical<br/>Priority: P0<br/>Family: System and Communications Protection<br/>Family: System and Communications Protocols</i></p>
1688
+ <div class="requirement-description">
1689
+ <p id="_">I recommend <i>this</i>.</p>
1690
+ </div>
1691
+ <div class="requirement-description">
1692
+ <p id="_">As for the measurement targets,</p>
1693
+ </div>
1694
+ <div class="requirement-measurement-target">
1695
+ <p id="_">The measurement target shall be measured as:</p>
1696
+ <div id="_"><div class="formula"><p><span class="stem">(#(r/1 = 0)#)</span>&#160; (1)</p></div></div>
1697
+ </div>
1698
+ <div class="requirement-verification">
1699
+ <p id="_">The following code will be run for verification:</p>
1700
+ <pre id="_" class="prettyprint ">CoreRoot(success): HttpResponse<br/>&#160;&#160;&#160;&#160;&#160; if (success)<br/>&#160;&#160;&#160;&#160;&#160; recommendation(label: success-response)<br/>&#160;&#160;&#160;&#160;&#160; end<br/>&#160;&#160;&#160; </pre>
1701
+ </div>
2015
1702
  </div>
2016
- </div>
1703
+ </div>
1704
+ <p class="zzSTDTitle1"/>
1705
+ <br/>
1706
+ <div>
1707
+ <h1 class='Section3'>Bibliography</h1>
1708
+ <p id='rfc2616' class='Biblio'>
1709
+ [1]&#160; IETF RFC 2616,
1710
+ <i>Hypertext Transfer Protocol&#8201;&#8212;&#8201;HTTP/1.1</i>
1711
+ </p>
1712
+ </div>
2017
1713
  </div>
2018
- <p class="zzSTDTitle1"/>
2019
- <br/>
2020
- <div>
2021
- <h1 class='Section3'>Bibliography</h1>
2022
- <p id='rfc2616' class='Biblio'>
2023
- [1]&#160; IETF RFC 2616,
2024
- <i>Hypertext Transfer Protocol&#8201;&#8212;&#8201;HTTP/1.1</i>
2025
- </p>
2026
- </div>
2027
- </div>
2028
- </body>
2029
- </html>
1714
+ </body>
1715
+ </html>
2030
1716
  OUTPUT
1717
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
1718
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
2031
1719
  end
2032
1720
 
2033
1721
  it "processes requirements (Presentation XML)" do
@@ -2084,7 +1772,7 @@ RSpec.describe IsoDoc do
2084
1772
  <?xml version='1.0'?>
2085
1773
  <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
2086
1774
  <preface>
2087
- <foreword>
1775
+ <foreword displayorder="1">
2088
1776
  <requirement id='A' unnumbered='true' keep-with-next='true' keep-lines-together='true'>
2089
1777
  <name>Requirement</name>
2090
1778
  <title>A New Requirement</title>
@@ -2283,7 +1971,7 @@ RSpec.describe IsoDoc do
2283
1971
  <language current="true">fr</language>
2284
1972
  <script current="true">Latn</script>
2285
1973
  </bibdata>
2286
- <preface><foreword>
1974
+ <preface><foreword displayorder="1">
2287
1975
  <requirement id="A" unnumbered="true"><name>Exigence</name>
2288
1976
  <title>A New Requirement</title>
2289
1977
  <label>/ogc/recommendation/wfs/2</label>
@@ -2449,7 +2137,7 @@ RSpec.describe IsoDoc do
2449
2137
  <?xml version='1.0'?>
2450
2138
  <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
2451
2139
  <preface>
2452
- <foreword>
2140
+ <foreword displayorder="1">
2453
2141
  <recommendation id='_' obligation='shall,could' keep-with-next='true' keep-lines-together='true'>
2454
2142
  <name>Recommendation 1</name>
2455
2143
  <label>/ogc/recommendation/wfs/2</label>
@@ -2612,7 +2300,7 @@ RSpec.describe IsoDoc do
2612
2300
  <bibdata>
2613
2301
  <language current="true">en</language>
2614
2302
  </bibdata>
2615
- <preface><foreword>
2303
+ <preface><foreword displayorder="1">
2616
2304
  <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/>
2617
2305
  &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;<smallcap>B</smallcap></p>
2618
2306
  <p id="_">&#xA0;&#xA0;<em>C</em></p></figure>
@@ -2791,7 +2479,7 @@ RSpec.describe IsoDoc do
2791
2479
  </figure>
2792
2480
  </sections>
2793
2481
  <bibliography>
2794
- <references hidden='true' normative='false'>
2482
+ <references hidden='true' normative='false' displayorder="1">
2795
2483
  <bibitem id='express_action_schema' type='internal'>
2796
2484
  <docidentifier type='repository'>express/action_schema</docidentifier>
2797
2485
  </bibitem>