metanorma-iso 1.7.2 → 1.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +11 -41
- data/.gitignore +2 -0
- data/.rubocop.yml +7 -1
- data/lib/asciidoctor/iso/base.rb +14 -11
- data/lib/asciidoctor/iso/biblio.rng +4 -6
- data/lib/asciidoctor/iso/cleanup.rb +40 -24
- data/lib/asciidoctor/iso/front.rb +29 -17
- data/lib/asciidoctor/iso/front_id.rb +81 -60
- data/lib/asciidoctor/iso/isodoc.rng +327 -2
- data/lib/asciidoctor/iso/isostandard.rng +12 -97
- data/lib/asciidoctor/iso/section.rb +2 -1
- data/lib/asciidoctor/iso/validate.rb +22 -109
- data/lib/asciidoctor/iso/validate_image.rb +97 -0
- data/lib/asciidoctor/iso/validate_requirements.rb +26 -20
- data/lib/asciidoctor/iso/validate_section.rb +39 -20
- data/lib/asciidoctor/iso/validate_style.rb +36 -24
- data/lib/asciidoctor/iso/validate_title.rb +23 -17
- data/lib/isodoc/iso/base_convert.rb +19 -2
- data/lib/isodoc/iso/html/style-human.css +7 -0
- data/lib/isodoc/iso/html/style-iso.css +7 -0
- data/lib/isodoc/iso/html_convert.rb +0 -1
- data/lib/isodoc/iso/i18n-en.yaml +4 -0
- data/lib/isodoc/iso/i18n-fr.yaml +4 -0
- data/lib/isodoc/iso/i18n-zh-Hans.yaml +4 -0
- data/lib/isodoc/iso/index.rb +140 -0
- data/lib/isodoc/iso/iso.amendment.xsl +1157 -208
- data/lib/isodoc/iso/iso.international-standard.xsl +1157 -208
- data/lib/isodoc/iso/metadata.rb +1 -0
- data/lib/isodoc/iso/presentation_xml_convert.rb +45 -37
- data/lib/isodoc/iso/sts_convert.rb +10 -13
- data/lib/isodoc/iso/word_convert.rb +0 -1
- data/lib/isodoc/iso/xref.rb +46 -25
- data/lib/metanorma/iso/processor.rb +1 -0
- data/lib/metanorma/iso/version.rb +1 -1
- data/metanorma-iso.gemspec +8 -8
- data/spec/{asciidoctor-iso → asciidoctor}/amd_spec.rb +5 -5
- data/spec/asciidoctor/base_spec.rb +825 -0
- data/spec/{asciidoctor-iso → asciidoctor}/blocks_spec.rb +0 -0
- data/spec/{asciidoctor-iso → asciidoctor}/cleanup_spec.rb +383 -25
- data/spec/{asciidoctor-iso → asciidoctor}/inline_spec.rb +0 -0
- data/spec/{asciidoctor-iso → asciidoctor}/lists_spec.rb +0 -0
- data/spec/{asciidoctor-iso → asciidoctor}/refs_spec.rb +0 -0
- data/spec/{asciidoctor-iso → asciidoctor}/section_spec.rb +0 -14
- data/spec/{asciidoctor-iso → asciidoctor}/table_spec.rb +0 -0
- data/spec/{asciidoctor-iso → asciidoctor}/validate_spec.rb +188 -83
- data/spec/isodoc/postproc_spec.rb +481 -438
- data/spec/isodoc/section_spec.rb +219 -0
- data/spec/spec_helper.rb +2 -0
- metadata +65 -64
- data/lib/isodoc/iso/html/scripts.html +0 -178
- data/spec/asciidoctor-iso/base_spec.rb +0 -704
data/lib/isodoc/iso/metadata.rb
CHANGED
@@ -1,17 +1,10 @@
|
|
1
1
|
require_relative "init"
|
2
2
|
require "isodoc"
|
3
|
+
require_relative "index"
|
3
4
|
|
4
5
|
module IsoDoc
|
5
6
|
module Iso
|
6
|
-
|
7
|
-
# A {Converter} implementation that generates HTML output, and a document
|
8
|
-
# schema encapsulation of the document for validation
|
9
|
-
#
|
10
7
|
class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
|
11
|
-
def initialize(options)
|
12
|
-
super
|
13
|
-
end
|
14
|
-
|
15
8
|
def convert1(docxml, filename, dir)
|
16
9
|
if amd(docxml)
|
17
10
|
@oldsuppressheadingnumbers = @suppressheadingnumbers
|
@@ -33,43 +26,57 @@ module IsoDoc
|
|
33
26
|
@xrefs = Xref.new(lang, script, klass, labels, options)
|
34
27
|
end
|
35
28
|
|
36
|
-
def figure1(
|
37
|
-
return if labelled_ancestor(
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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" ? " " : " — "
|
35
|
+
prefix_name(node, connective, l10n("#{figname}#{lbl}"), "name")
|
42
36
|
end
|
43
37
|
|
44
|
-
def example1(
|
45
|
-
n = @xrefs.get[
|
46
|
-
lbl =
|
47
|
-
|
48
|
-
|
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, " — ", lbl, "name")
|
49
46
|
end
|
50
47
|
|
51
|
-
def eref_localities1_zh(target, type, from, to, delim)
|
48
|
+
def eref_localities1_zh(target, type, from, to, n, delim)
|
52
49
|
subsection = from&.text&.match(/\./)
|
53
|
-
ret =
|
50
|
+
ret = if delim == ";"
|
51
|
+
";"
|
52
|
+
else
|
53
|
+
type == "list" ? "" : delim
|
54
|
+
end
|
54
55
|
ret += " 第#{from.text}" if from
|
55
56
|
ret += "–#{to.text}" if to
|
56
|
-
loc = (@i18n.locality[type] || type.sub(/^locality:/, "").capitalize
|
57
|
+
loc = (@i18n.locality[type] || type.sub(/^locality:/, "").capitalize)
|
57
58
|
ret += " #{loc}" unless subsection && type == "clause" ||
|
58
|
-
type == "list" || target.match(/^IEV$|^IEC 60050-/)
|
59
|
+
type == "list" || target.match(/^IEV$|^IEC 60050-/) ||
|
60
|
+
n["droploc"] == "true"
|
59
61
|
ret += ")" if type == "list"
|
60
62
|
ret
|
61
63
|
end
|
62
64
|
|
63
|
-
def eref_localities1(target, type, from, to, delim, lang = "en")
|
65
|
+
def eref_localities1(target, type, from, to, delim, n, lang = "en")
|
64
66
|
return "" if type == "anchor"
|
67
|
+
|
65
68
|
subsection = from&.text&.match(/\./)
|
66
69
|
type = type.downcase
|
67
70
|
lang == "zh" and
|
68
|
-
return l10n(eref_localities1_zh(target, type, from, to, delim))
|
69
|
-
ret =
|
70
|
-
|
71
|
-
|
72
|
-
|
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-/)
|
73
80
|
ret += " #{from.text}" if from
|
74
81
|
ret += "–#{to.text}" if to
|
75
82
|
ret += ")" if type == "list"
|
@@ -81,17 +88,18 @@ module IsoDoc
|
|
81
88
|
l10n(@xrefs.anchor(container, :xref) + delim + linkend)
|
82
89
|
end
|
83
90
|
|
84
|
-
def example_span_label(
|
91
|
+
def example_span_label(_node, div, name)
|
85
92
|
return if name.nil?
|
86
|
-
|
93
|
+
|
94
|
+
div.span **{ class: "example_label" } do |_p|
|
87
95
|
name.children.each { |n| parse(n, div) }
|
88
96
|
end
|
89
97
|
end
|
90
98
|
|
91
|
-
def clause1(
|
92
|
-
if !
|
93
|
-
!%w(sections preface bibliography).include?(
|
94
|
-
|
99
|
+
def clause1(node)
|
100
|
+
if !node.at(ns("./title")) &&
|
101
|
+
!%w(sections preface bibliography).include?(node.parent.name)
|
102
|
+
node["inline-header"] = "true"
|
95
103
|
end
|
96
104
|
super
|
97
105
|
end
|
@@ -99,8 +107,8 @@ module IsoDoc
|
|
99
107
|
def clause(docxml)
|
100
108
|
docxml.xpath(ns("//clause[not(ancestor::annex)] | "\
|
101
109
|
"//terms | //definitions | //references | "\
|
102
|
-
"//preface/introduction[clause]"))
|
103
|
-
|
110
|
+
"//preface/introduction[clause]"))
|
111
|
+
.each do |f|
|
104
112
|
clause1(f)
|
105
113
|
end
|
106
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(
|
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(
|
18
|
-
file = File.read(
|
19
|
-
|
20
|
-
/\.xml$/.match(
|
21
|
-
|
22
|
-
|
23
|
-
|
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(
|
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"),
|
data/lib/isodoc/iso/xref.rb
CHANGED
@@ -4,24 +4,33 @@ module IsoDoc
|
|
4
4
|
end
|
5
5
|
|
6
6
|
class Xref < IsoDoc::Xref
|
7
|
-
def initial_anchor_names(
|
8
|
-
if @klass.amd(
|
9
|
-
|
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(
|
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
|
-
|
32
|
+
|
33
|
+
clause.at(ns("./clause")) and @anchors[clause["id"]] =
|
25
34
|
{ label: "0", level: 1, xref: clause.at(ns("./title"))&.text, type: "clause" }
|
26
35
|
i = Counter.new
|
27
36
|
clause.xpath(ns("./clause")).each do |c|
|
@@ -35,17 +44,19 @@ module IsoDoc
|
|
35
44
|
super
|
36
45
|
end
|
37
46
|
|
38
|
-
def appendix_names(clause,
|
47
|
+
def appendix_names(clause, _num)
|
39
48
|
i = Counter.new
|
40
49
|
clause.xpath(ns("./appendix")).each do |c|
|
41
50
|
i.increment(c)
|
42
|
-
@anchors[c["id"]] = anchor_struct(i.print, nil, @labels["appendix"],
|
51
|
+
@anchors[c["id"]] = anchor_struct(i.print, nil, @labels["appendix"],
|
52
|
+
"clause")
|
43
53
|
@anchors[c["id"]][:level] = 2
|
44
54
|
@anchors[c["id"]][:container] = clause["id"]
|
45
55
|
j = Counter.new
|
46
56
|
c.xpath(ns("./clause | ./references")).each do |c1|
|
47
57
|
j.increment(c1)
|
48
|
-
|
58
|
+
lbl = "#{@labels['appendix']} #{i.print}.#{j.print}"
|
59
|
+
appendix_names1(c1, l10n(lbl), 3, clause["id"])
|
49
60
|
end
|
50
61
|
end
|
51
62
|
end
|
@@ -56,8 +67,8 @@ module IsoDoc
|
|
56
67
|
# subclauses are not prefixed with "Clause"
|
57
68
|
i = Counter.new
|
58
69
|
clause.xpath(ns("./clause | ./terms | ./term | ./definitions | "\
|
59
|
-
"./references"))
|
60
|
-
|
70
|
+
"./references"))
|
71
|
+
.each do |c|
|
61
72
|
i.increment(c)
|
62
73
|
section_names1(c, "#{num}.#{i.print}", level + 1)
|
63
74
|
end
|
@@ -73,7 +84,8 @@ module IsoDoc
|
|
73
84
|
end
|
74
85
|
|
75
86
|
def appendix_names1(clause, num, level, container)
|
76
|
-
@anchors[clause["id"]] = { label: num, xref: num, level: level,
|
87
|
+
@anchors[clause["id"]] = { label: num, xref: num, level: level,
|
88
|
+
container: container }
|
77
89
|
i = Counter.new
|
78
90
|
clause.xpath(ns("./clause | ./references")).each do |c|
|
79
91
|
i.increment(c)
|
@@ -85,6 +97,7 @@ module IsoDoc
|
|
85
97
|
c = IsoDoc::XrefGen::Counter.new
|
86
98
|
clause.xpath(ns(".//formula")).each do |t|
|
87
99
|
next if t["id"].nil? || t["id"].empty?
|
100
|
+
|
88
101
|
@anchors[t["id"]] =
|
89
102
|
anchor_struct("#{num}#{hiersep}#{c.increment(t).print}", t,
|
90
103
|
t["inequality"] ? @labels["inequality"] : @labels["formula"],
|
@@ -95,7 +108,8 @@ module IsoDoc
|
|
95
108
|
def figure_anchor(t, sublabel, label)
|
96
109
|
@anchors[t["id"]] = anchor_struct(
|
97
110
|
(sublabel ? "#{label} #{sublabel}" : label),
|
98
|
-
nil, @labels["figure"], "figure", t["unnumbered"]
|
111
|
+
nil, @labels["figure"], "figure", t["unnumbered"]
|
112
|
+
)
|
99
113
|
sublabel && t["unnumbered"] != "true" and
|
100
114
|
@anchors[t["id"]][:label] = sublabel
|
101
115
|
end
|
@@ -103,11 +117,12 @@ module IsoDoc
|
|
103
117
|
def sequential_figure_names(clause)
|
104
118
|
c = IsoDoc::XrefGen::Counter.new
|
105
119
|
j = 0
|
106
|
-
clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
|
107
|
-
each do |t|
|
120
|
+
clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
|
121
|
+
.each do |t|
|
108
122
|
j = subfigure_increment(j, c, t)
|
109
|
-
sublabel = j.zero? ? nil : "#{(j+96).chr})"
|
123
|
+
sublabel = j.zero? ? nil : "#{(j + 96).chr})"
|
110
124
|
next if t["id"].nil? || t["id"].empty?
|
125
|
+
|
111
126
|
figure_anchor(t, sublabel, c.print)
|
112
127
|
end
|
113
128
|
end
|
@@ -115,20 +130,26 @@ module IsoDoc
|
|
115
130
|
def hierarchical_figure_names(clause, num)
|
116
131
|
c = IsoDoc::XrefGen::Counter.new
|
117
132
|
j = 0
|
118
|
-
clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
|
119
|
-
each do |t|
|
133
|
+
clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
|
134
|
+
.each do |t|
|
120
135
|
j = subfigure_increment(j, c, t)
|
121
136
|
label = "#{num}#{hiersep}#{c.print}"
|
122
|
-
sublabel = j.zero? ? nil : "#{(j+96).chr})"
|
137
|
+
sublabel = j.zero? ? nil : "#{(j + 96).chr})"
|
123
138
|
next if t["id"].nil? || t["id"].empty?
|
139
|
+
|
124
140
|
figure_anchor(t, sublabel, label)
|
125
141
|
end
|
126
142
|
end
|
127
143
|
|
128
144
|
def reference_names(ref)
|
129
145
|
super
|
130
|
-
@anchors[ref["id"]] = { xref: @anchors[ref["id"]][:xref]
|
131
|
-
|
146
|
+
@anchors[ref["id"]] = { xref: @anchors[ref["id"]][:xref]
|
147
|
+
.sub(/ \(All Parts\)/i, "") }
|
148
|
+
end
|
149
|
+
|
150
|
+
def back_anchor_names(docxml)
|
151
|
+
super
|
152
|
+
docxml.xpath(ns("//indexsect")).each { |b| preface_names(b) }
|
132
153
|
end
|
133
154
|
end
|
134
155
|
end
|
data/metanorma-iso.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
lib = File.expand_path("
|
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.5.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 "
|
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
|
-
spec.add_development_dependency "rubocop", "
|
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
|
@@ -235,7 +235,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
235
235
|
<language>en</language>
|
236
236
|
<script>Latn</script>
|
237
237
|
<status>
|
238
|
-
<stage abbreviation="NP">10</stage>
|
238
|
+
<stage abbreviation="NP Amd">10</stage>
|
239
239
|
<substage>20</substage>
|
240
240
|
<iteration>3</iteration>
|
241
241
|
</status>
|
@@ -320,7 +320,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
320
320
|
<language>en</language>
|
321
321
|
<script>Latn</script>
|
322
322
|
<status>
|
323
|
-
<stage abbreviation="CD">30</stage>
|
323
|
+
<stage abbreviation="CD Amd">30</stage>
|
324
324
|
<substage>00</substage>
|
325
325
|
</status>
|
326
326
|
<copyright>
|
@@ -389,7 +389,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
389
389
|
<language>en</language>
|
390
390
|
<script>Latn</script>
|
391
391
|
<status>
|
392
|
-
<stage abbreviation="
|
392
|
+
<stage abbreviation="DAmd">40</stage>
|
393
393
|
<substage>00</substage>
|
394
394
|
</status>
|
395
395
|
<copyright>
|
@@ -527,7 +527,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
527
527
|
<language>en</language>
|
528
528
|
<script>Latn</script>
|
529
529
|
<status>
|
530
|
-
<stage abbreviation="CD">30</stage>
|
530
|
+
<stage abbreviation="CD Cor">30</stage>
|
531
531
|
<substage>00</substage>
|
532
532
|
</status>
|
533
533
|
<copyright>
|
@@ -596,7 +596,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
596
596
|
<language>en</language>
|
597
597
|
<script>Latn</script>
|
598
598
|
<status>
|
599
|
-
<stage abbreviation='
|
599
|
+
<stage abbreviation='FDCor'>50</stage>
|
600
600
|
<substage>00</substage>
|
601
601
|
</status>
|
602
602
|
<copyright>
|
@@ -0,0 +1,825 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Asciidoctor::ISO do
|
4
|
+
it "has a version number" do
|
5
|
+
expect(Metanorma::ISO::VERSION).not_to be nil
|
6
|
+
end
|
7
|
+
|
8
|
+
it "processes a blank document" do
|
9
|
+
input = <<~INPUT
|
10
|
+
#{ASCIIDOC_BLANK_HDR}
|
11
|
+
INPUT
|
12
|
+
output = <<~OUTPUT
|
13
|
+
#{BLANK_HDR}
|
14
|
+
<sections/>
|
15
|
+
</iso-standard>
|
16
|
+
OUTPUT
|
17
|
+
expect(xmlpp(Asciidoctor.convert(input, *OPTIONS)))
|
18
|
+
.to be_equivalent_to xmlpp(output)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "converts a blank document" do
|
22
|
+
input = <<~INPUT
|
23
|
+
= Document title
|
24
|
+
Author
|
25
|
+
:docfile: test.adoc
|
26
|
+
:novalid:
|
27
|
+
:no-isobib:
|
28
|
+
INPUT
|
29
|
+
output = <<~OUTPUT
|
30
|
+
#{BLANK_HDR}
|
31
|
+
<sections/>
|
32
|
+
</iso-standard>
|
33
|
+
OUTPUT
|
34
|
+
expect(xmlpp(Asciidoctor.convert(input, *OPTIONS)))
|
35
|
+
.to be_equivalent_to xmlpp(output)
|
36
|
+
expect(File.exist?("test_alt.html")).to be true
|
37
|
+
expect(File.exist?("test.html")).to be true
|
38
|
+
expect(File.exist?("test.doc")).to be true
|
39
|
+
expect(File.exist?("test.pdf")).to be true
|
40
|
+
expect(File.exist?("htmlstyle.css")).to be false
|
41
|
+
end
|
42
|
+
|
43
|
+
it "converts a blank document in French" do
|
44
|
+
input = <<~INPUT
|
45
|
+
= Document title
|
46
|
+
Author
|
47
|
+
:docfile: test.adoc
|
48
|
+
:novalid:
|
49
|
+
:no-isobib:
|
50
|
+
:no-pdf:
|
51
|
+
:language: fr
|
52
|
+
INPUT
|
53
|
+
output = <<~OUTPUT
|
54
|
+
#{BLANK_HDR_FR}
|
55
|
+
<sections/>
|
56
|
+
</iso-standard>
|
57
|
+
OUTPUT
|
58
|
+
expect(xmlpp(Asciidoctor.convert(input, *OPTIONS)))
|
59
|
+
.to be_equivalent_to xmlpp(output)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "processes default metadata" do
|
63
|
+
output = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
64
|
+
= Document title
|
65
|
+
Author
|
66
|
+
:docfile: test.adoc
|
67
|
+
:nodoc:
|
68
|
+
:novalid:
|
69
|
+
:no-isobib:
|
70
|
+
:docnumber: 1000
|
71
|
+
:partnumber: 1
|
72
|
+
:edition: 2
|
73
|
+
:revdate: 2000-01-01
|
74
|
+
:draft: 0.3.4
|
75
|
+
:technical-committee: TC
|
76
|
+
:technical-committee-number: 1
|
77
|
+
:technical-committee-type: A
|
78
|
+
:subcommittee: SC
|
79
|
+
:subcommittee-number: 2
|
80
|
+
:subcommittee-type: B
|
81
|
+
:workgroup: WG
|
82
|
+
:workgroup-number: 3
|
83
|
+
:workgroup-type: C
|
84
|
+
:technical-committee_2: TC1
|
85
|
+
:technical-committee-number_2: 11
|
86
|
+
:technical-committee-type_2: A1
|
87
|
+
:subcommittee_2: SC1
|
88
|
+
:subcommittee-number_2: 21
|
89
|
+
:subcommittee-type_2: B1
|
90
|
+
:workgroup_2: WG1
|
91
|
+
:workgroup-number_2: 31
|
92
|
+
:workgroup-type_2: C1
|
93
|
+
:secretariat: SECRETARIAT
|
94
|
+
:docstage: 20
|
95
|
+
:docsubstage: 20
|
96
|
+
:iteration: 3
|
97
|
+
:language: en
|
98
|
+
:title-intro-en: Introduction
|
99
|
+
:title-main-en: Main Title -- Title
|
100
|
+
:title-part-en: Title Part
|
101
|
+
:title-intro-fr: Introduction Française
|
102
|
+
:title-main-fr: Titre Principal
|
103
|
+
:title-part-fr: Part du Titre
|
104
|
+
:library-ics: 1,2,3
|
105
|
+
:copyright-year: 2000
|
106
|
+
:horizontal: true
|
107
|
+
INPUT
|
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"/>
|
127
|
+
<organization>
|
128
|
+
<name>International Organization for Standardization</name>
|
129
|
+
<abbreviation>ISO</abbreviation>
|
130
|
+
</organization>
|
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
|
190
|
+
end
|
191
|
+
|
192
|
+
it "processes complex metadata" do
|
193
|
+
output = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
194
|
+
= Document title
|
195
|
+
Author
|
196
|
+
:docfile: test.adoc
|
197
|
+
:nodoc:
|
198
|
+
:novalid:
|
199
|
+
:no-isobib:
|
200
|
+
:docnumber: 1000
|
201
|
+
:partnumber: 1-1
|
202
|
+
:tc-docnumber: 2000, 2003
|
203
|
+
:language: el
|
204
|
+
:script: Grek
|
205
|
+
:publisher: IEC;IETF;ISO
|
206
|
+
:copyright-holder: ISO;IETF
|
207
|
+
:copyright-year: 2001
|
208
|
+
:doctype: technical-report
|
209
|
+
:pub-address: 1 Infinity Loop + \
|
210
|
+
California
|
211
|
+
:pub-phone: 3333333
|
212
|
+
:pub-fax: 4444444
|
213
|
+
:pub-email: x@example.com
|
214
|
+
:pub-uri: http://www.example.com
|
215
|
+
INPUT
|
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
|
342
|
+
end
|
343
|
+
|
344
|
+
it "processes subdivisions" do
|
345
|
+
output = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
346
|
+
= Document title
|
347
|
+
Author
|
348
|
+
:docfile: test.adoc
|
349
|
+
:nodoc:
|
350
|
+
:novalid:
|
351
|
+
:revdate: 2000-01
|
352
|
+
:published-date: 1000-01
|
353
|
+
:docnumber: 1000
|
354
|
+
:partnumber: 1-1
|
355
|
+
:tc-docnumber: 2000
|
356
|
+
:language: el
|
357
|
+
:script: Grek
|
358
|
+
:subdivision: Subdivision
|
359
|
+
:subdivision-abbr: SD
|
360
|
+
:doctype: This is a DocType
|
361
|
+
:pub-address: 1 Infinity Loop + \\
|
362
|
+
California
|
363
|
+
:pub-phone: 3333333
|
364
|
+
:pub-fax: 4444444
|
365
|
+
:pub-email: x@example.com
|
366
|
+
:pub-uri: http://www.example.com
|
367
|
+
INPUT
|
368
|
+
expect(xmlpp(strip_guid(output
|
369
|
+
.sub(%r{<boilerplate>.*</boilerplate>}m, ""))))
|
370
|
+
.to be_equivalent_to xmlpp(<<~"OUTPUT")
|
371
|
+
<iso-standard xmlns="https://www.metanorma.org/ns/iso" type="semantic" version="#{Metanorma::ISO::VERSION}">
|
372
|
+
<bibdata type='standard'>
|
373
|
+
<docidentifier type='ISO'>SD 1000-1-1</docidentifier>
|
374
|
+
<docidentifier type='iso-with-lang'>SD 1000-1-1(X)</docidentifier>
|
375
|
+
<docidentifier type='iso-reference'>SD 1000-1-1(X)</docidentifier>
|
376
|
+
<docidentifier type='iso-tc'>2000</docidentifier>
|
377
|
+
<docnumber>1000</docnumber>
|
378
|
+
<date type='published'>
|
379
|
+
<on>1000-01</on>
|
380
|
+
</date>
|
381
|
+
<contributor>
|
382
|
+
<role type='author'/>
|
383
|
+
<organization>
|
384
|
+
<name>International Organization for Standardization</name>
|
385
|
+
<subdivision>Subdivision</subdivision>
|
386
|
+
<abbreviation>SD</abbreviation>
|
387
|
+
</organization>
|
388
|
+
</contributor>
|
389
|
+
<contributor>
|
390
|
+
<role type='publisher'/>
|
391
|
+
<organization>
|
392
|
+
<name>International Organization for Standardization</name>
|
393
|
+
<subdivision>Subdivision</subdivision>
|
394
|
+
<abbreviation>SD</abbreviation>
|
395
|
+
<address>
|
396
|
+
<formattedAddress>1 Infinity Loop <br/>California</formattedAddress>
|
397
|
+
</address>
|
398
|
+
<phone>3333333</phone>
|
399
|
+
<phone type='fax'>4444444</phone>
|
400
|
+
<email>x@example.com</email>
|
401
|
+
<uri>http://www.example.com</uri>
|
402
|
+
</organization>
|
403
|
+
</contributor>
|
404
|
+
<version>
|
405
|
+
<revision-date>2000-01</revision-date>
|
406
|
+
</version>
|
407
|
+
<language>el</language>
|
408
|
+
<script>Grek</script>
|
409
|
+
<status>
|
410
|
+
<stage abbreviation='IS'>60</stage>
|
411
|
+
<substage>60</substage>
|
412
|
+
</status>
|
413
|
+
<copyright>
|
414
|
+
<from>#{Time.now.year}</from>
|
415
|
+
<owner>
|
416
|
+
<organization>
|
417
|
+
<name>International Organization for Standardization</name>
|
418
|
+
<subdivision>Subdivision</subdivision>
|
419
|
+
<abbreviation>SD</abbreviation>
|
420
|
+
<address>
|
421
|
+
<formattedAddress>1 Infinity Loop
|
422
|
+
<br/>
|
423
|
+
California</formattedAddress>
|
424
|
+
</address>
|
425
|
+
<phone>3333333</phone>
|
426
|
+
<phone type="fax">4444444</phone>
|
427
|
+
<email>x@example.com</email>
|
428
|
+
<uri>http://www.example.com</uri>
|
429
|
+
</organization>
|
430
|
+
</owner>
|
431
|
+
</copyright>
|
432
|
+
<ext>
|
433
|
+
<doctype>this-is-a-doctype</doctype>
|
434
|
+
<editorialgroup>
|
435
|
+
<technical-committee/>
|
436
|
+
<subcommittee/>
|
437
|
+
<workgroup/>
|
438
|
+
</editorialgroup>
|
439
|
+
<structuredidentifier>
|
440
|
+
<project-number part="1" subpart="1">SD 1000</project-number>
|
441
|
+
</structuredidentifier>
|
442
|
+
<stagename>International standard</stagename>
|
443
|
+
</ext>
|
444
|
+
</bibdata>
|
445
|
+
<sections> </sections>
|
446
|
+
</iso-standard>
|
447
|
+
OUTPUT
|
448
|
+
end
|
449
|
+
|
450
|
+
it "defaults substage, defines iteration on stage 50" do
|
451
|
+
output = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
452
|
+
= Document title
|
453
|
+
Author
|
454
|
+
:docfile: test.adoc
|
455
|
+
:nodoc:
|
456
|
+
:novalid:
|
457
|
+
:no-isobib:
|
458
|
+
:docnumber: 1000
|
459
|
+
:docstage: 50
|
460
|
+
:language: fr
|
461
|
+
:doctype: international-standard
|
462
|
+
:iteration: 2
|
463
|
+
INPUT
|
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}">
|
535
|
+
<bibdata type="standard">
|
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>
|
539
|
+
<docnumber>1000</docnumber>
|
540
|
+
<contributor>
|
541
|
+
<role type="author"/>
|
542
|
+
<organization>
|
543
|
+
<name>International Organization for Standardization</name>
|
544
|
+
<abbreviation>ISO</abbreviation>
|
545
|
+
</organization>
|
546
|
+
</contributor>
|
547
|
+
<contributor>
|
548
|
+
<role type="publisher"/>
|
549
|
+
<organization>
|
550
|
+
<name>International Organization for Standardization</name>
|
551
|
+
<abbreviation>ISO</abbreviation>
|
552
|
+
</organization>
|
553
|
+
</contributor>
|
554
|
+
|
555
|
+
<language>en</language>
|
556
|
+
<script>Latn</script>
|
557
|
+
<status>
|
558
|
+
<stage abbreviation="IS">60</stage>
|
559
|
+
<substage>60</substage>
|
560
|
+
</status>
|
561
|
+
<copyright>
|
562
|
+
<from>#{Date.today.year}</from>
|
563
|
+
<owner>
|
564
|
+
<organization>
|
565
|
+
<name>International Organization for Standardization</name>
|
566
|
+
<abbreviation>ISO</abbreviation>
|
567
|
+
</organization>
|
568
|
+
</owner>
|
569
|
+
</copyright>
|
570
|
+
<ext>
|
571
|
+
<doctype>article</doctype>
|
572
|
+
<editorialgroup>
|
573
|
+
<technical-committee/>
|
574
|
+
<subcommittee/>
|
575
|
+
<workgroup/>
|
576
|
+
</editorialgroup>
|
577
|
+
<structuredidentifier>
|
578
|
+
<project-number>ISO 1000</project-number>
|
579
|
+
</structuredidentifier>
|
580
|
+
<stagename>International standard</stagename>
|
581
|
+
</ext>
|
582
|
+
</bibdata>
|
583
|
+
<sections/>
|
584
|
+
</iso-standard>
|
585
|
+
OUTPUT
|
586
|
+
end
|
587
|
+
|
588
|
+
it "populates metadata for PRF" do
|
589
|
+
output = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
590
|
+
= Document title
|
591
|
+
Author
|
592
|
+
:docfile: test.adoc
|
593
|
+
:nodoc:
|
594
|
+
:novalid:
|
595
|
+
:no-isobib:
|
596
|
+
:docnumber: 1000
|
597
|
+
:docstage: 60
|
598
|
+
:docsubstage: 00
|
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>
|
622
|
+
|
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
|
654
|
+
end
|
655
|
+
|
656
|
+
it "defaults metadata for DIR" do
|
657
|
+
output = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
658
|
+
= Document title
|
659
|
+
Author
|
660
|
+
:docfile: test.adoc
|
661
|
+
:nodoc:
|
662
|
+
:novalid:
|
663
|
+
:no-isobib:
|
664
|
+
:docnumber: 1000
|
665
|
+
:doctype: directive
|
666
|
+
INPUT
|
667
|
+
|
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'/>
|
678
|
+
<organization>
|
679
|
+
<name>International Organization for Standardization</name>
|
680
|
+
<abbreviation>ISO</abbreviation>
|
681
|
+
</organization>
|
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
|
721
|
+
end
|
722
|
+
|
723
|
+
it "reads scripts into blank HTML document" do
|
724
|
+
Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
725
|
+
= Document title
|
726
|
+
Author
|
727
|
+
:docfile: test.adoc
|
728
|
+
:novalid:
|
729
|
+
:no-isobib:
|
730
|
+
:no-pdf:
|
731
|
+
INPUT
|
732
|
+
html = File.read("test.html", encoding: "utf-8")
|
733
|
+
expect(html).to match(%r{<script>})
|
734
|
+
end
|
735
|
+
|
736
|
+
it "uses default fonts" do
|
737
|
+
Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
738
|
+
= Document title
|
739
|
+
Author
|
740
|
+
:docfile: test.adoc
|
741
|
+
:novalid:
|
742
|
+
:no-isobib:
|
743
|
+
:no-pdf:
|
744
|
+
INPUT
|
745
|
+
html = File.read("test.html", encoding: "utf-8")
|
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)
|
752
|
+
end
|
753
|
+
|
754
|
+
it "uses default fonts for alt doc" do
|
755
|
+
Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
756
|
+
= Document title
|
757
|
+
Author
|
758
|
+
:docfile: test.adoc
|
759
|
+
:novalid:
|
760
|
+
:no-isobib:
|
761
|
+
:no-pdf:
|
762
|
+
INPUT
|
763
|
+
html = File.read("test_alt.html", encoding: "utf-8")
|
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)
|
770
|
+
end
|
771
|
+
|
772
|
+
it "uses Chinese fonts" do
|
773
|
+
Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
774
|
+
= Document title
|
775
|
+
Author
|
776
|
+
:docfile: test.adoc
|
777
|
+
:novalid:
|
778
|
+
:no-isobib:
|
779
|
+
:script: Hans
|
780
|
+
:no-pdf:
|
781
|
+
INPUT
|
782
|
+
html = File.read("test.html", encoding: "utf-8")
|
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)
|
789
|
+
end
|
790
|
+
|
791
|
+
it "uses specified fonts" do
|
792
|
+
Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
793
|
+
= Document title
|
794
|
+
Author
|
795
|
+
:docfile: test.adoc
|
796
|
+
:novalid:
|
797
|
+
:no-isobib:
|
798
|
+
:script: Hans
|
799
|
+
:body-font: Zapf Chancery
|
800
|
+
:header-font: Comic Sans
|
801
|
+
:monospace-font: Andale Mono
|
802
|
+
:no-pdf:
|
803
|
+
INPUT
|
804
|
+
html = File.read("test.html", encoding: "utf-8")
|
805
|
+
expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: Andale Mono;]m)
|
806
|
+
expect(html)
|
807
|
+
.to match(%r[blockquote[^{]+\{[^{]+font-family: Zapf Chancery;]m)
|
808
|
+
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: Comic Sans;]m)
|
809
|
+
end
|
810
|
+
|
811
|
+
it "strips MS-specific CSS" do
|
812
|
+
Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
813
|
+
= Document title
|
814
|
+
Author
|
815
|
+
:docfile: test.adoc
|
816
|
+
:novalid:
|
817
|
+
:no-isobib:
|
818
|
+
:no-pdf:
|
819
|
+
INPUT
|
820
|
+
word = File.read("test.doc", encoding: "utf-8")
|
821
|
+
html = File.read("test.html", encoding: "utf-8")
|
822
|
+
expect(word).to match(%r[mso-style-name: "Intro Title";]m)
|
823
|
+
expect(html).not_to match(%r[mso-style-name: "Intro Title";]m)
|
824
|
+
end
|
825
|
+
end
|