slaw 4.0.0 → 4.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: feed0253f8ca8bfc11a4b7d8b844a66a4b50caf5ada01ec470cb8fb295f015da
4
- data.tar.gz: 31d43678f703b65e07e728cee6be876fa0b91d5f921a05147b4ce19c4d696ed2
3
+ metadata.gz: a7b2b24c5c8bd91ce9c0a852f6bec6c81e3719830d65f9e0691044b303d019b7
4
+ data.tar.gz: cf91c1517334866b6a9f8c62baed484c8ef8a35c10d0c3e1fc42ae104382e37c
5
5
  SHA512:
6
- metadata.gz: 0c966ce6ba9b80aa2d6de457150a83a6d26fbc0ad14d75ebee0fbb15dd3e9784723845b22222f525da370e3d170208199a723d08078a7640ae578b190296f78e
7
- data.tar.gz: fa39619402b136aa5f3ef74db739b74b588b2c7a06f790ac4405be6f52e3927c9110400df9e1afeef5fd523012c31222b4e1fd287b0fb5df870ae120ef1d7907
6
+ metadata.gz: 9e123803b17d5ad1c4d6530daad110715312f83f83901bbc0bac859af3dee15a4345964a9e4b0fd83795c7ff4595d69ed58afab8bc333b2650c2d77316e4dfd7
7
+ data.tar.gz: da86501ff2f5854d3433ac8a9c87613dd534ce2581206eb99984d2deeec2655da32980905bbf44bdc66723c17f03e13aff488b11f45d0672c5712968fcc9e12b
data/README.md CHANGED
@@ -81,6 +81,10 @@ You can create your own grammar by creating a gem that provides these files and
81
81
 
82
82
  ## Changelog
83
83
 
84
+ ### 4.1.0 (4 June 2019)
85
+
86
+ * BODY marks start of body
87
+
84
88
  ### 4.0.0 (29 May 2019)
85
89
 
86
90
  * Preserve whitespace for mixed content nodes
@@ -29,16 +29,19 @@ module Slaw
29
29
 
30
30
  rule preface
31
31
  !'PREAMBLE'
32
+ !'BODY'
32
33
  ('PREFACE'i space? eol)?
33
- statements:(!'PREAMBLE' preface_statement)* <Preface>
34
+ statements:(!'PREAMBLE' !'BODY' preface_statement)* <Preface>
34
35
  end
35
36
 
36
37
  rule preamble
38
+ !'BODY'
37
39
  'PREAMBLE'i space? eol
38
- statements:preamble_statement* <Preamble>
40
+ statements:(!'BODY' preamble_statement)* <Preamble>
39
41
  end
40
42
 
41
43
  rule body
44
+ ('BODY' space? eol)?
42
45
  children:(chapter / part / section / subsection / generic_container)+ <Body>
43
46
  end
44
47
 
@@ -79,9 +79,10 @@ module Slaw
79
79
 
80
80
  class Preface < Treetop::Runtime::SyntaxNode
81
81
  def to_xml(b, *args)
82
- if text_value != ""
82
+ stmts = statements.elements
83
+ if !stmts.empty?
83
84
  b.preface { |b|
84
- statements.elements.each { |element|
85
+ stmts.each { |element|
85
86
  for e in element.elements
86
87
  e.to_xml(b, "") if e.respond_to? :to_xml
87
88
  end
@@ -119,10 +120,11 @@ module Slaw
119
120
 
120
121
  class Preamble < Treetop::Runtime::SyntaxNode
121
122
  def to_xml(b, *args)
122
- if text_value != ""
123
+ stmts = statements.elements
124
+ if !stmts.empty?
123
125
  b.preamble { |b|
124
- statements.elements.each { |e|
125
- e.to_xml(b, "")
126
+ stmts.each { |e|
127
+ e.preamble_statement.to_xml(b, "")
126
128
  }
127
129
  }
128
130
  end
@@ -55,6 +55,13 @@
55
55
  <xsl:apply-templates />
56
56
  </xsl:template>
57
57
 
58
+ <xsl:template match="a:body">
59
+ <xsl:text>BODY</xsl:text>
60
+ <xsl:text>&#10;&#10;</xsl:text>
61
+
62
+ <xsl:apply-templates />
63
+ </xsl:template>
64
+
58
65
  <xsl:template match="a:part">
59
66
  <xsl:text>Part </xsl:text>
60
67
  <xsl:value-of select="a:num" />
data/lib/slaw/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Slaw
2
- VERSION = "4.0.0"
2
+ VERSION = "4.1.0"
3
3
  end
@@ -72,7 +72,9 @@ XML
72
72
  ))
73
73
 
74
74
  text = subject.text_from_act(doc)
75
- text.should == '1. Section
75
+ text.should == 'BODY
76
+
77
+ 1. Section
76
78
 
77
79
  \Chapter 2 ignored
78
80
 
@@ -136,7 +138,9 @@ XML
136
138
  ))
137
139
 
138
140
  text = subject.text_from_act(doc)
139
- text.should == '1. Section
141
+ text.should == 'BODY
142
+
143
+ 1. Section
140
144
 
141
145
  \(2) A special meeting [[ foo ]]:
142
146
 
@@ -162,7 +166,9 @@ XML
162
166
  ))
