metanorma-iso 1.7.4 → 1.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +3 -13
  3. data/.hound.yml +3 -1
  4. data/.rubocop.yml +3 -7
  5. data/lib/asciidoctor/iso/base.rb +14 -11
  6. data/lib/asciidoctor/iso/biblio.rng +1 -0
  7. data/lib/asciidoctor/iso/cleanup.rb +40 -24
  8. data/lib/asciidoctor/iso/front.rb +28 -16
  9. data/lib/asciidoctor/iso/front_id.rb +66 -50
  10. data/lib/asciidoctor/iso/isodoc.rng +321 -4
  11. data/lib/asciidoctor/iso/isostandard-amd.rng +3 -0
  12. data/lib/asciidoctor/iso/isostandard.rng +12 -0
  13. data/lib/asciidoctor/iso/section.rb +2 -1
  14. data/lib/asciidoctor/iso/validate.rb +22 -110
  15. data/lib/asciidoctor/iso/validate_image.rb +97 -0
  16. data/lib/asciidoctor/iso/validate_requirements.rb +26 -20
  17. data/lib/asciidoctor/iso/validate_section.rb +55 -29
  18. data/lib/asciidoctor/iso/validate_style.rb +36 -24
  19. data/lib/asciidoctor/iso/validate_title.rb +2 -4
  20. data/lib/isodoc/iso/base_convert.rb +8 -2
  21. data/lib/isodoc/iso/html/style-human.css +7 -0
  22. data/lib/isodoc/iso/html/style-iso.css +7 -0
  23. data/lib/isodoc/iso/html_convert.rb +0 -1
  24. data/lib/isodoc/iso/iso.amendment.xsl +680 -198
  25. data/lib/isodoc/iso/iso.international-standard.xsl +680 -198
  26. data/lib/isodoc/iso/metadata.rb +1 -0
  27. data/lib/isodoc/iso/presentation_xml_convert.rb +44 -33
  28. data/lib/isodoc/iso/sts_convert.rb +10 -13
  29. data/lib/isodoc/iso/word_convert.rb +0 -1
  30. data/lib/isodoc/iso/xref.rb +52 -34
  31. data/lib/metanorma/iso/processor.rb +1 -0
  32. data/lib/metanorma/iso/version.rb +1 -1
  33. data/metanorma-iso.gemspec +7 -7
  34. data/spec/asciidoctor/base_spec.rb +426 -305
  35. data/spec/asciidoctor/blocks_spec.rb +96 -34
  36. data/spec/asciidoctor/cleanup_spec.rb +383 -25
  37. data/spec/asciidoctor/section_spec.rb +0 -14
  38. data/spec/asciidoctor/validate_spec.rb +218 -83
  39. data/spec/isodoc/postproc_spec.rb +481 -438
  40. data/spec/spec_helper.rb +16 -15
  41. metadata +46 -46
  42. data/lib/isodoc/iso/html/scripts.html +0 -178
@@ -16,6 +16,7 @@ module IsoDoc
16
16
 
17
17
  def status_abbrev(stage, substage, iter, draft, doctype)
18
18
  return "" unless stage
19
+
19
20
  if %w(technical-report technical-specification).include?(doctype)
20
21
  stage = "DTS" if stage == "DIS"
21
22
  stage = "FDTS" if stage == "FDIS"
@@ -5,10 +5,6 @@ require_relative "index"
5
5
  module IsoDoc
6
6
  module Iso
7
7
  class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
8
- def initialize(options)
9
- super
10
- end
11
-
12
8
  def convert1(docxml, filename, dir)
13
9
  if amd(docxml)
14
10
  @oldsuppressheadingnumbers = @suppressheadingnumbers
@@ -30,43 +26,57 @@ module IsoDoc
30
26
  @xrefs = Xref.new(lang, script, klass, labels, options)
31
27
  end
32
28
 
33
- def figure1(f)
34
- return if labelled_ancestor(f) && f.ancestors("figure").empty?
35
- lbl = @xrefs.anchor(f['id'], :label, false) or return
36
- figname = f.parent.name == "figure" ? "" : "#{@i18n.figure} "
37
- connective = f.parent.name == "figure" ? "&nbsp; " : "&nbsp;&mdash; "
38
- prefix_name(f, connective, l10n("#{figname}#{lbl}"), "name")
29
+ def figure1(node)
30
+ return if labelled_ancestor(node) && node.ancestors("figure").empty?
31
+
32
+ lbl = @xrefs.anchor(node["id"], :label, false) or return
33
+ figname = node.parent.name == "figure" ? "" : "#{@i18n.figure} "
34
+ connective = node.parent.name == "figure" ? "&nbsp; " : "&nbsp;&mdash; "
35
+ prefix_name(node, connective, l10n("#{figname}#{lbl}"), "name")
39
36
  end
40
37
 
41
- def example1(f)
42
- n = @xrefs.get[f["id"]]
43
- lbl = (n.nil? || n[:label].nil? || n[:label].empty?) ? @i18n.example :
44
- l10n("#{@i18n.example} #{n[:label]}")
45
- prefix_name(f, "&nbsp;&mdash; ", lbl, "name")
38
+ def example1(node)
39
+ n = @xrefs.get[node["id"]]
40
+ lbl = if n.nil? || n[:label].nil? || n[:label].empty?
41
+ @i18n.example
42
+ else
43
+ l10n("#{@i18n.example} #{n[:label]}")
44
+ end
45
+ prefix_name(node, "&nbsp;&mdash; ", lbl, "name")
46
46
  end
47
47
 
48
- def eref_localities1_zh(target, type, from, to, delim)
48
+ def eref_localities1_zh(target, type, from, to, n, delim)
49
49
  subsection = from&.text&.match(/\./)
50
- ret = (delim == ";") ? ";" : (type == "list") ? "" : delim
50
+ ret = if delim == ";"
51
+ ";"
52
+ else
53
+ type == "list" ? "" : delim
54
+ end
51
55
  ret += " 第#{from.text}" if from
52
56
  ret += "&ndash;#{to.text}" if to
53
- loc = (@i18n.locality[type] || type.sub(/^locality:/, "").capitalize )
57
+ loc = (@i18n.locality[type] || type.sub(/^locality:/, "").capitalize)
54
58
  ret += " #{loc}" unless subsection && type == "clause" ||
55
- type == "list" || target.match(/^IEV$|^IEC 60050-/)
59
+ type == "list" || target.match(/^IEV$|^IEC 60050-/) ||
60
+ n["droploc"] == "true"
56
61
  ret += ")" if type == "list"
57
62
  ret
58
63
  end
59
64
 
60
- def eref_localities1(target, type, from, to, delim, lang = "en")
65
+ def eref_localities1(target, type, from, to, delim, n, lang = "en")
61
66
  return "" if type == "anchor"
67
+
62
68
  subsection = from&.text&.match(/\./)
63
69
  type = type.downcase
64
70
  lang == "zh" and
65
- return l10n(eref_localities1_zh(target, type, from, to, delim))
66
- ret = (delim == ";") ? ";" : (type == "list") ? "" : delim
67
- loc = @i18n.locality[type] || type.sub(/^locality:/, "").capitalize
68
- ret += " #{loc}" unless subsection && type == "clause" ||
69
- type == "list" || target.match(/^IEV$|^IEC 60050-/)
71
+ return l10n(eref_localities1_zh(target, type, from, to, n, delim))
72
+ ret = if delim == ";"
73
+ ";"
74
+ else
75
+ type == "list" ? "" : delim
76
+ end
77
+ ret += eref_locality_populate(type, n) unless subsection &&
78
+ type == "clause" || type == "list" ||
79
+ target.match(/^IEV$|^IEC 60050-/)
70
80
  ret += " #{from.text}" if from
