metanorma-standoc 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 810c273a1e6b17c407448b2bd4c8857cf76c90238924e2f891d9961564379fa8
4
- data.tar.gz: d2bb301e3c33c71443892e368174673d056d68e29f1ddeecc70f64c922116755
3
+ metadata.gz: a5a2ad92a10730612ba26466f6508a0359c4a12ecd7f973618f0b01d80a83b83
4
+ data.tar.gz: 395911c6e85240c42682d2a14e310162dd19fbe4a863478d0c90067e32aa6650
5
5
  SHA512:
6
- metadata.gz: 6771846b0c74aa8fd58317cf03135e3eb2a635037db1e64e488a6225b6dc4144ca934af8abc41cc551d9e1657abcab5331454a47c48f273fbc9150f8db8cddcf
7
- data.tar.gz: c94f478d887abd354b24aa6ba9f4dda8095c8eb6ae496f36a871945eaacef4c94e6fb5d8c2e618faaa74dc07ab20fcca0476665f3d533d4f8d8d311fdf75ae29
6
+ metadata.gz: 17a60dd786a93b4982d2c9408b3308af6b9b31bb852aae30143da11a62c8a35715a77cdbba3bc899445987e646a4a7550ab6942662522c744fb38e76661f9d0e
7
+ data.tar.gz: 121aa21c43db0262c907b54b0e03f033a319f54756a7dbaca9d0da94fbd3fe85700d576327ab3d581329c4d6a606a2d76f0fefd6ad949db3fc10bad6116f2b05
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metanorma-standoc (1.1.2)
4
+ metanorma-standoc (1.1.3)
5
5
  asciidoctor (~> 1.5.7)
6
6
  concurrent-ruby
7
7
  html2doc (~> 0.8.0)
@@ -16,7 +16,7 @@ GEM
16
16
  specs:
17
17
  addressable (2.6.0)
18
18
  public_suffix (>= 2.0.2, < 4.0)
19
- algoliasearch (1.25.2)
19
+ algoliasearch (1.26.0)
20
20
  httpclient (~> 2.8, >= 2.8.3)
21
21
  json (>= 1.5.1)
22
22
  asciidoctor (1.5.8)
@@ -81,7 +81,7 @@ GEM
81
81
  algoliasearch
82
82
  iecbib (~> 0.2.1)
83
83
  iso-bib-item (~> 0.4.2)
84
- isodoc (0.9.15)
84
+ isodoc (0.9.17)
85
85
  asciimath
86
86
  html2doc (~> 0.8.6)
87
87
  htmlentities (~> 4.3.4)
@@ -373,6 +373,10 @@ The following terms have non-normative effect, and should be ignored by the amet
373
373
  metrical foot consisting of a short, a long, and a short
374
374
  --
375
375
 
376
+ Any clause within a Terms & Definitions section which is a nonterminal subclause (has
377
+ child nodes) is automatically itself a terms (or definitions) section. On the other hand,
378
+ any descendant of a nonterm clause is also a nonterm clause.
379
+
376
380
  === Cross-references to external documents
377
381
 
378
382
  Metanorma Asciidoctor, like normal Asciidoctor, will process cross-references to
@@ -97,6 +97,7 @@ module Asciidoctor
97
97
  return note(node) if node.attr("name") == "note"
98
98
  noko do |xml|
99
99
  xml.admonition **admonition_attrs(node) do |a|
100
+ node.title.nil? or a.name { |name| name << node.title }
100
101
  wrap_in_para(node, a)
101
102
  end
102
103
  end.join("\n")
@@ -21,7 +21,8 @@ module Asciidoctor
21
21
  end
22
22
 
23
23
  def sectiontype(node)
24
- ret = node&.attr("heading")&.downcase || node.title.downcase
24
+ ret = node&.attr("heading")&.downcase ||
25
+ node.title.gsub(/<[^>]+>/, "").downcase
25
26
  return ret if ["symbols and abbreviated terms", "abbreviations",
26
27
  "abbreviated terms", "symbols"].include? ret
27
28
  return nil unless node.level == 1
@@ -53,8 +54,9 @@ module Asciidoctor
53
54
  when "bibliography" then bibliography_parse(a, xml, node)
54
55
  else
55
56
  if @term_def then term_def_subclause_parse(a, xml, node)
57
+ elsif @definitions then symbols_parse(a, xml, node)
56
58
  elsif @biblio then bibliography_parse(a, xml, node)
57
- elsif node.attr("style") == "bibliography" && node.level == 1
59
+ elsif node.attr("style") == "bibliography"
58
60
  bibliography_parse(a, xml, node)
59
61
  elsif node.attr("style") == "abstract"
60
62
  abstract_parse(a, xml, node)
@@ -114,24 +116,40 @@ module Asciidoctor
114
116
  @biblio = false
115
117
  end
116
118
 
119
+ def nonterm_symbols_parse(attrs, xml, node)
120
+ @definitions = false
121
+ clause_parse(attrs, xml, node)
122
+ @definitions = true
123
+ end
124
+
117
125
  def symbols_parse(attrs, xml, node)
126
+ node.role == "nonterm" and return nonterm_symbols_parse(attrs, xml, node)
118
127
  xml.definitions **attr_code(attrs) do |xml_section|
119
128
  xml_section.title { |t| t << node.title }
129
+ defs = @definitions
130
+ termdefs = @term_def
131
+ @definitions = true
132
+ @term_def = false
120
133
  xml_section << node.content
134
+ @definitions = defs
135
+ @term_def = termdefs
121
136
  end
122
137
  end
123
138
 
124
139
  SYMBOLS_TITLES = ["symbols and abbreviated terms", "symbols",
125
140
  "abbreviated terms"].freeze
126
141
 
142
+ def nonterm_term_def_subclause_parse(attrs, xml, node)
143
+ @term_def = false
144
+ clause_parse(attrs, xml, node)
145
+ @term_def = true
146
+ end
147
+
127
148
  # subclause contains subclauses
128
149
  def term_def_subclause_parse(attrs, xml, node)
129
- if node.role == "nonterm"
130
- @term_def = false
131
- clause_parse(attrs, xml, node)
132
- @term_def = true
133
- return
134
- end
150
+ node.role == "nonterm" and
151
+ return nonterm_term_def_subclause_parse(attrs, xml, node)
152
+ return symbols_parse(attrs, xml, node) if @definitions
135
153
  sub = node.find_by(context: :section) { |s| s.level == node.level + 1 }
136
154
  sub.empty? || (return term_def_parse(attrs, xml, node, false))
137
155
  SYMBOLS_TITLES.include?(node.title.downcase) and
@@ -26,7 +26,7 @@ module Asciidoctor
26
26
  end
27
27
 
28
28
  def asset_title_style(root)
29
- root.xpath("//figure[image][not(title)]").each do |node|
29
+ root.xpath("//figure[image][not(name)]").each do |node|
30
30
  style_warning(node, "Figure should have title", nil)
31
31
  end
32
32
  root.xpath("//table[not(name)]").each do |node|
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Standoc
3
- VERSION = "1.1.2".freeze
3
+ VERSION = "1.1.3".freeze
4
4
  end
5
5
  end
@@ -180,6 +180,34 @@ RSpec.describe Asciidoctor::Standoc do
180
180
  </clause>
181
181
  </terms>
182
182
  </sections>
183
+ </standard-document>
184
+
185
+ OUTPUT
186
+ end
187
+
188
+ it "processes term notes as plain notes in definitions subclauses of terms & definitions" do
189
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
190
+ #{ASCIIDOC_BLANK_HDR}
191
+ == Terms and Definitions
192
+
193
+ === Term1
194
+
195
+ === Symbols
196
+
197
+ NOTE: This is a note
198
+ INPUT
199
+ #{BLANK_HDR}
200
+ <sections>
201
+ <terms id="_" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title><term id="_">
202
+ <preferred>Term1</preferred>
203
+ </term>
204
+ <definitions id="_">
205
+ <title>Symbols</title>
206
+ <note id="_">
207
+ <p id="_">This is a note</p>
208
+ </note>
209
+ </definitions></terms>
210
+ </sections>
183
211
  </standard-document>
184
212
 
185
213
  OUTPUT
@@ -253,7 +281,7 @@ RSpec.describe Asciidoctor::Standoc do
253
281
  expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
254
282
  #{ASCIIDOC_BLANK_HDR}
255
283
  [CAUTION,type=Safety Precautions]
256
- .Safety Precautions
284
+ .Precautions
257
285
  ====
258
286
  While werewolves are hardy community members, keep in mind the following dietary concerns:
259
287
 
@@ -264,7 +292,7 @@ RSpec.describe Asciidoctor::Standoc do
264
292
  INPUT
265
293
  #{BLANK_HDR}
266
294
  <sections>
267
- <admonition id="_" type="safety precautions"><p id="_">While werewolves are hardy community members, keep in mind the following dietary concerns:</p>
295
+ <admonition id="_" type="safety precautions"><name>Precautions</name><p id="_">While werewolves are hardy community members, keep in mind the following dietary concerns:</p>
268
296
  <ol id="_" type="arabic">
