asciidoctor-iso 0.10.1 → 0.10.2

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.
@@ -1,10 +1,10 @@
1
- require "asciidoctor/iso/utils"
1
+ require "metanorma-standoc"
2
2
  require "nokogiri"
3
3
  require "pp"
4
4
 
5
5
  module Asciidoctor
6
6
  module ISO
7
- module Validate
7
+ class Converter < Standoc::Converter
8
8
  REQUIREMENT_RE_STR = <<~REGEXP.freeze
9
9
  \\b
10
10
  ( shall | (is|are)_to |
@@ -2,7 +2,7 @@ require "nokogiri"
2
2
 
3
3
  module Asciidoctor
4
4
  module ISO
5
- module Validate
5
+ class Converter < Standoc::Converter
6
6
  def section_validate(doc)
7
7
  foreword_validate(doc.root)
8
8
  normref_validate(doc.root)
@@ -10,8 +10,7 @@ module Asciidoctor
10
10
  sections_sequence_validate(doc.root)
11
11
  section_style(doc.root)
12
12
  subclause_validate(doc.root)
13
- sourcecode_style(doc.root)
14
- asset_style(doc.root)
13
+ super
15
14
  end
16
15
 
17
16
  def foreword_validate(root)
@@ -143,6 +142,13 @@ module Asciidoctor
143
142
  warn("ISO style: There are sections after the final Bibliography")
144
143
  end
145
144
 
145
+ def style_warning(node, msg, text)
146
+ return if @novalid
147
+ w = "ISO style: WARNING (#{Standoc::Utils::current_location(node)}): #{msg}"
148
+ w += ": #{text}" if text
149
+ warn w
150
+ end
151
+
146
152
  NORM_ISO_WARN = "non-ISO/IEC reference not expected as normative".freeze
147
153
  SCOPE_WARN = "Scope contains subclauses: should be succint".freeze
148
154
 
@@ -182,8 +188,8 @@ module Asciidoctor
182
188
 
183
189
  def norm_bibitem_style(root)
184
190
  root.xpath(NORM_BIBITEMS).each do |b|
185
- if b.at(Cleanup::ISO_PUBLISHER_XPATH).nil?
186
- Utils::warning(b, NORM_ISO_WARN, b.text)
191
+ if b.at(Standoc::Converter::ISO_PUBLISHER_XPATH).nil?
192
+ Standoc::Utils::warning(b, NORM_ISO_WARN, b.text)
187
193
  end
188
194
  end
189
195
  end
@@ -194,8 +200,8 @@ module Asciidoctor
194
200
  root.xpath("//note").each { |e| note_style(e) }
195
201
  root.xpath("//fn").each { |e| footnote_style(e) }
196
202
  root.xpath(ASSETS_TO_STYLE).each { |e| style(e, extract_text(e)) }
197
- asset_title_style(root)
198
203
  norm_bibitem_style(root)
204
+ super
199
205
  end
200
206
 
201
207
  def subclause_validate(root)
@@ -1,10 +1,10 @@
1
- require "asciidoctor/iso/utils"
1
+ require "metanorma-standoc"
2
2
  require "nokogiri"
3
3
  require "pp"
4
4
 
5
5
  module Asciidoctor
6
6
  module ISO
7
- module Validate
7
+ class Converter < Standoc::Converter
8
8
  def extract_text(node)
9
9
  return "" if node.nil?
10
10
  node1 = Nokogiri::XML.fragment(node.to_s)
@@ -54,13 +54,6 @@ module Asciidoctor
54
54
  style(node, extract_text(node))
55
55
  end
56
56
 
57
- def style_warning(node, msg, text)
58
- return if @novalid
59
- w = "ISO style: WARNING (#{Utils::current_location(node)}): #{msg}"
60
- w += ": #{text}" if text
61
- warn w
62
- end
63
-
64
57
  def style_regex(re, warning, n, text)
65
58
  (m = re.match(text)) && style_warning(n, warning, m[:num])
66
59
  end
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module ISO
3
- VERSION = "0.10.1".freeze
3
+ VERSION = "0.10.2".freeze
4
4
  end
5
5
  end
@@ -5,6 +5,7 @@ RSpec.describe Asciidoctor::ISO do
5
5
  expect(Asciidoctor::ISO::VERSION).not_to be nil
6
6
  end
7
7
 
8
+ =begin
8
9
  it "generates output for the Rice document" do
9
10
  system "cd spec/examples; rm -f rice.xml; rm -f rice.doc; rm -f rice.html; rm -f rice_alt.html; asciidoctor --trace -b iso -r 'asciidoctor-iso' rice.adoc; cd ../.."
10
11
  expect(File.exist?("spec/examples/rice.xml")).to be true
@@ -12,6 +13,7 @@ RSpec.describe Asciidoctor::ISO do
12
13
  expect(File.exist?("spec/examples/rice.html")).to be true
13
14
  expect(File.exist?("spec/examples/rice_alt.html")).to be true
14
15
  end
16
+ =end
15
17
 
16
18
  it "processes a blank document" do
17
19
  expect(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)).to be_equivalent_to <<~"OUTPUT"
@@ -104,7 +104,7 @@ Alice &lt;-- Bob: another authentication Response
104
104
  private
105
105
 
106
106
  def mock_plantuml_disabled
107
- expect(Asciidoctor::ISO::PlantUMLBlockMacroBackend).to receive(:plantuml_installed?) do
107
+ expect(Asciidoctor::Standoc::PlantUMLBlockMacroBackend).to receive(:plantuml_installed?) do
108
108
  false
109
109
  end
110
110
  end
@@ -460,7 +460,7 @@ RSpec.describe Asciidoctor::ISO do
460
460
  <abbreviation>ISO</abbreviation>
461
461
  </organization>
462
462
  </contributor>
463
-
463
+ <language>en</language>
464
464
  <script>Latn</script>
465
465
  <status>
466
466
  <stage>60</stage>
@@ -1,17 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe Asciidoctor::ISO do
4
- it "warns when missing a title" do
5
- expect { Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true) }.to output(/Table should have title/).to_stderr
6
- #{VALIDATING_BLANK_HDR}
7
- |===
8
- |A |B |C
9
-
10
- h|1 |2 |3
11
- |===
12
- INPUT
13
- end
14
-
15
4
 
16
5
  it "warns that introduction may contain requirement" do
17
6
  expect { Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true) }.to output(/Introduction may contain requirement/).to_stderr
@@ -134,7 +123,7 @@ it "warns that term source is not a real reference" do
134
123
  INPUT
135
124
  end
136
125
 
137
- it "warns that ndated reference has locality" do
126
+ it "warns that undated reference has locality" do
138
127
  expect { Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true) }.to output(/undated reference ISO 123 should not contain specific elements/).to_stderr
139
128
  #{VALIDATING_BLANK_HDR}
140
129
 
@@ -1,7 +1,7 @@
1
1
  MIME-Version: 1.0
2
- Content-Type: multipart/related; boundary="----=_NextPart_30405c9c.cfdb.4e46"
2
+ Content-Type: multipart/related; boundary="----=_NextPart_94e7f467.3c17.4d67"
3
3
 
4
- ------=_NextPart_30405c9c.cfdb.4e46
4
+ ------=_NextPart_94e7f467.3c17.4d67
5
5
  Content-Location: file:///C:/Doc/spec/assets/iso.htm
6
6
  Content-Type: text/html; charset="utf-8"
7
7
 
@@ -2069,11 +2069,11 @@ Switzerland<p class="MsoNormal"></p></span></p>
2069
2069
  <p class="MsoToc1"><span lang="EN-GB" xml:lang="EN-GB"><span style="mso-element:field-begin"></span><span style="mso-spacerun:yes">&#xA0;</span>TOC
2070
2070
  \o "1-2" \h \z \u <span style="mso-element:field-separator"></span></span>
2071
2071
  <span class="MsoHyperlink"><span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
2072
- <a href="#_Toc893822203">Foreword<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
2072
+ <a href="#_Toc938931447">Foreword<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
2073
2073
  <span style="mso-tab-count:1 dotted">. </span>
2074
2074
  </span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
2075
2075
  <span style="mso-element:field-begin"></span></span>
2076
- <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"> PAGEREF _Toc893822203 \h </span>
2076
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"> PAGEREF _Toc938931447 \h </span>
2077
2077
  <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-separator"></span></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">1</span>
2078
2078
  <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-end"></span></span></a></span></span></p>
2079
2079
 
@@ -2106,7 +2106,7 @@ Switzerland<p class="MsoNormal"></p></span></p>
2106
2106
  </html>
2107
2107
 
2108
2108
 
2109
- ------=_NextPart_30405c9c.cfdb.4e46
2109
+ ------=_NextPart_94e7f467.3c17.4d67
2110
2110
  Content-Location: file:///C:/Doc/spec/assets/iso_files/filelist.xml
2111
2111
  Content-Transfer-Encoding: base64
2112
2112
  Content-Type: application/xml
@@ -2116,7 +2116,7 @@ ICAgICAgIDxvOk1haW5GaWxlIEhSZWY9Ii4uL3NwZWMvYXNzZXRzL2lzby5odG0iLz4gIDxvOkZp
2116
2116
  bGUgSFJlZj0iZmlsZWxpc3QueG1sIi8+CiAgPG86RmlsZSBIUmVmPSJoZWFkZXIuaHRtbCIvPgo8
2117
2117
  L3htbD4K
2118
2118
 
2119
- ------=_NextPart_30405c9c.cfdb.4e46
2119
+ ------=_NextPart_94e7f467.3c17.4d67
2120
2120
  Content-Location: file:///C:/Doc/spec/assets/iso_files/header.html
2121
2121
  Content-Transfer-Encoding: base64
2122
2122
  Content-Type: text/html charset="utf-8"
@@ -2309,4 +2309,4 @@ cD4NCg0KPHAgY2xhc3M9TXNvRm9vdGVyPjxzcGFuIGxhbmc9RU4tQVUgc3R5bGU9J2ZvbnQtc2l6
2309
2309
  ZToxMC4wcHQ7Jz7CqQ0KJm5ic3A7Jm5ic3A74oCTIEFsbCByaWdodHMgcmVzZXJ2ZWQ8bzpwPjwv
2310
2310
  bzpwPjwvc3Bhbj48L3A+DQoNCjwvZGl2Pg0KDQoNCg0KPC9ib2R5Pg0KDQo8L2h0bWw+DQo=
2311
2311
 
2312
- ------=_NextPart_30405c9c.cfdb.4e46--
2312
+ ------=_NextPart_94e7f467.3c17.4d67--
@@ -110,6 +110,7 @@ BLANK_HDR = <<~"HDR"
110
110
  <abbreviation>ISO</abbreviation>
111
111
  </organization>
112
112
  </contributor>
113
+ <language>en</language>
113
114
  <script>Latn</script>
114
115
  <status>
115
116
  <stage>60</stage>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-iso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-08 00:00:00.000000000 Z
11
+ date: 2018-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.1.3
83
+ - !ruby/object:Gem::Dependency
84
+ name: metanorma-standoc
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.0.1
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.0.1
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: bundler
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -281,24 +295,13 @@ files:
281
295
  - lib/asciidoctor-iso.rb
282
296
  - lib/asciidoctor/iso/base.rb
283
297
  - lib/asciidoctor/iso/biblio.rng
284
- - lib/asciidoctor/iso/blocks.rb
285
298
  - lib/asciidoctor/iso/cleanup.rb
286
- - lib/asciidoctor/iso/cleanup_block.rb
287
- - lib/asciidoctor/iso/cleanup_footnotes.rb
288
- - lib/asciidoctor/iso/cleanup_ref.rb
289
299
  - lib/asciidoctor/iso/converter.rb
290
300
  - lib/asciidoctor/iso/front.rb
291
- - lib/asciidoctor/iso/inline.rb
292
301
  - lib/asciidoctor/iso/isodoc.rng
293
302
  - lib/asciidoctor/iso/isostandard.rnc
294
303
  - lib/asciidoctor/iso/isostandard.rng
295
- - lib/asciidoctor/iso/isostandard_diff.rnc
296
- - lib/asciidoctor/iso/lists.rb
297
- - lib/asciidoctor/iso/macros.rb
298
- - lib/asciidoctor/iso/ref.rb
299
304
  - lib/asciidoctor/iso/section.rb
300
- - lib/asciidoctor/iso/table.rb
301
- - lib/asciidoctor/iso/utils.rb
302
305
  - lib/asciidoctor/iso/validate.rb
303
306
  - lib/asciidoctor/iso/validate_requirements.rb
304
307
  - lib/asciidoctor/iso/validate_section.rb
@@ -1,190 +0,0 @@
1
- require "htmlentities"
2
- require "uri"
3
-
4
- module Asciidoctor
5
- module ISO
6
- module Blocks
7
- def id_attr(node = nil)
8
- { id: Utils::anchor_or_uuid(node) }
9
- end
10
-
11
- # open block is a container of multiple blocks,
12
- # treated as a single block.
13
- # We append each contained block to its parent
14
- def open(node)
15
- result = []
16
- node.blocks.each do |b|
17
- result << send(b.context, b)
18
- end
19
- result
20
- end
21
-
22
- def literal(node)
23
- paragraph(node)
24
- end
25
-
26
- # NOTE: html escaping is performed by Nokogiri
27
- def stem(node)
28
- stem_content = node.lines.join("\n")
29
- noko do |xml|
30
- xml.formula **id_attr(node) do |s|
31
- stem_parse(stem_content, s)
32
- end
33
- end
34
- end
35
-
36
- def sidebar_attrs(node)
37
- date = node.attr("date") || Date.today.iso8601.gsub(/\+.*$/, "")
38
- date += "T00:00:00Z" unless /T/.match date
39
- {
40
- reviewer: node.attr("reviewer") || node.attr("source") || "(Unknown)",
41
- id: Utils::anchor_or_uuid(node),
42
- date: date,
43
- from: node.attr("from"),
44
- to: node.attr("to") || node.attr("from"),
45
- }
46
- end
47
-
48
- def sidebar(node)
49
- return unless draft?
50
- noko do |xml|
51
- xml.review **attr_code(sidebar_attrs(node)) do |r|
52
- wrap_in_para(node, r)
53
- end
54
- end
55
- end
56
-
57
- def termnote(n)
58
- noko do |xml|
59
- xml.termnote **id_attr(n) do |ex|
60
- wrap_in_para(n, ex)
61
- end
62
- end.join("\n")
63
- end
64
-
65
- def note(n)
66
- noko do |xml|
67
- xml.note **id_attr(n) do |c|
68
- wrap_in_para(n, c)
69
- end
70
- end.join("\n")
71
- end
72
-
73
- def admonition_attrs(node)
74
- name = node.attr("name")
75
- if type = node.attr("type")
76
- ["danger", "safety precautions"].each do |t|
77
- name = t if type.casecmp(t).zero?
78
- end
79
- end
80
- { id: Utils::anchor_or_uuid(node), type: name }
81
- end
82
-
83
- def admonition(node)
84
- return termnote(node) if in_terms?
85
- return note(node) if node.attr("name") == "note"
86
- noko do |xml|
87
- xml.admonition **admonition_attrs(node) do |a|
88
- wrap_in_para(node, a)
89
- end
90
- end.join("\n")
91
- end
92
-
93
- def term_example(node)
94
- noko do |xml|
95
- xml.termexample **id_attr(node) do |ex|
96
- wrap_in_para(node, ex)
97
- end
98
- end.join("\n")
99
- end
100
-
101
- def example(node)
102
- return term_example(node) if in_terms?
103
- noko do |xml|
104
- xml.example **id_attr(node) do |ex|
105
- content = node.content
106
- ex << content
107
- end
108
- end.join("\n")
109
- end
110
-
111
- def preamble(node)
112
- noko do |xml|
113
- xml.foreword do |xml_abstract|
114
- xml_abstract.title { |t| t << "Foreword" }
115
- content = node.content
116
- xml_abstract << content
117
- end
118
- end.join("\n")
119
- end
120
-
121
- def image_attributes(node)
122
- uri = node.image_uri node.attr("target")
123
- types = MIME::Types.type_for(uri)
124
- { src: uri,
125
- id: Utils::anchor_or_uuid,
126
- imagetype: types.first.sub_type.upcase,
127
- height: node.attr("height") || "auto",
128
- width: node.attr("width") || "auto" }
129
- end
130
-
131
- def figure_title(node, f)
132
- unless node.title.nil?
133
- f.name { |name| name << node.title }
134
- end
135
- end
136
-
137
- def image(node)
138
- noko do |xml|
139
- xml.figure **id_attr(node) do |f|
140
- figure_title(node, f)
141
- f.image **attr_code(image_attributes(node))
142
- end
143
- end
144
- end
145
-
146
- def paragraph(node)
147
- return termsource(node) if node.role == "source"
148
- attrs = { align: node.attr("align"),
149
- id: Utils::anchor_or_uuid(node) }
150
- noko do |xml|
151
- xml.p **attr_code(attrs) do |xml_t|
152
- xml_t << node.content
153
- end
154
- end.join("\n")
155
- end
156
-
157
- def quote_attrs(node)
158
- { id: Utils::anchor_or_uuid(node), align: node.attr("align") }
159
- end
160
-
161
- def quote_attribution(node, out)
162
- if node.attr("citetitle")
163
- m = /^(?<cite>[^,]+)(,(?<text>.*$))?$/m.match node.attr("citetitle")
164
- out.source m[:text],
165
- **attr_code(target: m[:cite], type: "inline")
166
- end
167
- if node.attr("attribution")
168
- out.author { |a| a << node.attr("attribution") }
169
- end
170
- end
171
-
172
- def quote(node)
173
- noko do |xml|
174
- xml.quote **attr_code(quote_attrs(node)) do |q|
175
- quote_attribution(node, q)
176
- wrap_in_para(node, q)
177
- end
178
- end
179
- end
180
-
181
- def listing(node)
182
- # NOTE: html escaping is performed by Nokogiri
183
- noko do |xml|
184
- xml.sourcecode(**id_attr(node)) { |s| s << node.content }
185
- # xml.sourcecode(**id_attr(node)) { |s| s << node.lines.join("\n") }
186
- end
187
- end
188
- end
189
- end
190
- end