71
81
  ret += "&ndash;#{to.text}" if to
72
82
  ret += ")" if type == "list"
@@ -78,17 +88,18 @@ module IsoDoc
78
88
  l10n(@xrefs.anchor(container, :xref) + delim + linkend)
79
89
  end
80
90
 
81
- def example_span_label(node, div, name)
91
+ def example_span_label(_node, div, name)
82
92
  return if name.nil?
83
- div.span **{ class: "example_label" } do |p|
93
+
94
+ div.span **{ class: "example_label" } do |_p|
84
95
  name.children.each { |n| parse(n, div) }
85
96
  end
86
97
  end
87
98
 
88
- def clause1(f)
89
- if !f.at(ns("./title")) &&
90
- !%w(sections preface bibliography).include?(f.parent.name)
91
- f["inline-header"] = "true"
99
+ def clause1(node)
100
+ if !node.at(ns("./title")) &&
101
+ !%w(sections preface bibliography).include?(node.parent.name)
102
+ node["inline-header"] = "true"
92
103
  end
93
104
  super
94
105
  end
@@ -96,8 +107,8 @@ module IsoDoc
96
107
  def clause(docxml)
97
108
  docxml.xpath(ns("//clause[not(ancestor::annex)] | "\
98
109
  "//terms | //definitions | //references | "\
99
- "//preface/introduction[clause]")).
100
- each do |f|
110
+ "//preface/introduction[clause]"))
111
+ .each do |f|
101
112
  clause1(f)
102
113
  end
103
114
  end
@@ -4,28 +4,25 @@ require "mn2sts"
4
4
  module IsoDoc
5
5
  module Iso
6
6
 
7
- # A {Converter} implementation that generates HTML output, and a document
8
- # schema encapsulation of the document for validation
9
- #
10
7
  class StsConvert < IsoDoc::XslfoPdfConvert
11
- def initialize(options)
8
+ def initialize(_options) # rubocop:disable Lint/MissingSuper
12
9
  @libdir = File.dirname(__FILE__)
13
10
  @format = :sts
14
11
  @suffix = "sts.xml"
15
12
  end
16
13
 
17
- def convert(input_filename, file = nil, debug = false, output_filename = nil)
18
- file = File.read(input_filename, encoding: "utf-8") if file.nil?
19
- docxml, filename, dir = convert_init(file, input_filename, debug)
20
- /\.xml$/.match(input_filename) or
21
- input_filename = Tempfile.open([filename, ".xml"], encoding: "utf-8") do |f|
22
- f.write file
23
- f.path
14
+ def convert(in_fname, file = nil, debug = false, out_fname = nil)
15
+ file = File.read(in_fname, encoding: "utf-8") if file.nil?
16
+ _docxml, filename, dir = convert_init(file, in_fname, debug)
17
+ unless /\.xml$/.match?(in_fname)
18
+ in_fname = Tempfile.open([filename, ".xml"], encoding: "utf-8") do |f|
19
+ f.write file
20
+ f.path
21
+ end
24
22
  end
25
23
  FileUtils.rm_rf dir
26
- Mn2sts.convert(input_filename, output_filename || "#{filename}.#{@suffix}")
24
+ Mn2sts.convert(in_fname, out_fname || "#{filename}.#{@suffix}")
27
25
  end
28
26
  end
29
27
  end
30
28
  end
31
-
@@ -34,7 +34,6 @@ module IsoDoc
34
34
  html_doc_path("style-iso.scss")),
35
35
  htmlcoverpage: html_doc_path("html_iso_titlepage.html"),
36
36
  htmlintropage: html_doc_path("html_iso_intro.html"),
37
- scripts: html_doc_path("scripts.html"),
38
37
  wordstylesheet: html_doc_path("wordstyle.scss"),
39
38
  standardstylesheet: html_doc_path("isodoc.scss"),
40
39
  header: html_doc_path("header.html"),
@@ -4,25 +4,35 @@ module IsoDoc
4
4
  end
5
5
 
6
6
  class Xref < IsoDoc::Xref
7
- def initial_anchor_names(d)
8
- if @klass.amd(d)
9
- d.xpath(ns("//preface/*")).each { |c| c.element? and preface_names(c) }
10
- sequential_asset_names(d.xpath(ns("//preface/*")))
11
- d.xpath(ns("//sections/clause")).each { |c| c.element? and preface_names(c) }
12
- middle_section_asset_names(d)
13
- termnote_anchor_names(d)
14
- termexample_anchor_names(d)
7
+ def initial_anchor_names(doc)
8
+ if @klass.amd(doc)
9
+ initial_anchor_names_amd(doc)
15
10
  else
16
11
  super
17
12
  end
18
- introduction_names(d.at(ns("//introduction")))
13
+ introduction_names(doc.at(ns("//introduction")))
14
+ end
15
+
16
+ def initial_anchor_names_amd(doc)
17
+ doc.xpath(ns("//preface/*")).each do |c|
18
+ c.element? and preface_names(c)
19
+ end
20
+ sequential_asset_names(doc.xpath(ns("//preface/*")))
21
+ doc.xpath(ns("//sections/clause")).each do |c|
22
+ c.element? and preface_names(c)
23
+ end
24
+ middle_section_asset_names(doc)
25
+ termnote_anchor_names(doc)
26
+ termexample_anchor_names(doc)
19
27
  end
20
28
 
21
29
  # we can reference 0-number clauses in introduction
22
30
  def introduction_names(clause)
23
31
  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" }
32
+
33
+ clause.at(ns("./clause")) and
34
+ @anchors[clause["id"]] = { label: "0", level: 1, type: "clause",
35
+ xref: clause.at(ns("./title"))&.text }
26
36
  i = Counter.new
27
37
  clause.xpath(ns("./clause")).each do |c|
28
38
  i.increment(c)
@@ -35,17 +45,19 @@ module IsoDoc
35
45
  super
36
46
  end
37
47
 
38
- def appendix_names(clause, num)
48
+ def appendix_names(clause, _num)
39
49
  i = Counter.new
40
50
  clause.xpath(ns("./appendix")).each do |c|
41
51
  i.increment(c)
42
- @anchors[c["id"]] = anchor_struct(i.print, nil, @labels["appendix"], "clause")
52
+ @anchors[c["id"]] = anchor_struct(i.print, nil, @labels["appendix"],
53
+ "clause")
43
54
  @anchors[c["id"]][:level] = 2
44
55
  @anchors[c["id"]][:container] = clause["id"]
45
56
  j = Counter.new
46
57
  c.xpath(ns("./clause | ./references")).each do |c1|
47
58
  j.increment(c1)
48
- appendix_names1(c1, l10n("#{@labels["appendix"]} #{i.print}.#{j.print}"), 3, clause["id"])
59
+ lbl = "#{@labels['appendix']} #{i.print}.#{j.print}"
60
+ appendix_names1(c1, l10n(lbl), 3, clause["id"])
49
61
  end
50
62
  end
51
63
  end
@@ -56,8 +68,8 @@ module IsoDoc
56
68
  # subclauses are not prefixed with "Clause"