269
297
  <li>
270
298
  <p id="_">They are allergic to cinnamon.</p>
@@ -293,19 +321,18 @@ RSpec.describe Asciidoctor::Standoc do
293
321
  This is an example
294
322
  INPUT
295
323
  #{BLANK_HDR}
296
- <sections>
297
- <terms id="_" obligation="normative">
298
- <title>Terms and definitions</title>
299
- <term id="_">
300
- <preferred>Term1</preferred>
301
- <termexample id="_">
302
- <p id="_">This is an example</p>
303
- </termexample>
304
- </term>
305
- </terms>
306
- </sections>
307
- </standard-document>
324
+ <sections>
325
+ <terms id="_" obligation="normative">
326
+ <title>Terms and definitions</title>
327
+ <term id="_">
328
+ <preferred>Term1</preferred>
308
329
 
330
+ <termexample id="_">
331
+ <p id="_">This is an example</p>
332
+ </termexample></term>
333
+ </terms>
334
+ </sections>
335
+ </standard-document>
309
336
  OUTPUT
310
337
  end
311
338
 
@@ -336,6 +363,34 @@ RSpec.describe Asciidoctor::Standoc do
336
363
  OUTPUT
337
364
  end
338
365
 
366
+ it "processes term examples as plain examples in definitions subclauses of terms & definitions" do
367
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
368
+ #{ASCIIDOC_BLANK_HDR}
369
+ == Terms and Definitions
370
+
371
+ === Term1
372
+
373
+ === Symbols
374
+
375
+ [example]
376
+ This is an example
377
+ INPUT
378
+ #{BLANK_HDR}
379
+ <sections>
380
+ <terms id="_" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title><term id="_">
381
+ <preferred>Term1</preferred>
382
+ </term>
383
+ <definitions id="_">
384
+ <title>Symbols</title>
385
+ <example id="_">
386
+ <p id="_">This is an example</p>
387
+ </example>
388
+ </definitions></terms>
389
+ </sections>
390
+ </standard-document>
391
+ OUTPUT
392
+ end
393
+
339
394
 
340
395
  it "processes examples" do
341
396
  expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
@@ -32,12 +32,30 @@ RSpec.describe Asciidoctor::Standoc do
32
32
  [.nonterm]
33
33
  === Introduction
34
34
 
35
+ ==== Intro 1
36
+
37
+ === Intro 2
38
+
39
+ [.nonterm]
40
+ ==== Intro 3
41
+
42
+ === Intro 4
43
+
44
+ ==== Intro 5
45
+
46
+ ===== Term1
47
+
35
48
  === Normal Terms
36
49
 
37
50
  ==== Term2
38
51
 
39
52
  === Symbols and Abbreviated Terms
40
53
 
54
+ [.nonterm]
55
+ ==== General
56
+
57
+ ==== Symbols 1
58
+
41
59
  == Abbreviated Terms
42
60
 
43
61
  == Clause 4
@@ -57,65 +75,90 @@ RSpec.describe Asciidoctor::Standoc do
57
75
 
58
76
  === Bibliography Subsection
59
77
  INPUT
60
- <preface><abstract id="_">
61
- <p id="_">Text</p>
62
- </abstract><foreword obligation="informative">
63
- <title>Foreword</title>
64
- <p id="_">Text</p>
65
- </foreword><introduction id="_" obligation="informative">
66
- <title>Introduction</title>
67
- <clause id="_" inline-header="false" obligation="informative">
68
- <title>Introduction Subsection</title>
69
- </clause>
70
- </introduction></preface><sections>
71
-
72
- <clause id="_" inline-header="false" obligation="normative">
73
- <title>Scope</title>
74
- <p id="_">Text</p>
75
- </clause>
76
-
77
- <terms id="_" obligation="normative">
78
- <title>Terms and definitions</title>
79
- <term id="_">
80
- <preferred>Term1</preferred>
81
- </term>
82
- </terms>
83
- <clause id="_" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title><clause id="_" inline-header="false" obligation="normative">
84
- <title>Introduction</title>
85
- </clause>
86
- <terms id="_" obligation="normative">
87
- <title>Normal Terms</title>
88
- <term id="_">
89
- <preferred>Term2</preferred>
90
- </term>
91
- </terms>
92
- <definitions id="_"><title>Symbols and Abbreviated Terms</title></definitions>
93
- </clause>
94
- <definitions id="_"><title>Abbreviated Terms</title></definitions>
95
- <clause id="_" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="_" inline-header="false" obligation="normative">
96
- <title>Introduction</title>
97
- </clause>
98
- <clause id="_" inline-header="false" obligation="normative">
99
- <title>Clause 4.2</title>
100
- </clause></clause>
101
- <clause id="_" inline-header="false" obligation="normative">
102
- <title>Terms and Definitions</title>
103
- </clause>
104
-
105
- </sections><annex id="_" inline-header="false" obligation="normative">
106
- <title>Annex</title>
107
- <clause id="_" inline-header="false" obligation="normative">
108
- <title>Annex A.1</title>
109
- </clause>
110
- </annex><bibliography><references id="_" obligation="informative">
111
- <title>Normative References</title>
112
- </references><clause id="_" obligation="informative">
113
- <title>Bibliography</title>
114
- <references id="_" obligation="informative">
115
- <title>Bibliography Subsection</title>
116
- </references>
117
- </clause></bibliography>
118
- </standard-document>
78
+ <preface><abstract id="_">
79
+ <p id="_">Text</p>
80
+ </abstract><foreword obligation="informative">
81
+ <title>Foreword</title>
82
+ <p id="_">Text</p>
83
+ </foreword><introduction id="_" obligation="informative">
84
+ <title>Introduction</title>
85
+ <clause id="_" inline-header="false" obligation="informative">
86
+ <title>Introduction Subsection</title>
87
+ </clause>
88
+ </introduction></preface><sections>
89
+
90
+
91
+ <clause id="_" inline-header="false" obligation="normative">
92
+ <title>Scope</title>
93
+ <p id="_">Text</p>
94
+ </clause>
95
+
96
+ <terms id="_" obligation="normative">
97
+ <title>Terms and definitions</title>
98
+ <term id="_">
99
+ <preferred>Term1</preferred>
100
+ </term>
101
+ </terms>
102
+ <clause id="_" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title><clause id="_" inline-header="false" obligation="normative">
103
+ <title>Introduction</title>
104
+ <clause id="_" inline-header="false" obligation="normative">
105
+ <title>Intro 1</title>
106
+ </clause>
107
+ </clause>
108
+ <terms id="_" obligation="normative">
109
+ <title>Intro 2</title>
110
+ <clause id="_" inline-header="false" obligation="normative">
111
+ <title>Intro 3</title>
112
+ </clause>
113
+ </terms>
114
+ <clause id="_" obligation="normative">
115
+ <title>Intro 4</title>
116
+ <terms id="_" obligation="normative">
117
+ <title>Intro 5</title>
118
+ <term id="_">
119
+ <preferred>Term1</preferred>
120
+ </term>
121
+ </terms>
122
+ </clause>
123
+ <terms id="_" obligation="normative">
124
+ <title>Normal Terms</title>
125
+ <term id="_">
126
+ <preferred>Term2</preferred>
127
+ </term>
128
+ </terms>
129
+ <definitions id="_"><title>Symbols and Abbreviated Terms</title><clause id="_" inline-header="false" obligation="normative">
130
+ <title>General</title>
131
+ </clause>
132
+ <definitions id="_">
133
+ <title>Symbols 1</title>
134
+ </definitions></definitions></clause>
135
+ <definitions id="_">
136
+ <title>Abbreviated Terms</title>
137
+ </definitions>
138
+ <clause id="_" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="_" inline-header="false" obligation="normative">
139
+ <title>Introduction</title>
140
+ </clause>
141
+ <clause id="_" inline-header="false" obligation="normative">
142
+ <title>Clause 4.2</title>
143
+ </clause></clause>
144
+ <clause id="_" inline-header="false" obligation="normative">
145
+ <title>Terms and Definitions</title>
146
+ </clause>
147
+
148
+ </sections><annex id="_" inline-header="false" obligation="normative">
149
+ <title>Annex</title>
150
+ <clause id="_" inline-header="false" obligation="normative">
151
+ <title>Annex A.1</title>
152
+ </clause>
153
+ </annex><bibliography><references id="_" obligation="informative">
154
+ <title>Normative References</title>
155
+ </references><clause id="_" obligation="informative">
156
+ <title>Bibliography</title>
157
+ <references id="_" obligation="informative">
158
+ <title>Bibliography Subsection</title>
159
+ </references>
160
+ </clause></bibliography>
161
+ </standard-document>
119
162
  OUTPUT
120
163
  end
121
164
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-standoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-31 00:00:00.000000000 Z
11
+ date: 2019-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor