metanorma-iso 1.4.1 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/Rakefile +2 -0
  4. data/lib/asciidoctor/iso/base.rb +8 -19
  5. data/lib/asciidoctor/iso/cleanup.rb +2 -3
  6. data/lib/asciidoctor/iso/front.rb +0 -1
  7. data/lib/asciidoctor/iso/front_id.rb +1 -1
  8. data/lib/asciidoctor/iso/isodoc.rng +12 -6
  9. data/lib/asciidoctor/iso/section.rb +5 -11
  10. data/lib/asciidoctor/iso/term_lookup_cleanup.rb +0 -1
  11. data/lib/asciidoctor/iso/validate_section.rb +30 -44
  12. data/lib/isodoc/iso/base_convert.rb +3 -64
  13. data/lib/isodoc/iso/html/htmlstyle.css +47 -0
  14. data/lib/isodoc/iso/html/htmlstyle.scss +0 -1
  15. data/lib/isodoc/iso/html/isodoc.css +862 -0
  16. data/lib/isodoc/iso/html/isodoc.scss +0 -1
  17. data/lib/isodoc/iso/html/style-human.css +968 -0
  18. data/lib/isodoc/iso/html/style-iso.css +996 -0
  19. data/lib/isodoc/iso/html/wordstyle.css +1515 -0
  20. data/lib/isodoc/iso/html/wordstyle.scss +0 -1
  21. data/lib/isodoc/iso/html_convert.rb +2 -1
  22. data/lib/{asciidoctor → isodoc}/iso/i18n-en.yaml +0 -0
  23. data/lib/{asciidoctor → isodoc}/iso/i18n-fr.yaml +0 -0
  24. data/lib/{asciidoctor → isodoc}/iso/i18n-zh-Hans.yaml +0 -0
  25. data/lib/isodoc/iso/i18n.rb +19 -0
  26. data/lib/isodoc/iso/init.rb +33 -0
  27. data/lib/isodoc/iso/iso.amendment.xsl +1261 -1705
  28. data/lib/isodoc/iso/iso.international-standard.xsl +1261 -1705
  29. data/lib/isodoc/iso/metadata.rb +1 -1
  30. data/lib/isodoc/iso/presentation_xml_convert.rb +99 -1
  31. data/lib/isodoc/iso/sections.rb +3 -8
  32. data/lib/isodoc/iso/word_convert.rb +2 -1
  33. data/lib/isodoc/iso/xref.rb +2 -0
  34. data/lib/metanorma/iso/version.rb +1 -1
  35. data/metanorma-iso.gemspec +4 -3
  36. data/spec/asciidoctor-iso/cleanup_spec.rb +4 -4
  37. data/spec/asciidoctor-iso/inline_spec.rb +1 -1
  38. data/spec/asciidoctor-iso/refs_spec.rb +3 -3
  39. data/spec/asciidoctor-iso/section_spec.rb +9 -6
  40. data/spec/asciidoctor-iso/validate_spec.rb +13 -21
  41. data/spec/isodoc/amd_spec.rb +309 -153
  42. data/spec/isodoc/blocks_spec.rb +362 -28
  43. data/spec/isodoc/i18n_spec.rb +468 -108
  44. data/spec/isodoc/inline_spec.rb +99 -31
  45. data/spec/isodoc/iso_spec.rb +95 -29
  46. data/spec/isodoc/postproc_spec.rb +114 -149
  47. data/spec/isodoc/ref_spec.rb +175 -3
  48. data/spec/isodoc/section_spec.rb +148 -82
  49. data/spec/isodoc/table_spec.rb +142 -5
  50. data/spec/isodoc/terms_spec.rb +78 -53
  51. data/spec/isodoc/xref_spec.rb +831 -658
  52. data/spec/metanorma/processor_spec.rb +2 -1
  53. metadata +34 -13
@@ -3,7 +3,7 @@ require "isodoc"
3
3
  module IsoDoc
4
4
  module Iso
5
5
  class Metadata < IsoDoc::Metadata
6
- def initialize(lang, script, labels)
6
+ def initialize(lang, script, i18n)
7
7
  super
8
8
  @metadata = {
9
9
  tc: "XXXX",
@@ -1,4 +1,4 @@
1
- require_relative "base_convert"
1
+ require_relative "init"
2
2
  require "isodoc"
3
3
 
4
4
  module IsoDoc
@@ -8,6 +8,104 @@ module IsoDoc
8
8
  # schema encapsulation of the document for validation
9
9
  #
10
10
  class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
11
+ def initialize(options)
12
+ super
13
+ end
14
+
15
+ def convert1(docxml, filename, dir)
16
+ if amd(docxml)
17
+ @oldsuppressheadingnumbers = @suppressheadingnumbers
18
+ @suppressheadingnumbers = true
19
+ end
20
+ super
21
+ end
22
+
23
+ def annex(isoxml)
24
+ amd(isoxml) and @suppressheadingnumbers = @oldsuppressheadingnumbers
25
+ super
26
+ isoxml.xpath(ns("//annex//clause | //annex//appendix")).each do |f|
27
+ clause1(f)
28
+ end
29
+ amd(isoxml) and @suppressheadingnumbers = true
30
+ end
31
+
32
+ def xref_init(lang, script, klass, labels, options)
33
+ @xrefs = Xref.new(lang, script, klass, labels, options)
34
+ end
35
+
36
+ def figure1(f)
37
+ return if labelled_ancestor(f) && f.ancestors("figure").empty?
38
+ lbl = @xrefs.anchor(f['id'], :label, false) or return
39
+ figname = f.parent.name == "figure" ? "" : "#{@i18n.figure} "
40
+ connective = f.parent.name == "figure" ? "&nbsp; " : "&nbsp;&mdash; "
41
+ prefix_name(f, connective, l10n("#{figname}#{lbl}"), "name")
42
+ end
43
+
44
+ def example1(f)
45
+ n = @xrefs.get[f["id"]]
46
+ lbl = (n.nil? || n[:label].nil? || n[:label].empty?) ? @i18n.example :
47
+ l10n("#{@i18n.example} #{n[:label]}")
48
+ prefix_name(f, "&nbsp;&mdash; ", lbl, "name")
49
+ end
50
+
51
+ def eref_localities1_zh(target, type, from, to, delim)
52
+ subsection = from&.text&.match(/\./)
53
+ ret = (delim == ";") ? ";" : (type == "list") ? "" : delim
54
+ ret += " 第#{from.text}" if from
55
+ ret += "&ndash;#{to.text}" if to
56
+ loc = (@i18n.locality[type] || type.sub(/^locality:/, "").capitalize )
57
+ ret += " #{loc}" unless subsection && type == "clause" ||
58
+ type == "list" || target.match(/^IEV$|^IEC 60050-/)
59
+ ret += ")" if type == "list"
60
+ ret
61
+ end
62
+
63
+ def eref_localities1(target, type, from, to, delim, lang = "en")
64
+ return "" if type == "anchor"
65
+ subsection = from&.text&.match(/\./)
66
+ type = type.downcase
67
+ lang == "zh" and
68
+ return l10n(eref_localities1_zh(target, type, from, to, delim))
69
+ ret = (delim == ";") ? ";" : (type == "list") ? "" : delim
70
+ loc = @i18n.locality[type] || type.sub(/^locality:/, "").capitalize
71
+ ret += " #{loc}" unless subsection && type == "clause" ||
72
+ type == "list" || target.match(/^IEV$|^IEC 60050-/)
73
+ ret += " #{from.text}" if from
74
+ ret += "&ndash;#{to.text}" if to
75
+ ret += ")" if type == "list"
76
+ l10n(ret)
77
+ end
78
+
79
+ def prefix_container(container, linkend, target)
80
+ delim = @xrefs.anchor(target, :type) == "listitem" ? " " : ", "
81
+ l10n(@xrefs.anchor(container, :xref) + delim + linkend)
82
+ end
83
+
84
+ def example_span_label(node, div, name)
85
+ return if name.nil?
86
+ div.span **{ class: "example_label" } do |p|
87
+ name.children.each { |n| parse(n, div) }
88
+ end
89
+ end
90
+
91
+ def clause1(f)
92
+ if !f.at(ns("./title")) &&
93
+ !%w(sections preface bibliography).include?(f.parent.name)
94
+ f["inline-header"] = "true"
95
+ end
96
+ super
97
+ end
98
+
99
+ def clause(docxml)
100
+ docxml.xpath(ns("//clause[not(ancestor::annex)] | "\
101
+ "//terms | //definitions | //references | "\
102
+ "//preface/introduction[clause]")).
103
+ each do |f|
104
+ clause1(f)
105
+ end
106
+ end
107
+
108
+ include Init
11
109
  end
12
110
  end
13
111
  end
@@ -37,11 +37,10 @@ module IsoDoc
37
37
 
38
38
  def introduction(isoxml, out)
39
39
  f = isoxml.at(ns("//introduction")) || return
40
- num = f.at(ns(".//clause")) ? "0" : nil
41
40
  title_attr = { class: "IntroTitle" }
42
41
  page_break(out)
43
42
  out.div **{ class: "Section3", id: f["id"] } do |div|
44
- clause_name(num, @introduction_lbl, div, title_attr)
43
+ clause_name(nil, f.at(ns("./title")), div, title_attr)
45
44
  f.elements.each do |e|
46
45
  parse(e, div) unless e.name == "title"
47
46
  end
@@ -52,15 +51,11 @@ module IsoDoc
52
51
  f = isoxml.at(ns("//foreword")) || return
53
52
  page_break(out)
54
53
  out.div **attr_code(id: f["id"]) do |s|
55
- s.h1(**{ class: "ForewordTitle" }) { |h1| h1 << @foreword_lbl }
54
+ clause_name(nil, f.at(ns("./title")) || @i18n.foreword, s,
55
+ { class: "ForewordTitle" })
56
56
  f.elements.each { |e| parse(e, s) unless e.name == "title" }
57
57
  end
58
58
  end
59
-
60
- def clause_parse_title(node, div, c1, out)
61
- return inline_header_title(out, node, c1) if c1.nil?
62
- super
63
- end
64
59
  end
65
60
  end
66
61
  end
@@ -1,6 +1,6 @@
1
1
  require_relative "base_convert"
2
2
  require "isodoc"
3
- require_relative "metadata"
3
+ require_relative "init"
4
4
 
5
5
  module IsoDoc
6
6
  module Iso
@@ -121,6 +121,7 @@ module IsoDoc
121
121
  end
122
122
 
123
123
  include BaseConvert
124
+ include Init
124
125
  end
125
126
  end
126
127
  end
@@ -21,6 +21,8 @@ module IsoDoc
21
21
  # we can reference 0-number clauses in introduction
22
22
  def introduction_names(clause)
23
23
  return if clause.nil?
24
+ clause.at(ns("./clause")) and @anchors[clause["id"]] =
25
+ { label: "0", level: 1, xref: clause.at(ns("./title"))&.text, type: "clause" }
24
26
  clause.xpath(ns("./clause")).each_with_index do |c, i|
25
27
  section_names1(c, "0.#{i + 1}", 2)
26
28
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "1.4.1".freeze
3
+ VERSION = "1.5.1".freeze
4
4
  end
5
5
  end
@@ -30,17 +30,18 @@ Gem::Specification.new do |spec|
30
30
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
31
31
 
32
32
  spec.add_dependency "ruby-jing"
33
- spec.add_dependency "isodoc", "~> 1.1.0"
34
- spec.add_dependency "metanorma-standoc", "~> 1.4.0"
33
+ spec.add_dependency "isodoc", "~> 1.2.0"
34
+ spec.add_dependency "metanorma-standoc", "~> 1.5.0"
35
35
  spec.add_dependency "tokenizer", "~> 0.3.0"
36
36
  spec.add_dependency "twitter_cldr"
37
37
  spec.add_dependency "mn2sts", "~> 1.2.0"
38
38
 
39
39
  spec.add_development_dependency "byebug"
40
+ spec.add_development_dependency "sassc", "2.4.0"
40
41
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
41
42
  spec.add_development_dependency "guard", "~> 2.14"
42
43
  spec.add_development_dependency "guard-rspec", "~> 4.7"
43
- spec.add_development_dependency "rake", "~> 12.0"
44
+ spec.add_development_dependency "rake" #, "~> 12.0"
44
45
  spec.add_development_dependency "rspec", "~> 3.6"
45
46
  spec.add_development_dependency "rubocop", "= 0.54.0"
46
47
  spec.add_development_dependency "simplecov", "~> 0.15"
@@ -190,7 +190,7 @@ RSpec.describe Asciidoctor::ISO do
190
190
  </p>
191
191
  </foreword></preface><sections>
192
192
  </sections><bibliography><references id="_" obligation="informative" normative="true">
193
- <title>Normative References</title>
193
+ <title>Normative references</title>
194
194
  <p id="_">The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
195
195
  <bibitem id="iso216" type="standard">
196
196
  <title format="text/plain">Reference</title>
@@ -233,7 +233,7 @@ RSpec.describe Asciidoctor::ISO do
233
233
  </p>
234
234
  </foreword></preface><sections>
235
235
  </sections><bibliography><references id="_" obligation="informative" normative="true">
236
- <title>Normative References</title>
236
+ <title>Normative references</title>
237
237
  <p id="_">The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
238
238
  <bibitem id="iso216" type="standard">
239
239
  <title format="text/plain">Reference</title>
@@ -333,7 +333,7 @@ RSpec.describe Asciidoctor::ISO do
333
333
  INPUT
334
334
  #{BLANK_HDR}
335
335
  <sections></sections>
336
- <bibliography><references id="_" obligation="informative" normative="true"><title>Normative References</title>
336
+ <bibliography><references id="_" obligation="informative" normative="true"><title>Normative references</title>
337
337
  <p id="_">The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
338
338
  <bibitem id="iso216" type="standard">
339
339
  <title format="text/plain">Reference</title>
@@ -638,7 +638,7 @@ RSpec.describe Asciidoctor::ISO do
638
638
  </fn>
639
639
  </p>
640
640
  </clause></sections><bibliography><references id="_" obligation="informative" normative="true">
641
- <title>Normative References</title>
641
+ <title>Normative references</title>
642
642
  <p id="_">The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
643
643
  <bibitem id="iso123" type="standard">
644
644
  <title format="text/plain">Standard</title>
@@ -128,7 +128,7 @@ RSpec.describe Asciidoctor::ISO do
128
128
  <sections>
129
129
 
130
130
  </sections><bibliography><references id="_" obligation="informative" normative="true">
131
- <title>Normative References</title>
131
+ <title>Normative references</title>
132
132
  <p id="_">The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
133
133
  <bibitem id="ISO712">
134
134
  <formattedref format="application/x-isodoc+xml">Reference</formattedref>
@@ -16,7 +16,7 @@ RSpec.describe Asciidoctor::ISO do
16
16
  #{BLANK_HDR}
17
17
  <sections>
18
18
  </sections><bibliography><references id="_" obligation="informative" normative="true">
19
- <title>Normative References</title>
19
+ <title>Normative references</title>
20
20
  <p id="_">The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
21
21
  <bibitem id="iso123" type="standard">
22
22
  <title format="text/plain">Standard</title>
@@ -65,7 +65,7 @@ RSpec.describe Asciidoctor::ISO do
65
65
  </clause>
66
66
  </sections>
67
67
  <bibliography><references id="_" obligation="informative" normative="true">
68
- <title>Normative References</title>
68
+ <title>Normative references</title>
69
69
  <p id="_">The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
70
70
  <bibitem id="iso123" type="standard">
71
71
  <title format="text/plain">Standard</title>
@@ -101,7 +101,7 @@ RSpec.describe Asciidoctor::ISO do
101
101
  <sections>
102
102
 
103
103
  </sections><bibliography><references id="_" obligation="informative" normative="true">
104
- <title>Normative References</title>
104
+ <title>Normative references</title>
105
105
  <p id="_">The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
106
106
  <bibitem id="iso123">
107
107
  <formattedref format="application/x-isodoc+xml">
@@ -66,7 +66,7 @@ RSpec.describe Asciidoctor::ISO do
66
66
  <title>Acknowledgements</title>
67
67
  </acknowledgements>
68
68
  </preface><sections>
69
- <clause id="_" obligation="normative">
69
+ <clause id="_" obligation="normative" inline-header='false' type="scope">
70
70
  <title>Scope</title>
71
71
  <p id="_">Text</p>
72
72
  </clause>
@@ -88,7 +88,9 @@ standardization at the following addresses:</p>
88
88
  <preferred>Term1</preferred>
89
89
  </term>
90
90
  </terms>
91
- <clause id="_" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title><terms id="_" obligation="normative">
91
+ <clause id="_" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title>
92
+ <terms id="_" obligation="normative">
93
+ <title>Normal Terms</title>
92
94
  <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
93
95
  <p id='_'>
94
96
  ISO and IEC maintain terminological databases for use in
@@ -108,13 +110,14 @@ standardization at the following addresses:</p>
108
110
  </p>
109
111
  </li>
110
112
  </ul>
111
- <title>Normal Terms</title>
112
113
  <term id="term-term2">
113
114
  <preferred>Term2</preferred>
114
115
  </term>
115
116
  </terms>
116
- <definitions id="_"><title>Symbols and Abbreviated Terms</title></definitions></clause>
117
- <definitions id="_"><title>Symbols and Abbreviated Terms</title></definitions>
117
+ <definitions id="_" obligation="normative">
118
+ <title>Symbols and abbreviated terms</title></definitions></clause>
119
+ <definitions id="_" obligation="normative">
120
+ <title>Symbols and abbreviated terms</title></definitions>
118
121
  <clause id="_" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="_" inline-header="false" obligation="normative">
119
122
  <title>Introduction</title>
120
123
  </clause>
@@ -134,7 +137,7 @@ standardization at the following addresses:</p>
134
137
  <appendix id="_" inline-header="false" obligation="normative">
135
138
  <title>Appendix 1</title>
136
139
  </appendix></annex><bibliography><references id="_" obligation="informative" normative="true">
137
- <title>Normative References</title>
140
+ <title>Normative references</title>
138
141
  <p id="_">There are no normative references in this document.</p>
139
142
  </references><clause id="_" obligation="informative">
140
143
  <title>Bibliography</title>
@@ -527,7 +527,7 @@ it "Style warning if Symbols and Abbreviated Terms contains extraneous matter" d
527
527
  expect(File.read("test.err")).to include "Symbols and Abbreviated Terms can only contain a definition list"
528
528
  end
529
529
 
530
- it "Warning if do not start with scope or introduction" do
530
+ it "Warning if missing foreword" do
531
531
  FileUtils.rm_f "test.err"
532
532
  Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
533
533
  #{VALIDATING_BLANK_HDR}
@@ -536,19 +536,15 @@ it "Warning if do not start with scope or introduction" do
536
536
 
537
537
  Paragraph
538
538
  INPUT
539
- expect(File.read("test.err")).to include "Prefatory material must be followed by (clause) Scope"
539
+ expect(File.read("test.err")).to include "Initial section must be (content) Foreword"
540
540
  end
541
541
 
542
- it "Warning if introduction not followed by scope" do
542
+ it "Warning if do not start with scope or introduction" do
543
543
  FileUtils.rm_f "test.err"
544
544
  Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
545
545
  #{VALIDATING_BLANK_HDR}
546
-
547
- .Foreword
548
546
  Foreword
549
547
 
550
- == Introduction
551
-
552
548
  == Symbols and Abbreviated Terms
553
549
 
554
550
  Paragraph
@@ -556,7 +552,7 @@ it "Warning if introduction not followed by scope" do
556
552
  expect(File.read("test.err")).to include "Prefatory material must be followed by (clause) Scope"
557
553
  end
558
554
 
559
- it "Warning if normative references not followed by terms and definitions" do
555
+ it "Warning if introduction not followed by scope" do
560
556
  FileUtils.rm_f "test.err"
561
557
  Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
562
558
  #{VALIDATING_BLANK_HDR}
@@ -564,19 +560,16 @@ it "Warning if normative references not followed by terms and definitions" do
564
560
  .Foreword
565
561
  Foreword
566
562
 
567
- == Scope
568
-
569
- [bibliography]
570
- == Normative References
563
+ == Introduction
571
564
 
572
565
  == Symbols and Abbreviated Terms
573
566
 
574
567
  Paragraph
575
568
  INPUT
576
- expect(File.read("test.err")).to include "Normative References must be followed by Terms and Definitions"
569
+ expect(File.read("test.err")).to include "Prefatory material must be followed by (clause) Scope"
577
570
  end
578
571
 
579
- it "Warning if there are no clauses in the document" do
572
+ it "Warning if normative references not followed by terms and definitions" do
580
573
  FileUtils.rm_f "test.err"
581
574
  Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
582
575
  #{VALIDATING_BLANK_HDR}
@@ -589,20 +582,19 @@ it "Warning if there are no clauses in the document" do
589
582
  [bibliography]
590
583
  == Normative References
591
584
 
592
- == Terms and Definitions
593
-
594
585
  == Symbols and Abbreviated Terms
595
586
 
587
+ Paragraph
596
588
  INPUT
597
- expect(File.read("test.err")).to include "Document must contain clause after Terms and Definitions"
589
+ expect(File.read("test.err")).to include "Normative References must be followed by Terms and Definitions"
598
590
  end
599
591
 
600
- it "Warning if scope occurs after Terms and Definitions" do
592
+ it "Warning if there are no clauses in the document" do
601
593
  FileUtils.rm_f "test.err"
602
594
  Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
603
595
  #{VALIDATING_BLANK_HDR}
604
596
 
605
- .Foreword
597
+ .Foreword
606
598
  Foreword
607
599
 
608
600
  == Scope
@@ -612,10 +604,10 @@ it "Warning if scope occurs after Terms and Definitions" do
612
604
 
613
605
  == Terms and Definitions
614
606
 
615
- == Scope
607
+ == Symbols and Abbreviated Terms
616
608
 
617
609
  INPUT
618
- expect(File.read("test.err")).to include "Scope must occur before Terms and Definitions"
610
+ expect(File.read("test.err")).to include "Document must contain at least one clause"
619
611
  end
620
612
 
621
613
  it "Warning if scope occurs after Terms and Definitions" do
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  RSpec.describe IsoDoc do
4
4
  it "cross-references notes in amendments" do
5
- expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
5
+ expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
6
6
  <iso-standard xmlns="http://riboseinc.com/isoxml">
7
7
  <bibdata> <ext> <doctype>amendment</doctype> </ext> </bibdata>
8
8
  <preface>
@@ -56,66 +56,104 @@ RSpec.describe IsoDoc do
56
56
  </annex>
57
57
  </iso-standard>
58
58
  INPUT
59
- #{HTML_HDR}
60
- <br/>
61
- <div>
62
- <h1 class="ForewordTitle">Foreword</h1>
63
- <p>
64
- <a href="#N">[N]</a>
65
- <a href="#note1">[note1]</a>
66
- <a href="#note2">[note2]</a>
67
- <a href="#AN">A.1, Note</a>
68
- <a href="#Anote1">A.2, Note 1</a>
69
- <a href="#Anote2">A.2, Note 2</a>
70
- </p>
71
- </div>
72
- <p class="zzSTDTitle1"/>
73
- <div id="scope">
74
- <h1>Scope</h1>
75
- <div id="N" class="Note">
76
- <p><span class="note_label">NOTE</span>&#160; These results are based on a study carried out on three different types of kernel.</p>
77
- </div>
78
- <p>
79
- <a href="#N">[n]</a>
80
- </p>
81
- </div>
82
- <div id="terms"><h1/>
83
- </div>
84
- <div id="widgets">
85
- <h1>Widgets</h1>
86
- <div id="widgets1"><span class='zzMoveToFollowing'><b/></span>
87
- <div id="note1" class="Note"><p><span class="note_label">NOTE</span>&#160; These results are based on a study carried out on three different types of kernel.</p></div>
88
- <div id="note2" class="Note"><p><span class="note_label">NOTE</span>&#160; These results are based on a study carried out on three different types of kernel.</p></div>
89
- <p> <a href="#note1">[note1]</a> <a href="#note2">[note2]</a> </p>
90
-
91
- </div>
92
- </div>
93
- <br/>
94
- <div id="annex1" class="Section3">
95
- <h1 class='Annex'>
96
- <b>Annex A</b>
59
+ <?xml version='1.0'?>
60
+ <iso-standard xmlns='http://riboseinc.com/isoxml'>
61
+ <bibdata>
62
+ <ext>
63
+ <doctype>amendment</doctype>
64
+ </ext>
65
+ </bibdata>
66
+ <preface>
67
+ <foreword>
68
+ <p>
69
+ <xref target='N'>[N]</xref>
70
+ <xref target='note1'>[note1]</xref>
71
+ <xref target='note2'>[note2]</xref>
72
+ <xref target='AN'>A.1, Note</xref>
73
+ <xref target='Anote1'>A.2, Note 1</xref>
74
+ <xref target='Anote2'>A.2, Note 2</xref>
75
+ </p>
76
+ </foreword>
77
+ </preface>
78
+ <sections>
79
+ <clause id='scope'>
80
+ <title depth="1">Scope</title>
81
+ <note id='N'>
82
+ <name>NOTE</name>
83
+ <p id='_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f'>
84
+ These results are based on a study carried out on three different
85
+ types of kernel.
86
+ </p>
87
+ </note>
88
+ <p>
89
+ <xref target='N'>[n]</xref>
90
+ </p>
91
+ </clause>
92
+ <terms id='terms'/>
93
+ <clause id='widgets'>
94
+ <title depth="1">Widgets</title>
95
+ <clause id='widgets1' inline-header="true">
96
+ <note id='note1'>
97
+ <name>NOTE</name>
98
+ <p id='_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f'>
99
+ These results are based on a study carried out on three different
100
+ types of kernel.
101
+ </p>
102
+ </note>
103
+ <note id='note2'>
104
+ <name>NOTE</name>
105
+ <p id='_f06fd0d1-a203-4f3d-a515-0bdba0f8d83a'>
106
+ These results are based on a study carried out on three different
107
+ types of kernel.
108
+ </p>
109
+ </note>
110
+ <p>
111
+ <xref target='note1'>[note1]</xref>
112
+ <xref target='note2'>[note2]</xref>
113
+ </p>
114
+ </clause>
115
+ </clause>
116
+ </sections>
117
+ <annex id='annex1'>
118
+ <title>
119
+ <strong>Annex A</strong>
97
120
  <br/>
98
121
  (informative)
99
- <br/>
100
- <br/>
101
- <b/>
102
- </h1>
103
- <div id="annex1a"><span class='zzMoveToFollowing'><b>A.1&#160; </b></span>
104
- <div id="AN" class="Note"><p><span class="note_label">NOTE</span>&#160; These results are based on a study carried out on three different types of kernel.</p></div>
105
- </div>
106
- <div id="annex1b"><span class='zzMoveToFollowing'><b>A.2&#160; </b></span>
107
- <div id="Anote1" class="Note"><p><span class="note_label">NOTE 1</span>&#160; These results are based on a study carried out on three different types of kernel.</p></div>
108
- <div id="Anote2" class="Note"><p><span class="note_label">NOTE 2</span>&#160; These results are based on a study carried out on three different types of kernel.</p></div>
109
- </div>
110
- </div>
111
- </div>
112
- </body>
113
- </html>
122
+ </title>
123
+ <clause id='annex1a' inline-header='true'>
124
+ <title>A.1</title>
125
+ <note id='AN'>
126
+ <name>NOTE</name>
127
+ <p id='_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f'>
128
+ These results are based on a study carried out on three different
129
+ types of kernel.
130
+ </p>
131
+ </note>
132
+ </clause>
133
+ <clause id='annex1b' inline-header="true">
134
+ <title>A.2</title>
135
+ <note id='Anote1'>
136
+ <name>NOTE 1</name>
137
+ <p id='_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f'>
138
+ These results are based on a study carried out on three different
139
+ types of kernel.
140
+ </p>
141
+ </note>
142
+ <note id='Anote2'>
143
+ <name>NOTE 2</name>
144
+ <p id='_f06fd0d1-a203-4f3d-a515-0bdba0f8d83a'>
145
+ These results are based on a study carried out on three different
146
+ types of kernel.
147
+ </p>
148
+ </note>
149
+ </clause>
150
+ </annex>
151
+ </iso-standard>
114
152
  OUTPUT
115
153
  end
116
154
 
117
155
  it "cross-references sections" do
118
- expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
156
+ expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
119
157
  <iso-standard xmlns="http://riboseinc.com/isoxml">
120
158
  <bibdata> <ext> <doctype>amendment</doctype> </ext> </bibdata>
121
159
  <preface>
@@ -145,7 +183,7 @@ RSpec.describe IsoDoc do
145
183
  </clause>
146
184
  <clause id="C1" inline-header="false" obligation="informative">Text</clause>
147
185
  </introduction></preface><sections>
148
- <clause id="D" obligation="normative">
186
+ <clause id="D" obligation="normative" type="scope">
149
187
  <title>Scope</title>
150
188
  <p id="E">Text</p>
151
189
  </clause>
@@ -179,85 +217,107 @@ RSpec.describe IsoDoc do
179
217
  </bibliography>
180
218
  </iso-standard>
181
219
  INPUT
182
- #{HTML_HDR}
183
- <br/>
184
- <div>
185
- <h1 class="ForewordTitle">Foreword</h1>
186
- <p id="A">This is a preamble
187
- <a href='#C'>[C]</a>
188
- <a href='#C1'>[C1]</a>
189
- <a href='#D'>[D]</a>
190
- <a href='#H'>[H]</a>
191
- <a href='#I'>[I]</a>
192
- <a href='#J'>[J]</a>
193
- <a href='#K'>[K]</a>
194
- <a href='#L'>[L]</a>
195
- <a href='#M'>[M]</a>
196
- <a href='#N'>[N]</a>
197
- <a href='#O'>[O]</a>
198
- <a href='#P'>Annex A</a>
199
- <a href='#Q'>A.1</a>
200
- <a href='#Q1'>A.1.1</a>
201
- <a href='#Q2'>Annex A, Appendix 1</a>
202
- <a href='#R'>[R]</a>
203
- </p>
204
- </div>
205
- <br/>
206
- <div class="Section3" id="B">
207
- <h1 class="IntroTitle">Introduction</h1>
208
- <div id="C">
209
- <h1>Introduction Subsection</h1>
210
- </div>
211
- <div id="C1"><span class='zzMoveToFollowing'>
212
- <b/>
213
- </span>
214
- Text</div>
215
- </div>
216
- <p class="zzSTDTitle1"/>
217
- <div id="D">
218
- <h1>Scope</h1>
219
- <p id="E">Text</p>
220
- </div>
221
- <div>
222
- <h1>Normative references</h1>
223
- </div>
224
- <div id="M">
225
- <h1>Clause 4</h1>
226
- <div id="N">
227
- <h1>Introduction</h1>
228
- </div>
229
- <div id="O">
230
- <h1>Clause 4.2</h1>
231
- </div>
232
- </div>
233
- <br/>
234
- <div id="P" class="Section3">
235
- <h1 class="Annex"><b>Annex A</b><br/>(normative)<br/><br/><b>Annex</b></h1>
236
- <div id="Q">
237
- <h2>A.1&#160; Annex A.1</h2>
238
- <div id="Q1">
239
- <h3>A.1.1&#160; Annex A.1a</h3>
240
- </div>
241
- </div>
242
- <div id="Q2">
243
- <h2>Appendix 1&#160; An Appendix</h2>
244
- </div>
245
- </div>
246
- <br/>
247
- <div>
248
- <h1 class="Section3">Bibliography</h1>
249
- <div>
250
- <h2 class="Section3">Bibliography Subsection</h2>
251
- </div>
252
- </div>
253
- </div>
254
- </body>
255
- </html>
220
+ <?xml version='1.0'?>
221
+ <iso-standard xmlns='http://riboseinc.com/isoxml'>
222
+ <bibdata>
223
+ <ext>
224
+ <doctype>amendment</doctype>
225
+ </ext>
226
+ </bibdata>
227
+ <preface>
228
+ <foreword obligation='informative'>
229
+ <title>Foreword</title>
230
+ <p id='A'>
231
+ This is a preamble
232
+ <xref target='C'>[C]</xref>
233
+ <xref target='C1'>[C1]</xref>
234
+ <xref target='D'>[D]</xref>
235
+ <xref target='H'>[H]</xref>
236
+ <xref target='I'>[I]</xref>
237
+ <xref target='J'>[J]</xref>
238
+ <xref target='K'>[K]</xref>
239
+ <xref target='L'>[L]</xref>
240
+ <xref target='M'>[M]</xref>
241
+ <xref target='N'>[N]</xref>
242
+ <xref target='O'>[O]</xref>
243
+ <xref target='P'>Annex A</xref>
244
+ <xref target='Q'>A.1</xref>
245
+ <xref target='Q1'>A.1.1</xref>
246
+ <xref target='Q2'>Annex A, Appendix 1</xref>
247
+ <xref target='R'>[R]</xref>
248
+ </p>
249
+ </foreword>
250
+ <introduction id='B' obligation='informative'>
251
+ <title depth="1">Introduction</title>
252
+ <clause id='C' inline-header='false' obligation='informative'>
253
+ <title depth="1">Introduction Subsection</title>
254
+ </clause>
255
+ <clause id='C1' inline-header='true' obligation='informative'>Text</clause>
256
+ </introduction>
257
+ </preface>
258
+ <sections>
259
+ <clause id='D' obligation='normative' type="scope">
260
+ <title depth="1">Scope</title>
261
+ <p id='E'>Text</p>
262
+ </clause>
263
+ <clause id='M' inline-header='false' obligation='normative'>
264
+ <title depth="1">Clause 4</title>
265
+ <clause id='N' inline-header='false' obligation='normative'>
266
+ <title depth="1">Introduction</title>
267
+ </clause>
268
+ <clause id='O' inline-header='false' obligation='normative'>
269
+ <title depth="1">Clause 4.2</title>
270
+ </clause>
271
+ </clause>
272
+ </sections>
273
+ <annex id='P' inline-header='false' obligation='normative'>
274
+ <title>
275
+ <strong>Annex A</strong>
276
+ <br/>
277
+ (normative)
278
+ <br/>
279
+ <br/>
280
+ <strong>Annex</strong>
281
+ </title>
282
+ <clause id='Q' inline-header='false' obligation='normative'>
283
+ <title depth='2'>
284
+ A.1
285
+ <tab/>
286
+ Annex A.1
287
+ </title>
288
+ <clause id='Q1' inline-header='false' obligation='normative'>
289
+ <title depth='3'>
290
+ A.1.1
291
+ <tab/>
292
+ Annex A.1a
293
+ </title>
294
+ </clause>
295
+ </clause>
296
+ <appendix id='Q2' inline-header='false' obligation='normative'>
297
+ <title depth='2'>
298
+ Appendix 1
299
+ <tab/>
300
+ An Appendix
301
+ </title>
302
+ </appendix>
303
+ </annex>
304
+ <bibliography>
305
+ <references id='R' obligation='informative' normative='true'>
306
+ <title depth="1">Normative References</title>
307
+ </references>
308
+ <clause id='S' obligation='informative'>
309
+ <title depth="1">Bibliography</title>
310
+ <references id='T' obligation='informative' normative='false'>
311
+ <title depth="2">Bibliography Subsection</title>
312
+ </references>
313
+ </clause>
314
+ </bibliography>
315
+ </iso-standard>
256
316
  OUTPUT
257
317
  end
258
318
 
259
319
  it "processes section names" do
260
- expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
320
+ input = <<~INPUT
261
321
  <iso-standard xmlns="http://riboseinc.com/isoxml">
262
322
  <bibdata> <ext> <doctype>amendment</doctype> </ext> </bibdata>
263
323
  <boilerplate>
@@ -284,7 +344,7 @@ Text</div>
284
344
  </boilerplate>
285
345
  <preface>
286
346
  <abstract obligation="informative">
287
- <title>Foreword</title>
347
+ <title>Abstract</title>
288
348
  </abstract>
289
349
  <foreword obligation="informative">
290
350
  <title>Foreword</title>
@@ -300,11 +360,6 @@ Text</div>
300
360
  <title>Acknowledgements</title>
301
361
  </acknowledgements>
302
362
  </preface><sections>
303
- <clause id="D" obligation="normative">
304
- <title>Scope</title>
305
- <p id="E">Text</p>
306
- </clause>
307
-
308
363
  <clause id="M" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
309
364
  <title>Introduction</title>
310
365
  </clause>
@@ -314,7 +369,10 @@ Text</div>
314
369
  <clause id="O1" inline-header="false" obligation="normative">
315
370
  </clause>
316
371
  </clause>
317
-
372
+ <clause id="D" obligation="normative">
373
+ <title>Scope</title>
374
+ <p id="E">Text</p>
375
+ </clause>
318
376
  </sections><annex id="P" inline-header="false" obligation="normative">
319
377
  <title>Annex</title>
320
378
  <clause id="Q" inline-header="false" obligation="normative">
@@ -322,7 +380,6 @@ Text</div>
322
380
  <clause id="Q1" inline-header="false" obligation="normative">
323
381
  <title>Annex A.1a</title>
324
382
  </clause>
325
- <references id="Q2" normative="false"><title>Annex Bibliography</title></references>
326
383
  </clause>
327
384
  </annex>
328
385
  <annex id="P1" inline-header="false" obligation="normative">
@@ -338,6 +395,112 @@ Text</div>
338
395
  </bibliography>
339
396
  </iso-standard>
340
397
  INPUT
398
+ presxml = <<~OUTPUT
399
+ <iso-standard xmlns='http://riboseinc.com/isoxml'>
400
+ <bibdata>
401
+ <ext>
402
+ <doctype>amendment</doctype>
403
+ </ext>
404
+ </bibdata>
405
+ <boilerplate>
406
+ <copyright-statement>
407
+ <clause>
408
+ <title depth="1">Copyright</title>
409
+ </clause>
410
+ </copyright-statement>
411
+ <license-statement>
412
+ <clause>
413
+ <title depth="1">License</title>
414
+ </clause>
415
+ </license-statement>
416
+ <legal-statement>
417
+ <clause>
418
+ <title depth="1">Legal</title>
419
+ </clause>
420
+ </legal-statement>
421
+ <feedback-statement>
422
+ <clause>
423
+ <title depth="1">Feedback</title>
424
+ </clause>
425
+ </feedback-statement>
426
+ </boilerplate>
427
+ <preface>
428
+ <abstract obligation='informative'>
429
+ <title>Abstract</title>
430
+ </abstract>
431
+ <foreword obligation='informative'>
432
+ <title>Foreword</title>
433
+ <p id='A'>This is a preamble</p>
434
+ </foreword>
435
+ <introduction id='B' obligation='informative'>
436
+ <title depth='1'>Introduction</title>
437
+ <clause id='C' inline-header='false' obligation='informative'>
438
+ <title depth='1'>Introduction Subsection</title>
439
+ </clause>
440
+ </introduction>
441
+ <clause id='B1'>
442
+ <title depth='1'>Dedication</title>
443
+ </clause>
444
+ <clause id='B2'>
445
+ <title depth='1'>Note to reader</title>
446
+ </clause>
447
+ <acknowledgements obligation='informative'>
448
+ <title>Acknowledgements</title>
449
+ </acknowledgements>
450
+ </preface>
451
+ <sections>
452
+ <clause id='M' inline-header='false' obligation='normative'>
453
+ <title depth='1'>Clause 4</title>
454
+ <clause id='N' inline-header='false' obligation='normative'>
455
+ <title depth='1'>Introduction</title>
456
+ </clause>
457
+ <clause id='O' inline-header='false' obligation='normative'>
458
+ <title depth='1'>Clause 4.2</title>
459
+ </clause>
460
+ <clause id='O1' inline-header='true' obligation='normative'> </clause>
461
+ </clause>
462
+ <clause id='D' obligation='normative'>
463
+ <title depth='1'>Scope</title>
464
+ <p id='E'>Text</p>
465
+ </clause>
466
+ </sections>
467
+ <annex id='P' inline-header='false' obligation='normative'>
468
+ <title>
469
+ <strong>Annex A</strong>
470
+ <br/>
471
+ (normative)
472
+ <br/>
473
+ <br/>
474
+ <strong>Annex</strong>
475
+ </title>
476
+ <clause id='Q' inline-header='false' obligation='normative'>
477
+ <title depth='2'>A.1<tab/>Annex A.1</title>
478
+ <clause id='Q1' inline-header='false' obligation='normative'>
479
+ <title depth='3'>A.1.1<tab/>Annex A.1a</title>
480
+ </clause>
481
+ </clause>
482
+ </annex>
483
+ <annex id='P1' inline-header='false' obligation='normative'>
484
+ <title>
485
+ <strong>Annex B</strong>
486
+ <br/>
487
+ (normative)
488
+ </title>
489
+ </annex>
490
+ <bibliography>
491
+ <references id='R' obligation='informative' normative='true'>
492
+ <title depth='1'>Normative References</title>
493
+ </references>
494
+ <clause id='S' obligation='informative'>
495
+ <title depth='1'>Bibliography</title>
496
+ <references id='T' obligation='informative' normative='false'>
497
+ <title depth='2'>Bibliography Subsection</title>
498
+ </references>
499
+ </clause>
500
+ </bibliography>
501
+ </iso-standard>
502
+ OUTPUT
503
+ html = <<~OUTPUT
341
504
  <html xmlns:epub='http://www.idpf.org/2007/ops' lang='en'>
342
505
  <head/>
343
506
  <body lang='en'>
@@ -401,12 +564,8 @@ Text</div>
401
564
  <h1 class='IntroTitle'>Acknowledgements</h1>
402
565
  </div>
403
566
  <p class='zzSTDTitle1'/>
404
- <div id='D'>
405
- <h1>Scope</h1>
406
- <p id='E'>Text</p>
407
- </div>
408
567
  <div>
409
- <h1>Normative references</h1>
568
+ <h1>Normative References</h1>
410
569
  </div>
411
570
  <div id='M'>
412
571
  <h1>Clause 4</h1>
@@ -417,11 +576,12 @@ Text</div>
417
576
  <h1>Clause 4.2</h1>
418
577
  </div>
419
578
  <div id='O1'>
420
- <span class='zzMoveToFollowing'>
421
- <b/>
422
- </span>
423
579
  </div>
424
580
  </div>
581
+ <div id='D'>
582
+ <h1>Scope</h1>
583
+ <p id='E'>Text</p>
584
+ </div>
425
585
  <br/>
426
586
  <div id='P' class='Section3'>
427
587
  <h1 class='Annex'>
@@ -437,9 +597,6 @@ Text</div>
437
597
  <div id='Q1'>
438
598
  <h3>A.1.1&#160; Annex A.1a</h3>
439
599
  </div>
440
- <div>
441
- <h3>A.1.2&#160; Annex Bibliography</h3>
442
- </div>
443
600
  </div>
444
601
  </div>
445
602
  <br/>
@@ -448,9 +605,6 @@ Text</div>
448
605
  <b>Annex B</b>
449
606
  <br/>
450
607
  (normative)
451
- <br/>
452
- <br/>
453
- <b/>
454
608
  </h1>
455
609
  </div>
456
610
  <br/>
@@ -464,6 +618,8 @@ Text</div>
464
618
  </body>
465
619
  </html>
466
620
  OUTPUT
621
+ expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
622
+ expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
467
623
  end
468
624
 
469
625
  it "processes IsoXML metadata" do