57
69
  i = Counter.new
58
70
  clause.xpath(ns("./clause | ./terms | ./term | ./definitions | "\
59
- "./references")).
60
- each do |c|
71
+ "./references"))
72
+ .each do |c|
61
73
  i.increment(c)
62
74
  section_names1(c, "#{num}.#{i.print}", level + 1)
63
75
  end
@@ -73,7 +85,8 @@ module IsoDoc
73
85
  end
74
86
 
75
87
  def appendix_names1(clause, num, level, container)
76
- @anchors[clause["id"]] = { label: num, xref: num, level: level, container: container }
88
+ @anchors[clause["id"]] = { label: num, xref: num, level: level,
89
+ container: container }
77
90
  i = Counter.new
78
91
  clause.xpath(ns("./clause | ./references")).each do |c|
79
92
  i.increment(c)
@@ -85,29 +98,33 @@ module IsoDoc
85
98
  c = IsoDoc::XrefGen::Counter.new
86
99
  clause.xpath(ns(".//formula")).each do |t|
87
100
  next if t["id"].nil? || t["id"].empty?
88
- @anchors[t["id"]] =
89
- anchor_struct("#{num}#{hiersep}#{c.increment(t).print}", t,
90
- t["inequality"] ? @labels["inequality"] : @labels["formula"],
91
- "formula", t["unnumbered"])
101
+
102
+ @anchors[t["id"]] = anchor_struct(
103
+ "#{num}#{hiersep}#{c.increment(t).print}", t,
104
+ t["inequality"] ? @labels["inequality"] : @labels["formula"],
105
+ "formula", t["unnumbered"]
106
+ )
92
107
  end
93
108
  end
94
109
 
95
- def figure_anchor(t, sublabel, label)
96
- @anchors[t["id"]] = anchor_struct(
110
+ def figure_anchor(elem, sublabel, label)
111
+ @anchors[elem["id"]] = anchor_struct(
97
112
  (sublabel ? "#{label} #{sublabel}" : label),
98
- nil, @labels["figure"], "figure", t["unnumbered"])
99
- sublabel && t["unnumbered"] != "true" and
100
- @anchors[t["id"]][:label] = sublabel
113
+ nil, @labels["figure"], "figure", elem["unnumbered"]
114
+ )
115
+ sublabel && elem["unnumbered"] != "true" and
116
+ @anchors[elem["id"]][:label] = sublabel
101
117
  end
102
118
 
103
119
  def sequential_figure_names(clause)
104
120
  c = IsoDoc::XrefGen::Counter.new
105
121
  j = 0
106
- clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).
107
- each do |t|
122
+ clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
123
+ .each do |t|
108
124
  j = subfigure_increment(j, c, t)
109
- sublabel = j.zero? ? nil : "#{(j+96).chr})"
125
+ sublabel = j.zero? ? nil : "#{(j + 96).chr})"
110
126
  next if t["id"].nil? || t["id"].empty?
127
+
111
128
  figure_anchor(t, sublabel, c.print)
112
129
  end
113
130
  end
@@ -115,20 +132,21 @@ module IsoDoc
115
132
  def hierarchical_figure_names(clause, num)
116
133
  c = IsoDoc::XrefGen::Counter.new
117
134
  j = 0
118
- clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).
119
- each do |t|
135
+ clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
136
+ .each do |t|
120
137
  j = subfigure_increment(j, c, t)
121
138
  label = "#{num}#{hiersep}#{c.print}"
122
- sublabel = j.zero? ? nil : "#{(j+96).chr})"
139
+ sublabel = j.zero? ? nil : "#{(j + 96).chr})"
123
140
  next if t["id"].nil? || t["id"].empty?
141
+
124
142
  figure_anchor(t, sublabel, label)
125
143
  end
126
144
  end
127
145
 
128
146
  def reference_names(ref)
129
147
  super
130
- @anchors[ref["id"]] = { xref: @anchors[ref["id"]][:xref].
131
- sub(/ \(All Parts\)/i, "") }
148
+ @anchors[ref["id"]] = { xref: @anchors[ref["id"]][:xref]
149
+ .sub(/ \(All Parts\)/i, "") }
132
150
  end
133
151
 
134
152
  def back_anchor_names(docxml)
@@ -38,6 +38,7 @@ module Metanorma
38
38
 
39
39
  def use_presentation_xml(ext)
40
40
  return true if ext == :html_alt
41
+
41
42
  super
42
43
  end
43
44
 
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "1.7.4".freeze
3
+ VERSION = "1.8.4".freeze
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- lib = File.expand_path("../lib", __FILE__)
3
+ lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require "metanorma/iso/version"
6
6
 
@@ -29,22 +29,22 @@ Gem::Specification.new do |spec|
29
29
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
30
30
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
31
31
 
32
+ spec.add_dependency "isodoc", "~> 1.6.2"
33
+ spec.add_dependency "metanorma-standoc", "~> 1.9.0"
34
+ spec.add_dependency "mn2sts", "~> 1.8.0"
32
35
  spec.add_dependency "ruby-jing"
33
- spec.add_dependency "isodoc", "~> 1.5.0"
34
- spec.add_dependency "metanorma-standoc", "~> 1.8.0"
35
36
  spec.add_dependency "tokenizer", "~> 0.3.0"
36
37
  spec.add_dependency "twitter_cldr"
37
- spec.add_dependency "mn2sts", "~> 1.5.0"
38
38
 
39
39
  spec.add_development_dependency "byebug"
40
- spec.add_development_dependency "sassc", "2.4.0"
41
40
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
42
41
  spec.add_development_dependency "guard", "~> 2.14"
43
42
  spec.add_development_dependency "guard-rspec", "~> 4.7"
44
- spec.add_development_dependency "rake" , "~> 13.0"
43
+ spec.add_development_dependency "iev", "~> 0.2.0"
44
+ spec.add_development_dependency "rake", "~> 13.0"
45
45
  spec.add_development_dependency "rspec", "~> 3.6"
46
46
  spec.add_development_dependency "rubocop", "~> 1.5.2"
47
+ spec.add_development_dependency "sassc", "2.4.0"
47
48
  spec.add_development_dependency "simplecov", "~> 0.15"
48
49
  spec.add_development_dependency "timecop", "~> 0.9"
49
- spec.add_development_dependency "iev", "~> 0.2.0"
50
50
  end
@@ -6,27 +6,33 @@ RSpec.describe Asciidoctor::ISO do
6
6
  end
7
7
 
8
8
  it "processes a blank document" do
9
- expect(xmlpp(Asciidoctor.convert(<<~"INPUT", *OPTIONS))).to be_equivalent_to xmlpp(<<~"OUTPUT")
9
+ input = <<~INPUT
10
10
  #{ASCIIDOC_BLANK_HDR}
11
11
  INPUT
12
+ output = <<~OUTPUT
12
13
  #{BLANK_HDR}
13
14
  <sections/>
14
15
  </iso-standard>
15
16
  OUTPUT
17
+ expect(xmlpp(Asciidoctor.convert(input, *OPTIONS)))
18
+ .to be_equivalent_to xmlpp(output)
16
19
  end
17
20
 
18
21
  it "converts a blank document" do
19
- expect(xmlpp(Asciidoctor.convert(<<~"INPUT", *OPTIONS))).to be_equivalent_to xmlpp(<<~"OUTPUT")
22
+ input = <<~INPUT
20
23
  = Document title
21
24
  Author
22
25
  :docfile: test.adoc
23
26
  :novalid:
24
27
  :no-isobib:
25
28
  INPUT
29
+ output = <<~OUTPUT
26
30
  #{BLANK_HDR}
27
31
  <sections/>
28
32
  </iso-standard>
29
33
  OUTPUT
34
+ expect(xmlpp(Asciidoctor.convert(input, *OPTIONS)))
35
+ .to be_equivalent_to xmlpp(output)
30
36
  expect(File.exist?("test_alt.html")).to be true
31
37
  expect(File.exist?("test.html")).to be true
32
38
  expect(File.exist?("test.doc")).to be true
@@ -35,7 +41,7 @@ RSpec.describe Asciidoctor::ISO do
35
41
  end
36
42
 
37
43
  it "converts a blank document in French" do
38
- expect(xmlpp(Asciidoctor.convert(<<~"INPUT", *OPTIONS))).to be_equivalent_to xmlpp(<<~"OUTPUT")
44
+ input = <<~INPUT
39
45
  = Document title
40
46
  Author
41
47
  :docfile: test.adoc
@@ -44,10 +50,13 @@ RSpec.describe Asciidoctor::ISO do
44
50
  :no-pdf:
45
51
  :language: fr
46
52
  INPUT
53
+ output = <<~OUTPUT
47
54
  #{BLANK_HDR_FR}
48
55
  <sections/>
49
56
  </iso-standard>
50
57
  OUTPUT
58
+ expect(xmlpp(Asciidoctor.convert(input, *OPTIONS)))
59
+ .to be_equivalent_to xmlpp(output)
51
60
  end
52
61
 
53
62
  it "processes default metadata" do
@@ -96,87 +105,88 @@ RSpec.describe Asciidoctor::ISO do
96
105
  :copyright-year: 2000
97
106
  :horizontal: true
98
107
  INPUT
99
- expect(xmlpp(output.sub(%r{<boilerplate>.*</boilerplate>}m, ""))).to be_equivalent_to xmlpp(<<~"OUTPUT")
100
- <?xml version="1.0" encoding="UTF-8"?>
101
- <iso-standard type="semantic" version="#{Metanorma::ISO::VERSION}" xmlns="https://www.metanorma.org/ns/iso">
102
- <bibdata type="standard">
103
- <title format="text/plain" language="en" type="main">Introduction — Main Title — Title — Title Part</title>
104
- <title format="text/plain" language="en" type="title-intro">Introduction</title>
105
- <title format="text/plain" language="en" type="title-main">Main Title — Title</title>
106
- <title format="text/plain" language="en" type="title-part">Title Part</title>
107
- <title format="text/plain" language="fr" type="main">Introduction Française — Titre Principal — Part du Titre</title>
108
- <title format="text/plain" language="fr" type="title-intro">Introduction Française</title>
109
- <title format="text/plain" language="fr" type="title-main">Titre Principal</title>
110
- <title format="text/plain" language="fr" type="title-part">Part du Titre</title>
111
- <docidentifier type="ISO">ISO/PreWD3 1000-1</docidentifier>
112
- <docidentifier type="iso-with-lang">ISO/PreWD3 1000-1(E)</docidentifier>
113
- <docidentifier type="iso-reference">ISO/PreWD3 1000-1:2000(E)</docidentifier>
114
- <docnumber>1000</docnumber>
115
- <contributor>
116
- <role type="author"/>
117
- <organization>
118
- <name>International Organization for Standardization</name>
119
- <abbreviation>ISO</abbreviation>
120
- </organization>
121
- </contributor>
122
- <contributor>
123
- <role type="publisher"/>
124
- <organization>
125
- <name>International Organization for Standardization</name>
126
- <abbreviation>ISO</abbreviation>
127
- </organization>
128
- </contributor>
129
- <edition>2</edition>
130
- <version>
131
- <revision-date>2000-01-01</revision-date>
132
- <draft>0.3.4</draft>
133
- </version>
134
- <language>en</language>
135
- <script>Latn</script>
136
- <status>
137
- <stage abbreviation="WD">20</stage>
138
- <substage>20</substage>
139
- <iteration>3</iteration>
140
- </status>
141
- <copyright>
142
- <from>2000</from>
143
- <owner>
108
+ expect(xmlpp(output.sub(%r{<boilerplate>.*</boilerplate>}m, "")))
109
+ .to be_equivalent_to xmlpp(<<~"OUTPUT")
110
+ <?xml version="1.0" encoding="UTF-8"?>
111
+ <iso-standard type="semantic" version="#{Metanorma::ISO::VERSION}" xmlns="https://www.metanorma.org/ns/iso">
112
+ <bibdata type="standard">
113
+ <title format="text/plain" language="en" type="main">Introduction — Main Title — Title — Title Part</title>
114
+ <title format="text/plain" language="en" type="title-intro">Introduction</title>
115
+ <title format="text/plain" language="en" type="title-main">Main Title — Title</title>
116
+ <title format="text/plain" language="en" type="title-part">Title Part</title>
117
+ <title format="text/plain" language="fr" type="main">Introduction Française — Titre Principal — Part du Titre</title>
118
+ <title format="text/plain" language="fr" type="title-intro">Introduction Française</title>
119
+ <title format="text/plain" language="fr" type="title-main">Titre Principal</title>
120
+ <title format="text/plain" language="fr" type="title-part">Part du Titre</title>
121
+ <docidentifier type="ISO">ISO/PreWD3 1000-1</docidentifier>
122
+ <docidentifier type="iso-with-lang">ISO/PreWD3 1000-1(E)</docidentifier>
123
+ <docidentifier type="iso-reference">ISO/PreWD3 1000-1:2000(E)</docidentifier>
124
+ <docnumber>1000</docnumber>
125
+ <contributor>
126
+ <role type="author"/>
144
127
  <organization>
145
128
  <name>International Organization for Standardization</name>
146
129
  <abbreviation>ISO</abbreviation>
147
130
  </organization>
148
- </owner>
149
- </copyright>
150
- <ext>
151
- <doctype>article</doctype>
152
- <horizontal>true</horizontal>
153
- <editorialgroup>
154
- <technical-committee number="1" type="A">TC</technical-committee>
155
- <technical-committee number="11" type="A1">TC1</technical-committee>
156
- <subcommittee number="2" type="B">SC</subcommittee>
157
- <subcommittee number="21" type="B1">SC1</subcommittee>
158
- <workgroup number="3" type="C">WG</workgroup>
159
- <workgroup number="31" type="C1">WG1</workgroup>
160
- <secretariat>SECRETARIAT</secretariat>
161
- </editorialgroup>
162
- <ics>
163
- <code>1</code>
164
- </ics>
165
- <ics>
166
- <code>2</code>
167
- </ics>
168
- <ics>
169
- <code>3</code>
170
- </ics>
171
- <structuredidentifier>
172
- <project-number part="1">ISO 1000</project-number>
173
- </structuredidentifier>
174
- <stagename>Third working draft</stagename>
175
- </ext>
176
- </bibdata>
177
- <sections/>
178
- </iso-standard>
179
- OUTPUT
131
+ </contributor>
132
+ <contributor>
133
+ <role type="publisher"/>
134
+ <organization>
135
+ <name>International Organization for Standardization</name>
136
+ <abbreviation>ISO</abbreviation>
137
+ </organization>
138
+ </contributor>
139
+ <edition>2</edition>
140
+ <version>
141
+ <revision-date>2000-01-01</revision-date>
142
+ <draft>0.3.4</draft>
143
+ </version>
144
+ <language>en</language>
145
+ <script>Latn</script>
146
+ <status>
147
+ <stage abbreviation="WD">20</stage>
148
+ <substage>20</substage>
149
+ <iteration>3</iteration>
150
+ </status>
151
+ <copyright>
152
+ <from>2000</from>
153
+ <owner>
154
+ <organization>
155
+ <name>International Organization for Standardization</name>
156
+ <abbreviation>ISO</abbreviation>
157
+ </organization>
158
+ </owner>
159
+ </copyright>
160
+ <ext>
161
+ <doctype>article</doctype>
162
+ <horizontal>true</horizontal>
163
+ <editorialgroup>
164
+ <technical-committee number="1" type="A">TC</technical-committee>
165
+ <technical-committee number="11" type="A1">TC1</technical-committee>
166
+ <subcommittee number="2" type="B">SC</subcommittee>
167
+ <subcommittee number="21" type="B1">SC1</subcommittee>
168
+ <workgroup number="3" type="C">WG</workgroup>
169
+ <workgroup number="31" type="C1">WG1</workgroup>
170
+ <secretariat>SECRETARIAT</secretariat>
171
+ </editorialgroup>
172
+ <ics>
173
+ <code>1</code>
174
+ </ics>
175
+ <ics>
176
+ <code>2</code>
177
+ </ics>
178
+ <ics>
179
+ <code>3</code>
180
+ </ics>
181
+ <structuredidentifier>
182
+ <project-number part="1">ISO 1000</project-number>
183
+ </structuredidentifier>
184
+ <stagename>Third working draft</stagename>
185
+ </ext>
186
+ </bibdata>
187
+ <sections/>
188
+ </iso-standard>
189
+ OUTPUT
180
190
  end
181
191
 
182
192
  it "processes complex metadata" do
@@ -203,95 +213,132 @@ RSpec.describe Asciidoctor::ISO do
203
213
  :pub-email: x@example.com
204
214
  :pub-uri: http://www.example.com
205
215
  INPUT
206
- expect(xmlpp(output.sub(%r{<boilerplate>.*</boilerplate>}m, ""))).to be_equivalent_to xmlpp(<<~"OUTPUT")
207
- <?xml version="1.0" encoding="UTF-8"?>
208
- <iso-standard type="semantic" version="#{Metanorma::ISO::VERSION}" xmlns="https://www.metanorma.org/ns/iso">
209
- <bibdata type="standard">
210
- <docidentifier type="ISO">ISO/IEC/IETF/TR 1000-1-1:2001</docidentifier>
211
- <docidentifier type="iso-with-lang">ISO/IEC/IETF/TR 1000-1-1:2001(X)</docidentifier>
212
- <docidentifier type="iso-reference">ISO/IEC/IETF/TR 1000-1-1:2001(X)</docidentifier>
213
- <docidentifier type="iso-tc">2000</docidentifier>
214
- <docidentifier type="iso-tc">2003</docidentifier>
215
- <docnumber>1000</docnumber>
216
- <contributor>
217
- <role type="author"/>
218
- <organization>
219
- <name>International Electrotechnical Commission</name>
220
- <abbreviation>IEC</abbreviation>
221
- </organization>
222
- </contributor>
223
- <contributor>
224
- <role type="author"/>
225
- <organization>
226
- <name>IETF</name>
227
- </organization>
228
- </contributor>
229
- <contributor>
230
- <role type="author"/>
231
- <organization>
232
- <name>International Organization for Standardization</name>
233
- <abbreviation>ISO</abbreviation>
234
- </organization>
235
- </contributor>
236
- <contributor>
237
- <role type="publisher"/>
238
- <organization>
239
- <name>International Electrotechnical Commission</name>
240
- <abbreviation>IEC</abbreviation>
241
- </organization>
242
- </contributor>
243
- <contributor>
244
- <role type="publisher"/>
245
- <organization>
246
- <name>IETF</name>
247
- </organization>
248
- </contributor>
249
- <contributor>
250
- <role type="publisher"/>
251
- <organization>
252
- <name>International Organization for Standardization</name>
253
- <abbreviation>ISO</abbreviation>
254
- </organization>
255
- </contributor>
256
- <language>el</language>
257
- <script>Grek</script>
258
- <status>
259
- <stage abbreviation="IS">60</stage>
260
- <substage>60</substage>
261
- </status>
262
- <copyright>
263
- <from>2001</from>
264
- <owner>
265
- <organization>
266
- <name>International Organization for Standardization</name>
267
- <abbreviation>ISO</abbreviation>
268
- </organization>
269
- </owner>
270
- </copyright>
271
- <copyright>
272
- <from>2001</from>
273
- <owner>
274
- <organization>
275
- <name>IETF</name>
276
- </organization>
277
- </owner>
278
- </copyright>
279
- <ext>
280
- <doctype>technical-report</doctype>
281
- <editorialgroup>
282
- <technical-committee/>
283
- <subcommittee/>
284
- <workgroup/>
285
- </editorialgroup>
286
- <structuredidentifier>
287
- <project-number part="1" subpart="1">ISO/IEC/IETF 1000</project-number>
288
- </structuredidentifier>
289
- <stagename>International standard</stagename>
290
- </ext>
291
- </bibdata>
292
- <sections/>
293
- </iso-standard>
294
- OUTPUT
216
+ expect(xmlpp(output.sub(%r{<boilerplate>.*</boilerplate>}m, "")))
217
+ .to be_equivalent_to xmlpp(<<~"OUTPUT")
218
+ <?xml version="1.0" encoding="UTF-8"?>
219
+ <iso-standard type="semantic" version="#{Metanorma::ISO::VERSION}" xmlns="https://www.metanorma.org/ns/iso">
220
+ <bibdata type="standard">
221
+ <docidentifier type="ISO">ISO/IEC/IETF/TR 1000-1-1:2001</docidentifier>
222
+ <docidentifier type="iso-with-lang">ISO/IEC/IETF/TR 1000-1-1:2001(X)</docidentifier>
223
+ <docidentifier type="iso-reference">ISO/IEC/IETF/TR 1000-1-1:2001(X)</docidentifier>
224
+ <docidentifier type="iso-tc">2000</docidentifier>
225
+ <docidentifier type="iso-tc">2003</docidentifier>
226
+ <docnumber>1000</docnumber>
227
+ <contributor>
228
+ <role type="author"/>
229
+ <organization>
230
+ <name>International Electrotechnical Commission</name>
231
+ <abbreviation>IEC</abbreviation>
232
+ </organization>
233
+ </contributor>
234
+ <contributor>
235
+ <role type="author"/>
236
+ <organization>
237
+ <name>IETF</name>
238
+ </organization>
239
+ </contributor>
240
+ <contributor>
241
+ <role type="author"/>
242
+ <organization>
243
+ <name>International Organization for Standardization</name>
244
+ <abbreviation>ISO</abbreviation>
245
+ </organization>
246
+ </contributor>
247
+ <contributor>
248
+ <role type="publisher"/>
249
+ <organization>
250
+ <name>International Electrotechnical Commission</name>
251
+ <abbreviation>IEC</abbreviation>
252
+ <address>
253
+ <formattedAddress>1 Infinity Loop + California</formattedAddress>
254
+ </address>
255
+ <phone>3333333</phone>
256
+ <phone type='fax'>4444444</phone>
257
+ <email>x@example.com</email>
258
+ <uri>http://www.example.com</uri>
259
+ </organization>
260
+ </contributor>
261
+ <contributor>
262
+ <role type="publisher"/>
263
+ <organization>
264
+ <name>IETF</name>
265
+ <address>
266
+ <formattedAddress>1 Infinity Loop + California</formattedAddress>
267
+ </address>
268
+ <phone>3333333</phone>
269
+ <phone type='fax'>4444444</phone>
270
+ <email>x@example.com</email>
271
+ <uri>http://www.example.com</uri>
272
+ </organization>
273
+ </contributor>
274
+ <contributor>
275
+ <role type="publisher"/>
276
+ <organization>
277
+ <name>International Organization for Standardization</name>
278
+ <abbreviation>ISO</abbreviation>
279
+ <address>
280
+ <formattedAddress>1 Infinity Loop + California</formattedAddress>
281
+ </address>
282
+ <phone>3333333</phone>
283
+ <phone type='fax'>4444444</phone>
284
+ <email>x@example.com</email>
285
+ <uri>http://www.example.com</uri>
286
+ </organization>
287
+ </contributor>
288
+ <language>el</language>
289
+ <script>Grek</script>
290
+ <status>
291
+ <stage abbreviation="IS">60</stage>
292
+ <substage>60</substage>
293
+ </status>
294
+ <copyright>
295
+ <from>2001</from>
296
+ <owner>
297
+ <organization>
298
+ <name>International Organization for Standardization</name>
299
+ <abbreviation>ISO</abbreviation>
300
+ <address>
301
+ <formattedAddress>1 Infinity Loop + California</formattedAddress>
302
+ </address>
303
+ <phone>3333333</phone>
304
+ <phone type='fax'>4444444</phone>
305
+ <email>x@example.com</email>
306
+ <uri>http://www.example.com</uri>
307
+ #{' '}
308
+ </organization>
309
+ </owner>
310
+ </copyright>
311
+ <copyright>
312
+ <from>2001</from>
313
+ <owner>
314
+ <organization>
315
+ <name>IETF</name>
316
+ <address>
317
+ <formattedAddress>1 Infinity Loop + California</formattedAddress>
318
+ </address>
319
+ <phone>3333333</phone>
320
+ <phone type='fax'>4444444</phone>
321
+ <email>x@example.com</email>
322
+ <uri>http://www.example.com</uri>
323
+ </organization>
324
+ </owner>
325
+ </copyright>
326
+ <ext>
327
+ <doctype>technical-report</doctype>
328
+ <editorialgroup>
329
+ <technical-committee/>
330
+ <subcommittee/>
331
+ <workgroup/>
332
+ </editorialgroup>
333
+ <structuredidentifier>
334
+ <project-number part="1" subpart="1">ISO/IEC/IETF 1000</project-number>
335
+ </structuredidentifier>
336
+ <stagename>International standard</stagename>
337
+ </ext>
338
+ </bibdata>
339
+ <sections/>
340
+ </iso-standard>
341
+ OUTPUT
295
342
  end
296
343
 
297
344
  it "processes subdivisions" do
@@ -318,7 +365,8 @@ RSpec.describe Asciidoctor::ISO do
318
365
  :pub-email: x@example.com
319
366
  :pub-uri: http://www.example.com
320
367
  INPUT
321
- expect(xmlpp(strip_guid(output.sub(%r{<boilerplate>.*</boilerplate>}m, ""))))
368
+ expect(xmlpp(strip_guid(output
369
+ .sub(%r{<boilerplate>.*</boilerplate>}m, ""))))
322
370
  .to be_equivalent_to xmlpp(<<~"OUTPUT")
323
371
  <iso-standard xmlns="https://www.metanorma.org/ns/iso" type="semantic" version="#{Metanorma::ISO::VERSION}">
324
372
  <bibdata type='standard'>
@@ -336,13 +384,6 @@ RSpec.describe Asciidoctor::ISO do
336
384
  <name>International Organization for Standardization</name>
337
385
  <subdivision>Subdivision</subdivision>
338
386
  <abbreviation>SD</abbreviation>
339
- <address>
340
- <formattedAddress>1 Infinity Loop <br/>California</formattedAddress>
341
- </address>
342
- <phone>3333333</phone>
343
- <phone type='fax'>4444444</phone>
344
- <email>x@example.com</email>
345
- <uri>http://www.example.com</uri>
346
387
  </organization>
347
388
  </contributor>
348
389
  <contributor>
@@ -420,12 +461,81 @@ RSpec.describe Asciidoctor::ISO do
420
461
  :doctype: international-standard
421
462
  :iteration: 2
422
463
  INPUT
423
- expect(xmlpp(output.sub(%r{<boilerplate>.*</boilerplate>}m, ""))).to be_equivalent_to xmlpp(<<~"OUTPUT")
424
- <iso-standard type="semantic" version="#{Metanorma::ISO::VERSION}" xmlns="https://www.metanorma.org/ns/iso">
464
+ expect(xmlpp(output.sub(%r{<boilerplate>.*</boilerplate>}m, "")))
465
+ .to be_equivalent_to xmlpp(<<~"OUTPUT")
466
+ <iso-standard type="semantic" version="#{Metanorma::ISO::VERSION}" xmlns="https://www.metanorma.org/ns/iso">
467
+ <bibdata type="standard">
468
+ <docidentifier type='ISO'>ISO/FDIS 1000.2</docidentifier>
469
+ <docidentifier type='iso-with-lang'>ISO/FDIS 1000.2(F)</docidentifier>
470
+ <docidentifier type='iso-reference'>ISO/FDIS 1000.2(F)</docidentifier>
471
+ <docnumber>1000</docnumber>
472
+ <contributor>
473
+ <role type="author"/>
474
+ <organization>
475
+ <name>International Organization for Standardization</name>
476
+ <abbreviation>ISO</abbreviation>
477
+ </organization>
478
+ </contributor>
479
+ <contributor>
480
+ <role type="publisher"/>
481
+ <organization>
482
+ <name>International Organization for Standardization</name>
483
+ <abbreviation>ISO</abbreviation>
484
+ </organization>
485
+ </contributor>
486
+ <language>fr</language>
487
+ <script>Latn</script>
488
+ <status>
489
+ <stage abbreviation="FDIS">50</stage>
490
+ <substage>00</substage>
491
+ <iteration>2</iteration>
492
+ </status>
493
+ <copyright>
494
+ <from>#{Date.today.year}</from>
495
+ <owner>
496
+ <organization>
497
+ <name>International Organization for Standardization</name>
498
+ <abbreviation>ISO</abbreviation>
499
+ </organization>
500
+ </owner>
501
+ </copyright>
502
+ <ext>
503
+ <doctype>international-standard</doctype>
504
+ <editorialgroup>
505
+ <technical-committee/>
506
+ <subcommittee/>
507
+ <workgroup/>
508
+ </editorialgroup>
509
+ <structuredidentifier>
510
+ <project-number>ISO 1000</project-number>
511
+ </structuredidentifier>
512
+ <stagename>Final draft</stagename>
513
+ </ext>
514
+ </bibdata>
515
+ <sections/>
516
+ </iso-standard>
517
+ OUTPUT
518
+ end
519
+
520
+ it "defaults substage for stage 60" do
521
+ output = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
522
+ = Document title
523
+ Author
524
+ :docfile: test.adoc
525
+ :nodoc:
526
+ :novalid:
527
+ :no-isobib:
528
+ :docnumber: 1000
529
+ :docstage: 60
530
+ INPUT
531
+
532
+ expect(xmlpp(output.sub(%r{<boilerplate>.*</boilerplate>}m, "")))
533
+ .to be_equivalent_to xmlpp(<<~"OUTPUT")
534
+ <iso-standard xmlns="https://www.metanorma.org/ns/iso" type="semantic" version="#{Metanorma::ISO::VERSION}">
425
535
  <bibdata type="standard">
