slaw 9.1.0 → 9.2.0

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: 6c60448bb3a8c2cb9bad02e434eab59805129a845b13f6f95b6f062b3a61ef15
4
- data.tar.gz: dfcb7d9a0413b8c61448af102da840e41cb3f942ec0a249c35c5ec4808c4e090
3
+ metadata.gz: '0654597e1ede427474f5b9b4f703070c4d23fc34fdbf10700ae72485f8372a21'
4
+ data.tar.gz: d19cd4ebfe1e256f5366addde1723817547075e6468ab31b0d65c8d492f5c6d1
5
5
  SHA512:
6
- metadata.gz: 9930cf182f41f54ab0fc377a9f3d6a48d3cd8f466124ad9d3b404bd0739036a7e9615bdc1b715a16b94458b1215ed8bf77a1ab0a4d40092044faf1ecb2559caf
7
- data.tar.gz: 8db5857b43d42ccbacb24c48b2649ae49c431830a5e22a1ceeb121a16e6b8cc10f3a5757bbd6c64393e24c0e34d59486cd11e3a227badf32bfb92ebcfb08f8ce
6
+ metadata.gz: a778d4798462049e8fbb123c30d72d2e43c4f7f8344e0bc31590d2c5873daa3675979cafdb3fc14be1327f3ed262c19e6220b2e2ed40e825cc68fe353bb57614
7
+ data.tar.gz: 585ea851576bca2c5059a3693067066f9f06a9b1ef67761534b707ddcd51f447cc8953f7f7b33842486cb77e442b3f7d60dd63e763306d269db14f1c1b17fcaa
data/README.md CHANGED
@@ -86,6 +86,10 @@ You can create your own grammar by creating a gem that provides these files and
86
86
 
87
87
  ## Changelog
88
88
 
89
+ ### 9.2.0 (10 June 2020)
90
+
91
+ * Subpart numbers are optional
92
+
89
93
  ### 9.1.0 (15 April 2020)
90
94
 
91
95
  * Subsections can have numbers such as 1.1A and 1.1bis
@@ -257,7 +257,7 @@ module Slaw
257
257
  end
258
258
 
259
259
  rule subpart_heading_prefix
260
- 'subpart'i space alphanums [ :-]*
260
+ 'subpart'i num:(space alphanums)? [ :-]*
261
261
  end
262
262
 
263
263
  rule chapter_heading_prefix
@@ -168,6 +168,11 @@ module Slaw
168
168
  end
169
169
 
170
170
  def to_xml(b, id_prefix='', *args)
171
+ num = self.num
172
+ if num.empty?
173
+ num = Slaw::Grammars::Counters.counters[id_prefix]['subpart'] += 1
174
+ end
175
+
171
176
  id = id_prefix + "subpart-#{num}"
172
177
 
173
178
  b.subpart(id: id) { |b|
@@ -179,11 +184,11 @@ module Slaw
179
184
 
180
185
  class SubpartHeading < Treetop::Runtime::SyntaxNode
181
186
  def num
182
- subpart_heading_prefix.alphanums.text_value
187
+ subpart_heading_prefix.num.text_value.strip()
183
188
  end
184
189
 
185
190
  def to_xml(b)
186
- b.num(num)
191
+ b.num(num) unless self.num.empty?
187
192
  if heading.respond_to? :inline_items
188
193
  b.heading { |b|
189
194
  heading.inline_items.to_xml(b)
@@ -1,3 +1,3 @@
1
1
  module Slaw
2
- VERSION = "9.1.0"
2
+ VERSION = "9.2.0"
3
3
  end
@@ -828,6 +828,27 @@ EOS
828
828
  </subpart>
829
829
  </part>'
830
830
  end
831
+
832
+ it 'should allow optional numbers' do
833
+ node = parse :subpart, <<EOS
834
+ SUBPART - Heading - with a dash
835
+
836
+ 1. Section
837
+ Hello there
838
+ EOS
839
+ to_xml(node).should == '<subpart id="subpart-0">
840
+ <heading>Heading - with a dash</heading>
841
+ <section id="section-1">
842
+ <num>1.</num>
843
+ <heading>Section</heading>
844
+ <paragraph id="section-1.paragraph0">
845
+ <content>
846
+ <p>Hello there</p>
847
+ </content>
848
+ </paragraph>
849
+ </section>
850
+ </subpart>'
851
+ end
831
852
  end
832
853
 
833
854
  #-------------------------------------------------------------------------------
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slaw
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.1.0
4
+ version: 9.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Kempe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-15 00:00:00.000000000 Z
11
+ date: 2020-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake