metanorma-iec 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/bin/rspec +18 -0
- data/lib/asciidoctor/iec/biblio.rng +949 -0
- data/lib/asciidoctor/iec/converter.rb +68 -0
- data/lib/asciidoctor/iec/iec_intro_en.xml +15 -0
- data/lib/asciidoctor/iec/iec_intro_fr.xml +15 -0
- data/lib/asciidoctor/iec/isodoc.rng +1132 -0
- data/lib/asciidoctor/iec/isostandard.rng +789 -0
- data/lib/asciidoctor/iec/reqt.rng +162 -0
- data/lib/isodoc/iec/base_convert.rb +69 -0
- data/lib/isodoc/iec/html/header.html +160 -0
- data/lib/isodoc/iec/html/html_iec_intro.html +34 -0
- data/lib/isodoc/iec/html/html_iec_titlepage.html +62 -0
- data/lib/isodoc/iec/html/htmlstyle.scss +840 -0
- data/lib/isodoc/iec/html/isodoc.scss +785 -0
- data/lib/isodoc/iec/html/scripts.html +176 -0
- data/lib/isodoc/iec/html/word_iec_intro.html +72 -0
- data/lib/isodoc/iec/html/word_iec_titlepage.html +92 -0
- data/lib/isodoc/iec/html/wordstyle.scss +1849 -0
- data/lib/isodoc/iec/html_convert.rb +33 -0
- data/lib/isodoc/iec/i18n-en.yaml +3 -0
- data/lib/isodoc/iec/i18n-fr.yaml +3 -0
- data/lib/isodoc/iec/i18n-zh-Hans.yaml +3 -0
- data/lib/isodoc/iec/metadata.rb +20 -0
- data/lib/isodoc/iec/word_convert.rb +165 -0
- data/lib/metanorma-iec.rb +12 -0
- data/lib/metanorma/iec.rb +8 -0
- data/lib/metanorma/iec/processor.rb +40 -0
- data/lib/metanorma/iec/version.rb +6 -0
- data/metanorma-iec.gemspec +47 -0
- data/spec/asciidoctor-iec/base_spec.rb +609 -0
- data/spec/asciidoctor-iec/blocks_spec.rb +467 -0
- data/spec/asciidoctor-iec/cleanup_spec.rb +766 -0
- data/spec/asciidoctor-iec/inline_spec.rb +162 -0
- data/spec/asciidoctor-iec/lists_spec.rb +190 -0
- data/spec/asciidoctor-iec/macros_spec.rb +21 -0
- data/spec/asciidoctor-iec/refs_spec.rb +268 -0
- data/spec/asciidoctor-iec/section_spec.rb +341 -0
- data/spec/asciidoctor-iec/table_spec.rb +307 -0
- data/spec/asciidoctor-iec/validate_spec.rb +132 -0
- data/spec/examples/rice.adoc +723 -0
- data/spec/examples/rice.doc +19162 -0
- data/spec/examples/rice.html +1787 -0
- data/spec/examples/rice.xml +1951 -0
- data/spec/isodoc/i18n_spec.rb +642 -0
- data/spec/isodoc/inline_spec.rb +265 -0
- data/spec/isodoc/iso_spec.rb +319 -0
- data/spec/isodoc/metadata_spec.rb +153 -0
- data/spec/isodoc/postproc_spec.rb +569 -0
- data/spec/isodoc/section_spec.rb +686 -0
- data/spec/isodoc/terms_spec.rb +206 -0
- data/spec/isodoc/xref_spec.rb +1323 -0
- data/spec/metanorma/processor_spec.rb +88 -0
- data/spec/spec_helper.rb +253 -0
- metadata +325 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
require "isodoc"
|
2
|
+
require "metanorma-iso"
|
3
|
+
require_relative "base_convert"
|
4
|
+
|
5
|
+
module IsoDoc
|
6
|
+
module Iec
|
7
|
+
class HtmlConvert < IsoDoc::Iso::HtmlConvert
|
8
|
+
def initialize(options)
|
9
|
+
super
|
10
|
+
@libdir = File.dirname(__FILE__)
|
11
|
+
end
|
12
|
+
|
13
|
+
def default_file_locations(options)
|
14
|
+
@libdir = File.dirname(__FILE__)
|
15
|
+
{
|
16
|
+
htmlstylesheet: html_doc_path("htmlstyle.scss"),
|
17
|
+
htmlcoverpage: html_doc_path("html_iec_titlepage.html"),
|
18
|
+
htmlintropage: html_doc_path("html_iec_intro.html"),
|
19
|
+
scripts: html_doc_path("scripts.html"),
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def htmlstyle(docxml)
|
24
|
+
docxml = super
|
25
|
+
b = docxml.at("div[@class = 'boilerplate_legal']/ol")
|
26
|
+
b and b["type"] = "1"
|
27
|
+
docxml
|
28
|
+
end
|
29
|
+
|
30
|
+
include BaseConvert
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "isodoc"
|
2
|
+
require "metanorma-iso"
|
3
|
+
|
4
|
+
module IsoDoc
|
5
|
+
module Iec
|
6
|
+
class Metadata < IsoDoc::Iso::Metadata
|
7
|
+
STAGE_ABBRS = {
|
8
|
+
"00": "PWI",
|
9
|
+
"10": "NWIP",
|
10
|
+
"20": "WD",
|
11
|
+
"30": "CD",
|
12
|
+
"40": "CDV",
|
13
|
+
"50": "FDIS",
|
14
|
+
"60": "IS",
|
15
|
+
"90": "(Review)",
|
16
|
+
"95": "(Withdrawal)",
|
17
|
+
}.freeze
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
require "isodoc"
|
2
|
+
require "metanorma-iso"
|
3
|
+
require_relative "base_convert"
|
4
|
+
|
5
|
+
module IsoDoc
|
6
|
+
module Iec
|
7
|
+
class WordConvert < IsoDoc::Iso::WordConvert
|
8
|
+
def initialize(options)
|
9
|
+
super
|
10
|
+
@libdir = File.dirname(__FILE__)
|
11
|
+
end
|
12
|
+
|
13
|
+
def default_fonts(options)
|
14
|
+
{
|
15
|
+
bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Arial",sans-serif'),
|
16
|
+
headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Arial",sans-serif'),
|
17
|
+
monospacefont: '"Courier New",monospace',
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def default_file_locations(options)
|
22
|
+
@libdir = File.dirname(__FILE__)
|
23
|
+
{
|
24
|
+
wordstylesheet: html_doc_path("wordstyle.scss"),
|
25
|
+
standardstylesheet: html_doc_path("isodoc.scss"),
|
26
|
+
header: html_doc_path("header.html"),
|
27
|
+
wordcoverpage: html_doc_path("word_iec_titlepage.html"),
|
28
|
+
wordintropage: html_doc_path("word_iec_intro.html"),
|
29
|
+
ulstyle: "l22",
|
30
|
+
olstyle: "l2",
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def insert_toc(intro, docxml, level)
|
35
|
+
toc = ""
|
36
|
+
toc += make_WordToC(docxml, level)
|
37
|
+
if docxml.at("//p[@class = 'TableTitle']")
|
38
|
+
#toc += %{<p class="TOCTitle">List of Tables</p>}
|
39
|
+
toc += make_TableWordToC(docxml)
|
40
|
+
end
|
41
|
+
if docxml.at("//p[@class = 'FigureTitle']")
|
42
|
+
#toc += %{<p class="TOCTitle">List of Figures</p>}
|
43
|
+
toc += make_FigureWordToC(docxml)
|
44
|
+
end
|
45
|
+
intro.sub(/WORDTOC/, toc)
|
46
|
+
end
|
47
|
+
|
48
|
+
WORD_TOC_TABLE_PREFACE1 = <<~TOC.freeze
|
49
|
+
<span lang="EN-GB"><span
|
50
|
+
style='mso-element:field-begin'></span><span
|
51
|
+
style='mso-spacerun:yes'> </span>TOC
|
52
|
+
\\h \\z \\t "TableTitle,1" <span
|
53
|
+
style='mso-element:field-separator'></span></span>
|
54
|
+
TOC
|
55
|
+
|
56
|
+
WORD_TOC_FIGURE_PREFACE1 = <<~TOC.freeze
|
57
|
+
<span lang="EN-GB"><span
|
58
|
+
style='mso-element:field-begin'></span><span
|
59
|
+
style='mso-spacerun:yes'> </span>TOC
|
60
|
+
\\h \\z \\t "FigureTitle,1" <span
|
61
|
+
style='mso-element:field-separator'></span></span>
|
62
|
+
TOC
|
63
|
+
|
64
|
+
def make_TableWordToC(docxml)
|
65
|
+
toc = ""
|
66
|
+
docxml.xpath("//p[@class = 'TableTitle']").each do |h|
|
67
|
+
toc += word_toc_entry(1, header_strip(h))
|
68
|
+
end
|
69
|
+
toc.sub(/(<p class="MsoToc1">)/,
|
70
|
+
%{\\1#{WORD_TOC_TABLE_PREFACE1}}) + WORD_TOC_SUFFIX1
|
71
|
+
end
|
72
|
+
|
73
|
+
def make_FigureWordToC(docxml)
|
74
|
+
toc = ""
|
75
|
+
docxml.xpath("//p[@class = 'FigureTitle']").each do |h|
|
76
|
+
toc += word_toc_entry(1, header_strip(h))
|
77
|
+
end
|
78
|
+
toc.sub(/(<p class="MsoToc1">)/,
|
79
|
+
%{\\1#{WORD_TOC_FIGURE_PREFACE1}}) + WORD_TOC_SUFFIX1
|
80
|
+
end
|
81
|
+
|
82
|
+
def header_strip(h)
|
83
|
+
h = h.to_s.gsub(/<\/?p[^>]*>/, "")
|
84
|
+
super
|
85
|
+
end
|
86
|
+
|
87
|
+
def word_cleanup(docxml)
|
88
|
+
word_foreword_cleanup(docxml)
|
89
|
+
word_table_cleanup(docxml)
|
90
|
+
super
|
91
|
+
end
|
92
|
+
|
93
|
+
def make_tr_attr(td, row, totalrows)
|
94
|
+
ret = super
|
95
|
+
css_class = td.name == "th" ? "TABLE-col-heading" : "TABLE-cell"
|
96
|
+
ret.merge( "class": css_class )
|
97
|
+
end
|
98
|
+
|
99
|
+
def tr_parse(node, out, ord, totalrows, header)
|
100
|
+
out.tr do |r|
|
101
|
+
node.elements.each do |td|
|
102
|
+
attrs = make_tr_attr(td, ord, totalrows - 1)
|
103
|
+
attrs[:class] = "TABLE-col-heading" if header
|
104
|
+
r.send td.name, **attr_code(attrs) do |entry|
|
105
|
+
td.children.each { |n| parse(n, entry) }
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def word_table_cleanup(docxml)
|
112
|
+
docxml.xpath("//table//*[@class = 'Sourcecode']").each do |p|
|
113
|
+
p["class"] = "CODE-TableCell"
|
114
|
+
end
|
115
|
+
%w(TABLE-col-heading TABLE-cell).each do |style|
|
116
|
+
word_table_cleanup1(docxml, style)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def word_table_cleanup1(docxml, style)
|
121
|
+
%w(td th).each do |tdh|
|
122
|
+
docxml.xpath("//#{tdh}[@class = '#{style}'][not(descendant::p)]").each do |td|
|
123
|
+
p = Nokogiri::XML::Element.new("p", docxml)
|
124
|
+
td.children.each { |c| c.parent = p }
|
125
|
+
p.parent = td
|
126
|
+
end
|
127
|
+
docxml.xpath("//#{tdh}[@class = '#{style}']//p").each do |p|
|
128
|
+
p["class"] ||= style
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def word_annex_cleanup(docxml)
|
134
|
+
super
|
135
|
+
non_annex_h1(docxml)
|
136
|
+
end
|
137
|
+
|
138
|
+
def non_annex_h1(docxml)
|
139
|
+
docxml.xpath("//h1[not(@class)]").each do |h1|
|
140
|
+
h1["class"] = "main"
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
# Incredibly, the numbered boilerplate list in IEC is NOT A LIST,
|
145
|
+
# and it violates numbering conventions for ordered lists
|
146
|
+
# (arabic not alpha)
|
147
|
+
BOILERPLATE_PARAS = "//div[@class = 'boilerplate_legal']//li/p".freeze
|
148
|
+
|
149
|
+
def word_foreword_cleanup(docxml)
|
150
|
+
docxml.xpath(BOILERPLATE_PARAS).each_with_index do |l, i|
|
151
|
+
l["class"] = "FOREWORD"
|
152
|
+
l.children.first.add_previous_sibling(
|
153
|
+
%{#{i+1})<span style="mso-tab-count:1">  </span>})
|
154
|
+
end
|
155
|
+
docxml.xpath("//div[@class = 'boilerplate_legal']//li").each do |l|
|
156
|
+
l.replace(l.children)
|
157
|
+
end
|
158
|
+
b = docxml.at("div[@class = 'boilerplate_legal']")
|
159
|
+
b.replace(b.children)
|
160
|
+
end
|
161
|
+
|
162
|
+
include BaseConvert
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "asciidoctor" unless defined? Asciidoctor::Converter
|
2
|
+
require_relative "asciidoctor/iec/converter"
|
3
|
+
require_relative "metanorma/iec/version"
|
4
|
+
require "isodoc/iec/html_convert"
|
5
|
+
require "isodoc/iec/word_convert"
|
6
|
+
require "isodoc/iec/metadata"
|
7
|
+
|
8
|
+
if defined? Metanorma
|
9
|
+
require_relative "metanorma/iec"
|
10
|
+
Metanorma::Registry.instance.register(Metanorma::Iec::Processor)
|
11
|
+
end
|
12
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "metanorma/processor"
|
2
|
+
|
3
|
+
module Metanorma
|
4
|
+
module Iec
|
5
|
+
class Processor < Metanorma::Processor
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@short = :iec
|
9
|
+
@input_format = :asciidoc
|
10
|
+
@asciidoctor_backend = :iec
|
11
|
+
end
|
12
|
+
|
13
|
+
def output_formats
|
14
|
+
super.merge(
|
15
|
+
html: "html",
|
16
|
+
doc: "doc"
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def version
|
21
|
+
"Metanorma::Iec #{Metanorma::Iec::VERSION}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def input_to_isodoc(file, filename)
|
25
|
+
Metanorma::Input::Asciidoc.new.process(file, filename, @asciidoctor_backend)
|
26
|
+
end
|
27
|
+
|
28
|
+
def output(isodoc_node, outname, format, options={})
|
29
|
+
case format
|
30
|
+
when :html
|
31
|
+
IsoDoc::Iec::HtmlConvert.new(options).convert(outname, isodoc_node)
|
32
|
+
when :doc
|
33
|
+
IsoDoc::Iec::WordConvert.new(options).convert(outname, isodoc_node)
|
34
|
+
else
|
35
|
+
super
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "metanorma/iec/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "metanorma-iec"
|
9
|
+
spec.version = Metanorma::Iec::VERSION
|
10
|
+
spec.authors = ["Ribose Inc."]
|
11
|
+
spec.email = ["open.source@ribose.com"]
|
12
|
+
|
13
|
+
spec.summary = "metanorma-iec lets you write IEC standards "\
|
14
|
+
"in AsciiDoc."
|
15
|
+
spec.description = <<~DESCRIPTION
|
16
|
+
metanorma-iso lets you write IEC standards in AsciiDoc syntax.
|
17
|
+
|
18
|
+
This gem is in active development.
|
19
|
+
DESCRIPTION
|
20
|
+
|
21
|
+
spec.homepage = "https://github.com/metanorma/metanorma-iec"
|
22
|
+
spec.license = "BSD-2-Clause"
|
23
|
+
|
24
|
+
spec.bindir = "bin"
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
spec.files = `git ls-files`.split("\n")
|
27
|
+
spec.test_files = `git ls-files -- {spec}/*`.split("\n")
|
28
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
29
|
+
|
30
|
+
spec.add_dependency "asciidoctor", "~> 1.5.7"
|
31
|
+
spec.add_dependency "ruby-jing"
|
32
|
+
spec.add_dependency "isodoc", "~> 0.10.0"
|
33
|
+
spec.add_dependency "metanorma-iso", "~> 1.2.0"
|
34
|
+
|
35
|
+
spec.add_development_dependency "bundler", "~> 2.0.1"
|
36
|
+
spec.add_development_dependency "byebug"
|
37
|
+
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
38
|
+
spec.add_development_dependency "guard", "~> 2.14"
|
39
|
+
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
40
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
41
|
+
spec.add_development_dependency "rspec", "~> 3.6"
|
42
|
+
spec.add_development_dependency "rubocop", "= 0.54.0"
|
43
|
+
spec.add_development_dependency "simplecov", "~> 0.15"
|
44
|
+
spec.add_development_dependency "timecop", "~> 0.9"
|
45
|
+
spec.add_development_dependency "metanorma", "~> 0.3.0"
|
46
|
+
spec.add_development_dependency "iev", "~> 0.2.0"
|
47
|
+
end
|
@@ -0,0 +1,609 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
RSpec.describe Asciidoctor::Iec do
|
5
|
+
it "has a version number" do
|
6
|
+
expect(Metanorma::Iec::VERSION).not_to be nil
|
7
|
+
end
|
8
|
+
|
9
|
+
#it "generates output for the Rice document" do
|
10
|
+
#FileUtils.rm_f %w(spec/examples/rice.xml spec/examples/rice.doc spec/examples/rice.html spec/examples/rice_alt.html)
|
11
|
+
#FileUtils.cd "spec/examples"
|
12
|
+
#Asciidoctor.convert_file "rice.adoc", {:attributes=>{"backend"=>"iso"}, :safe=>0, :header_footer=>true, :requires=>["metanorma-iso"], :failure_level=>4, :mkdirs=>true, :to_file=>nil}
|
13
|
+
#FileUtils.cd "../.."
|
14
|
+
#expect(File.exist?("spec/examples/rice.xml")).to be true
|
15
|
+
#expect(File.exist?("spec/examples/rice.doc")).to be true
|
16
|
+
#expect(File.exist?("spec/examples/rice.html")).to be true
|
17
|
+
#expect(File.exist?("spec/examples/rice_alt.html")).to be true
|
18
|
+
#end
|
19
|
+
|
20
|
+
it "processes a blank document" do
|
21
|
+
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
|
22
|
+
#{ASCIIDOC_BLANK_HDR}
|
23
|
+
INPUT
|
24
|
+
#{BLANK_HDR}
|
25
|
+
<sections/>
|
26
|
+
</iso-standard>
|
27
|
+
OUTPUT
|
28
|
+
end
|
29
|
+
|
30
|
+
it "converts a blank document" do
|
31
|
+
FileUtils.rm_f "test.doc"
|
32
|
+
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
|
33
|
+
= Document title
|
34
|
+
Author
|
35
|
+
:docfile: test.adoc
|
36
|
+
:novalid:
|
37
|
+
:no-isobib:
|
38
|
+
INPUT
|
39
|
+
#{BLANK_HDR}
|
40
|
+
<sections/>
|
41
|
+
</iso-standard>
|
42
|
+
OUTPUT
|
43
|
+
expect(File.exist?("test.doc")).to be true
|
44
|
+
expect(File.exist?("htmlstyle.css")).to be false
|
45
|
+
end
|
46
|
+
|
47
|
+
it "processes default metadata" do
|
48
|
+
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
|
49
|
+
= Document title
|
50
|
+
Author
|
51
|
+
:docfile: test.adoc
|
52
|
+
:nodoc:
|
53
|
+
:novalid:
|
54
|
+
:no-isobib:
|
55
|
+
:docnumber: 1000
|
56
|
+
:partnumber: 1
|
57
|
+
:edition: 2
|
58
|
+
:revdate: 2000-01-01
|
59
|
+
:draft: 0.3.4
|
60
|
+
:technical-committee: TC
|
61
|
+
:technical-committee-number: 1
|
62
|
+
:technical-committee-type: A
|
63
|
+
:subcommittee: SC
|
64
|
+
:subcommittee-number: 2
|
65
|
+
:subcommittee-type: B
|
66
|
+
:workgroup: WG
|
67
|
+
:workgroup-number: 3
|
68
|
+
:workgroup-type: C
|
69
|
+
:technical-committee_2: TC1
|
70
|
+
:technical-committee-number_2: 11
|
71
|
+
:technical-committee-type_2: A1
|
72
|
+
:subcommittee_2: SC1
|
73
|
+
:subcommittee-number_2: 21
|
74
|
+
:subcommittee-type_2: B1
|
75
|
+
:workgroup_2: WG1
|
76
|
+
:workgroup-number_2: 31
|
77
|
+
:workgroup-type_2: C1
|
78
|
+
:secretariat: SECRETARIAT
|
79
|
+
:docstage: 10
|
80
|
+
:docsubstage: 20
|
81
|
+
:iteration: 3
|
82
|
+
:language: en
|
83
|
+
:title-intro-en: Introduction
|
84
|
+
:title-main-en: Main Title -- Title
|
85
|
+
:title-part-en: Title Part
|
86
|
+
:title-intro-fr: Introduction Française
|
87
|
+
:title-main-fr: Titre Principal
|
88
|
+
:title-part-fr: Part du Titre
|
89
|
+
:library-ics: 1,2,3
|
90
|
+
INPUT
|
91
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
92
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
93
|
+
<bibdata type="standard">
|
94
|
+
<title language="en" format="text/plain" type="main">Introduction — Main Title — Title — Title Part</title>
|
95
|
+
<title language="en" format="text/plain" type="title-intro">Introduction</title>
|
96
|
+
<title language="en" format="text/plain" type="title-main">Main Title — Title</title>
|
97
|
+
<title language="en" format="text/plain" type="title-part">Title Part</title>
|
98
|
+
<title language="fr" format="text/plain" type="main">Introduction Française — Titre Principal — Part du Titre</title>
|
99
|
+
<title language="fr" format="text/plain" type="title-intro">Introduction Française</title>
|
100
|
+
<title language="fr" format="text/plain" type="title-main">Titre Principal</title>
|
101
|
+
<title language="fr" format="text/plain" type="title-part">Part du Titre</title>
|
102
|
+
<docidentifier type="iso">IEC/PreNWIP3 1000-1</docidentifier>
|
103
|
+
<docnumber>1000</docnumber>
|
104
|
+
<edition>2</edition>
|
105
|
+
<version>
|
106
|
+
<revision-date>2000-01-01</revision-date>
|
107
|
+
<draft>0.3.4</draft>
|
108
|
+
</version>
|
109
|
+
<contributor>
|
110
|
+
<role type="author"/>
|
111
|
+
<organization>
|
112
|
+
<name>International Electrotechnical Commission</name>
|
113
|
+
<abbreviation>IEC</abbreviation>
|
114
|
+
</organization>
|
115
|
+
</contributor>
|
116
|
+
<contributor>
|
117
|
+
<role type="publisher"/>
|
118
|
+
<organization>
|
119
|
+
<name>International Electrotechnical Commission</name>
|
120
|
+
<abbreviation>IEC</abbreviation>
|
121
|
+
</organization>
|
122
|
+
</contributor>
|
123
|
+
<language>en</language>
|
124
|
+
<script>Latn</script>
|
125
|
+
<status>
|
126
|
+
<stage>10</stage>
|
127
|
+
<substage>20</substage>
|
128
|
+
<iteration>3</iteration>
|
129
|
+
</status>
|
130
|
+
<copyright>
|
131
|
+
<from>#{Date.today.year}</from>
|
132
|
+
<owner>
|
133
|
+
<organization>
|
134
|
+
<name>International Electrotechnical Commission</name>
|
135
|
+
<abbreviation>IEC</abbreviation>
|
136
|
+
</organization>
|
137
|
+
</owner>
|
138
|
+
</copyright>
|
139
|
+
<ext>
|
140
|
+
<doctype>article</doctype>
|
141
|
+
<editorialgroup>
|
142
|
+
<technical-committee number="1" type="A">TC</technical-committee>
|
143
|
+
<technical-committee number="11" type="A1">TC1</technical-committee>
|
144
|
+
<subcommittee number="2" type="B">SC</subcommittee>
|
145
|
+
<subcommittee number="21" type="B1">SC1</subcommittee>
|
146
|
+
<workgroup number="3" type="C">WG</workgroup>
|
147
|
+
<workgroup number="31" type="C1">WG1</workgroup>
|
148
|
+
<secretariat>SECRETARIAT</secretariat>
|
149
|
+
</editorialgroup>
|
150
|
+
<ics>
|
151
|
+
<code>1</code>
|
152
|
+
</ics>
|
153
|
+
<ics>
|
154
|
+
<code>2</code>
|
155
|
+
</ics>
|
156
|
+
<ics>
|
157
|
+
<code>3</code>
|
158
|
+
</ics>
|
159
|
+
<structuredidentifier>
|
160
|
+
<project-number part="1">IEC 1000</project-number>
|
161
|
+
</structuredidentifier>
|
162
|
+
</ext>
|
163
|
+
</bibdata>
|
164
|
+
#{BOILERPLATE}
|
165
|
+
<sections/>
|
166
|
+
</iso-standard>
|
167
|
+
OUTPUT
|
168
|
+
end
|
169
|
+
|
170
|
+
|
171
|
+
it "processes complex metadata" do
|
172
|
+
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
|
173
|
+
= Document title
|
174
|
+
Author
|
175
|
+
:docfile: test.adoc
|
176
|
+
:nodoc:
|
177
|
+
:novalid:
|
178
|
+
:no-isobib:
|
179
|
+
:docnumber: 1000
|
180
|
+
:partnumber: 1-1
|
181
|
+
:tc-docnumber: 2000
|
182
|
+
:language: el
|
183
|
+
:script: Grek
|
184
|
+
:publisher: IEC,IETF,ISO
|
185
|
+
:copyright-year: 2001
|
186
|
+
INPUT
|
187
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
188
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
189
|
+
<bibdata type="standard">
|
190
|
+
<docidentifier type="iso">ISO/IEC/IETF 1000-1-1:2001</docidentifier>
|
191
|
+
<docidentifier type="iso-tc">2000</docidentifier>
|
192
|
+
<docnumber>1000</docnumber>
|
193
|
+
<contributor>
|
194
|
+
<role type="author"/>
|
195
|
+
<organization>
|
196
|
+
<name>International Electrotechnical Commission</name>
|
197
|
+
<abbreviation>IEC</abbreviation>
|
198
|
+
</organization>
|
199
|
+
</contributor>
|
200
|
+
<contributor>
|
201
|
+
<role type="author"/>
|
202
|
+
<organization>
|
203
|
+
<name>IETF</name>
|
204
|
+
</organization>
|
205
|
+
</contributor>
|
206
|
+
<contributor>
|
207
|
+
<role type="author"/>
|
208
|
+
<organization>
|
209
|
+
<name>International Organization for Standardization</name>
|
210
|
+
<abbreviation>ISO</abbreviation>
|
211
|
+
</organization>
|
212
|
+
</contributor>
|
213
|
+
<contributor>
|
214
|
+
<role type="publisher"/>
|
215
|
+
<organization>
|
216
|
+
<name>International Electrotechnical Commission</name>
|
217
|
+
<abbreviation>IEC</abbreviation>
|
218
|
+
</organization>
|
219
|
+
</contributor>
|
220
|
+
<contributor>
|
221
|
+
<role type="publisher"/>
|
222
|
+
<organization>
|
223
|
+
<name>IETF</name>
|
224
|
+
</organization>
|
225
|
+
</contributor>
|
226
|
+
<contributor>
|
227
|
+
<role type="publisher"/>
|
228
|
+
<organization>
|
229
|
+
<name>International Organization for Standardization</name>
|
230
|
+
<abbreviation>ISO</abbreviation>
|
231
|
+
</organization>
|
232
|
+
</contributor>
|
233
|
+
<language>el</language>
|
234
|
+
<script>Grek</script>
|
235
|
+
<status>
|
236
|
+
<stage>60</stage>
|
237
|
+
<substage>60</substage>
|
238
|
+
</status>
|
239
|
+
<copyright>
|
240
|
+
<from>2001</from>
|
241
|
+
<owner>
|
242
|
+
<organization>
|
243
|
+
<name>International Electrotechnical Commission</name>
|
244
|
+
<abbreviation>IEC</abbreviation>
|
245
|
+
</organization>
|
246
|
+
</owner>
|
247
|
+
</copyright>
|
248
|
+
<copyright>
|
249
|
+
<from>2001</from>
|
250
|
+
<owner>
|
251
|
+
<organization>
|
252
|
+
<name>IETF</name>
|
253
|
+
</organization>
|
254
|
+
</owner>
|
255
|
+
</copyright>
|
256
|
+
<copyright>
|
257
|
+
<from>2001</from>
|
258
|
+
<owner>
|
259
|
+
<organization>
|
260
|
+
<name>International Organization for Standardization</name>
|
261
|
+
<abbreviation>ISO</abbreviation>
|
262
|
+
</organization>
|
263
|
+
</owner>
|
264
|
+
</copyright>
|
265
|
+
<ext>
|
266
|
+
<doctype>article</doctype>
|
267
|
+
<editorialgroup>
|
268
|
+
<technical-committee/>
|
269
|
+
<subcommittee/>
|
270
|
+
<workgroup/>
|
271
|
+
</editorialgroup>
|
272
|
+
<structuredidentifier>
|
273
|
+
<project-number part="1" subpart="1">ISO/IEC/IETF 1000</project-number>
|
274
|
+
</structuredidentifier>
|
275
|
+
</ext>
|
276
|
+
</bibdata>
|
277
|
+
#{BOILERPLATE}
|
278
|
+
<sections/>
|
279
|
+
</iso-standard>
|
280
|
+
OUTPUT
|
281
|
+
end
|
282
|
+
|
283
|
+
it "processes boilerplate in English" do
|
284
|
+
doc = (strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))
|
285
|
+
= Document title
|
286
|
+
Author
|
287
|
+
:docfile: test.adoc
|
288
|
+
:nodoc:
|
289
|
+
:novalid:
|
290
|
+
:no-isobib:
|
291
|
+
:docnumber: 1000
|
292
|
+
:partnumber: 1-1
|
293
|
+
:tc-docnumber: 2000
|
294
|
+
:language: en
|
295
|
+
:script: Latn
|
296
|
+
:publisher: IEC,IETF,ISO
|
297
|
+
:copyright-year: 2001
|
298
|
+
INPUT
|
299
|
+
expect(doc).to include "including individual experts"
|
300
|
+
expect(doc).not_to include "y compris ses experts particuliers"
|
301
|
+
end
|
302
|
+
|
303
|
+
it "processes boilerplate in French" do
|
304
|
+
doc = (strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))
|
305
|
+
= Document title
|
306
|
+
Author
|
307
|
+
:docfile: test.adoc
|
308
|
+
:nodoc:
|
309
|
+
:novalid:
|
310
|
+
:no-isobib:
|
311
|
+
:docnumber: 1000
|
312
|
+
:partnumber: 1-1
|
313
|
+
:tc-docnumber: 2000
|
314
|
+
:language: fr
|
315
|
+
:script: Latn
|
316
|
+
:publisher: IEC,IETF,ISO
|
317
|
+
:copyright-year: 2001
|
318
|
+
INPUT
|
319
|
+
expect(doc).not_to include "including individual experts"
|
320
|
+
expect(doc).to include "y compris ses experts particuliers"
|
321
|
+
end
|
322
|
+
|
323
|
+
it "defaults substage" do
|
324
|
+
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
|
325
|
+
= Document title
|
326
|
+
Author
|
327
|
+
:docfile: test.adoc
|
328
|
+
:nodoc:
|
329
|
+
:novalid:
|
330
|
+
:no-isobib:
|
331
|
+
:docnumber: 1000
|
332
|
+
:docstage: 50
|
333
|
+
INPUT
|
334
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
335
|
+
<bibdata type="standard">
|
336
|
+
<docidentifier type="iso">IEC/FDIS 1000</docidentifier>
|
337
|
+
<docnumber>1000</docnumber>
|
338
|
+
<contributor>
|
339
|
+
<role type="author"/>
|
340
|
+
<organization>
|
341
|
+
<name>International Electrotechnical Commission</name>
|
342
|
+
<abbreviation>IEC</abbreviation>
|
343
|
+
</organization>
|
344
|
+
</contributor>
|
345
|
+
<contributor>
|
346
|
+
<role type="publisher"/>
|
347
|
+
<organization>
|
348
|
+
<name>International Electrotechnical Commission</name>
|
349
|
+
<abbreviation>IEC</abbreviation>
|
350
|
+
</organization>
|
351
|
+
</contributor>
|
352
|
+
|
353
|
+
<language>en</language>
|
354
|
+
<script>Latn</script>
|
355
|
+
<status>
|
356
|
+
<stage>50</stage>
|
357
|
+
<substage>00</substage>
|
358
|
+
</status>
|
359
|
+
<copyright>
|
360
|
+
<from>#{Date.today.year}</from>
|
361
|
+
<owner>
|
362
|
+
<organization>
|
363
|
+
<name>International Electrotechnical Commission</name>
|
364
|
+
<abbreviation>IEC</abbreviation>
|
365
|
+
</organization>
|
366
|
+
</owner>
|
367
|
+
</copyright>
|
368
|
+
<ext>
|
369
|
+
<doctype>article</doctype>
|
370
|
+
<editorialgroup>
|
371
|
+
<technical-committee/>
|
372
|
+
<subcommittee/>
|
373
|
+
<workgroup/>
|
374
|
+
</editorialgroup>
|
375
|
+
<structuredidentifier>
|
376
|
+
<project-number>IEC 1000</project-number>
|
377
|
+
</structuredidentifier>
|
378
|
+
</ext>
|
379
|
+
</bibdata>
|
380
|
+
#{BOILERPLATE}
|
381
|
+
<sections/>
|
382
|
+
</iso-standard>
|
383
|
+
OUTPUT
|
384
|
+
end
|
385
|
+
|
386
|
+
it "defaults substage for stage 60" do
|
387
|
+
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
|
388
|
+
= Document title
|
389
|
+
Author
|
390
|
+
:docfile: test.adoc
|
391
|
+
:nodoc:
|
392
|
+
:novalid:
|
393
|
+
:no-isobib:
|
394
|
+
:docnumber: 1000
|
395
|
+
:docstage: 60
|
396
|
+
INPUT
|
397
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
398
|
+
<bibdata type="standard">
|
399
|
+
<docidentifier type="iso">IEC 1000</docidentifier>
|
400
|
+
<docnumber>1000</docnumber>
|
401
|
+
<contributor>
|
402
|
+
<role type="author"/>
|
403
|
+
<organization>
|
404
|
+
<name>International Electrotechnical Commission</name>
|
405
|
+
<abbreviation>IEC</abbreviation>
|
406
|
+
</organization>
|
407
|
+
</contributor>
|
408
|
+
<contributor>
|
409
|
+
<role type="publisher"/>
|
410
|
+
<organization>
|
411
|
+
<name>International Electrotechnical Commission</name>
|
412
|
+
<abbreviation>IEC</abbreviation>
|
413
|
+
</organization>
|
414
|
+
</contributor>
|
415
|
+
|
416
|
+
<language>en</language>
|
417
|
+
<script>Latn</script>
|
418
|
+
<status>
|
419
|
+
<stage>60</stage>
|
420
|
+
<substage>60</substage>
|
421
|
+
</status>
|
422
|
+
<copyright>
|
423
|
+
<from>#{Date.today.year}</from>
|
424
|
+
<owner>
|
425
|
+
<organization>
|
426
|
+
<name>International Electrotechnical Commission</name>
|
427
|
+
<abbreviation>IEC</abbreviation>
|
428
|
+
</organization>
|
429
|
+
</owner>
|
430
|
+
</copyright>
|
431
|
+
<ext>
|
432
|
+
<doctype>article</doctype>
|
433
|
+
<editorialgroup>
|
434
|
+
<technical-committee/>
|
435
|
+
<subcommittee/>
|
436
|
+
<workgroup/>
|
437
|
+
</editorialgroup>
|
438
|
+
<structuredidentifier>
|
439
|
+
<project-number>IEC 1000</project-number>
|
440
|
+
</structuredidentifier>
|
441
|
+
</ext>
|
442
|
+
</bibdata>
|
443
|
+
#{BOILERPLATE}
|
444
|
+
<sections/>
|
445
|
+
</iso-standard>
|
446
|
+
OUTPUT
|
447
|
+
end
|
448
|
+
|
449
|
+
it "populates metadata for PRF" do
|
450
|
+
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
|
451
|
+
= Document title
|
452
|
+
Author
|
453
|
+
:docfile: test.adoc
|
454
|
+
:nodoc:
|
455
|
+
:novalid:
|
456
|
+
:no-isobib:
|
457
|
+
:docnumber: 1000
|
458
|
+
:docstage: 60
|
459
|
+
:docsubstage: 00
|
460
|
+
INPUT
|
461
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
462
|
+
<bibdata type="standard">
|
463
|
+
<docidentifier type="iso">IEC/PRF 1000</docidentifier>
|
464
|
+
<docnumber>1000</docnumber>
|
465
|
+
<contributor>
|
466
|
+
<role type="author"/>
|
467
|
+
<organization>
|
468
|
+
<name>International Electrotechnical Commission</name>
|
469
|
+
<abbreviation>IEC</abbreviation>
|
470
|
+
</organization>
|
471
|
+
</contributor>
|
472
|
+
<contributor>
|
473
|
+
<role type="publisher"/>
|
474
|
+
<organization>
|
475
|
+
<name>International Electrotechnical Commission</name>
|
476
|
+
<abbreviation>IEC</abbreviation>
|
477
|
+
</organization>
|
478
|
+
</contributor>
|
479
|
+
|
480
|
+
<language>en</language>
|
481
|
+
<script>Latn</script>
|
482
|
+
<status>
|
483
|
+
<stage>60</stage>
|
484
|
+
<substage>00</substage>
|
485
|
+
</status>
|
486
|
+
<copyright>
|
487
|
+
<from>#{Date.today.year}</from>
|
488
|
+
<owner>
|
489
|
+
<organization>
|
490
|
+
<name>International Electrotechnical Commission</name>
|
491
|
+
<abbreviation>IEC</abbreviation>
|
492
|
+
</organization>
|
493
|
+
</owner>
|
494
|
+
</copyright>
|
495
|
+
<ext>
|
496
|
+
<doctype>article</doctype>
|
497
|
+
<editorialgroup>
|
498
|
+
<technical-committee/>
|
499
|
+
<subcommittee/>
|
500
|
+
<workgroup/>
|
501
|
+
</editorialgroup>
|
502
|
+
<structuredidentifier>
|
503
|
+
<project-number>IEC 1000</project-number>
|
504
|
+
</structuredidentifier>
|
505
|
+
</ext>
|
506
|
+
</bibdata>
|
507
|
+
#{BOILERPLATE}
|
508
|
+
<sections/>
|
509
|
+
</iso-standard>
|
510
|
+
OUTPUT
|
511
|
+
end
|
512
|
+
|
513
|
+
|
514
|
+
it "reads scripts into blank HTML document" do
|
515
|
+
FileUtils.rm_f "test.html"
|
516
|
+
Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)
|
517
|
+
= Document title
|
518
|
+
Author
|
519
|
+
:docfile: test.adoc
|
520
|
+
:novalid:
|
521
|
+
:no-isobib:
|
522
|
+
INPUT
|
523
|
+
html = File.read("test.html", encoding: "utf-8")
|
524
|
+
expect(html).to match(%r{<script>})
|
525
|
+
end
|
526
|
+
|
527
|
+
it "uses default fonts" do
|
528
|
+
FileUtils.rm_f "test.html"
|
529
|
+
Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)
|
530
|
+
= Document title
|
531
|
+
Author
|
532
|
+
:docfile: test.adoc
|
533
|
+
:novalid:
|
534
|
+
:no-isobib:
|
535
|
+
INPUT
|
536
|
+
html = File.read("test.html", encoding: "utf-8")
|
537
|
+
expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
|
538
|
+
expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Cambria", serif;]m)
|
539
|
+
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Cambria", serif;]m)
|
540
|
+
end
|
541
|
+
|
542
|
+
it "uses default fonts for alt doc" do
|
543
|
+
FileUtils.rm_f "test_alt.html"
|
544
|
+
Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)
|
545
|
+
= Document title
|
546
|
+
Author
|
547
|
+
:docfile: test.adoc
|
548
|
+
:novalid:
|
549
|
+
:no-isobib:
|
550
|
+
INPUT
|
551
|
+
html = File.read("test_alt.html", encoding: "utf-8")
|
552
|
+
expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: "Space Mono", monospace;]m)
|
553
|
+
expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Lato", sans-serif;]m)
|
554
|
+
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Lato", sans-serif;]m)
|
555
|
+
end
|
556
|
+
|
557
|
+
it "uses Chinese fonts" do
|
558
|
+
FileUtils.rm_f "test.html"
|
559
|
+
Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)
|
560
|
+
= Document title
|
561
|
+
Author
|
562
|
+
:docfile: test.adoc
|
563
|
+
:novalid:
|
564
|
+
:no-isobib:
|
565
|
+
:script: Hans
|
566
|
+
INPUT
|
567
|
+
html = File.read("test.html", encoding: "utf-8")
|
568
|
+
expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
|
569
|
+
expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "SimSun", serif;]m)
|
570
|
+
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "SimHei", sans-serif;]m)
|
571
|
+
end
|
572
|
+
|
573
|
+
it "uses specified fonts" do
|
574
|
+
FileUtils.rm_f "test.html"
|
575
|
+
Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)
|
576
|
+
= Document title
|
577
|
+
Author
|
578
|
+
:docfile: test.adoc
|
579
|
+
:novalid:
|
580
|
+
:no-isobib:
|
581
|
+
:script: Hans
|
582
|
+
:body-font: Zapf Chancery
|
583
|
+
:header-font: Comic Sans
|
584
|
+
:monospace-font: Andale Mono
|
585
|
+
INPUT
|
586
|
+
html = File.read("test.html", encoding: "utf-8")
|
587
|
+
expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: Andale Mono;]m)
|
588
|
+
expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: Zapf Chancery;]m)
|
589
|
+
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: Comic Sans;]m)
|
590
|
+
end
|
591
|
+
|
592
|
+
it "strips MS-specific CSS" do
|
593
|
+
FileUtils.rm_f "test.html"
|
594
|
+
FileUtils.rm_f "test.doc"
|
595
|
+
Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)
|
596
|
+
= Document title
|
597
|
+
Author
|
598
|
+
:docfile: test.adoc
|
599
|
+
:novalid:
|
600
|
+
:no-isobib:
|
601
|
+
INPUT
|
602
|
+
word = File.read("test.doc", encoding: "utf-8")
|
603
|
+
html = File.read("test.html", encoding: "utf-8")
|
604
|
+
expect(word).to match(%r[mso-style-name: "Intro Title";]m)
|
605
|
+
expect(html).not_to match(%r[mso-style-name: "Intro Title";]m)
|
606
|
+
end
|
607
|
+
|
608
|
+
|
609
|
+
end
|