426
- <docidentifier type='ISO'>ISO/FDIS 1000.2</docidentifier>
427
- <docidentifier type='iso-with-lang'>ISO/FDIS 1000.2(F)</docidentifier>
428
- <docidentifier type='iso-reference'>ISO/FDIS 1000.2(F)</docidentifier>
536
+ <docidentifier type="ISO">ISO 1000</docidentifier>
537
+ <docidentifier type='iso-with-lang'>ISO 1000(E)</docidentifier>
538
+ <docidentifier type='iso-reference'>ISO 1000(E)</docidentifier>
429
539
  <docnumber>1000</docnumber>
430
540
  <contributor>
431
541
  <role type="author"/>
@@ -441,12 +551,12 @@ RSpec.describe Asciidoctor::ISO do
441
551
  <abbreviation>ISO</abbreviation>
442
552
  </organization>
443
553
  </contributor>
444
- <language>fr</language>
554
+
555
+ <language>en</language>
445
556
  <script>Latn</script>
446
557
  <status>
447
- <stage abbreviation="FDIS">50</stage>
448
- <substage>00</substage>
449
- <iteration>2</iteration>
558
+ <stage abbreviation="IS">60</stage>
559
+ <substage>60</substage>
450
560
  </status>
451
561
  <copyright>
452
562
  <from>#{Date.today.year}</from>
@@ -458,7 +568,7 @@ RSpec.describe Asciidoctor::ISO do
458
568
  </owner>
459
569
  </copyright>
460
570
  <ext>
461
- <doctype>international-standard</doctype>
571
+ <doctype>article</doctype>
462
572
  <editorialgroup>
463
573
  <technical-committee/>
464
574
  <subcommittee/>
@@ -467,15 +577,15 @@ RSpec.describe Asciidoctor::ISO do
467
577
  <structuredidentifier>
468
578
  <project-number>ISO 1000</project-number>
469
579
  </structuredidentifier>
470
- <stagename>Final draft</stagename>
580
+ <stagename>International standard</stagename>
471
581
  </ext>
472
582
  </bibdata>
473
583
  <sections/>
474
- </iso-standard>
475
- OUTPUT
584
+ </iso-standard>
585
+ OUTPUT
476
586
  end
477
587
 
478
- it "defaults substage for stage 60" do
588
+ it "populates metadata for PRF" do
479
589
  output = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
480
590
  = Document title
481
591
  Author
@@ -485,64 +595,65 @@ RSpec.describe Asciidoctor::ISO do
485
595
  :no-isobib:
486
596
  :docnumber: 1000
487
597
  :docstage: 60
598
+ :docsubstage: 00
488
599
  INPUT
600
+ expect(xmlpp(output.sub(%r{<boilerplate>.*</boilerplate>}m, "")))
601
+ .to be_equivalent_to xmlpp(<<~"OUTPUT")
602
+ <iso-standard xmlns="https://www.metanorma.org/ns/iso" type="semantic" version="#{Metanorma::ISO::VERSION}">
603
+ <bibdata type="standard">
604
+ <docidentifier type="ISO">ISO 1000</docidentifier>
605
+ <docidentifier type='iso-with-lang'>ISO 1000(E)</docidentifier>
606
+ <docidentifier type='iso-reference'>ISO 1000(E)</docidentifier>
607
+ <docnumber>1000</docnumber>
608
+ <contributor>
609
+ <role type="author"/>
610
+ <organization>
611
+ <name>International Organization for Standardization</name>
612
+ <abbreviation>ISO</abbreviation>
613
+ </organization>
614
+ </contributor>
615
+ <contributor>
616
+ <role type="publisher"/>
617
+ <organization>
618
+ <name>International Organization for Standardization</name>
619
+ <abbreviation>ISO</abbreviation>
620
+ </organization>
621
+ </contributor>
489
622
 
490
- expect(xmlpp(output.sub(%r{<boilerplate>.*</boilerplate>}m, ""))).to be_equivalent_to xmlpp(<<~"OUTPUT")
491
- <iso-standard xmlns="https://www.metanorma.org/ns/iso" type="semantic" version="#{Metanorma::ISO::VERSION}">
492
- <bibdata type="standard">
493
- <docidentifier type="ISO">ISO 1000</docidentifier>
494
- <docidentifier type='iso-with-lang'>ISO 1000(E)</docidentifier>
495
- <docidentifier type='iso-reference'>ISO 1000(E)</docidentifier>
496
- <docnumber>1000</docnumber>
497
- <contributor>
498
- <role type="author"/>
499
- <organization>
500
- <name>International Organization for Standardization</name>
501
- <abbreviation>ISO</abbreviation>
502
- </organization>
503
- </contributor>
504
- <contributor>
505
- <role type="publisher"/>
506
- <organization>
507
- <name>International Organization for Standardization</name>
508
- <abbreviation>ISO</abbreviation>
509
- </organization>
510
- </contributor>
511
-
512
- <language>en</language>
513
- <script>Latn</script>
514
- <status>
515
- <stage abbreviation="IS">60</stage>
516
- <substage>60</substage>
517
- </status>
518
- <copyright>
519
- <from>#{Date.today.year}</from>
520
- <owner>
521
- <organization>
522
- <name>International Organization for Standardization</name>
523
- <abbreviation>ISO</abbreviation>
524
- </organization>
525
- </owner>
526
- </copyright>
527
- <ext>
528
- <doctype>article</doctype>
529
- <editorialgroup>
530
- <technical-committee/>
531
- <subcommittee/>
532
- <workgroup/>
533
- </editorialgroup>
534
- <structuredidentifier>
535
- <project-number>ISO 1000</project-number>
536
- </structuredidentifier>
537
- <stagename>International standard</stagename>
538
- </ext>
539
- </bibdata>
540
- <sections/>
541
- </iso-standard>
542
- OUTPUT
623
+ <language>en</language>
624
+ <script>Latn</script>
625
+ <status>
626
+ <stage abbreviation="PRF">60</stage>
627
+ <substage>00</substage>
628
+ </status>
629
+ <copyright>
630
+ <from>#{Date.today.year}</from>
631
+ <owner>
632
+ <organization>
633
+ <name>International Organization for Standardization</name>
634
+ <abbreviation>ISO</abbreviation>
635
+ </organization>
636
+ </owner>
637
+ </copyright>
638
+ <ext>
639
+ <doctype>article</doctype>
640
+ <editorialgroup>
641
+ <technical-committee/>
642
+ <subcommittee/>
643
+ <workgroup/>
644
+ </editorialgroup>
645
+ <structuredidentifier>
646
+ <project-number>ISO 1000</project-number>
647
+ </structuredidentifier>
648
+ <stagename>Proof</stagename>
649
+ </ext>
650
+ </bibdata>
651
+ <sections/>
652
+ </iso-standard>
653
+ OUTPUT
543
654
  end
544
655
 
545
- it "populates metadata for PRF" do
656
+ it "defaults metadata for DIR" do
546
657
  output = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
547
658
  = Document title
548
659
  Author
@@ -551,62 +662,62 @@ RSpec.describe Asciidoctor::ISO do
551
662
  :novalid:
552
663
  :no-isobib:
553
664
  :docnumber: 1000
554
- :docstage: 60
555
- :docsubstage: 00
665
+ :doctype: directive
556
666
  INPUT
557
- expect(xmlpp(output.sub(%r{<boilerplate>.*</boilerplate>}m, ""))).to be_equivalent_to xmlpp(<<~"OUTPUT")
558
- <iso-standard xmlns="https://www.metanorma.org/ns/iso" type="semantic" version="#{Metanorma::ISO::VERSION}">
559
- <bibdata type="standard">
560
- <docidentifier type="ISO">ISO 1000</docidentifier>
561
- <docidentifier type='iso-with-lang'>ISO 1000(E)</docidentifier>
562
- <docidentifier type='iso-reference'>ISO 1000(E)</docidentifier>
563
- <docnumber>1000</docnumber>
564
- <contributor>
565
- <role type="author"/>
566
- <organization>
567
- <name>International Organization for Standardization</name>
568
- <abbreviation>ISO</abbreviation>
569
- </organization>
570
- </contributor>
571
- <contributor>
572
- <role type="publisher"/>
573
- <organization>
574
- <name>International Organization for Standardization</name>
575
- <abbreviation>ISO</abbreviation>
576
- </organization>
577
- </contributor>
578
667
 
579
- <language>en</language>
580
- <script>Latn</script>
581
- <status>
582
- <stage abbreviation="PRF">60</stage>
583
- <substage>00</substage>
584
- </status>
585
- <copyright>
586
- <from>#{Date.today.year}</from>
587
- <owner>
668
+ expect(xmlpp(output.sub(%r{<boilerplate>.*</boilerplate>}m, "")))
669
+ .to be_equivalent_to xmlpp(<<~"OUTPUT")
670
+ <iso-standard xmlns="https://www.metanorma.org/ns/iso" type="semantic" version="#{Metanorma::ISO::VERSION}">
671
+ <bibdata type='standard'>
672
+ <docidentifier type='ISO'>ISO DIR 1000</docidentifier>
673
+ <docidentifier type='iso-with-lang'>ISO DIR 1000(E)</docidentifier>
674
+ <docidentifier type='iso-reference'>ISO DIR 1000(E)</docidentifier>
675
+ <docnumber>1000</docnumber>
676
+ <contributor>
677
+ <role type='author'/>
588
678
  <organization>
589
679
  <name>International Organization for Standardization</name>
590
680
  <abbreviation>ISO</abbreviation>
591
681
  </organization>
592
- </owner>
593
- </copyright>
594
- <ext>
595
- <doctype>article</doctype>
596
- <editorialgroup>
597
- <technical-committee/>
598
- <subcommittee/>
599
- <workgroup/>
600
- </editorialgroup>
601
- <structuredidentifier>
602
- <project-number>ISO 1000</project-number>
603
- </structuredidentifier>
604
- <stagename>Proof</stagename>
605
- </ext>
606
- </bibdata>
607
- <sections/>
608
- </iso-standard>
609
- OUTPUT
682
+ </contributor>
683
+ <contributor>
684
+ <role type='publisher'/>
685
+ <organization>
686
+ <name>International Organization for Standardization</name>
687
+ <abbreviation>ISO</abbreviation>
688
+ </organization>
689
+ </contributor>
690
+ <language>en</language>
691
+ <script>Latn</script>
692
+ <status>
693
+ <stage abbreviation='IS'>60</stage>
694
+ <substage>60</substage>
695
+ </status>
696
+ <copyright>
697
+ <from>2021</from>
698
+ <owner>
699
+ <organization>
700
+ <name>International Organization for Standardization</name>
701
+ <abbreviation>ISO</abbreviation>
702
+ </organization>
703
+ </owner>
704
+ </copyright>
705
+ <ext>
706
+ <doctype>directive</doctype>
707
+ <editorialgroup>
708
+ <technical-committee/>
709
+ <subcommittee/>
710
+ <workgroup/>
711
+ </editorialgroup>
712
+ <structuredidentifier>
713
+ <project-number>ISO 1000</project-number>
714
+ </structuredidentifier>
715
+ <stagename>International standard</stagename>
716
+ </ext>
717
+ </bibdata>
718
+ <sections> </sections>
719
+ </iso-standard>
720
+ OUTPUT
610
721
  end
611
722
 
612
723
  it "reads scripts into blank HTML document" do
@@ -632,9 +743,12 @@ RSpec.describe Asciidoctor::ISO do
632
743
  :no-pdf:
633
744
  INPUT
634
745
  html = File.read("test.html", encoding: "utf-8")
635
- expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
636
- expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Cambria", serif;]m)
637
- expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Cambria", serif;]m)
746
+ expect(html)
747
+ .to match(%r[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
748
+ expect(html)
749
+ .to match(%r[blockquote[^{]+\{[^{]+font-family: "Cambria", serif;]m)
750
+ expect(html)
751
+ .to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Cambria", serif;]m)
638
752
  end
639
753
 
640
754
  it "uses default fonts for alt doc" do
@@ -647,9 +761,12 @@ RSpec.describe Asciidoctor::ISO do
647
761
  :no-pdf:
648
762
  INPUT
649
763
  html = File.read("test_alt.html", encoding: "utf-8")
650
- expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: "Space Mono", monospace;]m)
651
- expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Lato", sans-serif;]m)
652
- expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Lato", sans-serif;]m)
764
+ expect(html)
765
+ .to match(%r[\bpre[^{]+\{[^{]+font-family: "Space Mono", monospace;]m)
766
+ expect(html)
767
+ .to match(%r[blockquote[^{]+\{[^{]+font-family: "Lato", sans-serif;]m)
768
+ expect(html)
769
+ .to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Lato", sans-serif;]m)
653
770
  end
654
771
 
655
772
  it "uses Chinese fonts" do
@@ -663,9 +780,12 @@ RSpec.describe Asciidoctor::ISO do
663
780
  :no-pdf:
664
781
  INPUT
665
782
  html = File.read("test.html", encoding: "utf-8")
666
- expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
667
- expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Source Han Sans", serif;]m)
668
- expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Source Han Sans", sans-serif;]m)
783
+ expect(html)
784
+ .to match(%r[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
785
+ expect(html)
786
+ .to match(%r[blockquote[^{]+\{[^{]+font-family: "Source Han Sans", serif;]m)
787
+ expect(html)
788
+ .to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Source Han Sans", sans-serif;]m)
669
789
  end
670
790
 
671
791
  it "uses specified fonts" do
@@ -683,7 +803,8 @@ RSpec.describe Asciidoctor::ISO do
683
803
  INPUT
684
804
  html = File.read("test.html", encoding: "utf-8")
685
805
  expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: Andale Mono;]m)
686
- expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: Zapf Chancery;]m)
806
+ expect(html)
807
+ .to match(%r[blockquote[^{]+\{[^{]+font-family: Zapf Chancery;]m)
687
808
  expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: Comic Sans;]m)
688
809
  end
689
810