163
167
 
164
168
  text = subject.text_from_act(doc)
165
- text.should == '1.
169
+ text.should == 'BODY
170
+
171
+ 1.
166
172
 
167
173
  [[ foo ]]
168
174
 
@@ -183,7 +189,9 @@ XML
183
189
  ))
184
190
 
185
191
  text = subject.text_from_act(doc)
186
- text.should == '1.
192
+ text.should == 'BODY
193
+
194
+ 1.
187
195
 
188
196
  Hello [there](/za/act/123) friend.
189
197
 
@@ -210,7 +218,9 @@ XML
210
218
  ))
211
219
 
212
220
  text = subject.text_from_act(doc)
213
- text.should == '1.
221
+ text.should == 'BODY
222
+
223
+ 1.
214
224
 
215
225
  {|
216
226
  |-
@@ -239,7 +249,9 @@ Subject to approval in terms of this By-Law.
239
249
  EOS
240
250
  )
241
251
  s = subject.text_from_act(doc)
242
- s.should == '1. Something
252
+ s.should == 'BODY
253
+
254
+ 1. Something
243
255
 
244
256
  SCHEDULE - First Schedule [[remark]]
245
257
  Subheading [[another]]
@@ -140,6 +140,33 @@ EOS
140
140
  </content>
141
141
  </paragraph>
142
142
  </section>
143
+ </body>'
144
+ end
145
+
146
+ it 'should understand a body marker' do
147
+ node = parse :body, <<EOS
148
+ BODY
149
+
150
+ Some content before the section
151
+
152
+ 1. Section
153
+ Hello there
154
+ EOS
155
+ to_xml(node).should == '<body>
156
+ <paragraph id="paragraph0">
157
+ <content>
158
+ <p>Some content before the section</p>
159
+ </content>
160
+ </paragraph>
161
+ <section id="section-1">
162
+ <num>1.</num>
163
+ <heading>Section</heading>
164
+ <paragraph id="section-1.paragraph0">
165
+ <content>
166
+ <p>Hello there</p>
167
+ </content>
168
+ </paragraph>
169
+ </section>
143
170
  </body>'
144
171
  end
145
172
  end
@@ -1137,7 +1164,7 @@ EOS
1137
1164
  </preamble>'
1138
1165
  end
1139
1166
 
1140
- it 'should support prefaces and preambles' do
1167
+ it 'should support explicit preface and preamble' do
1141
1168
  node = parse :act, <<EOS
1142
1169
  PREFACE
1143
1170
  this is in the preface
@@ -1156,6 +1183,33 @@ EOS
1156
1183
  <p>this is in the preamble</p>
1157
1184
  </preamble>'
1158
1185
  end
1186
+
1187
+ it 'should obey a BODY marker' do
1188
+ node = parse :act, <<EOS
1189
+ PREFACE
1190
+ this is in the preface
1191
+
1192
+ PREAMBLE
1193
+ this is in the preamble
1194
+
1195
+ BODY
1196
+ this is in the body
1197
+ EOS
1198
+
1199
+ to_xml(node.preface).should == '<preface>
1200
+ <p>this is in the preface</p>
1201
+ </preface>'
1202
+ to_xml(node.preamble).should == '<preamble>
1203
+ <p>this is in the preamble</p>
1204
+ </preamble>'
1205
+ to_xml(node.body).should == '<body>
1206
+ <paragraph id="paragraph0">
1207
+ <content>
1208
+ <p>this is in the body</p>
1209
+ </content>
1210
+ </paragraph>
1211
+ </body>'
1212
+ end
1159
1213
  end
1160
1214
 
1161
1215
  #-------------------------------------------------------------------------------
@@ -1228,6 +1282,46 @@ EOS
1228
1282
  <p>PREAMBLE</p>
1229
1283
  </preamble>'
1230
1284
  end
1285
+
1286
+ it 'should handle weird preamble indicators' do
1287
+ node = parse :act, <<EOS
1288
+ BODY
1289
+
1290
+ PREAMBLE
1291
+
1292
+ this is actually in the body
1293
+ EOS
1294
+
1295
+ to_xml(node.body).should == '<body>
1296
+ <paragraph id="paragraph0">
1297
+ <content>
1298
+ <p>PREAMBLE</p>
1299
+ <p>this is actually in the body</p>
1300
+ </content>
1301
+ </paragraph>
1302
+ </body>'
1303
+ end
1304
+
1305
+ it 'should handle weird preface indicators' do
1306
+ node = parse :act, <<EOS
1307
+ PREFACE
1308
+
1309
+ BODY
1310
+
1311
+ PREFACE
1312
+
1313
+ this is actually in the body
1314
+ EOS
1315
+
1316
+ to_xml(node.body).should == '<body>
1317
+ <paragraph id="paragraph0">
1318
+ <content>
1319
+ <p>PREFACE</p>
1320
+ <p>this is actually in the body</p>
1321
+ </content>
1322
+ </paragraph>
1323
+ </body>'
1324
+ end
1231
1325
  end
1232
1326
 
1233
1327
  #-------------------------------------------------------------------------------
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: 4.0.0
4
+ version: 4.1.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: 2019-05-29 00:00:00.000000000 Z
11
+ date: 2019-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake